Merge pull request #4256 from jmacxx/fix_trade_fees_export

Display correct trade and tx fees in CSV export
This commit is contained in:
sqrrm 2020-05-25 15:46:53 +02:00 committed by GitHub
commit 799d48e74a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 11 deletions

View File

@ -63,7 +63,7 @@ shared.priceInCurForCur=Price in {0} for 1 {1}
shared.fixedPriceInCurForCur=Fixed price in {0} for 1 {1}
shared.amount=Amount
shared.txFee=Transaction Fee
shared.makerFee=Maker Fee
shared.tradeFee=Trade Fee
shared.buyerSecurityDeposit=Buyer Deposit
shared.sellerSecurityDeposit=Seller Deposit
shared.amountWithCur=Amount in {0}

View File

@ -41,7 +41,7 @@
<TableColumn fx:id="amountColumn" minWidth="130"/>
<TableColumn fx:id="volumeColumn" minWidth="130"/>
<TableColumn fx:id="txFeeColumn" visible="false"/>
<TableColumn fx:id="makerFeeColumn" visible="false"/>
<TableColumn fx:id="tradeFeeColumn" visible="false"/>
<TableColumn fx:id="buyerSecurityDepositColumn" visible="false"/>
<TableColumn fx:id="sellerSecurityDepositColumn" visible="false"/>
<TableColumn fx:id="directionColumn" minWidth="80"/>

View File

@ -82,7 +82,7 @@ public class ClosedTradesView extends ActivatableViewAndModel<VBox, ClosedTrades
@FXML
TableView<ClosedTradableListItem> tableView;
@FXML
TableColumn<ClosedTradableListItem, ClosedTradableListItem> priceColumn, amountColumn, volumeColumn, txFeeColumn, makerFeeColumn, buyerSecurityDepositColumn, sellerSecurityDepositColumn,
TableColumn<ClosedTradableListItem, ClosedTradableListItem> priceColumn, amountColumn, volumeColumn, txFeeColumn, tradeFeeColumn, buyerSecurityDepositColumn, sellerSecurityDepositColumn,
marketColumn, directionColumn, dateColumn, tradeIdColumn, stateColumn, avatarColumn;
@FXML
HBox footerBox;
@ -121,7 +121,7 @@ public class ClosedTradesView extends ActivatableViewAndModel<VBox, ClosedTrades
@Override
public void initialize() {
txFeeColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.txFee")));
makerFeeColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.makerFee")));
tradeFeeColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.tradeFee")));
buyerSecurityDepositColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.buyerSecurityDeposit")));
sellerSecurityDepositColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.sellerSecurityDeposit")));
priceColumn.setGraphic(new AutoTooltipLabel(Res.get("shared.price")));
@ -141,7 +141,7 @@ public class ClosedTradesView extends ActivatableViewAndModel<VBox, ClosedTrades
setDirectionColumnCellFactory();
setAmountColumnCellFactory();
setTxFeeColumnCellFactory();
setMakerFeeColumnCellFactory();
setTradeFeeColumnCellFactory();
setBuyerSecurityDepositColumnCellFactory();
setSellerSecurityDepositColumnCellFactory();
setPriceColumnCellFactory();
@ -167,7 +167,7 @@ public class ClosedTradesView extends ActivatableViewAndModel<VBox, ClosedTrades
txFeeColumn.setComparator(nullsFirstComparing(o ->
o instanceof Trade ? ((Trade) o).getTxFee() : o.getOffer().getTxFee()
));
makerFeeColumn.setComparator(nullsFirstComparing(o ->
tradeFeeColumn.setComparator(nullsFirstComparing(o ->
o instanceof Trade ? ((Trade) o).getTakerFee() : o.getOffer().getMakerFee()
));
buyerSecurityDepositColumn.setComparator(nullsFirstComparing(o ->
@ -518,9 +518,9 @@ public class ClosedTradesView extends ActivatableViewAndModel<VBox, ClosedTrades
});
}
private void setMakerFeeColumnCellFactory() {
makerFeeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
makerFeeColumn.setCellFactory(
private void setTradeFeeColumnCellFactory() {
tradeFeeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
tradeFeeColumn.setCellFactory(
new Callback<>() {
@Override
public TableCell<ClosedTradableListItem, ClosedTradableListItem> call(

View File

@ -91,7 +91,7 @@ class ClosedTradesViewModel extends ActivatableWithDataModel<ClosedTradesDataMod
if (item == null)
return "";
Tradable tradable = item.getTradable();
if (tradable instanceof Trade)
if (!wasMyOffer(tradable) && (tradable instanceof Trade))
return formatter.formatCoin(((Trade) tradable).getTxFee());
else
return formatter.formatCoin(tradable.getOffer().getTxFee());
@ -101,7 +101,7 @@ class ClosedTradesViewModel extends ActivatableWithDataModel<ClosedTradesDataMod
if (item == null)
return "";
Tradable tradable = item.getTradable();
if (tradable instanceof Trade)
if (!wasMyOffer(tradable) && (tradable instanceof Trade))
return formatter.formatCoin(((Trade) tradable).getTakerFee());
else
return formatter.formatCoin(tradable.getOffer().getMakerFee());
@ -195,4 +195,8 @@ class ClosedTradesViewModel extends ActivatableWithDataModel<ClosedTradesDataMod
.collect(Collectors.toSet())
.size();
}
boolean wasMyOffer(Tradable tradable) {
return dataModel.closedTradableManager.wasMyOffer(tradable.getOffer());
}
}