use of org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration in project head by mifos.
the class IndependentOfCustomerMeetingScheduleLoanInstallmentGenerator method getInstallmentDates.
private final List<InstallmentDate> getInstallmentDates(final ScheduledEvent scheduledEvent, LocalDate meetingStartDate, final int noOfInstallments, final int installmentToSkip, Short officeId) {
List<InstallmentDate> dueInstallmentDates = new ArrayList<InstallmentDate>();
if (noOfInstallments > 0) {
List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
List<Holiday> holidays = new ArrayList<Holiday>();
DateTime startFromMeetingDate = meetingStartDate.toDateMidnight().toDateTime();
holidays = holidayDao.findAllHolidaysFromDateAndNext(officeId, startFromMeetingDate.toLocalDate().toString());
final int occurrences = noOfInstallments + installmentToSkip;
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, holidays);
List<Date> dueDates = new ArrayList<Date>();
DateTime startFromDayAfterAssignedMeetingDateRatherThanSkippingInstallments = startFromMeetingDate;
// ensure loans that are created or disbursed on a meeting date start on next valid meeting date and not todays meeting
// ensure loans that are created or disbursed before a meeting date start on next valid meeting date
startFromDayAfterAssignedMeetingDateRatherThanSkippingInstallments = startFromMeetingDate.plusDays(1);
List<DateTime> installmentDates = dateGeneration.generateScheduledDates(occurrences, startFromDayAfterAssignedMeetingDateRatherThanSkippingInstallments, scheduledEvent, false);
for (DateTime installmentDate : installmentDates) {
dueDates.add(installmentDate.toDate());
}
dueInstallmentDates = createInstallmentDates(installmentToSkip, dueDates);
}
return dueInstallmentDates;
}
use of org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration in project head by mifos.
the class CustomerAccountBO method regenerateFutureInstallments.
@Override
protected void regenerateFutureInstallments(final AccountActionDateEntity nextInstallment, final List<Days> workingDays, final List<Holiday> holidays) throws AccountException {
int numberOfInstallmentsToGenerate = getLastInstallmentId();
MeetingBO meeting = getMeetingForAccount();
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(meeting);
LocalDate currentDate = new LocalDate();
LocalDate thisIntervalStartDate = meeting.startDateForMeetingInterval(currentDate);
LocalDate nextMatchingDate = new LocalDate(scheduledEvent.nextEventDateAfter(thisIntervalStartDate.toDateTimeAtStartOfDay()));
DateTime futureIntervalStartDate = meeting.startDateForMeetingInterval(nextMatchingDate).toDateTimeAtStartOfDay();
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, holidays);
List<DateTime> meetingDates = dateGeneration.generateScheduledDates(numberOfInstallmentsToGenerate, futureIntervalStartDate, scheduledEvent, true);
updateSchedule(nextInstallment.getInstallmentId(), meetingDates);
}
use of org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration in project head by mifos.
the class ApplyHolidayChangesHelper method getScheduledDateGeneration.
private ScheduledDateGeneration getScheduledDateGeneration(Short officeId) {
ScheduledDateGeneration scheduledDateGeneration = officeScheduledDateGenerationMap.get(officeId);
if (scheduledDateGeneration != null) {
return scheduledDateGeneration;
}
List<Holiday> futureHolidays = getHolidayDao().findCurrentAndFutureOfficeHolidaysEarliestFirst(officeId);
scheduledDateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, futureHolidays);
officeScheduledDateGenerationMap.put(officeId, scheduledDateGeneration);
return scheduledDateGeneration;
}
Aggregations