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();
}
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));
}
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));
}
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);
}
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;
}
Aggregations