FINERACT-2162: Support chargeback for progressive loans with disabled interest recalculation and payment allocation

This commit is contained in:
Oleksii Novikov
2025-02-05 14:55:15 +01:00
committed by Adam Saghy
parent 224e84a9c2
commit 7d0474cc17
8 changed files with 374 additions and 15 deletions
@@ -140,6 +140,9 @@ public class LoanRepaymentScheduleInstallment extends AbstractAuditableWithUTCDa
@Column(name = "credits_amount", scale = 6, precision = 19, nullable = true)
private BigDecimal creditedPrincipal;
@Column(name = "credited_interest", scale = 6, precision = 19, nullable = true)
private BigDecimal creditedInterest;
@Column(name = "credited_fee", scale = 6, precision = 19, nullable = true)
private BigDecimal creditedFee;
@@ -232,8 +235,8 @@ public class LoanRepaymentScheduleInstallment extends AbstractAuditableWithUTCDa
public LoanRepaymentScheduleInstallment(Loan loan, Integer installmentNumber, LocalDate fromDate, LocalDate dueDate,
BigDecimal principal, BigDecimal interestCharged, BigDecimal feeChargesCharged, BigDecimal penaltyCharges,
BigDecimal creditedPrincipal, BigDecimal creditedFee, BigDecimal creditedPenalty, boolean additional, boolean isDownPayment,
boolean isReAged) {
BigDecimal creditedPrincipal, BigDecimal creditedInterest, BigDecimal creditedFee, BigDecimal creditedPenalty,
boolean additional, boolean isDownPayment, boolean isReAged) {
this.loan = loan;
this.installmentNumber = installmentNumber;
this.fromDate = fromDate;
@@ -243,6 +246,7 @@ public class LoanRepaymentScheduleInstallment extends AbstractAuditableWithUTCDa
this.feeChargesCharged = feeChargesCharged;
this.penaltyCharges = penaltyCharges;
this.creditedPrincipal = creditedPrincipal;
this.creditedInterest = creditedInterest;
this.creditedFee = creditedFee;
this.creditedPenalty = creditedPenalty;
this.additional = additional;
@@ -253,7 +257,7 @@ public class LoanRepaymentScheduleInstallment extends AbstractAuditableWithUTCDa
public static LoanRepaymentScheduleInstallment newReAgedInstallment(final Loan loan, final Integer installmentNumber,
final LocalDate fromDate, final LocalDate dueDate, final BigDecimal principal) {
return new LoanRepaymentScheduleInstallment(loan, installmentNumber, fromDate, dueDate, principal, null, null, null, null, null,
null, false, false, true);
null, null, false, false, true);
}
public static LoanRepaymentScheduleInstallment getLastNonDownPaymentInstallment(List<LoanRepaymentScheduleInstallment> installments) {
@@ -442,6 +446,10 @@ public class LoanRepaymentScheduleInstallment extends AbstractAuditableWithUTCDa
this.principal = this.principal.subtract(this.creditedPrincipal);
this.creditedPrincipal = null;
}
if (this.creditedInterest != null) {
this.interestCharged = this.interestCharged.subtract(this.creditedInterest);
this.creditedInterest = null;
}
if (this.creditedFee != null) {
this.feeChargesCharged = this.feeChargesCharged.subtract(this.creditedFee);
this.creditedFee = null;
@@ -853,6 +861,14 @@ public class LoanRepaymentScheduleInstallment extends AbstractAuditableWithUTCDa
}
}
public void addToCreditedInterest(final BigDecimal amount) {
if (this.creditedInterest == null) {
this.creditedInterest = amount;
} else {
this.creditedInterest = this.creditedInterest.add(amount);
}
}
public void addToCreditedFee(final BigDecimal amount) {
if (this.creditedFee == null) {
this.creditedFee = amount;