Fix incorrect display of ISK recurring cost.
This commit is contained in:
parent
cafa5c9e28
commit
7935d12675
3 changed files with 14 additions and 8 deletions
|
@ -410,10 +410,7 @@ class DonateToSignalFragment :
|
|||
val isActive = state.activeLevel == subscription.level && state.isSubscriptionActive
|
||||
|
||||
val activePrice = state.activeSubscription?.let { sub ->
|
||||
val activeCurrency = Currency.getInstance(sub.currency)
|
||||
val activeAmount = sub.amount.movePointLeft(activeCurrency.defaultFractionDigits)
|
||||
|
||||
FiatMoney(activeAmount, activeCurrency)
|
||||
FiatMoney.fromSignalNetworkAmount(sub.amount, Currency.getInstance(sub.currency))
|
||||
}
|
||||
|
||||
customPref(
|
||||
|
|
|
@ -265,12 +265,9 @@ class ManageDonationsFragment :
|
|||
state: ManageDonationsState
|
||||
) {
|
||||
presentSubscriptionSettingsWithState(state) {
|
||||
val activeCurrency = Currency.getInstance(activeSubscription.currency)
|
||||
val activeAmount = activeSubscription.amount.movePointLeft(activeCurrency.defaultFractionDigits)
|
||||
|
||||
customPref(
|
||||
ActiveSubscriptionPreference.Model(
|
||||
price = FiatMoney(activeAmount, activeCurrency),
|
||||
price = FiatMoney.fromSignalNetworkAmount(activeSubscription.amount, Currency.getInstance(activeSubscription.currency)),
|
||||
subscription = subscription,
|
||||
renewalTimestamp = TimeUnit.SECONDS.toMillis(activeSubscription.endOfCurrentPeriod),
|
||||
redemptionState = state.getMonthlyDonorRedemptionState(),
|
||||
|
|
|
@ -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) &&
|
||||
|
|
Loading…
Add table
Reference in a new issue