FINERACT-2104: Accrual Activity Reverse Replay Transaction

This commit is contained in:
Soma Sörös
2024-07-15 10:31:28 +02:00
committed by Adam Saghy
parent a4f077d675
commit 9fceaf98b3
8 changed files with 398 additions and 24 deletions
@@ -197,6 +197,7 @@ public class AdvancedPaymentScheduleTransactionProcessor extends AbstractLoanRep
case WAIVE_CHARGES -> log.debug("WAIVE_CHARGES transaction will not be processed.");
case REAMORTIZE -> handleReAmortization(loanTransaction, ctx.getCurrency(), ctx.getInstallments());
case REAGE -> handleReAge(loanTransaction, ctx);
case ACCRUAL_ACTIVITY -> calculateAccrualActivity(loanTransaction, ctx.getCurrency(), ctx.getInstallments());
// TODO: Cover rest of the transaction types
default -> {
log.warn("Unhandled transaction processing for transaction type: {}", loanTransaction.getTypeOf());
@@ -57,6 +57,10 @@ public class ChargeOrTransaction implements Comparable<ChargeOrTransaction> {
}
}
private boolean isAccrualActivity() {
return loanTransaction.isPresent() && loanTransaction.get().isAccrualActivity();
}
private boolean isBackdatedCharge() {
return loanCharge.get().getDueDate().isBefore(loanCharge.get().getSubmittedOnDate());
}
@@ -86,6 +90,12 @@ public class ChargeOrTransaction implements Comparable<ChargeOrTransaction> {
public int compareTo(@NotNull ChargeOrTransaction o) {
int datePortion = this.getEffectiveDate().compareTo(o.getEffectiveDate());
if (datePortion == 0) {
if (this.isAccrualActivity() && !o.isAccrualActivity()) {
return 1;
}
if (!this.isAccrualActivity() && o.isAccrualActivity()) {
return -1;
}
int submittedDate = this.getSubmittedOnDate().compareTo(o.getSubmittedOnDate());
if (submittedDate == 0) {
return this.getCreatedDateTime().compareTo(o.getCreatedDateTime());