Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix: convert add-ons correctly in QuoteToOrderModal

Rob Carringtonfa397bf095db
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteToOrderModal.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteToOrderModal.tsx
index c63c4a6232..cfbe8d5a21 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteToOrderModal.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteToOrderModal.tsx
@@ -492,7 +492,7 @@ const LinePricingOptions = ({
line.quantity?.reduce((acc, quantity) => {
const charges = Object.values(line.additionalCharges ?? {}).reduce(
(chargeAcc, charge) => {
- const amount = charge.amounts?.[quantity] * quoteExchangeRate;
+ const amount = charge.amounts?.[quantity];
return chargeAcc + amount;
},
0
@@ -501,6 +501,13 @@ const LinePricingOptions = ({
return acc;
}, {} as Record<number, number>) ?? {};
+ const convertedAdditionalChargesByQuantity = Object.entries(
+ additionalChargesByQuantity
+ ).reduce<Record<number, number>>((acc, [quantity, amount]) => {
+ acc[Number(quantity)] = amount * quoteExchangeRate;
+ return acc;
+ }, {});
+
return (
<VStack spacing={2}>
<RadioGroup
@@ -523,8 +530,9 @@ const LinePricingOptions = ({
addOn:
additionalChargesByQuantity[selectedOption.quantity] || 0,
convertedAddOn:
- additionalChargesByQuantity[selectedOption.quantity] *
- quoteExchangeRate || 0,
+ convertedAdditionalChargesByQuantity[
+ selectedOption.quantity
+ ] || 0,
leadTime: selectedOption.leadTime,
},
}));
@@ -573,14 +581,16 @@ const LinePricingOptions = ({
</Td>
<Td>
{formatter.format(
- additionalChargesByQuantity[option.quantity]
+ convertedAdditionalChargesByQuantity[option.quantity]
)}
</Td>
<Td>{option.leadTime} days</Td>
<Td>
{formatter.format(
(option.convertedNetExtendedPrice ?? 0) +
- additionalChargesByQuantity[option.quantity]
+ convertedAdditionalChargesByQuantity[
+ option.quantity
+ ]
)}
</Td>
</Tr>