Skip to main content

Class: TaxProviderService

Finds tax providers and assists in tax related operations.

Hierarchy

  • TransactionBaseServiceCopy to Clipboard

    TaxProviderServiceCopy to Clipboard

Constructors

constructor

new TaxProviderService(containerCopy to Clipboard)

Parameters

NameType
containerCopy to ClipboardAwilixContainerCopy to Clipboard<anyCopy to Clipboard>

Overrides

TransactionBaseService.constructor

Defined in

packages/medusa/src/services/tax-provider.ts:51

Properties

__configModule__

ProtectedCopy to Clipboard OptionalCopy to Clipboard ReadonlyCopy to Clipboard __configModule__: RecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard>

Inherited from

TransactionBaseService.__configModule__

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:10


__container__

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard __container__: anyCopy to Clipboard

Inherited from

TransactionBaseService.__container__

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:9


__moduleDeclaration__

ProtectedCopy to Clipboard OptionalCopy to Clipboard ReadonlyCopy to Clipboard __moduleDeclaration__: RecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard>

Inherited from

TransactionBaseService.__moduleDeclaration__

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:11


cacheService_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard cacheService_: ICacheServiceCopy to Clipboard

Defined in

packages/medusa/src/services/tax-provider.ts:44


container_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard container_: AwilixContainerCopy to Clipboard<anyCopy to Clipboard>

Defined in

packages/medusa/src/services/tax-provider.ts:43


eventBus_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard eventBus_: EventBusServiceCopy to Clipboard

Defined in

packages/medusa/src/services/tax-provider.ts:49


manager_

ProtectedCopy to Clipboard manager_: EntityManagerCopy to Clipboard

Overrides

TransactionBaseService.manager_

Defined in

packages/medusa/src/services/tax-provider.ts:40


smTaxLineRepo_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard smTaxLineRepo_: typeof ShippingMethodTaxLineRepositoryCopy to Clipboard

Defined in

packages/medusa/src/services/tax-provider.ts:47


taxLineRepo_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard taxLineRepo_: typeof LineItemTaxLineRepositoryCopy to Clipboard

Defined in

packages/medusa/src/services/tax-provider.ts:46


taxProviderRepo_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard taxProviderRepo_: typeof TaxProviderRepositoryCopy to Clipboard

Defined in

packages/medusa/src/services/tax-provider.ts:48


taxRateService_

ProtectedCopy to Clipboard ReadonlyCopy to Clipboard taxRateService_: TaxRateServiceCopy to Clipboard

Defined in

packages/medusa/src/services/tax-provider.ts:45


transactionManager_

ProtectedCopy to Clipboard transactionManager_: EntityManagerCopy to Clipboard

Overrides

TransactionBaseService.transactionManager_

Defined in

packages/medusa/src/services/tax-provider.ts:41

Methods

atomicPhase_

ProtectedCopy to Clipboard atomicPhase_<TResultCopy to Clipboard, TErrorCopy to Clipboard>(workCopy to Clipboard, isolationOrErrorHandler?Copy to Clipboard, maybeErrorHandlerOrDontFail?Copy to Clipboard): PromiseCopy to Clipboard<TResultCopy to Clipboard>

Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.

Type parameters

Name
TResultCopy to Clipboard
TErrorCopy to Clipboard

Parameters

NameTypeDescription
workCopy to Clipboard(transactionManagerCopy to Clipboard: EntityManagerCopy to Clipboard) => PromiseCopy to Clipboard<TResultCopy to Clipboard>the transactional work to be done
isolationOrErrorHandler?Copy to ClipboardIsolationLevelCopy to Clipboard | (errorCopy to Clipboard: TErrorCopy to Clipboard) => PromiseCopy to Clipboard<voidCopy to Clipboard | TResultCopy to Clipboard>the isolation level to be used for the work.
maybeErrorHandlerOrDontFail?Copy to Clipboard(errorCopy to Clipboard: TErrorCopy to Clipboard) => PromiseCopy to Clipboard<voidCopy to Clipboard | TResultCopy to Clipboard>Potential error handler

Returns

PromiseCopy to Clipboard<TResultCopy to Clipboard>

the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:50


clearLineItemsTaxLines

clearLineItemsTaxLines(itemIdsCopy to Clipboard): PromiseCopy to Clipboard<voidCopy to Clipboard>

