Skip to content

Commit

Permalink
Merge pull request #60 from charvam/ET-1028_old_et_format_ignores_fee…
Browse files Browse the repository at this point in the history
…_zero

Et 1028 old et format ignores fee zero
  • Loading branch information
charvam authored Jul 28, 2021
2 parents b152e75 + 959e275 commit 7b1b188
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 45 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
projectVersion=3.7.0
projectVersion=3.7.1
pf4jVersion=3.4.0
xchangeVersion=5.0.4
requiredEverytradeVersion=>=20210427
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
import io.everytrade.server.plugin.api.parser.FeeRebateImportedTransactionBean;
import io.everytrade.server.plugin.api.parser.ImportedTransactionBean;
import io.everytrade.server.plugin.api.parser.TransactionCluster;
import io.everytrade.server.plugin.impl.everytrade.parser.ParserUtils;
import io.everytrade.server.plugin.impl.everytrade.parser.exchange.ExchangeBean;

import java.math.BigDecimal;
import java.time.Instant;
import java.util.Collections;
import java.util.Date;
import java.util.List;

Expand Down Expand Up @@ -77,19 +79,25 @@ public TransactionCluster toTransactionCluster() {
quantity, //base quantity
price //unit price
);
List<ImportedTransactionBean> related;
if (ParserUtils.equalsToZero(fee)) {
related = Collections.emptyList();
} else {
related = List.of(
new FeeRebateImportedTransactionBean(
uid + FEE_UID_PART,
date,
symbolBase,
symbolQuote,
TransactionType.FEE,
fee,
symbolQuote
)
);
}
return new TransactionCluster(
buySell,
List.of(
new FeeRebateImportedTransactionBean(
uid + FEE_UID_PART,
date,
symbolBase,
symbolQuote,
TransactionType.FEE,
fee,
symbolQuote
)
)
related
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
import io.everytrade.server.model.TransactionType;
import io.everytrade.server.plugin.api.parser.BuySellImportedTransactionBean;
import io.everytrade.server.plugin.api.parser.FeeRebateImportedTransactionBean;
import io.everytrade.server.plugin.api.parser.ImportedTransactionBean;
import io.everytrade.server.plugin.api.parser.TransactionCluster;
import io.everytrade.server.plugin.impl.everytrade.parser.ParserUtils;
import io.everytrade.server.plugin.impl.everytrade.parser.exchange.ExchangeBean;

import java.math.BigDecimal;
import java.time.Instant;
import java.util.Collections;
import java.util.Date;
import java.util.List;

Expand Down Expand Up @@ -68,6 +71,21 @@ public void setFee(BigDecimal fee) {
public TransactionCluster toTransactionCluster() {
validateCurrencyPair(symbolBase, symbolQuote);

List<ImportedTransactionBean> related;
if (ParserUtils.equalsToZero(fee)) {
related = Collections.emptyList();
} else {
related = List.of(new FeeRebateImportedTransactionBean(
uid + FEE_UID_PART,
date,
symbolBase,
symbolQuote,
TransactionType.FEE,
fee,
symbolQuote
)
);
}
return new TransactionCluster(
new BuySellImportedTransactionBean(
uid,
Expand All @@ -78,16 +96,7 @@ public TransactionCluster toTransactionCluster() {
quantity,
evalUnitPrice(volume, quantity)
),
List.of(new FeeRebateImportedTransactionBean(
uid + FEE_UID_PART,
date,
symbolBase,
symbolQuote,
TransactionType.FEE,
fee,
symbolQuote
)
)
);
related
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,7 @@ void testConversionFromNullToZero() {
new BigDecimal("0.066506"),
new BigDecimal("210507.322647581")
),
List.of(
new FeeRebateImportedTransactionBean(
"1-fee",
Instant.parse("2019-09-01T14:43:18Z"),
Currency.BTC,
Currency.CZK,
TransactionType.FEE,
new BigDecimal("0"),
Currency.CZK
)
),
List.of(),
0
);
ParserTestUtils.checkEqual(expected, acual);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,7 @@ void testConversionFromNullToZero() {
new BigDecimal("0.066506"),
new BigDecimal("210507.3226475807")
),
List.of(
new FeeRebateImportedTransactionBean(
"1-fee",
Instant.parse("2019-09-01T14:43:18Z"),
Currency.BTC,
Currency.CZK,
TransactionType.FEE,
new BigDecimal("0"),
Currency.CZK
)
),
List.of(),
0
);
ParserTestUtils.checkEqual(expected, acual);
Expand Down

0 comments on commit 7b1b188

Please sign in to comment.