---
displayed_sidebar: servicesSidebar
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# TaxProviderService
Finds tax providers and assists in tax related operations.
## Constructors
#### constructor
`**new TaxProviderService**(container)`
##### Parameters
## Properties
`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "__container__",
"type": "`any`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "__moduleDeclaration__",
"type": "`Record`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "cacheService_",
"type": "[ICacheService](../interfaces/ICacheService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "container_",
"type": "AwilixContainer<any>",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "eventBus_",
"type": "[IEventBusService](../interfaces/IEventBusService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "manager_",
"type": "EntityManager",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "smTaxLineRepo_",
"type": "Repository<[ShippingMethodTaxLine](ShippingMethodTaxLine.mdx)> & ``{ deleteForCart: Method deleteForCart ; upsertLines: Method upsertLines }``",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "taxLineRepo_",
"type": "Repository<[LineItemTaxLine](LineItemTaxLine.mdx)> & ``{ deleteForCart: Method deleteForCart ; upsertLines: Method upsertLines }``",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "taxProviderRepo_",
"type": "Repository<[TaxProvider](TaxProvider.mdx)>",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "taxRateService_",
"type": "[TaxRateService](TaxRateService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "transactionManager_",
"type": "`undefined` \\| EntityManager",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
## Accessors
#### activeManager\_
`Protected` **activeManager\_**: [object Object]
## Methods
#### atomicPhase\_
`Protected **atomicPhase_**(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.
##### Type Parameters
##### Parameters
Promise<TResult>",
"description": "the transactional work to be done",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "isolationOrErrorHandler",
"type": "`IsolationLevel` \\| (`error`: `TError`) => Promise<void \\| TResult>",
"description": "the isolation level to be used for the work.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "maybeErrorHandlerOrDontFail",
"type": "(`error`: `TError`) => Promise<void \\| TResult>",
"description": "Potential error handler",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
##### Returns
Promise<TResult>
___
#### clearLineItemsTaxLines
`**clearLineItemsTaxLines**(itemIds): Promise<void>`
##### Parameters
##### Returns
Promise<void>
___
#### clearTaxLines
`**clearTaxLines**(cartId): Promise<void>`
##### Parameters
##### Returns
Promise<void>
___
#### createShippingTaxLines
`**createShippingTaxLines**(shippingMethod, calculationContext): Promise<([LineItemTaxLine](LineItemTaxLine.mdx) \| [ShippingMethodTaxLine](ShippingMethodTaxLine.mdx))[]>`
Persists the tax lines relevant for a shipping method to the database. Used
for return shipping methods.
##### Parameters
##### Returns
Promise<([LineItemTaxLine](LineItemTaxLine.mdx) \| [ShippingMethodTaxLine](ShippingMethodTaxLine.mdx))[]>
___
#### createTaxLines
`**createTaxLines**(cartOrLineItems, calculationContext): Promise<([LineItemTaxLine](LineItemTaxLine.mdx) \| [ShippingMethodTaxLine](ShippingMethodTaxLine.mdx))[]>`
Persists the tax lines relevant for an order to the database.
##### Parameters
##### Returns
Promise<([LineItemTaxLine](LineItemTaxLine.mdx) \| [ShippingMethodTaxLine](ShippingMethodTaxLine.mdx))[]>
___
#### getCacheKey
`Private **getCacheKey**(id, regionId): string`
The cache key to get cache hits by.
##### Parameters
##### Returns
`string`
___
#### getRegionRatesForProduct
`**getRegionRatesForProduct**(productIds, region): Promise<Map<string, [TaxServiceRate](../types/TaxServiceRate.mdx)[]>>`
Gets the tax rates configured for a product. The rates are cached between
calls.
##### Parameters
##### Returns
Promise<Map<string, [TaxServiceRate](../types/TaxServiceRate.mdx)[]>>
___
#### getRegionRatesForShipping
`**getRegionRatesForShipping**(optionId, regionDetails): Promise<[TaxServiceRate](../types/TaxServiceRate.mdx)[]>`
Gets the tax rates configured for a shipping option. The rates are cached
between calls.
##### Parameters
##### Returns
Promise<[TaxServiceRate](../types/TaxServiceRate.mdx)[]>
___
#### getShippingTaxLines
`**getShippingTaxLines**(shippingMethod, calculationContext): Promise<[ShippingMethodTaxLine](ShippingMethodTaxLine.mdx)[]>`
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](ShippingMethodTaxLine.mdx)[]>
___
#### getTaxLines
`**getTaxLines**(lineItems, calculationContext): Promise<([LineItemTaxLine](LineItemTaxLine.mdx) \| [ShippingMethodTaxLine](ShippingMethodTaxLine.mdx))[]>`
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](LineItemTaxLine.mdx) \| [ShippingMethodTaxLine](ShippingMethodTaxLine.mdx))[]>
___
#### getTaxLinesMap
`Protected **getTaxLinesMap**(items, calculationContext): Promise<[TaxLinesMaps](../types/TaxLinesMaps.mdx)>`
Return a map of tax lines for line items and shipping methods
##### Parameters
##### Returns
Promise<[TaxLinesMaps](../types/TaxLinesMaps.mdx)>
___
#### list
`**list**(): Promise<[TaxProvider](TaxProvider.mdx)[]>`
##### Returns
Promise<[TaxProvider](TaxProvider.mdx)[]>
___
#### registerInstalledProviders
`**registerInstalledProviders**(providers): Promise<void>`
##### Parameters
##### Returns
Promise<void>
___
#### retrieveProvider
`**retrieveProvider**(region): [ITaxService](../interfaces/ITaxService.mdx)`
Retrieves the relevant tax provider for the given region.
##### Parameters
##### Returns
[ITaxService](../interfaces/ITaxService.mdx)
Promise<[ProviderTaxLine](../types/ProviderTaxLine.mdx)[]>",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
___
#### shouldRetryTransaction\_
`Protected **shouldRetryTransaction_**(err): boolean`
##### Parameters
` \\| ``{ code: string }``",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
##### Returns
`boolean`
___
#### withTransaction
`**withTransaction**(transactionManager?): [TaxProviderService](TaxProviderService.mdx)`
##### Parameters
##### Returns
[TaxProviderService](TaxProviderService.mdx)