Parameters

NameType
itemIdsCopy to ClipboardstringCopy to Clipboard[]

Returns

PromiseCopy to Clipboard<voidCopy to Clipboard>

Defined in

packages/medusa/src/services/tax-provider.ts:97


clearTaxLines

clearTaxLines(cartIdCopy to Clipboard): PromiseCopy to Clipboard<voidCopy to Clipboard>

Parameters

NameType
cartIdCopy to ClipboardstringCopy to Clipboard

Returns

PromiseCopy to Clipboard<voidCopy to Clipboard>

Defined in

packages/medusa/src/services/tax-provider.ts:107


createShippingTaxLines

createShippingTaxLines(shippingMethodCopy to Clipboard, calculationContextCopy to Clipboard): PromiseCopy to Clipboard<(ShippingMethodTaxLineCopy to Clipboard | LineItemTaxLineCopy to Clipboard)[]>

Persists the tax lines relevant for a shipping method to the database. Used for return shipping methods.

Parameters

NameTypeDescription
shippingMethodCopy to ClipboardShippingMethodCopy to Clipboardthe shipping method to create tax lines for
calculationContextCopy to ClipboardTaxCalculationContextCopy to Clipboardthe calculation context to get tax lines by

Returns

PromiseCopy to Clipboard<(ShippingMethodTaxLineCopy to Clipboard | LineItemTaxLineCopy to Clipboard)[]>

the newly created tax lines

Defined in

packages/medusa/src/services/tax-provider.ts:183


createTaxLines

createTaxLines(cartOrLineItemsCopy to Clipboard, calculationContextCopy to Clipboard): PromiseCopy to Clipboard<(ShippingMethodTaxLineCopy to Clipboard | LineItemTaxLineCopy to Clipboard)[]>

Persists the tax lines relevant for an order to the database.

Parameters

NameTypeDescription
cartOrLineItemsCopy to ClipboardCartCopy to Clipboard | LineItemCopy to Clipboard[]the cart or line items to create tax lines for
calculationContextCopy to ClipboardTaxCalculationContextCopy to Clipboardthe calculation context to get tax lines by

Returns

PromiseCopy to Clipboard<(ShippingMethodTaxLineCopy to Clipboard | LineItemTaxLineCopy to Clipboard)[]>

the newly created tax lines

Defined in

packages/medusa/src/services/tax-provider.ts:129


getCacheKey

PrivateCopy to Clipboard getCacheKey(idCopy to Clipboard, regionIdCopy to Clipboard): stringCopy to Clipboard

The cache key to get cache hits by.

Parameters

NameTypeDescription
idCopy to ClipboardstringCopy to Clipboardthe entity id to cache
regionIdCopy to ClipboardstringCopy to Clipboardthe region id to cache

Returns

stringCopy to Clipboard

the cache key to use for the id set

Defined in

packages/medusa/src/services/tax-provider.ts:484


getRegionRatesForProduct

getRegionRatesForProduct(productIdCopy to Clipboard, regionCopy to Clipboard): PromiseCopy to Clipboard<TaxServiceRateCopy to Clipboard[]>

Gets the tax rates configured for a product. The rates are cached between calls.

Parameters

NameTypeDescription
productIdCopy to ClipboardstringCopy to Clipboardthe product id to get rates for
regionCopy to ClipboardRegionDetailsCopy to Clipboardthe region to get configured rates for.

Returns

PromiseCopy to Clipboard<TaxServiceRateCopy to Clipboard[]>

the tax rates configured for the shipping option.

Defined in

packages/medusa/src/services/tax-provider.ts:436


getRegionRatesForShipping

getRegionRatesForShipping(optionIdCopy to Clipboard, regionDetailsCopy to Clipboard): PromiseCopy to Clipboard<TaxServiceRateCopy to Clipboard[]>

Gets the tax rates configured for a shipping option. The rates are cached between calls.

Parameters

NameTypeDescription
optionIdCopy to ClipboardstringCopy to Clipboardthe option id of the shipping method.
regionDetailsCopy to ClipboardRegionDetailsCopy to Clipboardthe region to get configured rates for.

Returns

PromiseCopy to Clipboard<TaxServiceRateCopy to Clipboard[]>

the tax rates configured for the shipping option.

Defined in

packages/medusa/src/services/tax-provider.ts:389


getShippingTaxLines

