Skip to content

Commit d2d6a29

Browse files
authored
chore(types): improvements to tax provider tsdocs
1 parent 0eadcdd commit d2d6a29

File tree

1 file changed

+11
-39
lines changed

1 file changed

+11
-39
lines changed

packages/core/types/src/tax/provider.ts

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -38,55 +38,28 @@ export type ItemTaxCalculationLine = {
3838
}
3939

4040
/**
41-
* ## Overview
41+
*
42+
*
43+
* ### Identifier Property
4244
*
43-
* A tax provider is used to retrieve the tax lines in a provided context. The Tax Module provides a default `system` provider. You can create your own tax provider,
44-
* either in a plugin, in a provider module, or directly in your Medusa application's codebase, then use it in any tax region.
45-
*
46-
* ---
47-
*
48-
* ## How to Create a Tax Provider
49-
*
50-
* A tax provider class is defined in a TypeScript or JavaScript file. The class must implement the
51-
* `ITaxProvider` interface imported from `@medusajs/framework/types`.
52-
*
53-
* The file can be defined in a plugin, a provider module, or under the `src/services` directory of your Medusa application. You can later pass the package's name or the
54-
* path to the file in the `providers` option of the Tax Module.
55-
*
56-
* For example:
57-
*
58-
* ```ts title="src/services/my-tax.ts"
59-
* import { ITaxProvider } from "@medusajs/framework/types"
60-
*
61-
* export default class MyTaxProvider implements ITaxProvider {
62-
* // ...
63-
* }
64-
* ```
65-
*
66-
* ---
67-
*
68-
* ## Identifier Property
69-
*
70-
* The `identifier` property in a tax provider is used when the tax provider is registered in the dependency container or added to the database. A tax provider is represented in the database by the `TaxProvider` data model.
45+
* The `identifier` property in a tax provider is used when the tax provider is loaded by the Tax Module and added to the database. A tax provider is represented in the database by the `TaxProvider` data model.
7146
*
7247
* For example:
7348
*
74-
* ```ts title="src/services/my-tax.ts"
49+
* ```ts title="src/modules/my-tax/service.ts"
7550
* export default class MyTaxProvider implements ITaxProvider {
7651
* static identifier = "my-tax"
7752
* // ...
7853
* }
7954
* ```
8055
*
81-
* ---
56+
* ### constructor
8257
*
83-
* ## Constructor
84-
*
85-
* You can use the `constructor` of your tax provider to access the resources registered in the dependency container.
58+
* You can use the `constructor` of your tax provider to access the resources registered in the [Module Container](https://docs.medusajs.com/resources/medusa-container-resources#module-container-resources).
8659
*
8760
* You can also use the constructor to initialize your integration with the third-party provider. For example, if you use a client to connect to the third-party provider’s APIs, you can initialize it in the constructor and use it in other methods in the service.
8861
*
89-
* Additionally, if you’re creating your tax provider as a plugin or a provider module to be installed in any Medusa application and you want to access its options, you can access them in the constructor.
62+
* Additionally, if you’re creating your tax provider as a plugin or a module provider to be installed in any Medusa application and you want to access its options, you can access them in the second parameter of the constructor.
9063
*
9164
* For example:
9265
*
@@ -112,10 +85,9 @@ export interface ITaxProvider {
11285
getIdentifier(): string
11386

11487
/**
115-
* This method is used to retrieve the tax lines of items and shipping methods. It's used
116-
* when the `getTaxLines` method of the Tax Module's main service is called.
117-
*
118-
* This method is useful during checkout or when calculating the totals of orders or exchanges.
88+
* This method is used to retrieve the tax lines of items and shipping methods. It's used during checkout
89+
* when the `getTaxLines` method of the Tax Module's main service is called for a tax
90+
* region that uses this tax provider.
11991
*
12092
* @param {ItemTaxCalculationLine[]} itemLines - The line item lines to calculate taxes for.
12193
* @param {ShippingTaxCalculationLine[]} shippingLines - The shipping method lines to calculate taxes for.

0 commit comments

Comments
 (0)