Skip to content

Commit

Permalink
fix: repair quote price display
Browse files Browse the repository at this point in the history
  • Loading branch information
b3aton committed Feb 3, 2023
1 parent 278f13e commit 5d7dc81
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion apps/storefront/src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ input[type=number]::-webkit-outer-spin-button
.b2b-quote-global-action {
display: flex;
align-items: center;
padding: 4px 0px 0px 16px;
padding: 2px 0 2px 16px;
margin-left: 30px;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/storefront/src/pages/quote/QuoteDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ const QuoteDetail = () => {
</Grid>

{
(+role !== 100 && +quoteDetail.status !== 4) && (
(+role !== 2 && +quoteDetail.status !== 4) && (
<QuoteDetailFooter
quoteId={quoteDetail.id}
quoteDate={quoteDetail?.createdAt?.toString()}
Expand Down
6 changes: 3 additions & 3 deletions apps/storefront/src/pages/quote/QuotesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,17 @@ const QuotesList = () => {
render: (item: ListItem) => format(displayFormat(item.expiredAt, false), 'dd MMM yy'),
},
{
key: 'subtotal',
key: 'grandTotal',
title: 'Subtotal',
render: (item: ListItem) => {
const {
currency: {
token,
},
subtotal,
grandTotal,
} = item

return (`${token}${(+subtotal).toFixed(2)}`)
return (`${token}${(+grandTotal).toFixed(2)}`)
},
},
{
Expand Down
23 changes: 12 additions & 11 deletions apps/storefront/src/pages/quote/components/QuoteDetailTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@ const QuoteDetailTable = (props: ShoppingDetailTableProps, ref: Ref<unknown>) =>
render: (row) => {
const {
basePrice,
discount,
offeredPrice,
} = row

const price = +basePrice
const isDiscount = +discount > 0
const offeredPrice = +basePrice - +discount
const discountPrice = +offeredPrice
const isDiscount = price - discountPrice > 0

return (
<>
Expand All @@ -228,11 +228,11 @@ const QuoteDetailTable = (props: ShoppingDetailTableProps, ref: Ref<unknown>) =>

<Typography
sx={{
padding: 0,
padding: isDiscount ? '0' : '12px 0 0 0',
color: isDiscount ? '#2E7D32' : '#212121',
}}
>
{`${currencyToken}${offeredPrice.toFixed(2)}`}
{`${currencyToken}${discountPrice.toFixed(2)}`}
</Typography>

</>
Expand Down Expand Up @@ -261,13 +261,14 @@ const QuoteDetailTable = (props: ShoppingDetailTableProps, ref: Ref<unknown>) =>
const {
basePrice,
quantity,
discount,
offeredPrice,
} = row
const total = +basePrice * +quantity
const offeredPrice = +basePrice - +discount
const price = +basePrice
const discountPrice = +offeredPrice
const isDiscount = price - discountPrice > 0

const isDiscount = +discount > 0
const totalWithDiscount = +offeredPrice * +quantity
const total = price * +quantity
const totalWithDiscount = discountPrice * +quantity

return (
<Box>
Expand All @@ -285,7 +286,7 @@ const QuoteDetailTable = (props: ShoppingDetailTableProps, ref: Ref<unknown>) =>
}
<Typography
sx={{
padding: '0',
padding: isDiscount ? '0' : '12px 0 0 0',
color: isDiscount ? '#2E7D32' : '#212121',
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ const QuoteDetailTableCard = (props: QuoteTableCardProps) => {
options,
sku,
notes,
discount,
offeredPrice,
} = quoteTableItem

const total = +basePrice * +quantity
const price = +basePrice
const isDiscount = +discount > 0
const offeredPrice = +basePrice - +discount
const totalWithDiscount = +offeredPrice * +quantity
const discountPrice = +offeredPrice
const isDiscount = price - discountPrice > 0

const total = price * +quantity
const totalWithDiscount = discountPrice * +quantity

return (
<Box
Expand Down
8 changes: 4 additions & 4 deletions apps/storefront/src/pages/quote/components/QuoteItemCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const QuoteItemCard = (props: QuoteItemCardProps) => {
title: 'Title',
},
{
key: 'salesRep',
key: 'salesRepEmail',
title: 'Sales rep',
},
{
Expand All @@ -72,17 +72,17 @@ export const QuoteItemCard = (props: QuoteItemCardProps) => {
render: () => format(+item.expiredAt * 1000, 'dd MMM yy'),
},
{
key: 'subtotal',
key: 'grandTotal',
title: 'Subtotal',
render: () => {
const {
currency: {
token,
},
subtotal,
grandTotal,
} = item

return (`${token}${subtotal}`)
return (`${token}${(+grandTotal).toFixed(2)}`)
},
},
]
Expand Down
9 changes: 4 additions & 5 deletions apps/storefront/src/utils/b3Init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@ export const getQuoteEnabled = (
let productQuoteEnabled = quoteEnabled && customerEnabled === '1' && productEnabled === '1'
let cartQuoteEnabled = quoteEnabled && customerEnabled === '1' && cartEnabled === '1'

// BCUser
if (!isB2BUser || (`${role}` === '3' && !isAgenting)) {
productQuoteEnabled = productQuoteEnabled && bcUserEnabled === '1'
cartQuoteEnabled = cartQuoteEnabled && bcUserEnabled === '1'
} else if (`${role}` === '100') { // guest
if (`${role}` === '100') { // guest
productQuoteEnabled = productQuoteEnabled && guestEnabled === '1'
cartQuoteEnabled = cartQuoteEnabled && guestEnabled === '1'
} else if (!isB2BUser || (`${role}` === '3' && !isAgenting)) { // BCUser
productQuoteEnabled = productQuoteEnabled && bcUserEnabled === '1'
cartQuoteEnabled = cartQuoteEnabled && bcUserEnabled === '1'
}

return {
Expand Down

0 comments on commit 5d7dc81

Please sign in to comment.