Skip to main content
Skip to main content

NewTotalsService

Constructors

constructor

**new NewTotalsService**(«destructured»)

Parameters
__namedParametersInjectedDependenciesRequired

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
featureFlagRouter_FlagRouterRequired
manager_EntityManagerRequired
taxCalculationStrategy_ITaxCalculationStrategyRequired
taxProviderService_TaxProviderServiceRequired
transactionManager_undefined | EntityManagerRequired

Accessors

activeManager_

Protected activeManager_: [object Object]

Methods

atomicPhase_

Protected **atomicPhase_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise&#60;TResult&#62;

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
TResultobjectRequired
TErrorobjectRequired
Parameters
work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>
the isolation level to be used for the work.
maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>
Potential error handler
Returns

Promise<TResult>

PromisePromise<TResult>Required
the result of the transactional work

getGiftCardTotals

**getGiftCardTotals**(giftCardableAmount, «destructured»): Promise&#60;&#123; tax_total: number ; total: number &#125;&#62;

Calculate and return the gift cards totals

Parameters
giftCardableAmountnumberRequired
__namedParametersobjectRequired
__namedParameters.giftCardTransactionsGiftCardTransaction[]
__namedParameters.giftCardsGiftCard[]
__namedParameters.regionRegionRequired
A region holds settings specific to a geographical location, including the currency, tax rates, and fulfillment and payment providers. A Region can consist of multiple countries to accomodate common shopping settings across countries.
Returns

Promise<{ tax_total: number ; total: number }>

PromisePromise<{ tax_total: number ; total: number }>Required

getGiftCardTransactionsTotals

**getGiftCardTransactionsTotals**(«destructured»): &#123; tax_total: number ; total: number &#125;

Calculate and return the gift cards totals based on their transactions

Parameters
__namedParametersobjectRequired
__namedParameters.giftCardTransactionsGiftCardTransaction[]Required
__namedParameters.regionobjectRequired
__namedParameters.region.gift_cards_taxablebooleanRequired
__namedParameters.region.tax_ratenumberRequired
Returns

object

objectobject
tax_totalnumberRequired
totalnumberRequired

getGiftCardableAmount

**getGiftCardableAmount**(«destructured»): number

Parameters
__namedParametersobjectRequired
__namedParameters.discount_totalnumberRequired
__namedParameters.gift_cards_taxableboolean
__namedParameters.shipping_totalnumberRequired
__namedParameters.subtotalnumberRequired
__namedParameters.tax_totalnumberRequired
Returns

number

numbernumber

getLineItemRefund

**getLineItemRefund**(lineItem, «destructured»): number

Return the amount that can be refund on a line item

Parameters
lineItemobjectRequired
lineItem.idstringRequired
lineItem.includes_taxbooleanRequired
lineItem.quantitynumberRequired
lineItem.tax_linesLineItemTaxLine[]Required
lineItem.unit_pricenumberRequired
__namedParametersobjectRequired
__namedParameters.calculationContextTaxCalculationContextRequired
__namedParameters.taxRatenull | number
Returns

number

numbernumber

getLineItemRefundLegacy

Protected **getLineItemRefundLegacy**(lineItem, «destructured»): number

Parameters
lineItemobjectRequired
lineItem.idstringRequired
lineItem.includes_taxbooleanRequired
lineItem.quantitynumberRequired
lineItem.unit_pricenumberRequired
__namedParametersobjectRequired
__namedParameters.calculationContextTaxCalculationContextRequired
__namedParameters.taxRatenumberRequired
Returns

number

numbernumber

getLineItemTotals

**getLineItemTotals**(items, «destructured»): Promise&#60;&#123; [lineItemId: string]: [LineItemTotals](/references/services/types/LineItemTotals); &#125;&#62;

Calculate and return the items totals for either the legacy calculation or the new calculation

Parameters
itemsLineItem | LineItem[]Required
__namedParametersobjectRequired
__namedParameters.calculationContextTaxCalculationContextRequired
__namedParameters.includeTaxboolean
__namedParameters.taxRatenull | number
Returns

