FINERACT-2181: Fix Consult Loan repayment schedule with disbursement harge using amount plus interest
This commit is contained in:
committed by
Adam Saghy
parent
9d6243442c
commit
94cc68ba7c
+7
-3
@@ -749,7 +749,8 @@ public class LoanScheduleAssembler {
|
||||
|
||||
LoanScheduleModel loanScheduleModel = loanScheduleGenerator.generate(mc, loanApplicationTerms, loanCharges, detailDTO);
|
||||
if (!nonCompoundingCharges.isEmpty()) {
|
||||
updateDisbursementWithCharges(loanScheduleModel.getPeriods(), nonCompoundingCharges);
|
||||
updateDisbursementWithCharges(loanApplicationTerms.getPrincipal().getAmount(), loanScheduleModel.getPeriods(),
|
||||
nonCompoundingCharges);
|
||||
}
|
||||
return loanScheduleModel;
|
||||
}
|
||||
@@ -1564,14 +1565,17 @@ public class LoanScheduleAssembler {
|
||||
return interestCharges;
|
||||
}
|
||||
|
||||
private void updateDisbursementWithCharges(final Collection<LoanScheduleModelPeriod> periods,
|
||||
private void updateDisbursementWithCharges(final BigDecimal principal, final Collection<LoanScheduleModelPeriod> periods,
|
||||
final Set<LoanCharge> nonCompoundingCharges) {
|
||||
final BigDecimal totalInterest = periods.stream().filter(p -> p.isRepaymentPeriod()).map(LoanScheduleModelPeriod::interestDue)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
for (LoanScheduleModelPeriod loanScheduleModelPeriod : periods) {
|
||||
if (loanScheduleModelPeriod instanceof LoanScheduleModelDisbursementPeriod) {
|
||||
for (final LoanCharge loanCharge : nonCompoundingCharges) {
|
||||
loanChargeService.populateDerivedFields(loanCharge, totalInterest, loanCharge.amountOrPercentage(), null,
|
||||
final BigDecimal amountAppliedTo = loanCharge.getChargeCalculation().isPercentageOfAmountAndInterest()
|
||||
? principal.add(totalInterest)
|
||||
: totalInterest;
|
||||
loanChargeService.populateDerivedFields(loanCharge, amountAppliedTo, loanCharge.amountOrPercentage(), null,
|
||||
BigDecimal.ZERO);
|
||||
loanScheduleModelPeriod.addLoanCharges(loanCharge.getAmountOutstanding(), BigDecimal.ZERO);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user