Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
13 KiB
displayed_sidebar
| displayed_sidebar |
|---|
| jsClientSidebar |
Class: NewTotalsService
internal.internal.NewTotalsService
Hierarchy
-
↳
NewTotalsService
Properties
__configModule__
• Protected Optional Readonly __configModule__: Record<string, unknown>
Inherited from
TransactionBaseService.configModule
Defined in
packages/medusa/dist/interfaces/transaction-base-service.d.ts:5
__container__
• Protected Readonly __container__: any
Inherited from
TransactionBaseService.container
Defined in
packages/medusa/dist/interfaces/transaction-base-service.d.ts:4
__moduleDeclaration__
• Protected Optional Readonly __moduleDeclaration__: Record<string, unknown>
Inherited from
TransactionBaseService.moduleDeclaration
Defined in
packages/medusa/dist/interfaces/transaction-base-service.d.ts:6
featureFlagRouter_
• Protected Readonly featureFlagRouter_: FlagRouter
Defined in
packages/medusa/dist/services/new-totals.d.ts:42
manager_
• Protected manager_: EntityManager
Inherited from
TransactionBaseService.manager_
Defined in
packages/medusa/dist/interfaces/transaction-base-service.d.ts:7
taxCalculationStrategy_
• Protected Readonly taxCalculationStrategy_: ITaxCalculationStrategy
Defined in
packages/medusa/dist/services/new-totals.d.ts:43
taxProviderService_
• Protected Readonly taxProviderService_: TaxProviderService
Defined in
packages/medusa/dist/services/new-totals.d.ts:41
transactionManager_
• Protected transactionManager_: undefined | EntityManager
Inherited from
TransactionBaseService.transactionManager_
Defined in
packages/medusa/dist/interfaces/transaction-base-service.d.ts:8
Accessors
activeManager_
• Protected get activeManager_(): EntityManager
Returns
EntityManager
Inherited from
TransactionBaseService.activeManager_
Defined in
packages/medusa/dist/interfaces/transaction-base-service.d.ts:9
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
packages/medusa/dist/interfaces/transaction-base-service.d.ts:24
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
packages/medusa/dist/services/new-totals.d.ts:123
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
packages/medusa/dist/services/new-totals.d.ts:136
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
packages/medusa/dist/services/new-totals.d.ts:91
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
packages/medusa/dist/services/new-totals.d.ts:107
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
packages/medusa/dist/services/new-totals.d.ts:52
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
packages/medusa/dist/services/new-totals.d.ts:80
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
packages/medusa/dist/services/new-totals.d.ts:67
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
packages/medusa/dist/services/new-totals.d.ts:154
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
packages/medusa/dist/services/new-totals.d.ts:183
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
packages/medusa/dist/services/new-totals.d.ts:170
shouldRetryTransaction_
▸ Protected shouldRetryTransaction_(err): boolean
Parameters
| Name | Type |
|---|---|
err |
Record<string, unknown> | { code: string } |
Returns
boolean
Inherited from
TransactionBaseService.shouldRetryTransaction_
Defined in
packages/medusa/dist/interfaces/transaction-base-service.d.ts:12
withTransaction
▸ withTransaction(transactionManager?): NewTotalsService
Parameters
| Name | Type |
|---|---|
transactionManager? |
EntityManager |
Returns
Inherited from
TransactionBaseService.withTransaction
Defined in
packages/medusa/dist/interfaces/transaction-base-service.d.ts:11