use of org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration in project head by mifos.
the class AnyScheduledEventLoanInstallmentGenerator method generate.
@Override
public List<InstallmentDate> generate(LocalDate actualDisbursementDate, int numberOfInstallments, GraceType graceType, int gracePeriodDuration, Short officeId) {
List<InstallmentDate> installmentDates = new ArrayList<InstallmentDate>();
if (numberOfInstallments > 0) {
List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
List<Holiday> holidays = new ArrayList<Holiday>();
LocalDate startFromMeetingDate = null;
if (scheduledEvent instanceof DailyScheduledEvent) {
startFromMeetingDate = actualDisbursementDate.plusDays(scheduledEvent.getEvery());
} else {
startFromMeetingDate = actualDisbursementDate.plusDays(1);
}
holidays = holidayDao.findAllHolidaysFromDateAndNext(officeId, startFromMeetingDate.toString());
int occurrences = numberOfInstallments;
if (graceType == GraceType.GRACEONALLREPAYMENTS) {
occurrences += gracePeriodDuration;
}
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, holidays);
List<Date> dueDates = new ArrayList<Date>();
List<DateTime> installmentDateTimes = dateGeneration.generateScheduledDates(occurrences, startFromMeetingDate.toDateMidnight().toDateTime(), scheduledEvent, false);
for (DateTime installmentDate : installmentDateTimes) {
dueDates.add(installmentDate.toDate());
}
installmentDates = createInstallmentDates(dueDates);
if (graceType == GraceType.GRACEONALLREPAYMENTS) {
removeInstallmentsNeedNotPay(gracePeriodDuration, installmentDates);
}
}
return installmentDates;
}
use of org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration in project head by mifos.
the class AccountBO method getFeeDates.
public final List<Date> getFeeDates(final MeetingBO feeMeetingFrequency, final List<InstallmentDate> installmentDates, final boolean adjustForHolidays) {
MeetingBO customerMeeting = getCustomer().getCustomerMeetingValue();
List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
HolidayDao holidayDao = ApplicationContextProvider.getBean(HolidayDao.class);
List<Holiday> holidays;
if (adjustForHolidays) {
holidays = holidayDao.findAllHolidaysThisYearAndNext(getOffice().getOfficeId());
} else {
holidays = new ArrayList<Holiday>();
}
DateTime startFromMeetingDate = new DateTime(installmentDates.get(0).getInstallmentDueDate());
DateTime repaymentEndDatetime = new DateTime(installmentDates.get(installmentDates.size() - 1).getInstallmentDueDate());
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(customerMeeting, feeMeetingFrequency);
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, holidays);
List<DateTime> feeScheduleDates = dateGeneration.generateScheduledDatesThrough(startFromMeetingDate, repaymentEndDatetime, scheduledEvent, true);
List<Date> feeSchedulesAsJavaDates = new ArrayList<Date>();
for (DateTime feeSchedule : feeScheduleDates) {
feeSchedulesAsJavaDates.add(feeSchedule.toDate());
}
return feeSchedulesAsJavaDates;
}
use of org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration in project head by mifos.
the class TestObjectFactory method getMeetingDatesThroughTo.
public static List<Date> getMeetingDatesThroughTo(short officeId, final MeetingBO meeting, Date endDate) {
List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
List<Holiday> upcomingHolidays = ApplicationContextProvider.getBean(HolidayDao.class).findAllHolidaysThisYearAndNext(officeId);
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(meeting);
DateTime meetingStartDate = new DateTime(meeting.getMeetingStartDate());
DateTime endDateTime = new DateTime(endDate);
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, upcomingHolidays);
List<DateTime> allDates = dateGeneration.generateScheduledDatesThrough(meetingStartDate, endDateTime, scheduledEvent, false);
List<Date> dates = new ArrayList<Date>();
for (DateTime dateTime : allDates) {
dates.add(dateTime.toDate());
}
return dates;
}
use of org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration in project head by mifos.
the class TestObjectFactory method getMeetingDates.
public static List<Date> getMeetingDates(short officeId, final MeetingBO meeting, final int occurrences) {
List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
List<Holiday> upcomingHolidays = ApplicationContextProvider.getBean(HolidayDao.class).findAllHolidaysThisYearAndNext(officeId);
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(meeting);
DateTime meetingStartDate = new DateTime(meeting.getMeetingStartDate());
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, upcomingHolidays);
List<DateTime> allDates = dateGeneration.generateScheduledDates(occurrences, meetingStartDate, scheduledEvent, false);
List<Date> dates = new ArrayList<Date>();
for (DateTime dateTime : allDates) {
dates.add(dateTime.toDate());
}
return dates;
}
use of org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration in project head by mifos.
the class AccountBO method getInstallmentDates.
/**
* @deprecated - used to create installment dates based on 'loan meeting' and working das, holidays, moratoria etc
*
* better to pull capability of creating 'installments' out of loan into something more reuseable and isolated
*/
@Deprecated
public final List<InstallmentDate> getInstallmentDates(final MeetingBO meeting, final Short noOfInstallments, final Short installmentToSkip, final boolean isRepaymentIndepOfMeetingEnabled, final boolean adjustForHolidays) {
logger.debug("Generating intallment dates");
List<InstallmentDate> dueInstallmentDates = new ArrayList<InstallmentDate>();
if (noOfInstallments > 0) {
List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
List<Holiday> holidays = new ArrayList<Holiday>();
DateTime startFromMeetingDate = new DateTime(meeting.getMeetingStartDate());
if (adjustForHolidays) {
HolidayDao holidayDao = ApplicationContextProvider.getBean(HolidayDao.class);
holidays = holidayDao.findAllHolidaysFromDateAndNext(getOffice().getOfficeId(), startFromMeetingDate.toLocalDate().toString());
}
final int occurrences = noOfInstallments + installmentToSkip;
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(meeting);
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, holidays);
List<Date> dueDates = new ArrayList<Date>();
// FIXME - keithw - this whole area of installment creation should be pulled out of domain
DateTime startFromDayAfterAssignedMeetingDateRatherThanSkippingInstallments = startFromMeetingDate;
if (this.isLoanAccount()) {
// 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;
}
Aggregations