use of org.mifos.application.holiday.business.Holiday 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();
}
use of org.mifos.application.holiday.business.Holiday in project head by mifos.
the class HolidayDaoHibernateIntegrationTest method shouldSaveFutureHoliday.
@Test
public void shouldSaveFutureHoliday() throws Exception {
List<Holiday> holidays = holidayDao.findAllHolidaysThisYearAndNext((short) 1);
int initialCount = holidays.size();
OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
Holiday futureHoliday = new HolidayBuilder().from(new DateTime()).to(new DateTime().plusDays(1)).appliesTo(headOffice).build();
StaticHibernateUtil.startTransaction();
holidayDao.save(futureHoliday);
StaticHibernateUtil.flushSession();
holidays = holidayDao.findAllHolidaysThisYearAndNext(headOffice.getOfficeId());
assertFalse(holidays.isEmpty());
assertThat(holidays.size() - initialCount, is(1));
}
use of org.mifos.application.holiday.business.Holiday in project head by mifos.
the class HolidayDaoHibernateIntegrationTest method shouldFindAllHolidaysOrderedByFromDateAscending.
@Ignore
@Test
public void shouldFindAllHolidaysOrderedByFromDateAscending() throws Exception {
DateTime secondlastDayOfYear = new DateTime().withMonthOfYear(12).withDayOfMonth(30).toDateMidnight().toDateTime();
DateTime lastDayOfYear = secondlastDayOfYear.plusDays(1);
DateTime secondOfJanNextYear = new DateTime().plusYears(1).withMonthOfYear(1).withDayOfMonth(2).toDateMidnight().toDateTime();
DateTime thirdOfJanNextYear = new DateTime().plusYears(1).withMonthOfYear(1).withDayOfMonth(3).toDateMidnight().toDateTime();
List<Holiday> holidays = holidayDao.findAllHolidaysThisYearAndNext(new Short("1"));
int initialCountOfHolidays = holidays.size();
List<Holiday> futureHolidays = holidayDao.findAllHolidaysFromDateAndNext(new Short("1"), secondOfJanNextYear.toLocalDate().toString());
int initialCountOfFutureHolidays = futureHolidays.size();
Holiday holiday1 = new HolidayBuilder().from(secondlastDayOfYear).to(secondlastDayOfYear).build();
Holiday holiday2 = new HolidayBuilder().from(secondOfJanNextYear).to(secondOfJanNextYear).build();
Holiday holiday3 = new HolidayBuilder().from(thirdOfJanNextYear).to(thirdOfJanNextYear).build();
Holiday holiday4 = new HolidayBuilder().from(lastDayOfYear).to(lastDayOfYear).build();
insertHoliday(holiday2);
insertHoliday(holiday3);
insertHoliday(holiday1);
insertHoliday(holiday4);
holidays = holidayDao.findAllHolidaysThisYearAndNext(new Short("1"));
assertThat(holidays.size() - initialCountOfHolidays, is(4));
assertTrue(holidays.get(0).encloses(secondlastDayOfYear.toDate()));
assertTrue(holidays.get(1).encloses(lastDayOfYear.toDate()));
assertTrue(holidays.get(2).encloses(secondOfJanNextYear.toDate()));
assertTrue(holidays.get(3).encloses(thirdOfJanNextYear.toDate()));
futureHolidays = holidayDao.findAllHolidaysFromDateAndNext(new Short("1"), secondOfJanNextYear.toLocalDate().toString());
assertThat(futureHolidays.size() - initialCountOfFutureHolidays, is(2));
assertTrue(futureHolidays.get(0).encloses(secondOfJanNextYear.toDate()));
assertTrue(futureHolidays.get(1).encloses(thirdOfJanNextYear.toDate()));
}
use of org.mifos.application.holiday.business.Holiday in project head by mifos.
the class TestObjectFactory method getMeetingDatesThroughTo.
public static List<Date> getMeetingDatesThroughTo(short officeId, final MeetingBO meeting, Date endDate) {
List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
List<Holiday> upcomingHolidays = ApplicationContextProvider.getBean(HolidayDao.class).findAllHolidaysThisYearAndNext(officeId);
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(meeting);
DateTime meetingStartDate = new DateTime(meeting.getMeetingStartDate());
DateTime endDateTime = new DateTime(endDate);
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, upcomingHolidays);
List<DateTime> allDates = dateGeneration.generateScheduledDatesThrough(meetingStartDate, endDateTime, scheduledEvent, false);
List<Date> dates = new ArrayList<Date>();
for (DateTime dateTime : allDates) {
dates.add(dateTime.toDate());
}
return dates;
}
use of org.mifos.application.holiday.business.Holiday in project head by mifos.
the class TestObjectFactory method getMeetingDates.
public static List<Date> getMeetingDates(short officeId, final MeetingBO meeting, final int occurrences) {
List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
List<Holiday> upcomingHolidays = ApplicationContextProvider.getBean(HolidayDao.class).findAllHolidaysThisYearAndNext(officeId);
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(meeting);
DateTime meetingStartDate = new DateTime(meeting.getMeetingStartDate());
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, upcomingHolidays);
List<DateTime> allDates = dateGeneration.generateScheduledDates(occurrences, meetingStartDate, scheduledEvent, false);
List<Date> dates = new ArrayList<Date>();
for (DateTime dateTime : allDates) {
dates.add(dateTime.toDate());
}
return dates;
}
Aggregations