use of org.mifos.schedule.ScheduledDateGeneration 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.ScheduledDateGeneration in project head by mifos.
the class ApplyHolidayChangesHelper method reschedule.
private void reschedule(Holiday holiday, AccountBatch accountBatch) throws PersistenceException {
long rescheduleStartTime = new DateTimeService().getCurrentDateTime().getMillis();
List<Object[]> accountIdsArray = accountBatch.getAccountIdsWithDatesIn(holiday);
accountCount = accountIdsArray.size();
logMessage("No. of " + accountBatch.getAccountTypeName() + " Accounts to Process: " + accountCount + " : Query took: " + (new DateTimeService().getCurrentDateTime().getMillis() - rescheduleStartTime) + " ms");
rollingStartTime = new DateTimeService().getCurrentDateTime().getMillis();
currentRecordNumber = 0;
StaticHibernateUtil.getSessionTL();
StaticHibernateUtil.startTransaction();
for (Object[] accountIds : accountIdsArray) {
Integer accountId = (Integer) accountIds[0];
Short officeId = (Short) accountIds[1];
Integer meetingId = (Integer) accountIds[2];
currentRecordNumber++;
ScheduledDateGeneration officeScheduledDateGeneration = getScheduledDateGeneration(officeId);
DateTime amendedThruDate = holiday.getThruDate();
// Normal holidays only affect installments between the fromDate and thruDate
if (holiday.getRepaymentRuleType().getValue().equals(RepaymentRuleTypes.REPAYMENT_MORATORIUM.getValue())) {
amendedThruDate = holiday.getThruDate().plusYears(10);
}
List<AccountActionDateEntity> futureAffectedInstallments = accountBatch.getAffectedInstallments(accountId, holiday.getFromDate(), amendedThruDate);
MeetingBO meeting = (MeetingBO) StaticHibernateUtil.getSessionTL().get(MeetingBO.class, meetingId);
rescheduleDatesForNewHolidays(officeScheduledDateGeneration, futureAffectedInstallments, meeting);
houseKeeping();
}
StaticHibernateUtil.commitTransaction();
long rescheduleEndTime = new DateTimeService().getCurrentDateTime().getMillis();
String message = "" + currentRecordNumber + " updated, " + (accountCount - currentRecordNumber) + " remaining, batch time: " + (rescheduleEndTime - rollingStartTime) + " ms";
logMessage(message);
String finalMessage = accountBatch.getAccountTypeName() + " accounts Processed in: " + (rescheduleEndTime - rescheduleStartTime) + " ms";
logMessage(finalMessage);
}
use of org.mifos.schedule.ScheduledDateGeneration 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