FINERACT-418 penalties should be applied until the day before running job

This commit is contained in:
Lionel Raymundi - Poincenot
2017-03-19 23:11:29 -03:00
parent 8cc560cd84
commit a7b27d6d36
@@ -2395,15 +2395,15 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Long penaltyPostingWaitPeriodValue = this.configurationDomainService.retrieveGraceOnPenaltyPostingPeriod(); final Long penaltyPostingWaitPeriodValue = this.configurationDomainService.retrieveGraceOnPenaltyPostingPeriod();
final LocalDate dueDate = command.localDateValueOfParameterNamed("dueDate"); final LocalDate dueDate = command.localDateValueOfParameterNamed("dueDate");
Long diff = penaltyWaitPeriodValue + 1 - penaltyPostingWaitPeriodValue; Long diff = penaltyWaitPeriodValue + 1 - penaltyPostingWaitPeriodValue;
if (diff < 0) { if (diff < 1) {
diff = 0L; diff = 1L;
} }
LocalDate startDate = dueDate.plusDays(penaltyWaitPeriodValue.intValue() + 1); LocalDate startDate = dueDate.plusDays(penaltyWaitPeriodValue.intValue() + 1);
Integer frequencyNunber = 1; Integer frequencyNunber = 1;
if (feeFrequency == null) { if (feeFrequency == null) {
scheduleDates.put(frequencyNunber++, startDate.minusDays(diff.intValue())); scheduleDates.put(frequencyNunber++, startDate.minusDays(diff.intValue()));
} else { } else {
while (DateUtils.getLocalDateOfTenant().isAfter(startDate)) { while (!startDate.isAfter(DateUtils.getLocalDateOfTenant())) {
scheduleDates.put(frequencyNunber++, startDate.minusDays(diff.intValue())); scheduleDates.put(frequencyNunber++, startDate.minusDays(diff.intValue()));
LocalDate scheduleDate = scheduledDateGenerator.getRepaymentPeriodDate(PeriodFrequencyType.fromInt(feeFrequency), LocalDate scheduleDate = scheduledDateGenerator.getRepaymentPeriodDate(PeriodFrequencyType.fromInt(feeFrequency),
chargeDefinition.feeInterval(), startDate, null, null); chargeDefinition.feeInterval(), startDate, null, null);