Correct negative amount display

This commit is contained in:
Hillel Coren 2021-02-08 09:00:06 +02:00
parent 6f045918d9
commit 251b7ad1d0
1 changed files with 3 additions and 2 deletions

View File

@ -196,13 +196,14 @@ String formatNumber(
formatted = formatter.format(value < 0 ? value * -1 : value); formatted = formatter.format(value < 0 ? value * -1 : value);
} }
final prefix = value < 0 ? '-' : '';
if (formatNumberType == FormatNumberType.percent) { if (formatNumberType == FormatNumberType.percent) {
return '$formatted%'; return '$formatted%';
} else if ((showCurrencyCode ?? company.settings.showCurrencyCode ?? false) || } else if ((showCurrencyCode ?? company.settings.showCurrencyCode ?? false) ||
currency.symbol.isEmpty) { currency.symbol.isEmpty) {
return '$formatted ${currency.code}'; return '$prefix$formatted ${currency.code}';
} else { } else {
final prefix = value < 0 ? '-' : '';
if (swapCurrencySymbol) { if (swapCurrencySymbol) {
return '$prefix$formatted ${currency.symbol.trim()}'; return '$prefix$formatted ${currency.symbol.trim()}';
} else { } else {