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);
}
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);
}
}
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();
}
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);
}
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);
}
Aggregations