use of org.mifos.accounts.util.helpers.InstallmentDate 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.accounts.util.helpers.InstallmentDate in project head by mifos.
the class AnyScheduledEventLoanInstallmentGenerator method removeInstallmentsNeedNotPay.
private void removeInstallmentsNeedNotPay(final int installmentSkipToStartRepayment, final List<InstallmentDate> installmentDates) {
int removeCounter = 0;
for (int i = 0; i < installmentSkipToStartRepayment; i++) {
installmentDates.remove(removeCounter);
}
// re-adjust the installment ids
if (installmentSkipToStartRepayment > 0) {
int count = installmentDates.size();
for (int i = 0; i < count; i++) {
InstallmentDate instDate = installmentDates.get(i);
instDate.setInstallmentId(new Short(Integer.toString(i + 1)));
}
}
}
use of org.mifos.accounts.util.helpers.InstallmentDate in project head by mifos.
the class AnyScheduledEventLoanInstallmentGenerator method createInstallmentDates.
private List<InstallmentDate> createInstallmentDates(final List<Date> dueDates) {
List<InstallmentDate> installmentDates = new ArrayList<InstallmentDate>();
int installmentId = 1;
for (Date date : dueDates) {
installmentDates.add(new InstallmentDate((short) installmentId++, date));
}
return installmentDates;
}
use of org.mifos.accounts.util.helpers.InstallmentDate in project head by mifos.
the class LoanScheduleServiceDomain method generateScheduleDates.
private List<DateTime> generateScheduleDates(LoanOfferingBO loanProduct, MeetingBO loanMeeting, LoanProductOverridenDetail overridenDetail, LoanScheduleConfiguration configuration, Short userBranchOfficeId) {
LoanInstallmentGenerator loanInstallmentGenerator = loanInstallmentFactory.create(loanMeeting, configuration.isLoanScheduleIndependentOfCustomerMeetingEnabled());
List<InstallmentDate> installmentDates = loanInstallmentGenerator.generate(overridenDetail.getDisbursementDate(), overridenDetail.getNumberOfInstallments(), loanProduct.getGracePeriodType().asEnum(), overridenDetail.getGraceDuration(), userBranchOfficeId);
List<DateTime> loanScheduleDates = new ArrayList<DateTime>();
for (InstallmentDate installmentDate : installmentDates) {
loanScheduleDates.add(new DateTime(installmentDate.getInstallmentDueDate()));
}
return loanScheduleDates;
}
use of org.mifos.accounts.util.helpers.InstallmentDate in project head by mifos.
the class IndependentOfCustomerMeetingScheduleLoanInstallmentGenerator method createInstallmentDates.
private List<InstallmentDate> createInstallmentDates(final int installmentToSkip, final List<Date> dueDates) {
List<InstallmentDate> installmentDates = new ArrayList<InstallmentDate>();
int installmentId = 1;
for (Date date : dueDates) {
installmentDates.add(new InstallmentDate((short) installmentId++, date));
}
removeInstallmentsNeedNotPay(installmentToSkip, installmentDates);
return installmentDates;
}
Aggregations