use of org.mifos.schedule.ScheduledEvent in project head by mifos.
the class FeeInstallmentTest method createMergedFeeInstallmentsForOneFeeBothAccountAndFeeAreScheduledEveryWeekShouldGetOneFeeInstallmentPerAccountEvent.
@Test
public void createMergedFeeInstallmentsForOneFeeBothAccountAndFeeAreScheduledEveryWeekShouldGetOneFeeInstallmentPerAccountEvent() {
ScheduledEvent masterEvent = new ScheduledEventBuilder().every(1).weeks().build();
FeeBO feeBO = createWeeklyFeeBO(1);
AccountFeesEntity accountFeesEntity = createAccountFeesEntity(feeBO, 10.0);
List<FeeInstallment> feeInstallments = FeeInstallment.createMergedFeeInstallmentsForOneFee(masterEvent, accountFeesEntity, 3);
assertThat(feeInstallments.size(), is(3));
assertFeeInstallment(feeInstallments.get(0), 1, 10.0, feeBO);
assertFeeInstallment(feeInstallments.get(1), 2, 10.0, feeBO);
assertFeeInstallment(feeInstallments.get(2), 3, 10.0, feeBO);
}
use of org.mifos.schedule.ScheduledEvent in project head by mifos.
the class FeeInstallmentTest method createMergedFeeInstallmentsForOneFeeAccountScheduledEveryWeekFeeScheduledEveryOtherWeekShouldGetOneFeeInstallmentPerEveryOtherAccountEvent.
@Test
public void createMergedFeeInstallmentsForOneFeeAccountScheduledEveryWeekFeeScheduledEveryOtherWeekShouldGetOneFeeInstallmentPerEveryOtherAccountEvent() {
ScheduledEvent accountEvent = new ScheduledEventBuilder().every(1).weeks().build();
FeeBO feeBO = createWeeklyFeeBO(2);
AccountFeesEntity accountFeesEntity = createAccountFeesEntity(feeBO, 10.0);
List<FeeInstallment> feeInstallments = FeeInstallment.createMergedFeeInstallmentsForOneFee(accountEvent, accountFeesEntity, 4);
assertThat(feeInstallments.size(), is(2));
assertFeeInstallment(feeInstallments.get(0), 1, 10.0, feeBO);
assertFeeInstallment(feeInstallments.get(1), 3, 10.0, feeBO);
}
use of org.mifos.schedule.ScheduledEvent in project head by mifos.
the class LoanBO method regenerateFutureInstallments.
/**
* regenerate installments starting from nextInstallmentId
*/
@Override
protected void regenerateFutureInstallments(final AccountActionDateEntity nextInstallment, final List<Days> workingDays, final List<Holiday> holidays) throws AccountException {
int numberOfInstallmentsToGenerate = getLastInstallmentId();
MeetingBO meeting = buildLoanMeeting(customer.getCustomerMeeting().getMeeting(), getLoanMeeting(), getLoanMeeting().getMeetingStartDate());
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(meeting);
LocalDate currentDate = new LocalDate();
LocalDate thisIntervalStartDate = meeting.startDateForMeetingInterval(currentDate);
LocalDate nextMatchingDate = new LocalDate(scheduledEvent.nextEventDateAfter(thisIntervalStartDate.toDateTimeAtStartOfDay()));
DateTime futureIntervalStartDate = meeting.startDateForMeetingInterval(nextMatchingDate).toDateTimeAtStartOfDay();
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, holidays);
List<DateTime> meetingDates = dateGeneration.generateScheduledDates(numberOfInstallmentsToGenerate, futureIntervalStartDate, scheduledEvent, false);
updateSchedule(nextInstallment.getInstallmentId(), meetingDates);
}
use of org.mifos.schedule.ScheduledEvent in project head by mifos.
the class CustomerAccountBO method createSchedulesAndFeeSchedulesForFirstTimeActiveCustomer.
/**
* Create an initial meeting schedule with fees attached, if any.
*
* <p>PostConditions:</p>
*
* <ul>
* <li> <code>numberOfMeetingDatesToGenerateOnCreation</code> {@link CustomerScheduleEntity}s are created
* starting with <code>customerMeeting</code>'s start date, scheduled according to <code>customerMeeting</code>'s
* frequency and recurrence, and subject to rules for scheduling around on working days and around holidays. See
* {@link HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration} for scheduling rules.</li>
* <li> One-time upfront fees are attached to the first meeting.</li>
* <li> Periodic fees are attached to the first meeting and subsequent meetings that match the fee's frequency
* and recurrence</li>
* <li> The <code>lastAppliedDate</code> for each fee is set to the date of the latest meeting to which the fee
* is attached
* </ul>
*/
public void createSchedulesAndFeeSchedulesForFirstTimeActiveCustomer(CustomerBO customer, List<AccountFeesEntity> accountFees, MeetingBO customerMeeting, CalendarEvent applicableCalendarEvents, DateTime scheduleGenerationStartingFrom) {
final ScheduledEvent customerMeetingEvent = new RecurringScheduledEventFactoryImpl().createScheduledEventFrom(customerMeeting);
DateTime beginningFrom = scheduleGenerationStartingFrom;
// synch up generated schedule for center/group/client or group/client hierarchy
CustomerBO upmostParent = upmostParentOf(customer);
if (upmostParent != null) {
LocalDate parentCustomerActiviationDate = new LocalDate(upmostParent.getCustomerActivationDate());
LocalDate childCustomerActiviationDate = new LocalDate(customer.getCustomerActivationDate());
LocalDate validCustomerMeetingMatch = null;
if (customerMeetingEvent instanceof DailyScheduledEvent) {
validCustomerMeetingMatch = new LocalDate(parentCustomerActiviationDate.toDateMidnight().toDateTime());
} else {
validCustomerMeetingMatch = new LocalDate(customerMeetingEvent.nearestMatchNotTakingIntoAccountScheduleFrequency(parentCustomerActiviationDate.toDateMidnight().toDateTime()));
}
while (childCustomerActiviationDate.isAfter(validCustomerMeetingMatch)) {
validCustomerMeetingMatch = new LocalDate(customerMeetingEvent.rollFrowardDateByFrequency(validCustomerMeetingMatch.toDateMidnight().toDateTime()));
}
beginningFrom = validCustomerMeetingMatch.toDateMidnight().toDateTime();
}
DateTime meetingStartDate = new DateTime(customer.getCustomerMeetingValue().getMeetingStartDate());
if (beginningFrom.isBefore(meetingStartDate)) {
beginningFrom = meetingStartDate;
}
createInitialSetOfCustomerScheduleEntities(customer, beginningFrom, applicableCalendarEvents, customerMeetingEvent);
applyFeesToInitialSetOfInstallments(new ArrayList<AccountFeesEntity>(accountFees), customerMeetingEvent);
}
use of org.mifos.schedule.ScheduledEvent in project head by mifos.
the class CustomerAccountBO method applyPeriodicFee.
/*
* Package-level visibility for testing
*/
void applyPeriodicFee(final FeeBO fee, final Money charge, final List<AccountActionDateEntity> dueInstallments) throws AccountException {
AccountFeesEntity accountFee = getAccountFee(fee, charge.getAmountDoubleValue());
accountFee.setAccountFeeAmount(charge);
List<InstallmentDate> installmentDates = new ArrayList<InstallmentDate>();
for (AccountActionDateEntity accountActionDateEntity : dueInstallments) {
installmentDates.add(new InstallmentDate(accountActionDateEntity.getInstallmentId(), accountActionDateEntity.getActionDate()));
}
// List<FeeInstallment> feeInstallmentList = mergeFeeInstallments(handlePeriodic(accountFee, installmentDates));
ScheduledEvent loanScheduledEvent = ScheduledEventFactory.createScheduledEventFrom(this.getMeetingForAccount());
List<FeeInstallment> feeInstallmentList = FeeInstallment.createMergedFeeInstallmentsForOneFeeStartingWith(loanScheduledEvent, accountFee, dueInstallments.size(), dueInstallments.get(0).getInstallmentId());
// MIFOS-3701: we want to display only fee charge, not the totalFeeAmountApplied
applyFeeToInstallments(feeInstallmentList, dueInstallments);
updateCustomerActivity(fee.getFeeId(), charge, fee.getFeeName() + AccountConstants.APPLIED);
accountFee.setFeeStatus(FeeStatus.ACTIVE);
}
Aggregations