Search in sources :

Example 1 with ScheduledEvent

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);
}
Also used : SavingsInterestScheduledEventFactory(org.mifos.accounts.savings.interest.schedule.SavingsInterestScheduledEventFactory) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) ScheduledEvent(org.mifos.schedule.ScheduledEvent) ArrayList(java.util.ArrayList) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration) ScheduledDateGeneration(org.mifos.schedule.ScheduledDateGeneration) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) CustomerBO(org.mifos.customers.business.CustomerBO) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration)

Example 2 with ScheduledEvent

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);
    }
}
Also used : InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) ScheduledEvent(org.mifos.schedule.ScheduledEvent) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration) ScheduledDateGeneration(org.mifos.schedule.ScheduledDateGeneration) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) DateTime(org.joda.time.DateTime) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration)

Example 3 with ScheduledEvent

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);
}
Also used : SavingsInterestScheduledEventFactory(org.mifos.accounts.savings.interest.schedule.SavingsInterestScheduledEventFactory) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) ScheduledEvent(org.mifos.schedule.ScheduledEvent) ArrayList(java.util.ArrayList) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration) ScheduledDateGeneration(org.mifos.schedule.ScheduledDateGeneration) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration)

Example 4 with ScheduledEvent

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);
    }
}
Also used : InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) ScheduledEvent(org.mifos.schedule.ScheduledEvent) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration) ScheduledDateGeneration(org.mifos.schedule.ScheduledDateGeneration) CustomerException(org.mifos.customers.exceptions.CustomerException) AccountException(org.mifos.accounts.exceptions.AccountException) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerBO(org.mifos.customers.business.CustomerBO) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration)

Example 5 with ScheduledEvent

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);
}
Also used : ScheduledEvent(org.mifos.schedule.ScheduledEvent) DateTime(org.joda.time.DateTime)

Aggregations

ScheduledEvent (org.mifos.schedule.ScheduledEvent)38 DateTime (org.joda.time.DateTime)23 LocalDate (org.joda.time.LocalDate)16 ArrayList (java.util.ArrayList)14 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)13 Test (org.junit.Test)12 FeeInstallment (org.mifos.accounts.util.helpers.FeeInstallment)12 ScheduledDateGeneration (org.mifos.schedule.ScheduledDateGeneration)12 HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration (org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration)12 Date (java.util.Date)11 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)11 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)10 FeeBO (org.mifos.accounts.fees.business.FeeBO)9 ScheduledEventBuilder (org.mifos.domain.builders.ScheduledEventBuilder)9 InstallmentDate (org.mifos.accounts.util.helpers.InstallmentDate)8 MeetingBO (org.mifos.application.meeting.business.MeetingBO)7 InterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent)6 HolidayDao (org.mifos.application.holiday.persistence.HolidayDao)5 Days (org.joda.time.Days)4 Holiday (org.mifos.application.holiday.business.Holiday)4