use of org.mifos.schedule.ScheduledEvent in project head by mifos.
the class SavingsBO method determineAccountActivationDetails.
public static SavingsAccountActivationDetail determineAccountActivationDetails(CustomerBO customer, SavingsOfferingBO savingsProduct, Money recommendedOrMandatoryAmount, AccountState savingsAccountState, CalendarEvent calendarEvents, List<CustomerBO> activeAndOnHoldClients) {
List<AccountActionDateEntity> scheduledPayments = new ArrayList<AccountActionDateEntity>();
LocalDate activationDate = new LocalDate();
LocalDate nextInterestPostingDate = new LocalDate();
if (savingsAccountState.isActiveSavingsAccountState()) {
activationDate = new LocalDate();
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(customer.getCustomerMeetingValue());
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(calendarEvents.getWorkingDays(), calendarEvents.getHolidays());
for (CustomerBO client : activeAndOnHoldClients) {
List<DateTime> depositDates = dateGeneration.generateScheduledDates(10, activationDate.toDateTimeAtStartOfDay(), scheduledEvent, false);
short installmentNumber = 1;
for (DateTime date : depositDates) {
java.sql.Date depositDueDate = new java.sql.Date(date.toDate().getTime());
AccountActionDateEntity scheduledSavingsDeposit = new SavingsScheduleEntity(client, installmentNumber, depositDueDate, PaymentStatus.UNPAID, recommendedOrMandatoryAmount, savingsProduct.getCurrency());
scheduledPayments.add(scheduledSavingsDeposit);
}
}
InterestScheduledEvent interestPostingEvent = new SavingsInterestScheduledEventFactory().createScheduledEventFrom(savingsProduct.getFreqOfPostIntcalc().getMeeting());
nextInterestPostingDate = interestPostingEvent.nextMatchingDateAfter(new LocalDate(startOfFiscalYear()), activationDate);
}
return new SavingsAccountActivationDetail(activationDate, nextInterestPostingDate, scheduledPayments);
}
use of org.mifos.schedule.ScheduledEvent in project head by mifos.
the class SavingsBO method generateDepositAccountActions.
@Deprecated
public void generateDepositAccountActions(final CustomerBO customer, final MeetingBO meeting, final List<Days> workingDays, final List<Holiday> holidays, final DateTime startingFrom) {
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(meeting);
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, holidays);
List<DateTime> depositDates = dateGeneration.generateScheduledDates(10, startingFrom, scheduledEvent, false);
short installmentNumber = 1;
for (DateTime date : depositDates) {
AccountActionDateEntity actionDate = helper.createActionDateObject(this, customer, installmentNumber++, date.toDate(), userContext.getId(), getRecommendedAmount());
addAccountActionDate(actionDate);
logger.debug("In SavingsBO::generateDepositAccountActions(), Successfully added account action on date: " + date);
}
}
use of org.mifos.schedule.ScheduledEvent in project head by mifos.
the class SavingsBO method generateAccountActivationDetails.
public static SavingsAccountActivationDetail generateAccountActivationDetails(CustomerBO customer, SavingsOfferingBO savingsProduct, Money recommendedOrMandatoryAmount, AccountState savingsAccountState, CalendarEvent calendarEvents, LocalDate activationDate) {
List<AccountActionDateEntity> scheduledPayments = new ArrayList<AccountActionDateEntity>();
LocalDate nextInterestPostingDate = new LocalDate();
if (savingsAccountState.isActiveSavingsAccountState()) {
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(customer.getCustomerMeetingValue());
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(calendarEvents.getWorkingDays(), calendarEvents.getHolidays());
List<DateTime> depositDates = dateGeneration.generateScheduledDates(10, activationDate.toDateTimeAtStartOfDay(), scheduledEvent, false);
short installmentNumber = 0;
for (DateTime date : depositDates) {
java.sql.Date depositDueDate = new java.sql.Date(date.toDate().getTime());
AccountActionDateEntity scheduledSavingsDeposit = new SavingsScheduleEntity(customer, installmentNumber++, depositDueDate, PaymentStatus.UNPAID, recommendedOrMandatoryAmount, savingsProduct.getCurrency());
scheduledPayments.add(scheduledSavingsDeposit);
}
InterestScheduledEvent interestPostingEvent = new SavingsInterestScheduledEventFactory().createScheduledEventFrom(savingsProduct.getFreqOfPostIntcalc().getMeeting());
nextInterestPostingDate = interestPostingEvent.nextMatchingDateAfter(new LocalDate(startOfFiscalYear()), activationDate);
}
return new SavingsAccountActivationDetail(activationDate, nextInterestPostingDate, scheduledPayments);
}
use of org.mifos.schedule.ScheduledEvent in project head by mifos.
the class SavingsBO method regenerateFutureInstallments.
@Override
protected void regenerateFutureInstallments(final AccountActionDateEntity nextInstallment, final List<Days> workingDays, final List<Holiday> holidays) throws AccountException {
MeetingBO customerMeeting = getCustomer().getCustomerMeetingValue();
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(customerMeeting);
LocalDate currentDate = new LocalDate();
LocalDate thisIntervalStartDate = customerMeeting.startDateForMeetingInterval(currentDate);
LocalDate nextMatchingDate = new LocalDate(scheduledEvent.nextEventDateAfter(thisIntervalStartDate.toDateTimeAtStartOfDay()));
DateTime futureIntervalStartDate = customerMeeting.startDateForMeetingInterval(nextMatchingDate).toDateTimeAtStartOfDay();
ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, holidays);
int numberOfInstallmentsToGenerate = getLastInstallmentId();
List<DateTime> meetingDates = dateGeneration.generateScheduledDates(numberOfInstallmentsToGenerate, futureIntervalStartDate, scheduledEvent, false);
if (getCustomer().getCustomerLevel().getId().equals(CustomerLevel.CLIENT.getValue()) || getCustomer().getCustomerLevel().getId().equals(CustomerLevel.GROUP.getValue()) && getRecommendedAmntUnit().getId().equals(RecommendedAmountUnit.COMPLETE_GROUP.getValue())) {
updateSchedule(nextInstallment.getInstallmentId(), meetingDates);
} else {
List<CustomerBO> children;
try {
children = getCustomer().getChildren(CustomerLevel.CLIENT, ChildrenStateType.OTHER_THAN_CLOSED);
} catch (CustomerException ce) {
throw new AccountException(ce);
}
updateSavingsSchedule(nextInstallment.getInstallmentId(), meetingDates, children);
}
}
use of org.mifos.schedule.ScheduledEvent in project head by mifos.
the class ApplyHolidayChangesHelper method getDatesToReplaceScheduledDates.
private List<DateTime> getDatesToReplaceScheduledDates(final ScheduledDateGeneration dateGeneration, List<AccountActionDateEntity> installments, final MeetingBO meeting) {
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(meeting);
int numberOfDatesToGenerate = installments.size() + 1;
DateTime dayBeforeFirstDateToGenerate = new DateTime(installments.get(0).getActionDate()).minusDays(1);
return dateGeneration.generateScheduledDates(numberOfDatesToGenerate, dayBeforeFirstDateToGenerate, scheduledEvent, false);
}
Aggregations