Search in sources :

Example 6 with FiscalCalendarRules

use of org.mifos.config.FiscalCalendarRules in project head by mifos.

the class AnyScheduledEventLoanInstallmentGenerator method generate.

@Override
public List<InstallmentDate> generate(LocalDate actualDisbursementDate, int numberOfInstallments, GraceType graceType, int gracePeriodDuration, Short officeId) {
    List<InstallmentDate> installmentDates = new ArrayList<InstallmentDate>();
    if (numberOfInstallments > 0) {
        List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
        List<Holiday> holidays = new ArrayList<Holiday>();
        LocalDate startFromMeetingDate = null;
        if (scheduledEvent instanceof DailyScheduledEvent) {
            startFromMeetingDate = actualDisbursementDate.plusDays(scheduledEvent.getEvery());
        } else {
            startFromMeetingDate = actualDisbursementDate.plusDays(1);
        }
        holidays = holidayDao.findAllHolidaysFromDateAndNext(officeId, startFromMeetingDate.toString());
        int occurrences = numberOfInstallments;
        if (graceType == GraceType.GRACEONALLREPAYMENTS) {
            occurrences += gracePeriodDuration;
        }
        ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, holidays);
        List<Date> dueDates = new ArrayList<Date>();
        List<DateTime> installmentDateTimes = dateGeneration.generateScheduledDates(occurrences, startFromMeetingDate.toDateMidnight().toDateTime(), scheduledEvent, false);
        for (DateTime installmentDate : installmentDateTimes) {
            dueDates.add(installmentDate.toDate());
        }
        installmentDates = createInstallmentDates(dueDates);
        if (graceType == GraceType.GRACEONALLREPAYMENTS) {
            removeInstallmentsNeedNotPay(gracePeriodDuration, installmentDates);
        }
    }
    return installmentDates;
}
Also used : DailyScheduledEvent(org.mifos.schedule.internal.DailyScheduledEvent) ArrayList(java.util.ArrayList) LocalDate(org.joda.time.LocalDate) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration) ScheduledDateGeneration(org.mifos.schedule.ScheduledDateGeneration) Holiday(org.mifos.application.holiday.business.Holiday) Days(org.joda.time.Days) FiscalCalendarRules(org.mifos.config.FiscalCalendarRules) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration)

Example 7 with FiscalCalendarRules

use of org.mifos.config.FiscalCalendarRules in project head by mifos.

the class LoanAccountAction method handleRepaymentsIndependentOfMeetingIfConfigured.

private void handleRepaymentsIndependentOfMeetingIfConfigured(final HttpServletRequest request, final LoanAccountActionForm loanActionForm, final String recurMonth) throws PageExpiredException, Exception {
    if (configService.isRepaymentIndepOfMeetingEnabled()) {
        storeObjectOnSessionForUseInJspPage(request, LoanConstants.REPAYMENT_SCHEDULES_INDEPENDENT_OF_MEETING_IS_ENABLED, Integer.valueOf(1));
        storeObjectOnSessionForUseInJspPage(request, LoanConstants.LOANACCOUNTOWNERISACLIENT, LoanConstants.LOAN_ACCOUNT_OWNER_IS_GROUP_YES);
        storeCollectionOnSessionForUseInJspPage(request, MeetingConstants.WEEKDAYSLIST, fillWeekDaysWithLocalizedName(new FiscalCalendarRules().getWorkingDays()));
        storeCollectionOnSessionForUseInJspPage(request, MeetingConstants.WEEKRANKLIST, RankOfDay.getRankOfDayList());
        loanActionForm.setRecurMonth(recurMonth);
    }
}
Also used : FiscalCalendarRules(org.mifos.config.FiscalCalendarRules)

Example 8 with FiscalCalendarRules

use of org.mifos.config.FiscalCalendarRules in project head by mifos.

the class SavingsBOTest method setupMifosLoggerDueToUseOfStaticClientRules.

@BeforeClass
public static void setupMifosLoggerDueToUseOfStaticClientRules() {
    savedFiscalCalendarRulesWorkingDays = new FiscalCalendarRules().getWorkingDaysAsString();
    new FiscalCalendarRules().setWorkingDays("MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY,SUNDAY");
    defaultCurrency = TestUtils.RUPEE;
    Money.setDefaultCurrency(defaultCurrency);
}
Also used : FiscalCalendarRules(org.mifos.config.FiscalCalendarRules) BeforeClass(org.junit.BeforeClass)

Example 9 with FiscalCalendarRules

use of org.mifos.config.FiscalCalendarRules 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;
}
Also used : ScheduledEvent(org.mifos.schedule.ScheduledEvent) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) DateTime(org.joda.time.DateTime) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration) ScheduledDateGeneration(org.mifos.schedule.ScheduledDateGeneration) Holiday(org.mifos.application.holiday.business.Holiday) Days(org.joda.time.Days) FiscalCalendarRules(org.mifos.config.FiscalCalendarRules) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration)

Example 10 with FiscalCalendarRules

use of org.mifos.config.FiscalCalendarRules in project head by mifos.

the class TestObjectFactory method getMeetingDatesThroughTo.

public static List<Date> getMeetingDatesThroughTo(short officeId, final MeetingBO meeting, Date endDate) {
    List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
    List<Holiday> upcomingHolidays = ApplicationContextProvider.getBean(HolidayDao.class).findAllHolidaysThisYearAndNext(officeId);
    ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(meeting);
    DateTime meetingStartDate = new DateTime(meeting.getMeetingStartDate());
    DateTime endDateTime = new DateTime(endDate);
    ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, upcomingHolidays);
    List<DateTime> allDates = dateGeneration.generateScheduledDatesThrough(meetingStartDate, endDateTime, scheduledEvent, false);
    List<Date> dates = new ArrayList<Date>();
    for (DateTime dateTime : allDates) {
        dates.add(dateTime.toDate());
    }
    return dates;
}
Also used : ScheduledEvent(org.mifos.schedule.ScheduledEvent) ArrayList(java.util.ArrayList) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) DateTime(org.joda.time.DateTime) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration) ScheduledDateGeneration(org.mifos.schedule.ScheduledDateGeneration) Holiday(org.mifos.application.holiday.business.Holiday) Days(org.joda.time.Days) FiscalCalendarRules(org.mifos.config.FiscalCalendarRules) HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration)

Aggregations

FiscalCalendarRules (org.mifos.config.FiscalCalendarRules)23 ArrayList (java.util.ArrayList)14 Holiday (org.mifos.application.holiday.business.Holiday)13 Days (org.joda.time.Days)12 LocalDate (org.joda.time.LocalDate)8 Date (java.util.Date)7 DateTime (org.joda.time.DateTime)7 ScheduledDateGeneration (org.mifos.schedule.ScheduledDateGeneration)7 HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration (org.mifos.schedule.internal.HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration)7 MessageLookup (org.mifos.application.master.MessageLookup)5 WeekDay (org.mifos.application.meeting.util.helpers.WeekDay)5 InstallmentDate (org.mifos.accounts.util.helpers.InstallmentDate)4 HolidayDao (org.mifos.application.holiday.persistence.HolidayDao)4 ScheduledEvent (org.mifos.schedule.ScheduledEvent)4 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)3 MeetingBO (org.mifos.application.meeting.business.MeetingBO)3 PersistenceException (org.mifos.framework.exceptions.PersistenceException)3 Test (org.junit.Test)2 BigDecimal (java.math.BigDecimal)1 Calendar (java.util.Calendar)1