TaxProviderService
internal.internal.TaxProviderService
Finds tax providers and assists in tax related operations.
Properties
__configModule__Record<string, unknown>__container__anyRequired__moduleDeclaration__Record<string, unknown>container_AwilixContainer<any>RequiredgetCacheKeyanyRequiredmanager_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
EntityManagerEntityManagerRequiredInherited from
TransactionBaseService.activeManager_
Methods
atomicPhase_
Protected atomicPhase_<TResult, 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.
TResultobjectRequiredTErrorobjectRequiredParameters
work(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>Returns
Promise<TResult>
PromisePromise<TResult>RequiredInherited from
TransactionBaseService.atomicPhase_
clearLineItemsTaxLines
clearLineItemsTaxLines(itemIds): Promise<void>
Parameters
itemIdsstring[]RequiredReturns
Promise<void>
PromisePromise<void>RequiredclearTaxLines
clearTaxLines(cartId): Promise<void>
Parameters
cartIdstringRequiredReturns
Promise<void>
PromisePromise<void>RequiredcreateShippingTaxLines
createShippingTaxLines(shippingMethod, calculationContext): Promise<(ShippingMethodTaxLine | LineItemTaxLine)[]>
Persists the tax lines relevant for a shipping method to the database. Used for return shipping methods.
Parameters
Returns
Promise<(ShippingMethodTaxLine | LineItemTaxLine)[]>
the newly created tax lines
createTaxLines
createTaxLines(cartOrLineItems, calculationContext): Promise<(ShippingMethodTaxLine | LineItemTaxLine)[]>
Persists the tax lines relevant for an order to the database.
Parameters
Returns
Promise<(ShippingMethodTaxLine | LineItemTaxLine)[]>
the newly created tax lines
getRegionRatesForProduct
getRegionRatesForProduct(productIds, region): Promise<Map<string, TaxServiceRate[]>>
Gets the tax rates configured for a product. The rates are cached between calls.
Parameters
productIdsstring | string[]RequiredReturns
Promise<Map<string, TaxServiceRate[]>>
the tax rates configured for the shipping option. A map by product id
getRegionRatesForShipping
getRegionRatesForShipping(optionId, regionDetails): Promise<TaxServiceRate[]>
Gets the tax rates configured for a shipping option. The rates are cached between calls.
Parameters
optionIdstringRequiredReturns
Promise<TaxServiceRate[]>
the tax rates configured for the shipping option.
getShippingTaxLines
getShippingTaxLines(shippingMethod, calculationContext): Promise<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[]>
the computed tax lines
getTaxLines
getTaxLines(lineItems, calculationContext): Promise<(ShippingMethodTaxLine | LineItemTaxLine)[]>
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<(ShippingMethodTaxLine | LineItemTaxLine)[]>
the computed tax lines
getTaxLinesMap
Protected getTaxLinesMap(items, calculationContext): Promise<TaxLinesMaps>
Return a map of tax lines for line items and shipping methods
Parameters
Returns
Promise<TaxLinesMaps>
list
list(): Promise<TaxProvider[]>
Returns
Promise<TaxProvider[]>
registerInstalledProviders
registerInstalledProviders(providers): Promise<void>
Parameters
providersstring[]RequiredReturns
Promise<void>
PromisePromise<void>RequiredretrieveProvider
retrieveProvider(region): 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
errRecord<string, unknown> | { code: string }RequiredReturns
boolean
booleanbooleanInherited from
TransactionBaseService.shouldRetryTransaction_
withTransaction
withTransaction(transactionManager?): TaxProviderService
Parameters
transactionManagerEntityManager