Search in sources :

Example 1 with HolidayDao

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

the class SavingsBO method goActiveForFristTimeAndGenerateSavingsSchedule.

/**
     * use minimal constructor which generates scheduled savings payments correctly and does not
     * do through this method.
     */
@Deprecated
private void goActiveForFristTimeAndGenerateSavingsSchedule(final CustomerBO customer) throws AccountException {
    HolidayDao holidayDao = ApplicationContextProvider.getBean(HolidayDao.class);
    CalendarEvent futureCalendarEventsApplicableToOffice = holidayDao.findCalendarEventsForThisYearAndNext(customer.getOfficeId());
    this.activationDate = new DateTime(new DateTimeService().getCurrentJavaDateTime()).toDate();
    List<Days> workingDays = futureCalendarEventsApplicableToOffice.getWorkingDays();
    List<Holiday> holidays = futureCalendarEventsApplicableToOffice.getHolidays();
    logger.debug("In SavingsBO::generateDepositAccountActions()");
    // center/group with individual deposits, insert row for every client
    if (this.getCustomer().getCustomerMeeting() != null && this.getCustomer().getCustomerMeeting().getMeeting() != null) {
        MeetingBO depositSchedule = this.getCustomer().getCustomerMeeting().getMeeting();
        if (this.getCustomer().getCustomerLevel().getId().equals(CustomerLevel.CLIENT.getValue()) || this.getCustomer().getCustomerLevel().getId().equals(CustomerLevel.GROUP.getValue()) && this.getRecommendedAmntUnit().getId().equals(RecommendedAmountUnit.COMPLETE_GROUP.getValue())) {
            this.generateDepositAccountActions(this.getCustomer(), depositSchedule, workingDays, holidays, new DateTime(this.activationDate));
        } else {
            List<CustomerBO> children;
            try {
                children = this.getCustomer().getChildren(CustomerLevel.CLIENT, ChildrenStateType.ACTIVE_AND_ONHOLD);
            } catch (CustomerException ce) {
                throw new AccountException(ce);
            }
            for (CustomerBO customer1 : children) {
                this.generateDepositAccountActions(customer1, depositSchedule, workingDays, holidays, new DateTime(this.activationDate));
            }
        }
    }
    InterestScheduledEvent interestPostingEvent = new SavingsInterestScheduledEventFactory().createScheduledEventFrom(this.savingsOffering.getFreqOfPostIntcalc().getMeeting());
    this.nextIntPostDate = interestPostingEvent.nextMatchingDateAfter(new LocalDate(startOfFiscalYear()), new LocalDate(this.activationDate)).toDateMidnight().toDate();
}
Also used : SavingsInterestScheduledEventFactory(org.mifos.accounts.savings.interest.schedule.SavingsInterestScheduledEventFactory) CustomerException(org.mifos.customers.exceptions.CustomerException) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CalendarEvent(org.mifos.calendar.CalendarEvent) LocalDate(org.joda.time.LocalDate) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) DateTime(org.joda.time.DateTime) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) AccountException(org.mifos.accounts.exceptions.AccountException) Holiday(org.mifos.application.holiday.business.Holiday) Days(org.joda.time.Days) CustomerBO(org.mifos.customers.business.CustomerBO) DateTimeService(org.mifos.framework.util.DateTimeService)

Example 2 with HolidayDao

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

the class LegacyAccountDaoIntegrationTest method testGetListOfAccountIdsHavingLoanSchedulesWithinAHoliday.

