Search in sources :

Example 11 with InstallmentDate

use of org.mifos.accounts.util.helpers.InstallmentDate in project head by mifos.

the class CustomerAccountBO method handlePeriodic.

@Override
protected final List<FeeInstallment> handlePeriodic(final AccountFeesEntity accountFees, final List<InstallmentDate> installmentDates, final List<InstallmentDate> nonAdjustedInstallmentDates) throws AccountException {
    Money accountFeeAmount = accountFees.getAccountFeeAmount();
    MeetingBO feeMeetingFrequency = accountFees.getFees().getFeeFrequency().getFeeMeetingFrequency();
    List<Date> feeDates = getFeeDates(feeMeetingFrequency, nonAdjustedInstallmentDates);
    ListIterator<Date> feeDatesIterator = feeDates.listIterator();
    List<FeeInstallment> feeInstallmentList = new ArrayList<FeeInstallment>();
    while (feeDatesIterator.hasNext()) {
        Date feeDate = feeDatesIterator.next();
        logger.debug("Handling periodic fee.." + feeDate);
        Short installmentId = getMatchingInstallmentId(installmentDates, feeDate);
        feeInstallmentList.add(buildFeeInstallment(installmentId, accountFeeAmount, accountFees));
    }
    return feeInstallmentList;
}
Also used : Money(org.mifos.framework.util.helpers.Money) MeetingBO(org.mifos.application.meeting.business.MeetingBO) FeeInstallment(org.mifos.accounts.util.helpers.FeeInstallment) ArrayList(java.util.ArrayList) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate)

Example 12 with InstallmentDate

use of org.mifos.accounts.util.helpers.InstallmentDate in project head by mifos.

the class AccountBO method handleOneTime.

protected final FeeInstallment handleOneTime(final AccountFeesEntity accountFee, final List<InstallmentDate> installmentDates) {
    Money accountFeeAmount = accountFee.getAccountFeeAmount();
    Date feeDate = installmentDates.get(0).getInstallmentDueDate();
    logger.debug("Handling OneTime fee" + feeDate);
    Short installmentId = getMatchingInstallmentId(installmentDates, feeDate);
    logger.debug("OneTime fee applicable installment id " + installmentId);
    return buildFeeInstallment(installmentId, accountFeeAmount, accountFee);
}
Also used : Money(org.mifos.framework.util.helpers.Money) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate)

Example 13 with InstallmentDate

use of org.mifos.accounts.util.helpers.InstallmentDate in project head by mifos.

the class AccountBO method removeInstallmentsNeedNotPay.

private void removeInstallmentsNeedNotPay(final Short 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 14 with InstallmentDate

use of org.mifos.accounts.util.helpers.InstallmentDate in project head by mifos.

the class AccountBO method createInstallmentDates.

/**
     * @deprecated - remove when loan schedules or 'installment' creation responsibility is moved out of account/loan
     */
@Deprecated
protected List<InstallmentDate> createInstallmentDates(final Short 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)

Example 15 with InstallmentDate

use of org.mifos.accounts.util.helpers.InstallmentDate 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;
}
Also used : ScheduledEvent(org.mifos.schedule.ScheduledEvent) ArrayList(java.util.ArrayList) DateTime(org.joda.time.DateTime) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate) 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)

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