Fix incorrect display of ISK recurring cost.

This commit is contained in:
Alex Hart
2024-09-20 16:11:47 -03:00
parent cafa5c9e28
commit 7935d12675
3 changed files with 14 additions and 8 deletions

View File

@@ -77,6 +77,18 @@ public class FiatMoney {
return formatter.format(amount.multiply(multiplicand));
}
/**
* Transforms the given currency / amount pair from a signal network amount to a FiatMoney, accounting for the special
* cased multiplicands for ISK and UGX
*/
public static @NonNull FiatMoney fromSignalNetworkAmount(@NonNull BigDecimal amount, @NonNull Currency currency) {
String currencyCode = currency.getCurrencyCode();
int shift = SPECIAL_CASE_MULTIPLICANDS.contains(currencyCode) ? 2: currency.getDefaultFractionDigits();
BigDecimal shiftedAmount = amount.movePointLeft(shift);
return new FiatMoney(shiftedAmount, currency);
}
public static boolean equals(FiatMoney left, FiatMoney right) {
return Objects.equals(left.amount, right.amount) &&
Objects.equals(left.currency, right.currency) &&