Update getAdjustedFiatVolume and getAdjustedAmount methods

This commit is contained in:
Manfred Karrer 2018-08-19 12:30:04 +02:00
parent 005d330db9
commit a2f2503b47
No known key found for this signature in database
GPG key ID: 401250966A6B2C46
4 changed files with 9 additions and 8 deletions

View file

@ -673,7 +673,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs
if (isHalCashAccount())
volumeByAmount = OfferUtil.getAdjustedVolumeForHalCash(volumeByAmount);
else if (CurrencyUtil.isFiatCurrency(tradeCurrencyCode.get()))
volumeByAmount = OfferUtil.getRoundedFiatVolume(volumeByAmount, tradeCurrencyCode.get());
volumeByAmount = OfferUtil.getRoundedFiatVolume(volumeByAmount);
volume.set(volumeByAmount);
} catch (Throwable t) {
@ -695,7 +695,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel implements Bs
if (isHalCashAccount())
value = OfferUtil.getAdjustedAmountForHalCash(value, price.get(), getMaxTradeLimit());
else if (CurrencyUtil.isFiatCurrency(tradeCurrencyCode.get()))
value = OfferUtil.getRoundedFiatAmount(value, price.get(), tradeCurrencyCode.get(), getMaxTradeLimit());
value = OfferUtil.getRoundedFiatAmount(value, price.get(), getMaxTradeLimit());
calculateVolume();

View file

@ -764,7 +764,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
if (dataModel.isHalCashAccount())
volume = OfferUtil.getAdjustedVolumeForHalCash(volume);
else if (CurrencyUtil.isFiatCurrency(tradeCurrencyCode.get()))
volume = OfferUtil.getRoundedFiatVolume(volume, tradeCurrencyCode.get());
volume = OfferUtil.getRoundedFiatVolume(volume);
this.volume.set(btcFormatter.formatVolume(volume));
}
@ -979,7 +979,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
if (dataModel.isHalCashAccount())
amount = OfferUtil.getAdjustedAmountForHalCash(amount, price, maxTradeLimit);
else if (CurrencyUtil.isFiatCurrency(tradeCurrencyCode.get()))
amount = OfferUtil.getRoundedFiatAmount(amount, price, tradeCurrencyCode.get(), maxTradeLimit);
amount = OfferUtil.getRoundedFiatAmount(amount, price, maxTradeLimit);
}
dataModel.setAmount(amount);
if (syncMinAmountWithAmount ||
@ -1003,7 +1003,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> ext
if (dataModel.isHalCashAccount())
minAmount = OfferUtil.getAdjustedAmountForHalCash(minAmount, price, maxTradeLimit);
else if (CurrencyUtil.isFiatCurrency(tradeCurrencyCode.get()))
minAmount = OfferUtil.getRoundedFiatAmount(minAmount, price, tradeCurrencyCode.get(), maxTradeLimit);
minAmount = OfferUtil.getRoundedFiatAmount(minAmount, price, maxTradeLimit);
}
dataModel.setMinAmount(minAmount);

View file

@ -496,7 +496,7 @@ class TakeOfferDataModel extends OfferDataModel {
if (offer.getPaymentMethod().getId().equals(PaymentMethod.HAL_CASH_ID))
volumeByAmount = OfferUtil.getAdjustedVolumeForHalCash(volumeByAmount);
else if (CurrencyUtil.isFiatCurrency(getCurrencyCode()))
volumeByAmount = OfferUtil.getRoundedFiatVolume(volumeByAmount, getCurrencyCode());
volumeByAmount = OfferUtil.getRoundedFiatVolume(volumeByAmount);
volume.set(volumeByAmount);

View file

@ -296,7 +296,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
// We only apply the rounding if the amount is variable (minAmount is lower as amount).
// Otherwise we could get an amount lower then the minAmount set by rounding
Coin roundedAmount = OfferUtil.getRoundedFiatAmount(dataModel.getAmount().get(), tradePrice,
dataModel.getCurrencyCode(), maxTradeLimit);
maxTradeLimit);
dataModel.applyAmount(roundedAmount);
}
amount.set(btcFormatter.formatCoin(dataModel.getAmount().get()));
@ -566,7 +566,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
} else if (CurrencyUtil.isFiatCurrency(dataModel.getCurrencyCode()) && !isAmountEqualMinAmount(amount)) {
// We only apply the rounding if the amount is variable (minAmount is lower as amount).
// Otherwise we could get an amount lower then the minAmount set by rounding
amount = OfferUtil.getRoundedFiatAmount(amount, price, dataModel.getCurrencyCode(), maxTradeLimit);
amount = OfferUtil.getRoundedFiatAmount(amount, price, maxTradeLimit);
}
}
dataModel.applyAmount(amount);
@ -577,6 +577,7 @@ class TakeOfferViewModel extends ActivatableWithDataModel<TakeOfferDataModel> im
return amount.value == offer.getMinAmount().value;
}
///////////////////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////////////////