Promise<{ [lineItemId: string]: LineItemTotals; }>

PromisePromise<{ [lineItemId: string]: LineItemTotals; }>Required

getLineItemTotalsLegacy

Protected **getLineItemTotalsLegacy**(item, «destructured»): Promise&#60;[LineItemTotals](/references/services/types/LineItemTotals)&#62;

Calculate and return the legacy calculated totals using the tax rate

Parameters
itemLineItemRequired
__namedParametersobjectRequired
__namedParameters.calculationContextTaxCalculationContextRequired
__namedParameters.lineItemAllocationobjectRequired
__namedParameters.lineItemAllocation.discountDiscountAllocation
__namedParameters.lineItemAllocation.gift_cardGiftCardAllocation
__namedParameters.taxRatenumberRequired
Returns

Promise<LineItemTotals>

PromisePromise<LineItemTotals>Required

getLineItemTotals_

Protected **getLineItemTotals_**(item, «destructured»): Promise&#60;[LineItemTotals](/references/services/types/LineItemTotals)&#62;

Calculate and return the totals for an item

Parameters
itemLineItemRequired
__namedParametersobjectRequired
__namedParameters.calculationContextTaxCalculationContextRequired
__namedParameters.includeTaxboolean
__namedParameters.lineItemAllocationobjectRequired
__namedParameters.lineItemAllocation.discountDiscountAllocation
__namedParameters.lineItemAllocation.gift_cardGiftCardAllocation
__namedParameters.taxLinesLineItemTaxLine[]
Returns

Promise<LineItemTotals>

PromisePromise<LineItemTotals>Required

getShippingMethodTotals

**getShippingMethodTotals**(shippingMethods, «destructured»): Promise&#60;&#123; [shippingMethodId: string]: [ShippingMethodTotals](/references/services/types/ShippingMethodTotals); &#125;&#62;

Calculate and return the shipping methods totals for either the legacy calculation or the new calculation

Parameters
shippingMethodsShippingMethod | ShippingMethod[]Required
__namedParametersobjectRequired
__namedParameters.calculationContextTaxCalculationContextRequired
__namedParameters.discountsDiscount[]
__namedParameters.includeTaxboolean
__namedParameters.taxRatenull | number
Returns

Promise<{ [shippingMethodId: string]: ShippingMethodTotals; }>

PromisePromise<{ [shippingMethodId: string]: ShippingMethodTotals; }>Required

getShippingMethodTotalsLegacy

Protected **getShippingMethodTotalsLegacy**(shippingMethod, «destructured»): Promise&#60;[ShippingMethodTotals](/references/services/types/ShippingMethodTotals)&#62;

Calculate and return the shipping method totals legacy using the tax rate

Parameters
shippingMethodShippingMethodRequired
__namedParametersobjectRequired
__namedParameters.calculationContextTaxCalculationContextRequired
__namedParameters.discountsDiscount[]
__namedParameters.taxRatenumberRequired
Returns

Promise<ShippingMethodTotals>

PromisePromise<ShippingMethodTotals>Required

getShippingMethodTotals_

Protected **getShippingMethodTotals_**(shippingMethod, «destructured»): Promise&#60;[ShippingMethodTotals](/references/services/types/ShippingMethodTotals)&#62;

Calculate and return the shipping method totals

Parameters
shippingMethodShippingMethodRequired
__namedParametersobjectRequired
__namedParameters.calculationContextTaxCalculationContextRequired
__namedParameters.discountsDiscount[]
__namedParameters.includeTaxboolean
__namedParameters.taxLinesShippingMethodTaxLine[]
Returns

Promise<ShippingMethodTotals>

PromisePromise<ShippingMethodTotals>Required

shouldRetryTransaction_

Protected **shouldRetryTransaction_**(err): boolean

Parameters
errRecord<string, unknown> | { code: string }Required
Returns

boolean

booleanboolean

withTransaction

**withTransaction**(transactionManager?): [NewTotalsService](/references/services/classes/NewTotalsService)

Parameters
transactionManagerEntityManager
Returns

NewTotalsService

defaultNewTotalsServiceRequired
Was this section helpful?