FINERACT-1992: Backdated delinquency pause events

This commit is contained in:
Ruchi Dhamankar
2023-12-15 11:01:54 +01:00
committed by Adam Saghy
parent cd2f2f8102
commit 5edd18aec2
3 changed files with 128 additions and 6 deletions
@@ -157,12 +157,13 @@ public class LoanDelinquencyRangeChangeBusinessEventSerializer implements Busine
.build();
// get list of charges for installments in same range
List<LoanCharge> chargesForInstallmentsInSameRange = loan.getLoanCharges().stream()
.filter(loanCharge -> !loanCharge.isPaid() && delinquentInstallmentsInSameRange.stream().anyMatch(
installmentForCharge -> (DateUtils.isAfter(loanCharge.getDueDate(), installmentForCharge.getFromDate())
|| DateUtils.isEqual(loanCharge.getDueDate(), installmentForCharge.getFromDate()))
&& (DateUtils.isBefore(loanCharge.getDueDate(), installmentForCharge.getDueDate())
|| DateUtils.isEqual(loanCharge.getDueDate(), installmentForCharge.getDueDate()))))
List<LoanCharge> chargesForInstallmentsInSameRange = loan.getLoanCharges().stream().filter(loanCharge -> !loanCharge
.isPaid()
&& delinquentInstallmentsInSameRange.stream().anyMatch(installmentForCharge -> (DateUtils
.isAfter(loanCharge.getEffectiveDueDate(), installmentForCharge.getFromDate())
|| DateUtils.isEqual(loanCharge.getEffectiveDueDate(), installmentForCharge.getFromDate()))
&& (DateUtils.isBefore(loanCharge.getEffectiveDueDate(), installmentForCharge.getDueDate())
|| DateUtils.isEqual(loanCharge.getEffectiveDueDate(), installmentForCharge.getDueDate()))))
.toList();
List<LoanChargeDataRangeViewV1> charges = new ArrayList<>();
@@ -236,6 +236,10 @@ public class DelinquencyWritePlatformServiceImpl implements DelinquencyWritePlat
if (DateUtils.isBefore(parsedDelinquencyAction.getStartDate(), businessDate)
&& DelinquencyAction.PAUSE.equals(parsedDelinquencyAction.getAction())) {
recalculateLoanDelinquencyData(loan);
// if pause end date is after current business date, loan delinquency pause flag is changed, emit event
if (DateUtils.isAfter(parsedDelinquencyAction.getEndDate(), businessDate)) {
businessEventNotifierService.notifyPostBusinessEvent(new LoanDelinquencyRangeChangeBusinessEvent(loan));
}
}
businessEventNotifierService.notifyPostBusinessEvent(new LoanAccountDelinquencyPauseChangedBusinessEvent(loan));
return new CommandProcessingResultBuilder().withCommandId(command.commandId()) //