getShippingTaxLines(shippingMethodCopy to Clipboard, calculationContextCopy to Clipboard): PromiseCopy to Clipboard<ShippingMethodTaxLineCopy to Clipboard[]>

Gets the relevant tax lines for a shipping method. Note: this method doesn't persist the tax lines. Use createShippingTaxLines if you wish to persist the tax lines to the DB layer.

Parameters

NameTypeDescription
shippingMethodCopy to ClipboardShippingMethodCopy to Clipboardthe shipping method to get tax lines for
calculationContextCopy to ClipboardTaxCalculationContextCopy to Clipboardthe calculation context to get tax lines by

Returns

PromiseCopy to Clipboard<ShippingMethodTaxLineCopy to Clipboard[]>

the computed tax lines

Defined in

packages/medusa/src/services/tax-provider.ts:204


getTaxLines

getTaxLines(lineItemsCopy to Clipboard, calculationContextCopy to Clipboard): PromiseCopy to Clipboard<(ShippingMethodTaxLineCopy to Clipboard | LineItemTaxLineCopy to Clipboard)[]>

Gets the relevant tax lines for an order or cart. If an order is provided the order's tax lines will be returned. If a cart is provided the tax lines will be computed from the tax rules and potentially a 3rd party tax plugin. Note: this method doesn't persist the tax lines. Use createTaxLines if you wish to persist the tax lines to the DB layer.

Parameters

NameTypeDescription
lineItemsCopy to ClipboardLineItemCopy to Clipboard[]the cart or order to get tax lines for
calculationContextCopy to ClipboardTaxCalculationContextCopy to Clipboardthe calculation context to get tax lines by

Returns

PromiseCopy to Clipboard<(ShippingMethodTaxLineCopy to Clipboard | LineItemTaxLineCopy to Clipboard)[]>

the computed tax lines

Defined in

packages/medusa/src/services/tax-provider.ts:256


getTaxLinesMap

ProtectedCopy to Clipboard getTaxLinesMap(itemsCopy to Clipboard, calculationContextCopy to Clipboard): PromiseCopy to Clipboard<TaxLinesMapsCopy to Clipboard>

Return a map of tax lines for line items and shipping methods

Parameters

NameType
itemsCopy to ClipboardLineItemCopy to Clipboard[]
calculationContextCopy to ClipboardTaxCalculationContextCopy to Clipboard

Returns

PromiseCopy to Clipboard<TaxLinesMapsCopy to Clipboard>

Defined in

packages/medusa/src/services/tax-provider.ts:352


list

list(): PromiseCopy to Clipboard<TaxProviderCopy to Clipboard[]>

Returns

PromiseCopy to Clipboard<TaxProviderCopy to Clipboard[]>

Defined in

packages/medusa/src/services/tax-provider.ts:65


registerInstalledProviders

registerInstalledProviders(providersCopy to Clipboard): PromiseCopy to Clipboard<voidCopy to Clipboard>

Parameters

NameType
providersCopy to ClipboardstringCopy to Clipboard[]

Returns

PromiseCopy to Clipboard<voidCopy to Clipboard>

Defined in

packages/medusa/src/services/tax-provider.ts:488


retrieveProvider

retrieveProvider(regionCopy to Clipboard): ITaxServiceCopy to Clipboard

Retrieves the relevant tax provider for the given region.

Parameters

NameTypeDescription
regionCopy to ClipboardRegionCopy to Clipboardthe region to get tax provider for.

Returns

ITaxServiceCopy to Clipboard

the region specific tax provider

Defined in

packages/medusa/src/services/tax-provider.ts:75


shouldRetryTransaction_

ProtectedCopy to Clipboard shouldRetryTransaction_(errCopy to Clipboard): booleanCopy to Clipboard

Parameters

NameType
errCopy to ClipboardRecordCopy to Clipboard<stringCopy to Clipboard, unknownCopy to Clipboard> | { codeCopy to Clipboard: stringCopy to Clipboard }

Returns

booleanCopy to Clipboard

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:31


withTransaction

withTransaction(transactionManager?Copy to Clipboard): TaxProviderServiceCopy to Clipboard

Parameters

NameType
transactionManager?Copy to ClipboardEntityManagerCopy to Clipboard

Returns

TaxProviderServiceCopy to Clipboard

Inherited from

TransactionBaseService.withTransaction

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:14