chore(types): improvements to tax provider tsdocs
This commit is contained in:
@@ -38,55 +38,28 @@ export type ItemTaxCalculationLine = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ## Overview
|
*
|
||||||
|
*
|
||||||
|
* ### Identifier Property
|
||||||
*
|
*
|
||||||
* 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,
|
* 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.
|
||||||
* either in a plugin, in a provider module, or directly in your Medusa application's codebase, then use it in any tax region.
|
|
||||||
*
|
|
||||||
* ---
|
|
||||||
*
|
|
||||||
* ## How to Create a Tax Provider
|
|
||||||
*
|
|
||||||
* A tax provider class is defined in a TypeScript or JavaScript file. The class must implement the
|
|
||||||
* `ITaxProvider` interface imported from `@medusajs/framework/types`.
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* path to the file in the `providers` option of the Tax Module.
|
|
||||||
*
|
*
|
||||||
* For example:
|
* For example:
|
||||||
*
|
*
|
||||||
* ```ts title="src/services/my-tax.ts"
|
* ```ts title="src/modules/my-tax/service.ts"
|
||||||
* import { ITaxProvider } from "@medusajs/framework/types"
|
|
||||||
*
|
|
||||||
* export default class MyTaxProvider implements ITaxProvider {
|
|
||||||
* // ...
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* ---
|
|
||||||
*
|
|
||||||
* ## Identifier Property
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* For example:
|
|
||||||
*
|
|
||||||
* ```ts title="src/services/my-tax.ts"
|
|
||||||
* export default class MyTaxProvider implements ITaxProvider {
|
* export default class MyTaxProvider implements ITaxProvider {
|
||||||
* static identifier = "my-tax"
|
* static identifier = "my-tax"
|
||||||
* // ...
|
* // ...
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* ---
|
* ### constructor
|
||||||
*
|
*
|
||||||
* ## Constructor
|
* 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).
|
||||||
*
|
|
||||||
* You can use the `constructor` of your tax provider to access the resources registered in the dependency container.
|
|
||||||
*
|
*
|
||||||
* 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.
|
* 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.
|
||||||
*
|
*
|
||||||
* 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.
|
* 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.
|
||||||
*
|
*
|
||||||
* For example:
|
* For example:
|
||||||
*
|
*
|
||||||
@@ -112,10 +85,9 @@ export interface ITaxProvider {
|
|||||||
getIdentifier(): string
|
getIdentifier(): string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used to retrieve the tax lines of items and shipping methods. It's used
|
* This method is used to retrieve the tax lines of items and shipping methods. It's used during checkout
|
||||||
* when the `getTaxLines` method of the Tax Module's main service is called.
|
* when the `getTaxLines` method of the Tax Module's main service is called for a tax
|
||||||
*
|
* region that uses this tax provider.
|
||||||
* This method is useful during checkout or when calculating the totals of orders or exchanges.
|
|
||||||
*
|
*
|
||||||
* @param {ItemTaxCalculationLine[]} itemLines - The line item lines to calculate taxes for.
|
* @param {ItemTaxCalculationLine[]} itemLines - The line item lines to calculate taxes for.
|
||||||
* @param {ShippingTaxCalculationLine[]} shippingLines - The shipping method lines to calculate taxes for.
|
* @param {ShippingTaxCalculationLine[]} shippingLines - The shipping method lines to calculate taxes for.
|
||||||
|
|||||||
Reference in New Issue
Block a user