Skip to content

Commit 6a12bad

Browse files
committed
refactor AbstractTransaction
1 parent 34bea52 commit 6a12bad

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/main/java/org/spacious_team/broker/report_parser/api/AbstractTransaction.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public List<TransactionCashFlow> getTransactionCashFlows() {
7676
}
7777

7878
protected Optional<TransactionCashFlow> getValueCashFlow(CashFlowType type) {
79-
if (value != null && valueCurrency != null && Math.abs(value.floatValue()) >= 0.0001) {
79+
if (value != null && valueCurrency != null && isNotZero(value)) {
8080
return Optional.of(TransactionCashFlow.builder()
8181
.transactionId(id)
8282
.eventType(type)
@@ -88,7 +88,7 @@ protected Optional<TransactionCashFlow> getValueCashFlow(CashFlowType type) {
8888
}
8989

9090
protected Optional<TransactionCashFlow> getFeeCashFlow() {
91-
if (fee != null && feeCurrency != null && Math.abs(fee.floatValue()) >= 0.0001) {
91+
if (fee != null && feeCurrency != null && isNotZero(fee)) {
9292
return Optional.of(TransactionCashFlow.builder()
9393
.transactionId(id)
9494
.eventType(FEE)
@@ -99,6 +99,10 @@ protected Optional<TransactionCashFlow> getFeeCashFlow() {
9999
return Optional.empty();
100100
}
101101

102+
protected boolean isNotZero(BigDecimal value) {
103+
return Math.abs(value.floatValue()) >= 0.0001;
104+
}
105+
102106
@EqualsAndHashCode.Include
103107
@SuppressWarnings("unused")
104108
private @Nullable BigDecimal getValueForEquals() {

src/main/java/org/spacious_team/broker/report_parser/api/SecurityTransaction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public List<TransactionCashFlow> getTransactionCashFlows() {
5252

5353
private Optional<TransactionCashFlow> getAccruedInterestCashFlow() {
5454
// for securities accrued interest = 0
55-
if (accruedInterest != null && valueCurrency != null && Math.abs(accruedInterest.floatValue()) >= 0.0001) {
55+
if (accruedInterest != null && valueCurrency != null && isNotZero(accruedInterest)) {
5656
return Optional.of(TransactionCashFlow.builder()
5757
.transactionId(id)
5858
.eventType(CashFlowType.ACCRUED_INTEREST)

0 commit comments

Comments
 (0)