TaxProviderService
Finds tax providers and assists in tax related operations.
Constructors
constructor
**new TaxProviderService**(container)
Parameters
container
AwilixContainer<any>RequiredProperties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>container_
AwilixContainer<any>Requiredmanager_
EntityManagerRequiredsmTaxLineRepo_
Repository<ShippingMethodTaxLine> & { deleteForCart: Method deleteForCart ; upsertLines: Method upsertLines }RequiredtaxLineRepo_
Repository<LineItemTaxLine> & { deleteForCart: Method deleteForCart ; upsertLines: Method upsertLines }RequiredtransactionManager_
undefined | EntityManagerRequiredAccessors
activeManager_
Protected get**activeManager_**(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredMethods
atomicPhase_
Protected **atomicPhase_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise<TResult>
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.
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise<TResult>
Promise
Promise<TResult>RequiredclearLineItemsTaxLines
**clearLineItemsTaxLines**(itemIds): Promise<void>
Parameters
itemIds
string[]RequiredReturns
Promise<void>
Promise
Promise<void>RequiredclearTaxLines
**clearTaxLines**(cartId): Promise<void>
Parameters
cartId
stringRequiredReturns
Promise<void>
Promise
Promise<void>RequiredcreateShippingTaxLines
**createShippingTaxLines**(shippingMethod, calculationContext): Promise<([LineItemTaxLine](/references/services/classes/LineItemTaxLine) \| [ShippingMethodTaxLine](/references/services/classes/ShippingMethodTaxLine))[]>
Persists the tax lines relevant for a shipping method to the database. Used for return shipping methods.
Parameters
Returns
Promise<(LineItemTaxLine | ShippingMethodTaxLine)[]>
createTaxLines
**createTaxLines**(cartOrLineItems, calculationContext): Promise<([LineItemTaxLine](/references/services/classes/LineItemTaxLine) \| [ShippingMethodTaxLine](/references/services/classes/ShippingMethodTaxLine))[]>
Persists the tax lines relevant for an order to the database.
Parameters
Returns
Promise<(LineItemTaxLine | ShippingMethodTaxLine)[]>
getCacheKey
Private **getCacheKey**(id, regionId): string
The cache key to get cache hits by.
Parameters
id
stringRequiredregionId
stringRequiredReturns
string
string
stringgetRegionRatesForProduct
**getRegionRatesForProduct**(productIds, region): Promise<Map<string, [TaxServiceRate](/references/services/types/TaxServiceRate)[]>>
Gets the tax rates configured for a product. The rates are cached between calls.
Parameters
productIds
string | string[]RequiredReturns
Promise<Map<string, TaxServiceRate[]>>
getRegionRatesForShipping
**getRegionRatesForShipping**(optionId, regionDetails): Promise<[TaxServiceRate](/references/services/types/TaxServiceRate)[]>
Gets the tax rates configured for a shipping option. The rates are cached between calls.
Parameters
optionId
stringRequiredReturns
Promise<TaxServiceRate[]>
getShippingTaxLines
**getShippingTaxLines**(shippingMethod, calculationContext): Promise<[ShippingMethodTaxLine](/references/services/classes/ShippingMethodTaxLine)[]>
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
Returns
Promise<ShippingMethodTaxLine[]>
getTaxLines
**getTaxLines**(lineItems, calculationContext): Promise<([LineItemTaxLine](/references/services/classes/LineItemTaxLine) \| [ShippingMethodTaxLine](/references/services/classes/ShippingMethodTaxLine))[]>
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
Returns
Promise<(LineItemTaxLine | ShippingMethodTaxLine)[]>
getTaxLinesMap
Protected **getTaxLinesMap**(items, calculationContext): Promise<[TaxLinesMaps](/references/services/types/TaxLinesMaps)>
Return a map of tax lines for line items and shipping methods
Parameters
Returns
Promise<TaxLinesMaps>
list
**list**(): Promise<[TaxProvider](/references/services/classes/TaxProvider)[]>
Returns
Promise<TaxProvider[]>
registerInstalledProviders
**registerInstalledProviders**(providers): Promise<void>
Parameters
providers
string[]RequiredReturns
Promise<void>
Promise
Promise<void>RequiredretrieveProvider
**retrieveProvider**(region): [ITaxService](/references/services/interfaces/ITaxService)
Retrieves the relevant tax provider for the given region.
Parameters
Returns
getTaxLines
(itemLines: ItemTaxCalculationLine[], shippingLines: ShippingTaxCalculationLine[], context: TaxCalculationContext) => Promise<ProviderTaxLine[]>RequiredshouldRetryTransaction_
Protected **shouldRetryTransaction_**(err): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanwithTransaction
**withTransaction**(transactionManager?): [TaxProviderService](/references/services/classes/TaxProviderService)
Parameters
transactionManager
EntityManager