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: handle undefined or null currency codes

Brad Barbin126ca416f846
diff --git a/apps/carbon/app/components/Form/ExchangeRate.tsx b/apps/carbon/app/components/Form/ExchangeRate.tsx
index ae7d328de9..a4e4a6451c 100644
--- a/apps/carbon/app/components/Form/ExchangeRate.tsx
+++ b/apps/carbon/app/components/Form/ExchangeRate.tsx
@@ -38,7 +38,7 @@ const ExchangeRate: React.FC<ExchangeRateProps> = ({
return (
<div className="relative">
- <HStack spacing={0}>
+ <HStack spacing={0} className="items-end">
<Input
label={
<HStack spacing={1}>
@@ -60,10 +60,10 @@ const ExchangeRate: React.FC<ExchangeRateProps> = ({
{onRefresh && (
<IconButton
aria-label="Refresh exchange rate"
- className="bg-transparent flex-shrink-0 h-10 rounded-l-none border-l-0 shadow-sm self-end"
+ className="flex-shrink-0 h-10 w-10 px-3 rounded-l-none border-l-0 shadow-sm"
icon={<LuRefreshCw />}
variant="secondary"
- size="lg"
+ size="md"
onClick={onRefresh}
/>
)}
diff --git a/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsx b/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsx
index d6baf5b367..836296ddf5 100644
--- a/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/Quotes/QuoteForm.tsx
@@ -174,6 +174,7 @@ const QuoteForm = ({ initialValues }: QuoteFormProps) => {
}}
/>
{isEditing &&
+ !!customer.currencyCode &&
customer.currencyCode !== company.baseCurrencyCode && (
<ExchangeRate
name="exchangeRate"
diff --git a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderForm.tsx b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderForm.tsx
index da7be8838d..004f4108a2 100644
--- a/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderForm.tsx
+++ b/apps/carbon/app/modules/sales/ui/SalesOrder/SalesOrderForm.tsx
@@ -166,6 +166,7 @@ const SalesOrderForm = ({ initialValues }: SalesOrderFormProps) => {
/>
{isEditing &&
+ !!customer.currencyCode &&
customer.currencyCode !== company.baseCurrencyCode && (
<ExchangeRate
name="exchangeRate"
diff --git a/packages/documents/src/pdf/QuotePDF.tsx b/packages/documents/src/pdf/QuotePDF.tsx
index 51de1e4d17..567bb2f60e 100644
--- a/packages/documents/src/pdf/QuotePDF.tsx
+++ b/packages/documents/src/pdf/QuotePDF.tsx
@@ -67,7 +67,8 @@ const QuotePDF = ({
} = quoteCustomerDetails;
const currencyCode = quote.currencyCode ?? company.baseCurrencyCode;
- const shouldConvertCurrency = currencyCode !== company.baseCurrencyCode;
+ const shouldConvertCurrency =
+ !!currencyCode && currencyCode !== company.baseCurrencyCode;
const formatter = getCurrencyFormatter(currencyCode, locale);
const pricesByLine = quoteLinePrices.reduce<
diff --git a/packages/documents/src/pdf/SalesOrderPDF.tsx b/packages/documents/src/pdf/SalesOrderPDF.tsx
index 1083eb4914..d450eeeb29 100644
--- a/packages/documents/src/pdf/SalesOrderPDF.tsx
+++ b/packages/documents/src/pdf/SalesOrderPDF.tsx
@@ -65,7 +65,8 @@ const SalesOrderPDF = ({
} = salesOrderLocations;
const currencyCode = salesOrder.currencyCode ?? company.baseCurrencyCode;
- const shouldConvertCurrency = currencyCode !== company.baseCurrencyCode;
+ const shouldConvertCurrency =
+ !!currencyCode && currencyCode !== company.baseCurrencyCode;
const formatter = getCurrencyFormatter(currencyCode, locale);
return (