Euro Sign is randomly left or right in the Client Table #174

This commit is contained in:
Hillel Coren 2021-01-17 18:24:25 +02:00
parent 20b48f92ad
commit 2f0ed79aa2
1 changed files with 14 additions and 7 deletions

View File

@ -109,8 +109,14 @@ String formatNumber(
}
final CurrencyEntity currency = state.staticState.currencyMap[currencyId];
final CurrencyEntity companyCurrency =
state.staticState.currencyMap[company.currencyId];
final CountryEntity country =
state.staticState.countryMap[countryId] ?? CountryEntity();
final CountryEntity companyCountry =
state.staticState.countryMap[company.settings.countryId] ??
CountryEntity();
if (currency == null) {
return '';
@ -122,10 +128,10 @@ String formatNumber(
String thousandSeparator = currency.thousandSeparator;
String decimalSeparator = currency.decimalSeparator;
bool swapCurrencySymbol = currency.swapCurrencySymbol;
bool swapCurrencySymbol = companyCurrency.swapCurrencySymbol;
if (currency.id == kCurrencyEuro) {
swapCurrencySymbol = country.swapCurrencySymbol;
swapCurrencySymbol = companyCountry.swapCurrencySymbol;
if (country.thousandSeparator != null &&
country.thousandSeparator.isNotEmpty) {
thousandSeparator = country.thousandSeparator;
@ -195,12 +201,13 @@ String formatNumber(
} else if ((showCurrencyCode ?? company.settings.showCurrencyCode ?? false) ||
currency.symbol.isEmpty) {
return '$formatted ${currency.code}';
} else if (swapCurrencySymbol) {
return '$formatted ${currency.symbol.trim()}';
} else if (value < 0) {
return '${currency.symbol}$formatted';
} else {
return '${currency.symbol}$formatted';
final prefix = value < 0 ? '-' : '';
if (swapCurrencySymbol) {
return '$prefix$formatted ${currency.symbol.trim()}';
} else {
return '$prefix${currency.symbol}$formatted';
}
}
}