Skip to content

Commit

Permalink
Merge pull request #5452 from BtcContributor/addfiatequivalent
Browse files Browse the repository at this point in the history
 Add fiat equivalent for Total Amount & Security Deposit for both makers and sellers
  • Loading branch information
ripcurlx authored May 4, 2021
2 parents ec4ce60 + de74ab0 commit 31b7bd1
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,10 @@ public TradeCurrency getTradeCurrency() {
}

public String getTradeAmount() {
return btcFormatter.formatCoinWithCode(dataModel.getAmount().get());
return FeeUtil.getTradeFeeWithFiatEquivalent(offerUtil,
dataModel.getAmount().get(),
true,
btcFormatter);
}

public String getSecurityDepositLabel() {
Expand All @@ -1006,10 +1009,13 @@ public String getSecurityDepositPopOverLabel(String depositInBTC) {
}

public String getSecurityDepositInfo() {
return btcFormatter.formatCoinWithCode(dataModel.getSecurityDeposit()) +
GUIUtil.getPercentageOfTradeAmount(dataModel.getSecurityDeposit(),
dataModel.getAmount().get(),
Restrictions.getMinBuyerSecurityDepositAsCoin());
return FeeUtil.getTradeFeeWithFiatEquivalentAndPercentage(offerUtil,
dataModel.getSecurityDeposit(),
dataModel.getAmount().get(),
true,
btcFormatter,
Restrictions.getMinBuyerSecurityDepositAsCoin()
);
}

public String getSecurityDepositWithCode() {
Expand Down Expand Up @@ -1044,11 +1050,17 @@ public String getMakerFeePercentage() {
}

public String getTotalToPayInfo() {
final String totalToPay = this.totalToPay.get();
if (dataModel.isCurrencyForMakerFeeBtc())
return totalToPay;
else
return totalToPay + " + " + bsqFormatter.formatCoinWithCode(dataModel.getMakerFee());
if (dataModel.isCurrencyForMakerFeeBtc()) {
return FeeUtil.getTradeFeeWithFiatEquivalent(offerUtil,
dataModel.totalToPayAsCoin.get(),
true,
btcFormatter);
} else {
return FeeUtil.getTradeFeeWithFiatEquivalent(offerUtil,
dataModel.totalToPayAsCoin.get(),
true,
btcFormatter) + " + " + getTradeFee();
}
}

public String getFundsStructure() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public abstract class OfferDataModel extends ActivatableDataModel {
@Getter
protected final BooleanProperty isBtcWalletFunded = new SimpleBooleanProperty();
@Getter
protected final ObjectProperty<Coin> totalToPayAsCoin = new SimpleObjectProperty<>();
public final ObjectProperty<Coin> totalToPayAsCoin = new SimpleObjectProperty<>();
@Getter
protected final ObjectProperty<Coin> balance = new SimpleObjectProperty<>();
@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ private void onShowPayFundsScreen() {

String tradeAmountText = model.isSeller() ? Res.get("takeOffer.takeOfferFundWalletInfo.tradeAmount", model.getTradeAmount()) : "";
String message = Res.get("takeOffer.takeOfferFundWalletInfo.msg",
model.totalToPay.get(),
model.getTotalToPayInfo(),
tradeAmountText,
model.getSecurityDepositInfo(),
model.getTradeFee(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -684,14 +684,20 @@ public String getAmountDescription() {
}

String getTradeAmount() {
return btcFormatter.formatCoinWithCode(dataModel.getAmount().get());
return FeeUtil.getTradeFeeWithFiatEquivalent(offerUtil,
dataModel.getAmount().get(),
true,
btcFormatter);
}

public String getSecurityDepositInfo() {
return btcFormatter.formatCoinWithCode(dataModel.getSecurityDeposit()) +
GUIUtil.getPercentageOfTradeAmount(dataModel.getSecurityDeposit(),
dataModel.getAmount().get(),
Restrictions.getMinBuyerSecurityDepositAsCoin());
return FeeUtil.getTradeFeeWithFiatEquivalentAndPercentage(offerUtil,
dataModel.getSecurityDeposit(),
dataModel.getAmount().get(),
true,
btcFormatter,
Restrictions.getMinBuyerSecurityDepositAsCoin()
);
}

public String getSecurityDepositWithCode() {
Expand Down Expand Up @@ -725,11 +731,17 @@ public String getTakerFeePercentage() {
}

public String getTotalToPayInfo() {
final String totalToPay = this.totalToPay.get();
if (dataModel.isCurrencyForTakerFeeBtc())
return totalToPay;
else
return totalToPay + " + " + bsqFormatter.formatCoinWithCode(dataModel.getTakerFee());
if (dataModel.isCurrencyForTakerFeeBtc()) {
return FeeUtil.getTradeFeeWithFiatEquivalent(offerUtil,
dataModel.totalToPayAsCoin.get(),
true,
btcFormatter);
} else {
return FeeUtil.getTradeFeeWithFiatEquivalent(offerUtil,
dataModel.totalToPayAsCoin.get(),
true,
btcFormatter) + " + " + getTradeFee();
}
}

public String getTxFee() {
Expand Down

0 comments on commit 31b7bd1

Please sign in to comment.