mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Add currency suffix if currency cannot be determined (#282)
This commit is contained in:
parent
82f25dfc90
commit
b2d4522fb2
@ -88,13 +88,24 @@ String renderCurrency(double? amount, String currency, {int decimals = 2}) {
|
|||||||
if (amount == null) return "-";
|
if (amount == null) return "-";
|
||||||
if (amount.isInfinite || amount.isNaN) return "-";
|
if (amount.isInfinite || amount.isNaN) return "-";
|
||||||
|
|
||||||
|
currency = currency.trim();
|
||||||
|
|
||||||
|
if (currency.isEmpty) return "-";
|
||||||
|
|
||||||
CurrencyFormatterSettings backupSettings = CurrencyFormatterSettings(
|
CurrencyFormatterSettings backupSettings = CurrencyFormatterSettings(
|
||||||
symbol: "\$",
|
symbol: "\$",
|
||||||
symbolSide: SymbolSide.left,
|
symbolSide: SymbolSide.left,
|
||||||
);
|
);
|
||||||
|
|
||||||
return CurrencyFormatter.format(
|
String value = CurrencyFormatter.format(
|
||||||
amount,
|
amount,
|
||||||
CurrencyFormatter.majors[currency.toLowerCase()] ?? backupSettings
|
CurrencyFormatter.majors[currency.toLowerCase()] ?? backupSettings
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// If we were not able to determine the currency
|
||||||
|
if (!CurrencyFormatter.majors.containsKey(currency.toLowerCase())) {
|
||||||
|
value += " ${currency}";
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user