FINERACT-2081: Loan account data additional fields for summary and delinquency

This commit is contained in:
Jose Alberto Hernandez
2024-07-11 17:41:57 +02:00
committed by Adam Saghy
parent 4ac102f4e0
commit 79f32d32a3
11 changed files with 371 additions and 34 deletions
@@ -73,7 +73,8 @@ public class LoanBusinessEventSerializer implements BusinessEventSerializer {
if (data.getSummary() != null) {
final Collection<LoanTransactionData> currentLoanTransactions = service.retrieveLoanTransactions(loanId);
data.setSummary(LoanSummaryData.withTransactionAmountsSummary(data.getSummary(), currentLoanTransactions));
data.setSummary(
LoanSummaryData.withTransactionAmountsSummary(data.getSummary(), currentLoanTransactions, data.getRepaymentSchedule()));
} else {
data.setSummary(LoanSummaryData.withOnlyCurrencyData(data.getCurrency()));
}
@@ -1114,8 +1114,8 @@ public class LoansApiResource {
// updating summary with transaction amounts summary
if (loanBasicDetails.getSummary() != null) {
loanBasicDetails
.setSummary(LoanSummaryData.withTransactionAmountsSummary(loanBasicDetails.getSummary(), currentLoanRepayments));
loanBasicDetails.setSummary(
LoanSummaryData.withTransactionAmountsSummary(loanBasicDetails.getSummary(), currentLoanRepayments, repaymentSchedule));
}
final LoanAccountData loanAccount = LoanAccountData.associationsAndTemplate(loanBasicDetails, repaymentSchedule, loanRepayments,
@@ -636,7 +636,13 @@ final class LoansApiResourceSwagger {
@Schema(example = "0.000000")
public Double totalRepaymentTransaction;
@Schema(example = "0.000000")
public Double totalInterestPaymentWaiver;
@Schema(example = "0.000000")
public Double totalRepaymentTransactionReversed;
@Schema(example = "0.000000")
public Double totalUnpaidAccruedDueInterest;
@Schema(example = "0.000000")
public Double totalUnpaidAccruedNotDueInterest;
public Set<GetLoansLoanIdOverdueCharges> overdueCharges;
@Schema(example = "1")
public Long chargeOffReasonId;
@@ -1004,6 +1010,14 @@ final class LoansApiResourceSwagger {
public LocalDate delinquentDate;
@Schema(example = "100.000000")
public Double delinquentAmount;
@Schema(example = "80.000000")
public Double delinquentPrincipal;
@Schema(example = "10.000000")
public Double delinquentInterest;
@Schema(example = "6.000000")
public Double delinquentFee;
@Schema(example = "4.000000")
public Double delinquentPenalty;
@Schema(example = "[2022, 07, 01]")
public LocalDate lastPaymentDate;
@Schema(example = "100.000000")
@@ -1160,8 +1160,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService, Loa
+ " ls.fee_charges_amount as feeChargesDue, ls.fee_charges_completed_derived as feeChargesPaid, ls.fee_charges_waived_derived as feeChargesWaived, ls.fee_charges_writtenoff_derived as feeChargesWrittenOff, "
+ " ls.penalty_charges_amount as penaltyChargesDue, ls.penalty_charges_completed_derived as penaltyChargesPaid, ls.penalty_charges_waived_derived as penaltyChargesWaived, "
+ " ls.penalty_charges_writtenoff_derived as penaltyChargesWrittenOff, ls.total_paid_in_advance_derived as totalPaidInAdvanceForPeriod, "
+ " ls.total_paid_late_derived as totalPaidLateForPeriod, ls.credits_amount as principalCredits, ls.credited_fee as feeCredits, ls.credited_penalty as penaltyCredits, ls.is_down_payment isDownPayment "
+ " from m_loan_repayment_schedule ls ";
+ " ls.total_paid_late_derived as totalPaidLateForPeriod, ls.credits_amount as principalCredits, ls.credited_fee as feeCredits, ls.credited_penalty as penaltyCredits, ls.is_down_payment isDownPayment, "
+ " ls.accrual_interest_derived as accrualInterest " + " from m_loan_repayment_schedule ls ";
}
@Override
@@ -1260,6 +1260,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService, Loa
final BigDecimal interestWrittenOff = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "interestWrittenOff");
final BigDecimal totalInstallmentAmount = totalPrincipalPaid.zero().plus(principalDue).plus(interestExpectedDue)
.getAmount();
final BigDecimal accrualInterest = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "accrualInterest");
final BigDecimal interestActualDue = interestExpectedDue.subtract(interestWaived).subtract(interestWrittenOff);
final BigDecimal interestOutstanding = interestActualDue.subtract(interestPaid);
@@ -1331,7 +1332,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService, Loa
penaltyChargesPaid, penaltyChargesWaived, penaltyChargesWrittenOff, penaltyChargesOutstanding, totalDueForPeriod,
totalPaidForPeriod, totalPaidInAdvanceForPeriod, totalPaidLateForPeriod, totalWaivedForPeriod,
totalWrittenOffForPeriod, totalOutstandingForPeriod, totalActualCostOfLoanForPeriod, totalInstallmentAmount,
credits, isDownPayment);
credits, isDownPayment, accrualInterest);
periods.add(periodData);
}
@@ -2313,6 +2314,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService, Loa
final BigDecimal totalPaid = null;
final BigDecimal totalInstallmentAmount = null;
final BigDecimal totalCredits = null;
final BigDecimal totalAccruedInterest = null;
return LoanSchedulePeriodData.periodWithPayments(loanId, period, fromDate, dueDate, obligationsMetOnDate, complete,
principalOriginalDue, principalPaid, principalWrittenOff, principalOutstanding, outstandingPrincipalBalanceOfLoan,
@@ -2320,7 +2322,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService, Loa
feeChargesPaid, feeChargesWaived, feeChargesWrittenOff, feeChargesOutstanding, penaltyChargesDue, penaltyChargesPaid,
penaltyChargesWaived, penaltyChargesWrittenOff, penaltyChargesOutstanding, totalDueForPeriod, totalPaid,
totalPaidInAdvanceForPeriod, totalPaidLateForPeriod, totalWaived, totalWrittenOff, totalOutstanding,
totalActualCostOfLoanForPeriod, totalInstallmentAmount, totalCredits, false);
totalActualCostOfLoanForPeriod, totalInstallmentAmount, totalCredits, false, totalAccruedInterest);
}
}