@Test
public void testGetListOfAccountIdsHavingLoanSchedulesWithinAHoliday() throws Exception {
    Set<HolidayBO> holidays;
    DateTime fromDate = new DateMidnight().toDateTime().plusDays(1);
    DateTime thruDate = new DateMidnight().toDateTime().plusDays(30);
    GenericDao genericDao = new GenericDaoHibernate();
    OfficeDao officeDao = new OfficeDaoHibernate(genericDao);
    HolidayDao holidayDao = new HolidayDaoHibernate(genericDao);
    OfficeBO sampleBranch = officeDao.findOfficeById(this.getBranchOffice().getOfficeId());
    holidays = new HashSet<HolidayBO>();
    holiday = new HolidayBuilder().withName("Welcome Holiday").from(fromDate).to(thruDate).build();
    holidayDao.save(holiday);
    holidays.add((HolidayBO) holiday);
    sampleBranch.setHolidays(holidays);
    new OfficePersistence().createOrUpdate(sampleBranch);
    StaticHibernateUtil.flushSession();
    List<Object[]> AccountIds = legacyAccountDao.getListOfAccountIdsHavingLoanSchedulesWithinAHoliday(holiday);
    Assert.assertNotNull(AccountIds);
    assertThat(AccountIds.size(), is(2));
}
Also used : GenericDaoHibernate(org.mifos.accounts.savings.persistence.GenericDaoHibernate) GenericDao(org.mifos.accounts.savings.persistence.GenericDao) DateTime(org.joda.time.DateTime) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) HolidayDaoHibernate(org.mifos.application.holiday.persistence.HolidayDaoHibernate) DateMidnight(org.joda.time.DateMidnight) OfficeBO(org.mifos.customers.office.business.OfficeBO) OfficeDao(org.mifos.customers.office.persistence.OfficeDao) HolidayBO(org.mifos.application.holiday.business.HolidayBO) OfficeDaoHibernate(org.mifos.customers.office.persistence.OfficeDaoHibernate) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Test(org.junit.Test)

Example 3 with HolidayDao

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

the class LegacyAccountDaoIntegrationTest method testGetListOfAccountIdsHavingCustomerSchedulesWithinAHoliday.

@Test
public void testGetListOfAccountIdsHavingCustomerSchedulesWithinAHoliday() throws Exception {
    Set<HolidayBO> holidays;
    DateTime fromDate = new DateMidnight().toDateTime().plusDays(1);
    DateTime thruDate = new DateMidnight().toDateTime().plusDays(30);
    GenericDao genericDao = new GenericDaoHibernate();
    OfficeDao officeDao = new OfficeDaoHibernate(genericDao);
    HolidayDao holidayDao = new HolidayDaoHibernate(genericDao);
    OfficeBO sampleBranch = officeDao.findOfficeById(this.getBranchOffice().getOfficeId());
    holidays = new HashSet<HolidayBO>();
    holiday = new HolidayBuilder().withName("Welcome Holiday").from(fromDate).to(thruDate).build();
    holidayDao.save(holiday);
    holidays.add((HolidayBO) holiday);
    sampleBranch.setHolidays(holidays);
    new OfficePersistence().createOrUpdate(sampleBranch);
    StaticHibernateUtil.flushSession();
    List<Object[]> AccountIds = legacyAccountDao.getListOfAccountIdsHavingCustomerSchedulesWithinAHoliday(holiday);
    Assert.assertNotNull(AccountIds);
    assertThat(AccountIds.size(), is(3));
}
Also used : GenericDaoHibernate(org.mifos.accounts.savings.persistence.GenericDaoHibernate) GenericDao(org.mifos.accounts.savings.persistence.GenericDao) DateTime(org.joda.time.DateTime) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) HolidayDaoHibernate(org.mifos.application.holiday.persistence.HolidayDaoHibernate) DateMidnight(org.joda.time.DateMidnight) OfficeBO(org.mifos.customers.office.business.OfficeBO) OfficeDao(org.mifos.customers.office.persistence.OfficeDao) HolidayBO(org.mifos.application.holiday.business.HolidayBO) OfficeDaoHibernate(org.mifos.customers.office.persistence.OfficeDaoHibernate) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Test(org.junit.Test)

Example 4 with HolidayDao

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

the class LoanInstallmentFactoryImpl method create.

@Override
public LoanInstallmentGenerator create(MeetingBO meeting, boolean repaymentsShouldNotHaveToMatchCustomerMeetingSchedule) {
    HolidayDao holidayDao = ApplicationContextProvider.getBean(HolidayDao.class);
    ScheduledEvent scheduledEvent = scheduledEventFactory.createScheduledEventFrom(meeting);
    if (repaymentsShouldNotHaveToMatchCustomerMeetingSchedule) {
        LocalDate meetingStartDate = new LocalDate(meeting.getMeetingStartDate());
        return new IndependentOfCustomerMeetingScheduleLoanInstallmentGenerator(scheduledEvent, holidayDao, meetingStartDate);
    }
    return new AnyScheduledEventLoanInstallmentGenerator(scheduledEvent, holidayDao);
}
Also used : ScheduledEvent(org.mifos.schedule.ScheduledEvent) LocalDate(org.joda.time.LocalDate) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao)

Example 5 with HolidayDao

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

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