Search in sources :

Example 6 with HolidayDao

use of org.mifos.application.holiday.persistence.HolidayDao 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)

Example 7 with HolidayDao

use of org.mifos.application.holiday.persistence.HolidayDao in project head by mifos.

the class SavingsScheduleIntegrationTest method createClientSavingsAccount.

public void createClientSavingsAccount() throws Exception {
    meeting = new MeetingBuilder().customerMeeting().weekly().every(1).withStartDate(expectedFirstDepositDate).build();
    IntegrationTestObjectMother.saveMeeting(meeting);
    center = new CenterBuilder().with(meeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
    IntegrationTestObjectMother.createCenter(center, meeting);
    group = new GroupBuilder().withMeeting(meeting).withName("Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
    IntegrationTestObjectMother.createGroup(group, meeting);
    client = new ClientBuilder().withMeeting(meeting).withName("Client 1").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(client, meeting);
    savingsProduct = new SavingsProductBuilder().mandatory().appliesToClientsOnly().buildForIntegrationTests();
    HolidayDao holidayDao = ApplicationContextProvider.getBean(HolidayDao.class);
    List<Holiday> holidays = holidayDao.findAllHolidaysThisYearAndNext(client.getOfficeId());
    savingsAccount = new SavingsAccountBuilder().withSavingsProduct(savingsProduct).withCustomer(client).with(holidays).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) Holiday(org.mifos.application.holiday.business.Holiday) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) ClientBuilder(org.mifos.domain.builders.ClientBuilder)

Aggregations

HolidayDao (org.mifos.application.holiday.persistence.HolidayDao)7 DateTime (org.joda.time.DateTime)5 LocalDate (org.joda.time.LocalDate)4 Holiday (org.mifos.application.holiday.business.Holiday)4 Days (org.joda.time.Days)3 ScheduledEvent (org.mifos.schedule.ScheduledEvent)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 DateMidnight (org.joda.time.DateMidnight)2 Test (org.junit.Test)2 GenericDao (org.mifos.accounts.savings.persistence.GenericDao)2 GenericDaoHibernate (org.mifos.accounts.savings.persistence.GenericDaoHibernate)2 InstallmentDate (org.mifos.accounts.util.helpers.InstallmentDate)2 HolidayBO (org.mifos.application.holiday.business.HolidayBO)2 HolidayDaoHibernate (org.mifos.application.holiday.persistence.HolidayDaoHibernate)2 MeetingBO (org.mifos.application.meeting.business.MeetingBO)2 FiscalCalendarRules (org.mifos.config.FiscalCalendarRules)2 OfficeBO (org.mifos.customers.office.business.OfficeBO)2 OfficeDao (org.mifos.customers.office.persistence.OfficeDao)2 OfficeDaoHibernate (org.mifos.customers.office.persistence.OfficeDaoHibernate)2