Skip to content

Commit

Permalink
feat: quote Tax and Estimated Tax judgment and shipping display
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 authored and libruce committed Dec 25, 2023
1 parent 752b73e commit 96d35fb
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 57 deletions.
127 changes: 72 additions & 55 deletions apps/storefront/src/pages/quote/components/QuoteDetailSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,51 @@ export default function QuoteDetailSummary(props: QuoteDetailSummaryProps) {

const priceFormat = (price: number) => `${currencyFormat(price)}`

const getShippingAndTax = () => {
if (quoteDetail?.shippingMethod?.id) {
return {
shippingText: `${b3Lang('quoteDetail.summary.shipping')}(${
quoteDetail?.shippingMethod?.description || ''
})`,
shippingVal: priceFormat(+shipping),
taxText: b3Lang('quoteDetail.summary.tax'),
taxVal: priceFormat(+tax),
}
}

if (
!quoteDetail?.salesRepEmail &&
!quoteDetail?.shippingMethod?.id &&
+status === 1
) {
return {
shippingText: b3Lang('quoteDetail.summary.shipping'),
shippingVal: b3Lang('quoteDetail.summary.tbd'),
taxText: b3Lang('quoteDetail.summary.estimatedTax'),
taxVal: priceFormat(+tax),
}
}

if (
quoteDetail?.salesRepEmail &&
!quoteDetail?.shippingMethod?.id &&
(+status === 1 || +status === 5)
) {
return {
shippingText: `${b3Lang('quoteDetail.summary.shipping')}(${b3Lang(
'quoteDetail.summary.quoteCheckout'
)})`,
shippingVal: b3Lang('quoteDetail.summary.tbd'),
taxText: b3Lang('quoteDetail.summary.tax'),
taxVal: b3Lang('quoteDetail.summary.tbd'),
}
}

return null
}

const shippingAndTax = getShippingAndTax()

return (
<Card>
<CardContent>
Expand Down Expand Up @@ -71,22 +116,26 @@ export default function QuoteDetailSummary(props: QuoteDetailSummaryProps) {
{priceFormat(getCurrentPrice(subtotalPrice, quoteDetailTax))}
</Typography>
</Grid>
<Grid
container
justifyContent="space-between"
sx={{
margin: '4px 0',
}}
>
<Typography>
{b3Lang('quoteDetail.summary.discountAmount')}
</Typography>
<Typography>
{+discount > 0
? `-${priceFormat(+discount)}`
: priceFormat(+discount)}
</Typography>
</Grid>

{!quoteDetail?.salesRepEmail && +status === 1 ? null : (
<Grid
container
justifyContent="space-between"
sx={{
margin: '4px 0',
}}
>
<Typography>
{b3Lang('quoteDetail.summary.discountAmount')}
</Typography>
<Typography>
{+discount > 0
? `-${priceFormat(+discount)}`
: priceFormat(+discount)}
</Typography>
</Grid>
)}

<Grid
container
justifyContent="space-between"
Expand All @@ -111,7 +160,8 @@ export default function QuoteDetailSummary(props: QuoteDetailSummaryProps) {
{priceFormat(getCurrentPrice(quotedSubtotal, quoteDetailTax))}
</Typography>
</Grid>
{quoteDetail?.shippingMethod?.id ? (

{shippingAndTax && (
<>
<Grid
container
Expand All @@ -126,11 +176,9 @@ export default function QuoteDetailSummary(props: QuoteDetailSummaryProps) {
wordBreak: 'break-word',
}}
>
{`${b3Lang('quoteDetail.summary.shipping')}(${
quoteDetail?.shippingMethod?.description || ''
})`}
{shippingAndTax.shippingText}
</Typography>
<Typography>{priceFormat(+shipping)}</Typography>
<Typography>{shippingAndTax.shippingVal}</Typography>
</Grid>
<Grid
container
Expand All @@ -139,43 +187,12 @@ export default function QuoteDetailSummary(props: QuoteDetailSummaryProps) {
margin: '4px 0',
}}
>
<Typography>{b3Lang('quoteDetail.summary.tax')}</Typography>
<Typography>{priceFormat(+tax)}</Typography>
<Typography>{shippingAndTax.taxText}</Typography>
<Typography>{shippingAndTax.taxVal}</Typography>
</Grid>
</>
) : null}
)}

{quoteDetail?.salesRepEmail &&
!quoteDetail?.shippingMethod?.id &&
(+status === 1 || +status === 5) ? (
<>
<Grid
container
justifyContent="space-between"
sx={{
margin: '4px 0',
flexWrap: 'nowrap',
}}
>
<Typography>
{`${b3Lang('quoteDetail.summary.shipping')}(${b3Lang(
'quoteDetail.summary.quoteCheckout'
)})`}
</Typography>
<Typography>TBD</Typography>
</Grid>
<Grid
container
justifyContent="space-between"
sx={{
margin: '4px 0',
}}
>
<Typography>{b3Lang('quoteDetail.summary.tax')}</Typography>
<Typography>TBD</Typography>
</Grid>
</>
) : null}
<Grid
container
justifyContent="space-between"
Expand Down
24 changes: 23 additions & 1 deletion apps/storefront/src/pages/quote/components/QuoteSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,29 @@ const QuoteSummary = forwardRef((_, ref: Ref<unknown>) => {
<Typography>{priceFormat(quoteSummary.subtotal)}</Typography>
</Grid>

{/* Remove the Shipping and Tax lines on a “draft” Quote. --BUN-1550 */}
<Grid
container
justifyContent="space-between"
sx={{
margin: '4px 0',
}}
>
<Typography>
{b3Lang('quoteDraft.quoteSummary.shipping')}
</Typography>
<Typography>{b3Lang('quoteDraft.quoteSummary.tbd')}</Typography>
</Grid>

<Grid
container
justifyContent="space-between"
sx={{
margin: '4px 0',
}}
>
<Typography>{b3Lang('quoteDraft.quoteSummary.tax')}</Typography>
<Typography>{priceFormat(quoteSummary.tax)}</Typography>
</Grid>

<Grid
container
Expand Down
5 changes: 4 additions & 1 deletion packages/lang/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,8 @@
"quoteDraft.quoteSummary.summary": "Quote summary",
"quoteDraft.quoteSummary.subTotal": "Sub total",
"quoteDraft.quoteSummary.shipping": "Shipping",
"quoteDraft.quoteSummary.tax": "Tax",
"quoteDraft.quoteSummary.tax": "Estimated Tax",
"quoteDraft.quoteSummary.tbd": "TBD",
"quoteDraft.quoteSummary.grandTotal": "Grand total",
"quoteDraft.quoteTable.productUpdated": "Product was updated in your quote.",
"quoteDraft.quoteTable.product": "Product",
Expand Down Expand Up @@ -588,6 +589,8 @@
"quoteDetail.summary.quotedSubtotal": "Quoted subtotal",
"quoteDetail.summary.shipping": "Shipping",
"quoteDetail.summary.tax": "Tax",
"quoteDetail.summary.tbd": "TBD",
"quoteDetail.summary.estimatedTax": "Estimated Tax",
"quoteDetail.summary.grandTotal": "Grand total",
"quoteDetail.table.product": "Product",
"quoteDetail.table.price": "Price",
Expand Down

0 comments on commit 96d35fb

Please sign in to comment.