Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.function.Predicate;
import lombok.Getter;
Expand Down Expand Up @@ -1014,9 +1015,28 @@ public void updateAmount(BigDecimal bigDecimal) {
this.amount = bigDecimal;
}

// TODO missing hashCode(), equals(Object obj), but probably OK as long as
// this is never stored in a Collection.

@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof LoanTransaction other)) {
return false;
}
if (getId() == null || other.getId() == null) {
return false;
}
return Objects.equals(getId(), other.getId());
}


@Override
public int hashCode() {
return Objects.hash(getId());
}


public void updateTransactionDate(final LocalDate transactionDate) {
this.dateOf = transactionDate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ private Map<AllocationType, Money> adjustOriginalAllocationWithFormerChargebacks
// let's figure out the original transaction for these chargebacks, and order them by ascending order
Comparator<LoanTransaction> comparator = LoanTransactionComparator.INSTANCE;
List<LoanTransaction> chargebacksForTheSameOriginal = chargebacks.stream()
.filter(tr -> findChargebackOriginalTransaction(tr, ctx) == originalTransaction
.filter(tr -> Objects.equals(findChargebackOriginalTransaction(tr, ctx), originalTransaction)
&& comparator.compare(tr, chargebackTransaction) < 0)
.sorted(comparator).toList();

Expand Down Expand Up @@ -1355,7 +1355,7 @@ private Predicate<LoanTransactionRelation> hasMatchingToLoanTransaction(Long id,

private Predicate<LoanTransactionRelation> hasMatchingToLoanTransaction(LoanTransaction loanTransaction,
LoanTransactionRelationTypeEnum typeEnum) {
return relation -> relation.getRelationType().equals(typeEnum) && relation.getToTransaction() == loanTransaction;
return relation -> relation.getRelationType().equals(typeEnum) && Objects.equals(relation.getToTransaction(), loanTransaction);
}

protected void handleRefund(LoanTransaction loanTransaction, TransactionCtx ctx) {
Expand Down
Loading