@caratlogic/design-system 0.1.46 → 0.1.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/molecules/InvoiceComboBox/InvoiceComboBox.utils.d.ts.map +1 -1
- package/dist/index.cjs.js +12 -8
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +12 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/utils/currencyUtils.d.ts +2 -0
- package/dist/utils/currencyUtils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -14011,9 +14011,15 @@ const getCurrencySymbol = (code) => {
|
|
|
14011
14011
|
CAD: 'CA$',
|
|
14012
14012
|
CHF: 'CHF',
|
|
14013
14013
|
INR: '₹',
|
|
14014
|
+
PLN: 'zł',
|
|
14014
14015
|
};
|
|
14015
14016
|
return symbols[c] ?? c;
|
|
14016
14017
|
};
|
|
14018
|
+
/** Intl prints the bare code for currencies with no English symbol (PLN 1,230.00); use our symbol instead. */
|
|
14019
|
+
const withCurrencySymbol = (formatted, code) => {
|
|
14020
|
+
const symbol = getCurrencySymbol(code);
|
|
14021
|
+
return symbol === code ? formatted : formatted.replace(code, symbol);
|
|
14022
|
+
};
|
|
14017
14023
|
/**
|
|
14018
14024
|
* Format currency amount with proper symbol, ensuring USD always shows as "$" not "US$"
|
|
14019
14025
|
* This normalizes browser inconsistencies in Intl.NumberFormat output
|
|
@@ -14037,7 +14043,7 @@ function formatCurrencyAmount(amount, currency, options) {
|
|
|
14037
14043
|
if (currencyCode === 'USD' && formatted.includes('US$')) {
|
|
14038
14044
|
formatted = formatted.replace(/US\$/g, '$');
|
|
14039
14045
|
}
|
|
14040
|
-
return formatted;
|
|
14046
|
+
return withCurrencySymbol(formatted, currencyCode);
|
|
14041
14047
|
}
|
|
14042
14048
|
catch (error) {
|
|
14043
14049
|
// Fallback if currency code is invalid
|
|
@@ -44615,17 +44621,15 @@ const WarehouseFilter = ({ getWarehouseList, ...props }) => {
|
|
|
44615
44621
|
};
|
|
44616
44622
|
|
|
44617
44623
|
function formatInvoiceLabel(invoice) {
|
|
44618
|
-
const amount =
|
|
44619
|
-
style: 'currency',
|
|
44620
|
-
currency: invoice.baseCurrency || 'USD',
|
|
44621
|
-
}).format(invoice.totalAmount);
|
|
44624
|
+
const amount = formatCurrency(invoice.totalAmount, invoice.baseCurrency);
|
|
44622
44625
|
return `${invoice.invoiceNumber} - ${invoice.customer?.contactName || 'N/A'} (${amount})`;
|
|
44623
44626
|
}
|
|
44624
44627
|
function formatCurrency(amount, currency) {
|
|
44625
|
-
|
|
44628
|
+
const code = currency || 'USD';
|
|
44629
|
+
return withCurrencySymbol(new Intl.NumberFormat('en-US', {
|
|
44626
44630
|
style: 'currency',
|
|
44627
|
-
currency:
|
|
44628
|
-
}).format(amount);
|
|
44631
|
+
currency: code,
|
|
44632
|
+
}).format(amount), code);
|
|
44629
44633
|
}
|
|
44630
44634
|
/** The currency the invoice was issued in; `baseCurrency` is only its ledger currency. */
|
|
44631
44635
|
function getInvoiceCurrency(invoice) {
|