Search in sources :

Example 11 with FiscalCalendarRules

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

the class TestObjectFactory method getMeetingDates.

public static List<Date> getMeetingDates(short officeId, final MeetingBO meeting, final int occurrences) {
    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());
    ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, upcomingHolidays);
    List<DateTime> allDates = dateGeneration.generateScheduledDates(occurrences, meetingStartDate, 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)

Example 12 with FiscalCalendarRules

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

the class ConfigurationInitializer method setFiscalStartOfWeek.

private void setFiscalStartOfWeek(Map<Key, Object> officeConfigMap) throws SystemException, ApplicationException {
    Short id = new FiscalCalendarRules().getStartOfWeek();
    officeConfigMap.put(new Key(getHeadOffice().getOfficeId(), ConfigConstants.FISCAL_START_OF_WEEK), id);
}
Also used : Key(org.mifos.config.cache.Key) FiscalCalendarRules(org.mifos.config.FiscalCalendarRules)

Example 13 with FiscalCalendarRules

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

the class AccountBO method getInstallmentDates.

/**
     * @deprecated - used to create installment dates based on 'loan meeting' and working das, holidays, moratoria etc
     *
     * better to pull capability of creating 'installments' out of loan into something more reuseable and isolated
     */
@Deprecated
public final List<InstallmentDate> getInstallmentDates(final MeetingBO meeting, final Short noOfInstallments, final Short installmentToSkip, final boolean isRepaymentIndepOfMeetingEnabled, final boolean adjustForHolidays) {
    logger.debug("Generating intallment dates");
    List<InstallmentDate> dueInstallmentDates = new ArrayList<InstallmentDate>();
    if (noOfInstallments > 0) {
        List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
        List<Holiday> holidays = new ArrayList<Holiday>();
        DateTime startFromMeetingDate = new DateTime(meeting.getMeetingStartDate());
        if (adjustForHolidays) {
            HolidayDao holidayDao = ApplicationContextProvider.getBean(HolidayDao.class);
            holidays = holidayDao.findAllHolidaysFromDateAndNext(getOffice().getOfficeId(), startFromMeetingDate.toLocalDate().toString());
        }
        final int occurrences = noOfInstallments + installmentToSkip;
        ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(meeting);
        ScheduledDateGeneration dateGeneration = new HolidayAndWorkingDaysAndMoratoriaScheduledDateGeneration(workingDays, holidays);
        List<Date> dueDates = new ArrayList<Date>();
        // FIXME - keithw - this whole area of installment creation should be pulled out of domain
        DateTime startFromDayAfterAssignedMeetingDateRatherThanSkippingInstallments = startFromMeetingDate;
        if (this.isLoanAccount()) {
            // ensure loans that are created or disbursed on a meeting date start on next valid meeting date and not todays meeting
            // ensure loans that are created or disbursed before a meeting date start on next valid meeting date
            startFromDayAfterAssignedMeetingDateRatherThanSkippingInstallments = startFromMeetingDate.plusDays(1);
        }
        List<DateTime> installmentDates = dateGeneration.generateScheduledDates(occurrences, startFromDayAfterAssignedMeetingDateRatherThanSkippingInstallments, scheduledEvent, false);
        for (DateTime installmentDate : installmentDates) {
            dueDates.add(installmentDate.toDate());
        }
        dueInstallmentDates = createInstallmentDates(installmentToSkip, dueDates);
    }
    return dueInstallmentDates;
}
Also used : ScheduledEvent(org.mifos.schedule.ScheduledEvent) ArrayList(java.util.ArrayList) DateTime(org.joda.time.DateTime) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) Date(java.util.Date) InstallmentDate(org.mifos.accounts.util.helpers.InstallmentDate) LocalDate(org.joda.time.LocalDate) 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 14 with FiscalCalendarRules

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

the class MeetingAction method getLocalizedWorkingDays.

private List<WeekDay> getLocalizedWorkingDays() {
    List<WeekDay> workingDays = new FiscalCalendarRules().getWorkingDays();
    for (WeekDay workDay : workingDays) {
        String weekdayName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(workDay.getPropertiesKey());
        workDay.setWeekdayName(weekdayName);
    }
    return workingDays;
}
Also used : WeekDay(org.mifos.application.meeting.util.helpers.WeekDay) MessageLookup(org.mifos.application.master.MessageLookup) FiscalCalendarRules(org.mifos.config.FiscalCalendarRules)

Example 15 with FiscalCalendarRules

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

the class ViewOrganizationSettingsServiceFacadeWebTier method getWorkingDays.

private String getWorkingDays() {
    List<WeekDay> workDaysList = new FiscalCalendarRules().getWorkingDays();
    List<String> workDayNames = new ArrayList<String>();
    for (WeekDay workDay : workDaysList) {
        String weekdayName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(workDay.getPropertiesKey());
        workDay.setWeekdayName(weekdayName);
        workDayNames.add(workDay.getName());
    }
    return StringUtils.join(workDayNames, DELIMITER);
}
Also used : WeekDay(org.mifos.application.meeting.util.helpers.WeekDay) MessageLookup(org.mifos.application.master.MessageLookup) ArrayList(java.util.ArrayList) FiscalCalendarRules(org.mifos.config.FiscalCalendarRules)

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