use of org.mifos.schedule.ScheduledEvent in project head by mifos.
the class AccountBO method getNextMeetingDate.
public Date getNextMeetingDate() {
AccountActionDateEntity nextAccountAction = getDetailsOfNextInstallment();
if (nextAccountAction != null) {
return nextAccountAction.getActionDate();
}
// calculate the next date based on the customer's meeting object
CustomerMeetingEntity customerMeeting = customer.getCustomerMeeting();
if (customerMeeting != null) {
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(customerMeeting.getMeeting());
DateTime nextMeetingDate = scheduledEvent.nearestMatchingDateBeginningAt(new LocalDate().toDateTimeAtStartOfDay());
return new java.sql.Date(nextMeetingDate.toDate().getTime());
}
return new java.sql.Date(DateUtils.getCurrentDateWithoutTimeStamp().getTime());
}
use of org.mifos.schedule.ScheduledEvent 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;
}
use of org.mifos.schedule.ScheduledEvent in project head by mifos.
the class MeetingBOIntegrationTest method verifyFirstDateForWeekForGivenStartDateAndWeekDay.
/**
* Asserts that meeting.getFirstDateForWeek(startDate) returns a date matching the expected date.
*
* A dummy meeting is created with the given weekDay, and then the resulting date from
* meeting.getFirstDateForWeek(startDate) is asserted to be the expected date
*
*/
private void verifyFirstDateForWeekForGivenStartDateAndWeekDay(final WeekDay weekDay, final Date startDate, final Date expectedDate) throws MeetingException {
// Assert getFirstDateForWeek works as expected for meeting with given
// weekDay
MeetingBO meeting = createWeeklyMeeting(weekDay, ONE, new Date());
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(meeting);
DateTime nearestDate = scheduledEvent.nearestMatchingDateBeginningAt(new DateTime(startDate));
Assert.assertTrue(nearestDate.toDate().compareTo(expectedDate) == 0);
}
use of org.mifos.schedule.ScheduledEvent in project head by mifos.
the class FeeInstallmentTest method createMergedFeeInstallmentsForTwoFeesBothAccountAndFeesAreScheduledEveryWeekShouldGetOneFeeInstallmentPerAccountEventPerFee.
/**********************************
* Tests verify merging fees when two or more fees are attached to the account
*
* TODO: KRP: Remove the assumption of order that fee installments appear in the created list.
**********************************/
@Test
public void createMergedFeeInstallmentsForTwoFeesBothAccountAndFeesAreScheduledEveryWeekShouldGetOneFeeInstallmentPerAccountEventPerFee() {
ScheduledEvent masterEvent = new ScheduledEventBuilder().every(1).weeks().build();
FeeBO feeBO1 = createWeeklyFeeBO(1);
FeeBO feeBO2 = createWeeklyFeeBO(1);
AccountFeesEntity accountFeesEntity1 = createAccountFeesEntity(feeBO1, 10.0);
AccountFeesEntity accountFeesEntity2 = createAccountFeesEntity(feeBO2, 13.0);
List<AccountFeesEntity> accountFees = Arrays.asList(new AccountFeesEntity[] { accountFeesEntity1, accountFeesEntity2 });
List<FeeInstallment> feeInstallments = FeeInstallment.createMergedFeeInstallments(masterEvent, accountFees, 3);
assertThat(feeInstallments.size(), is(6));
assertFeeInstallment(feeInstallments.get(0), 1, 10.0, feeBO1);
assertFeeInstallment(feeInstallments.get(1), 2, 10.0, feeBO1);
assertFeeInstallment(feeInstallments.get(2), 3, 10.0, feeBO1);
assertFeeInstallment(feeInstallments.get(3), 1, 13.0, feeBO2);
assertFeeInstallment(feeInstallments.get(4), 2, 13.0, feeBO2);
assertFeeInstallment(feeInstallments.get(5), 3, 13.0, feeBO2);
}
use of org.mifos.schedule.ScheduledEvent in project head by mifos.
the class FeeInstallmentTest method createMergedFeeInstallmentsForOneFeeAccountScheduledEveryOtherWeekFeeScheduledEveryWeekt.
@Test
public void createMergedFeeInstallmentsForOneFeeAccountScheduledEveryOtherWeekFeeScheduledEveryWeekt() {
ScheduledEvent masterEvent = new ScheduledEventBuilder().every(2).weeks().build();
FeeBO feeBO = createWeeklyFeeBO(1);
AccountFeesEntity accountFeesEntity = createAccountFeesEntity(feeBO, 10.0);
List<FeeInstallment> feeInstallments = FeeInstallment.createMergedFeeInstallmentsForOneFee(masterEvent, accountFeesEntity, 4);
assertThat(feeInstallments.size(), is(4));
assertFeeInstallment(feeInstallments.get(0), 1, 10.0, feeBO);
assertFeeInstallment(feeInstallments.get(1), 2, 20.0, feeBO);
assertFeeInstallment(feeInstallments.get(2), 3, 20.0, feeBO);
assertFeeInstallment(feeInstallments.get(3), 4, 20.0, feeBO);
}
Aggregations