Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display correct trade and tx fees in CSV export #4256

Merged
merged 1 commit into from May 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -121,7 +121,7 @@ public ClosedTradesView(ClosedTradesViewModel model,
@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")));
Expand All @@ -141,7 +141,7 @@ public void initialize() {
setDirectionColumnCellFactory();
setAmountColumnCellFactory();
setTxFeeColumnCellFactory();
setMakerFeeColumnCellFactory();
setTradeFeeColumnCellFactory();
setBuyerSecurityDepositColumnCellFactory();
setSellerSecurityDepositColumnCellFactory();
setPriceColumnCellFactory();
Expand All @@ -167,7 +167,7 @@ public void initialize() {
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 ->
Expand Down Expand Up @@ -518,9 +518,9 @@ public void updateItem(final ClosedTradableListItem item, boolean empty) {
});
}

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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ String getTxFee(ClosedTradableListItem item) {
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());
Expand All @@ -101,7 +101,7 @@ String getMakerFee(ClosedTradableListItem item) {
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());
Expand Down Expand Up @@ -195,4 +195,8 @@ int getNumPastTrades(Tradable tradable) {
.collect(Collectors.toSet())
.size();
}

boolean wasMyOffer(Tradable tradable) {
return dataModel.closedTradableManager.wasMyOffer(tradable.getOffer());
}
}