Skip to content

Commit

Permalink
fix: discount still showing when"discount disabled" inside a Buyer Po…
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 authored and libruce committed Feb 7, 2024
1 parent ebd189d commit 9372408
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 21 deletions.
1 change: 1 addition & 0 deletions apps/storefront/src/pages/quote/QuoteDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ function QuoteDetail() {
isHandleApprove={isHandleApprove}
getQuoteTableDetails={getQuoteTableDetails}
getTaxRate={getTaxRate}
displayDiscount={quoteDetail.displayDiscount}
/>
</Box>
</Grid>
Expand Down
34 changes: 18 additions & 16 deletions apps/storefront/src/pages/quote/components/QuoteDetailSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,24 @@ export default function QuoteDetailSummary(props: QuoteDetailSummaryProps) {
color: '#212121',
}}
>
<Grid
container
justifyContent="space-between"
sx={{
margin: '4px 0',
}}
>
<Typography>
{b3Lang('quoteDetail.summary.originalSubtotal')}
</Typography>
<Typography>
{showPrice(
priceFormat(getCurrentPrice(subtotalPrice, quoteDetailTax))
)}
</Typography>
</Grid>
{quoteDetail?.displayDiscount && (
<Grid
container
justifyContent="space-between"
sx={{
margin: '4px 0',
}}
>
<Typography>
{b3Lang('quoteDetail.summary.originalSubtotal')}
</Typography>
<Typography>
{showPrice(
priceFormat(getCurrentPrice(subtotalPrice, quoteDetailTax))
)}
</Typography>
</Grid>
)}

{!quoteDetail?.salesRepEmail && +status === 1 ? null : (
<Grid
Expand Down
14 changes: 11 additions & 3 deletions apps/storefront/src/pages/quote/components/QuoteDetailTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ interface ShoppingDetailTableProps {
}>
isHandleApprove: boolean
getTaxRate: (taxClassId: number, variants: any) => number
displayDiscount: boolean
}

interface SearchProps {
Expand Down Expand Up @@ -103,7 +104,13 @@ const StyledImage = styled('img')(() => ({

function QuoteDetailTable(props: ShoppingDetailTableProps, ref: Ref<unknown>) {
const b3Lang = useB3Lang()
const { total, getQuoteTableDetails, getTaxRate, isHandleApprove } = props
const {
total,
getQuoteTableDetails,
getTaxRate,
isHandleApprove,
displayDiscount,
} = props

const {
global: {
Expand Down Expand Up @@ -240,7 +247,7 @@ function QuoteDetailTable(props: ShoppingDetailTableProps, ref: Ref<unknown>) {
const price = getBCPrice(+basePrice, taxPrice)
const discountPrice = getBCPrice(+offeredPrice, discountTaxPrice)

const isDiscount = +basePrice - +offeredPrice > 0
const isDiscount = +basePrice - +offeredPrice > 0 && displayDiscount

return (
<>
Expand Down Expand Up @@ -309,7 +316,7 @@ function QuoteDetailTable(props: ShoppingDetailTableProps, ref: Ref<unknown>) {

const price = getBCPrice(+basePrice, taxPrice)
const discountPrice = getBCPrice(+offeredPrice, discountTaxPrice)
const isDiscount = +basePrice - +offeredPrice > 0
const isDiscount = +basePrice - +offeredPrice > 0 && displayDiscount

const total = price * +quantity
const totalWithDiscount = discountPrice * +quantity
Expand Down Expand Up @@ -381,6 +388,7 @@ function QuoteDetailTable(props: ShoppingDetailTableProps, ref: Ref<unknown>) {
item={row}
showPrice={showPrice}
itemIndex={index}
displayDiscount={displayDiscount}
getTaxRate={getTaxRate}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface QuoteTableCardProps {
getTaxRate: (taxClassId: number, variants: any) => number
itemIndex?: number
showPrice: (price: string, row: CustomFieldItems) => string | number
displayDiscount: boolean
}

const StyledImage = styled('img')(() => ({
Expand All @@ -21,7 +22,14 @@ const StyledImage = styled('img')(() => ({
}))

function QuoteDetailTableCard(props: QuoteTableCardProps) {
const { item: quoteTableItem, len, itemIndex, getTaxRate, showPrice } = props
const {
item: quoteTableItem,
len,
itemIndex,
getTaxRate,
showPrice,
displayDiscount,
} = props
const b3Lang = useB3Lang()

const {
Expand Down Expand Up @@ -51,7 +59,7 @@ function QuoteDetailTableCard(props: QuoteTableCardProps) {
const price = getBCPrice(+basePrice, taxPrice)
const discountPrice = getBCPrice(+offeredPrice, discountTaxPrice)

const isDiscount = +basePrice - +offeredPrice > 0
const isDiscount = +basePrice - +offeredPrice > 0 && displayDiscount

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

0 comments on commit 9372408

Please sign in to comment.