Search in sources :

Example 16 with FiscalCalendarRules

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

the class ViewOrganizationSettingsServiceFacadeWebTier method getOffDays.

private String getOffDays() {
    List<Short> offDaysList = new FiscalCalendarRules().getWeekDayOffList();
    List<String> offDayNames = new ArrayList<String>();
    for (Short offDayNum : offDaysList) {
        WeekDay weekDay = WeekDay.getWeekDay(offDayNum);
        String weekdayName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(weekDay.getPropertiesKey());
        weekDay.setWeekdayName(weekdayName);
        offDayNames.add(weekDay.getName());
    }
    return StringUtils.join(offDayNames, 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)

Example 17 with FiscalCalendarRules

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

the class CustomerServiceImpl method generateSavingSchedulesForGroupAndCenterSavingAccounts.

private void generateSavingSchedulesForGroupAndCenterSavingAccounts(ClientBO client) {
    try {
        List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
        List<Holiday> holidays = new ArrayList<Holiday>();
        UserContext userContext = client.getUserContext();
        CustomerBO group = client.getParentCustomer();
        if (group != null) {
            List<SavingsBO> groupSavingAccounts = new CustomerPersistence().retrieveSavingsAccountForCustomer(group.getCustomerId());
            CustomerBO center = group.getParentCustomer();
            if (center != null) {
                List<SavingsBO> centerSavingAccounts = new CustomerPersistence().retrieveSavingsAccountForCustomer(center.getCustomerId());
                groupSavingAccounts.addAll(centerSavingAccounts);
            }
            for (SavingsBO savings : groupSavingAccounts) {
                savings.setUserContext(userContext);
                if (client.getCustomerMeetingValue() != null) {
                    if (!(savings.getCustomer().getLevel() == CustomerLevel.GROUP && savings.getRecommendedAmntUnit().getId().equals(RecommendedAmountUnit.COMPLETE_GROUP.getValue()))) {
                        DateTime today = new DateTime().toDateMidnight().toDateTime();
                        savings.generateDepositAccountActions(client, client.getCustomerMeeting().getMeeting(), workingDays, holidays, today);
                    }
                }
            }
        }
    } catch (PersistenceException pe) {
        throw new MifosRuntimeException(pe);
    }
}
Also used : UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) DateTime(org.joda.time.DateTime) Holiday(org.mifos.application.holiday.business.Holiday) Days(org.joda.time.Days) PersistenceException(org.mifos.framework.exceptions.PersistenceException) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) FiscalCalendarRules(org.mifos.config.FiscalCalendarRules) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 18 with FiscalCalendarRules

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

the class AccountRegenerateScheduleIntegrationTestCase method testChangeInMeetingScheduleForDates.

public void testChangeInMeetingScheduleForDates(MeetingBO customerMeeting, MeetingBO loanMeeting, MeetingBO newMeeting, LocalDate startDate, LocalDate dateWhenMeetingWillBeChanged, boolean useClosedAndCancelled) throws Exception {
    log("Start: " + startDate + ", Test: " + dateWhenMeetingWillBeChanged);
    accountBO = createLoanAccount(customerMeeting, loanMeeting);
    savingsBO = createSavingsAccount(customerMeeting);
    // center initially set up with meeting today
    center = TestObjectFactory.getCenter(center.getCustomerId());
    accountBO = TestObjectFactory.getObject(LoanBO.class, accountBO.getAccountId());
    if (useClosedAndCancelled) {
        PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
        accountBO.changeStatus(AccountState.LOAN_CANCELLED, null, "", loggedInUser);
        savingsBO.changeStatus(AccountState.SAVINGS_CANCELLED.getValue(), null, "", loggedInUser);
        CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(CustomerStatus.GROUP_CLOSED);
        CustomerBOTestUtils.setCustomerStatus(group, customerStatusEntity);
        StaticHibernateUtil.flushSession();
    }
    new DateTimeService().setCurrentDateTime(dateWhenMeetingWillBeChanged.toDateTimeAtStartOfDay());
    CustomerService customerService = ApplicationContextProvider.getBean(CustomerService.class);
    newMeeting.updateDetails(TestUtils.makeUser());
    customerService.updateCustomerMeetingSchedule(newMeeting, center);
    TestObjectFactory.updateObject(center);
    List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
    List<Holiday> holidays = new ArrayList<Holiday>();
    boolean isTopOfHierarchy = center.isTopOfHierarchy();
    center.getCustomerAccount().handleChangeInMeetingSchedule(workingDays, holidays, isTopOfHierarchy);
    accountBO.handleChangeInMeetingSchedule(workingDays, holidays, isTopOfHierarchy);
    savingsBO.handleChangeInMeetingSchedule(workingDays, holidays, isTopOfHierarchy);
    StaticHibernateUtil.flushSession();
}
Also used : CustomerService(org.mifos.customers.business.service.CustomerService) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) Holiday(org.mifos.application.holiday.business.Holiday) LoanBO(org.mifos.accounts.loan.business.LoanBO) Days(org.joda.time.Days) ArrayList(java.util.ArrayList) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) DateTimeService(org.mifos.framework.util.DateTimeService) FiscalCalendarRules(org.mifos.config.FiscalCalendarRules)

Example 19 with FiscalCalendarRules

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

the class ConfigurationIntegrationTest method testFiscalCalendarRules.

@Test
public void testFiscalCalendarRules() {
    Assert.assertEquals(Short.valueOf("2"), new FiscalCalendarRules().getStartOfWeek());
    Assert.assertEquals("same_day", new FiscalCalendarRules().getScheduleMeetingIfNonWorkingDay());
    enableCustomWorkingDays();
    List<Short> weekOffs = new FiscalCalendarRules().getWeekDayOffList();
    Assert.assertEquals(weekOffs.size(), 0);
}
Also used : FiscalCalendarRules(org.mifos.config.FiscalCalendarRules) Test(org.junit.Test)

Example 20 with FiscalCalendarRules

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

the class CalendarEventBuilder method build.

public CalendarEvent build() {
    List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
    List<Holiday> holidays = new ArrayList<Holiday>();
    return new CalendarEvent(workingDays, holidays);
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) Days(org.joda.time.Days) ArrayList(java.util.ArrayList) CalendarEvent(org.mifos.calendar.CalendarEvent) 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