Skip to content

Commit

Permalink
FINERACT-2081: Apply penalty to overdue loans enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Alberto Hernandez committed Aug 30, 2024
1 parent 284022a commit 179ec48
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public class ApplyChargeToOverdueLoansBusinessStep implements LoanCOBBusinessSte
public Loan execute(Loan loan) {
final Collection<OverdueLoanScheduleData> overdueLoanScheduleDataList = loanReadPlatformService
.retrieveAllOverdueInstallmentsForLoan(loan);
loanChargeWritePlatformService.applyOverdueChargesForLoan(loan.getId(), overdueLoanScheduleDataList);
if (!overdueLoanScheduleDataList.isEmpty()) {
loanChargeWritePlatformService.applyOverdueChargesForLoan(loan.getId(), overdueLoanScheduleDataList);
}
return loan;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,15 @@ public Collection<OverdueLoanScheduleData> retrieveAllOverdueInstallmentsForLoan
if (!loan.isOpen()) {
return list;
}

Optional<Charge> optPenaltyCharge = loan.getLoanProduct().getCharges().stream()
.filter((e) -> ChargeTimeType.OVERDUE_INSTALLMENT.getValue().equals(e.getChargeTimeType()) && e.isLoanCharge()).findFirst();

if (optPenaltyCharge.isEmpty()) {
return list;
}
final Charge penaltyCharge = optPenaltyCharge.get();

final Long penaltyWaitPeriod = configurationDomainService.retrievePenaltyWaitPeriod();
final boolean backdatePenalties = configurationDomainService.isBackdatePenaltiesEnabled();

Expand All @@ -1657,16 +1666,9 @@ public Collection<OverdueLoanScheduleData> retrieveAllOverdueInstallmentsForLoan
if (!backdatePenalties && !isDueToday) {
continue;
}
Optional<Charge> penaltyCharge = loan.getLoanProduct().getCharges().stream()
.filter((e) -> ChargeTimeType.OVERDUE_INSTALLMENT.getValue().equals(e.getChargeTimeType()) && e.isLoanCharge())
.findFirst();

if (penaltyCharge.isEmpty()) {
continue;
}

list.add(new OverdueLoanScheduleData(loan.getId(), penaltyCharge.get().getId(),
DateUtils.DEFAULT_DATE_FORMATTER.format(installment.getDueDate()), penaltyCharge.get().getAmount(),
list.add(new OverdueLoanScheduleData(loan.getId(), penaltyCharge.getId(),
DateUtils.DEFAULT_DATE_FORMATTER.format(installment.getDueDate()), penaltyCharge.getAmount(),
DateUtils.DEFAULT_DATE_FORMAT, Locale.ENGLISH.toLanguageTag(),
installment.getPrincipalOutstanding(loan.getCurrency()).getAmount(),
installment.getInterestOutstanding(loan.getCurrency()).getAmount(), installment.getInstallmentNumber()));
Expand Down

0 comments on commit 179ec48

Please sign in to comment.