Skip to content

Commit

Permalink
feat: subtotal and shipping calculations on orders when tax settings …
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 authored and libruce committed Jan 22, 2024
1 parent eabcd72 commit 5f03541
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions apps/storefront/src/pages/orderDetail/shared/B2BOrderData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { LangFormatFunction } from '@b3/lang'

import { store } from '@/store'
import { getActiveCurrencyInfo } from '@/utils'

import {
Expand Down Expand Up @@ -97,13 +98,19 @@ const getOrderSummary = (data: B2BOrderData, b3Lang: LangFormatFunction) => {
lastName,
totalTax,
subtotalExTax,
subtotalIncTax,
totalExTax,
totalIncTax,
handlingCostExTax,
handlingCostIncTax,
shippingCostExTax,
shippingCostIncTax,
} = data

const {
global: { showInclusiveTaxPrice },
} = store.getState()

const labels = {
subTotal: b3Lang('orderDetail.summary.subTotal'),
shipping: b3Lang('orderDetail.summary.shipping'),
Expand All @@ -116,8 +123,12 @@ const getOrderSummary = (data: B2BOrderData, b3Lang: LangFormatFunction) => {
createAt: dateCreated,
name: `${firstName} ${lastName}`,
priceData: {
[labels.subTotal]: formatPrice(subtotalExTax || ''),
[labels.shipping]: formatPrice(shippingCostExTax || ''),
[labels.subTotal]: formatPrice(
showInclusiveTaxPrice ? subtotalIncTax : subtotalExTax
),
[labels.shipping]: formatPrice(
showInclusiveTaxPrice ? shippingCostIncTax : shippingCostExTax
),
[labels.handingFee]: formatPrice(
handlingCostIncTax || handlingCostExTax || ''
),
Expand Down

0 comments on commit 5f03541

Please sign in to comment.