Format currency correctly by placing negative sign at beginning.

This is forcefully placed at the beginning of the formatted currency because of how `currency` message is customisable. Until a better solution arises this shall stay.
This commit is contained in:
Ali Moghnieh 2017-08-19 20:11:21 +01:00
parent 04755cee33
commit 365ae356bd
No known key found for this signature in database
GPG Key ID: F09D3A1BAF2E6D70

View File

@ -55,11 +55,23 @@ public class NumberUtil {
}
public static String displayCurrency(final BigDecimal value, final IEssentials ess) {
return tl("currency", ess.getSettings().getCurrencySymbol(), formatAsPrettyCurrency(value));
String currency = formatAsPrettyCurrency(value);
String sign = "";
if (value.signum() < 0) {
currency = currency.substring(1);
sign = "-";
}
return sign + tl("currency", ess.getSettings().getCurrencySymbol(), currency);
}
public static String displayCurrencyExactly(final BigDecimal value, final IEssentials ess) {
return tl("currency", ess.getSettings().getCurrencySymbol(), value.toPlainString());
String currency = value.toPlainString();
String sign = "";
if (value.signum() < 0) {
currency = currency.substring(1);
sign = "-";
}
return sign + tl("currency", ess.getSettings().getCurrencySymbol(), currency);
}
public static boolean isInt(final String sInt) {