Search in sources :

Example 11 with HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration

use of org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration in project head by mifos.

the class SavingsBO method determineAccountActivationDetails.

public static SavingsAccountActivationDetail determineAccountActivationDetails(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 = 1;
        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 12 with HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration

use of org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration in project head by mifos.

the class SavingsBO method generateDepositAccountActions.

private void generateDepositAccountActions(final CustomerBO customer, final MeetingBO meeting, final AccountActionDateEntity lastInstallment, final List<Days> workingDays, final List<Holiday> holidays) {
    DateTime startFromDayAfterLastKnownInstallmentDate = new DateTime(lastInstallment.getActionDate()).plusDays(1);
    ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(meeting);
    ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, holidays);
    List<DateTime> depositDates = dateGeneration.generateScheduledDates(10, startFromDayAfterLastKnownInstallmentDate, scheduledEvent, false);
    short installmentNumber = lastInstallment.getInstallmentId();
    for (DateTime depositDate : depositDates) {
        AccountActionDateEntity actionDate = helper.createActionDateObject(this, customer, ++installmentNumber, depositDate.toDate(), (short) 1, getRecommendedAmount());
        addAccountActionDate(actionDate);
        logger.debug("In SavingsBO::generateDepositAccountActions(), Successfully added account action on date: " + depositDate);
    }
}
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 13 with HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration

use of org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration in project head by mifos.

the class HolidayAndWorkingDaysAndMoratoriaScheduledDateGenerationTest method setupAndInjectDependencies.

@Before
public void setupAndInjectDependencies() {
    workingDays = Arrays.asList(DayOfWeek.mondayAsDay(), DayOfWeek.tuesdayAsDay(), DayOfWeek.wednesdayAsDay(), DayOfWeek.thursdayAsDay(), DayOfWeek.fridayAsDay());
    List<Holiday> upcomingHolidays = new ArrayList<Holiday>();
    scheduleGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, upcomingHolidays);
//Dates frequently used in tests
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) ArrayList(java.util.ArrayList) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration) Before(org.junit.Before)

Example 14 with HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration

use of org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration 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);
}
Also used : ScheduledEvent(org.mifos.schedule.ScheduledEvent) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration) ScheduledDateGeneration(org.mifos.schedule.ScheduledDateGeneration) MeetingBO(org.mifos.application.meeting.business.MeetingBO) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration)

Example 15 with HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration

use of org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration in project head by mifos.

the class CustomerAccountBO method generateInitialInstallmentDates.

private List<InstallmentDate> generateInitialInstallmentDates(DateTime startingFrom, CalendarEvent calendarEvents, ScheduledEvent meetingEvent) {
    ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(calendarEvents.getWorkingDays(), calendarEvents.getHolidays());
    List<DateTime> meetingDates = dateGeneration.generateScheduledDates(numberOfMeetingDatesToGenerate, startingFrom, meetingEvent, true);
    return InstallmentDate.createInstallmentDates(meetingDates);
}
Also used : HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration) ScheduledDateGeneration(org.mifos.schedule.ScheduledDateGeneration) DateTime(org.joda.time.DateTime) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration)

Aggregations

HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration (org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration)18 ScheduledDateGeneration (org.mifos.schedule.ScheduledDateGeneration)17 DateTime (org.joda.time.DateTime)15 LocalDate (org.joda.time.LocalDate)12 ScheduledEvent (org.mifos.schedule.ScheduledEvent)12 ArrayList (java.util.ArrayList)11 Date (java.util.Date)9 Holiday (org.mifos.application.holiday.business.Holiday)9 FiscalCalendarRules (org.mifos.config.FiscalCalendarRules)7 Days (org.joda.time.Days)6 InterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent)6 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)5 InstallmentDate (org.mifos.accounts.util.helpers.InstallmentDate)4 HolidayDao (org.mifos.application.holiday.persistence.HolidayDao)4 MeetingBO (org.mifos.application.meeting.business.MeetingBO)4 SavingsInterestScheduledEventFactory (org.mifos.accounts.savings.interest.schedule.SavingsInterestScheduledEventFactory)3 CustomerBO (org.mifos.customers.business.CustomerBO)2 DailyScheduledEvent (org.mifos.schedule.internal.DailyScheduledEvent)2 List (java.util.List)1 Before (org.junit.Before)1