Search in sources :

Example 6 with InstallmentDate

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;
}
Also used : DailyScheduledEvent(org.mifos.schedule.internal.DailyScheduledEvent) ArrayList(java.util.ArrayList) LocalDate(org.joda.time.LocalDate) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration) ScheduledDateGeneration(org.mifos.schedule.ScheduledDateGeneration) Holiday(org.mifos.application.holiday.business.Holiday) Days(org.joda.time.Days) FiscalCalendarRules(org.mifos.config.FiscalCalendarRules) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration)

Example 7 with InstallmentDate

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)));
        }
    }
}
Also used : InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate)

Example 8 with InstallmentDate

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;
}
Also used : ArrayList(java.util.ArrayList) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate)

Example 9 with InstallmentDate

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;
}
Also used : LoanInstallmentGenerator(org.mifos.clientportfolio.newloan.domain.LoanInstallmentGenerator) ArrayList(java.util.ArrayList) DateTime(org.joda.time.DateTime) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate)

Example 10 with InstallmentDate

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;
}
Also used : ArrayList(java.util.ArrayList) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate)

Aggregations

InstallmentDate (org.mifos.accounts.util.helpers.InstallmentDate)25 ArrayList (java.util.ArrayList)18 Date (java.util.Date)12 LocalDate (org.joda.time.LocalDate)12 Money (org.mifos.framework.util.helpers.Money)10 DateTime (org.joda.time.DateTime)9 FeeInstallment (org.mifos.accounts.util.helpers.FeeInstallment)9 ScheduledEvent (org.mifos.schedule.ScheduledEvent)7 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)6 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)6 MeetingBO (org.mifos.application.meeting.business.MeetingBO)5 Days (org.joda.time.Days)4 InstallmentPrincipalAndInterest (org.mifos.accounts.loan.util.helpers.InstallmentPrincipalAndInterest)4 Holiday (org.mifos.application.holiday.business.Holiday)4 FiscalCalendarRules (org.mifos.config.FiscalCalendarRules)4 ScheduledDateGeneration (org.mifos.schedule.ScheduledDateGeneration)4 HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration (org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration)4 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 RateAmountFlag (org.mifos.accounts.fees.util.helpers.RateAmountFlag)2