Files
medusa-store/www/apps/docs/content/references/services/classes/NewTotalsService.md
github-actions[bot] 5c8a1eef12 chore(docs): Generated Services Reference (automated) (#5423)
Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
2023-10-19 16:59:51 +00:00

13 KiB

Class: NewTotalsService

Hierarchy

  • TransactionBaseService

    NewTotalsService

Constructors

constructor

new NewTotalsService(«destructured»)

Parameters

Name Type
«destructured» InjectedDependencies

Overrides

TransactionBaseService.constructor

Defined in

medusa/src/services/new-totals.ts:67

Properties

__configModule__

Protected Optional Readonly __configModule__: Record<string, unknown>

Inherited from

TransactionBaseService.__configModule__

Defined in

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


__container__

Protected Readonly __container__: any

Inherited from

TransactionBaseService.__container__

Defined in

medusa/src/interfaces/transaction-base-service.ts:13


__moduleDeclaration__

Protected Optional Readonly __moduleDeclaration__: Record<string, unknown>

Inherited from

TransactionBaseService.__moduleDeclaration__

Defined in

medusa/src/interfaces/transaction-base-service.ts:15


featureFlagRouter_

Protected Readonly featureFlagRouter_: FlagRouter

Defined in

medusa/src/services/new-totals.ts:64


manager_

Protected manager_: EntityManager

Inherited from

TransactionBaseService.manager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:5


taxCalculationStrategy_

Protected Readonly taxCalculationStrategy_: ITaxCalculationStrategy

Defined in

medusa/src/services/new-totals.ts:65


taxProviderService_

Protected Readonly taxProviderService_: TaxProviderService

Defined in

medusa/src/services/new-totals.ts:63


transactionManager_

Protected transactionManager_: undefined | EntityManager

Inherited from

TransactionBaseService.transactionManager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:6

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

Inherited from

TransactionBaseService.activeManager_

Defined in

medusa/src/interfaces/transaction-base-service.ts:8

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.

Type parameters

Name
TResult
TError

Parameters

Name Type Description
work (transactionManager: EntityManager) => Promise<TResult> the transactional work to be done
isolationOrErrorHandler? IsolationLevel | (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>

the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_

Defined in

medusa/src/interfaces/transaction-base-service.ts:56


getGiftCardTotals

getGiftCardTotals(giftCardableAmount, «destructured»): Promise<{ tax_total: number ; total: number }>

Calculate and return the gift cards totals

Parameters

Name Type
giftCardableAmount number
«destructured» Object
› giftCardTransactions? GiftCardTransaction[]
› giftCards? GiftCard[]
› region Region

Returns

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

Defined in

medusa/src/services/new-totals.ts:447


getGiftCardTransactionsTotals

getGiftCardTransactionsTotals(«destructured»): Object

Calculate and return the gift cards totals based on their transactions

Parameters

Name Type
«destructured» Object
› giftCardTransactions GiftCardTransaction[]
› region Object
› region.gift_cards_taxable boolean
› region.tax_rate number

Returns

Object

Name Type
tax_total number
total number

Defined in

medusa/src/services/new-totals.ts:526


getLineItemRefund

getLineItemRefund(lineItem, «destructured»): number

Return the amount that can be refund on a line item

Parameters

Name Type
lineItem Object
lineItem.id string
lineItem.includes_tax boolean
lineItem.quantity number
lineItem.tax_lines LineItemTaxLine[]
lineItem.unit_price number
«destructured» Object
› calculationContext TaxCalculationContext
› taxRate? null | number

Returns

number

Defined in

medusa/src/services/new-totals.ts:333


getLineItemRefundLegacy

Protected getLineItemRefundLegacy(lineItem, «destructured»): number

Parameters

Name Type
lineItem Object
lineItem.id string
lineItem.includes_tax boolean
lineItem.quantity number
lineItem.unit_price number
«destructured» Object
› calculationContext TaxCalculationContext
› taxRate number

Returns

number

Defined in

medusa/src/services/new-totals.ts:403


getLineItemTotals

getLineItemTotals(items, «destructured»): Promise<{ [lineItemId: string]: LineItemTotals; }>

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

Parameters

Name Type
items LineItem | LineItem[]
«destructured» Object
› calculationContext TaxCalculationContext
› includeTax? boolean
› taxRate? null | number

Returns

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

Defined in

medusa/src/services/new-totals.ts:87


getLineItemTotalsLegacy

Protected getLineItemTotalsLegacy(item, «destructured»): Promise<LineItemTotals>

Calculate and return the legacy calculated totals using the tax rate

Parameters

Name Type
item LineItem
«destructured» Object
› calculationContext TaxCalculationContext
› lineItemAllocation Object
› lineItemAllocation.discount? DiscountAllocation
› lineItemAllocation.gift_card? GiftCardAllocation
› taxRate number

Returns

Promise<LineItemTotals>

Defined in

medusa/src/services/new-totals.ts:254


getLineItemTotals_

Protected getLineItemTotals_(item, «destructured»): Promise<LineItemTotals>

Calculate and return the totals for an item

Parameters

Name Type
item LineItem
«destructured» Object
› calculationContext TaxCalculationContext
› includeTax? boolean
› lineItemAllocation Object
› lineItemAllocation.discount? DiscountAllocation
› lineItemAllocation.gift_card? GiftCardAllocation
› taxLines? LineItemTaxLine[]

Returns

Promise<LineItemTotals>

Defined in

medusa/src/services/new-totals.ts:147


getShippingMethodTotals

getShippingMethodTotals(shippingMethods, «destructured»): Promise<{ [shippingMethodId: string]: ShippingMethodTotals; }>

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

Parameters

Name Type
shippingMethods ShippingMethod | ShippingMethod[]
«destructured» Object
› calculationContext TaxCalculationContext
› discounts? Discount[]
› includeTax? boolean
› taxRate? null | number

Returns

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

Defined in

medusa/src/services/new-totals.ts:572


getShippingMethodTotalsLegacy

Protected getShippingMethodTotalsLegacy(shippingMethod, «destructured»): Promise<ShippingMethodTotals>

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

Parameters

Name Type
shippingMethod ShippingMethod
«destructured» Object
› calculationContext TaxCalculationContext
› discounts? Discount[]
› taxRate number

Returns

Promise<ShippingMethodTotals>

Defined in

medusa/src/services/new-totals.ts:729


getShippingMethodTotals_

Protected getShippingMethodTotals_(shippingMethod, «destructured»): Promise<ShippingMethodTotals>

Calculate and return the shipping method totals

Parameters

Name Type
shippingMethod ShippingMethod
«destructured» Object
› calculationContext TaxCalculationContext
› discounts? Discount[]
› includeTax? boolean
› taxLines? ShippingMethodTaxLine[]

Returns

Promise<ShippingMethodTotals>

Defined in

medusa/src/services/new-totals.ts:646


shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

Name Type
err Record<string, unknown> | { code: string }

Returns

boolean

Inherited from

TransactionBaseService.shouldRetryTransaction_

Defined in

medusa/src/interfaces/transaction-base-service.ts:37


withTransaction

withTransaction(transactionManager?): NewTotalsService

Parameters

Name Type
transactionManager? EntityManager

Returns

NewTotalsService

Inherited from

TransactionBaseService.withTransaction

Defined in

medusa/src/interfaces/transaction-base-service.ts:20