use of org.mifos.application.holiday.business.Holiday in project head by mifos.
the class HolidayAndWorkingDaysScheduledDateGenerationTest 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 HolidayAndWorkingDaysScheduledDateGeneration(workingDays, upcomingHolidays);
}
use of org.mifos.application.holiday.business.Holiday in project head by mifos.
the class HolidayDaoHibernate method validateNoExtraFutureHolidaysApplicableOnParentOffice.
@Override
public void validateNoExtraFutureHolidaysApplicableOnParentOffice(Short oldParentOfficeId, Short newParentOfficeId) throws ApplicationException {
List<Holiday> previousApplicableHolidays = retrieveCurrentAndFutureHolidaysForOfficeHierarchyInAscendingOrder(oldParentOfficeId);
List<Holiday> possibleApplicableHolidays = retrieveCurrentAndFutureHolidaysForOfficeHierarchyInAscendingOrder(newParentOfficeId);
if (previousApplicableHolidays.size() != possibleApplicableHolidays.size()) {
throw new ApplicationException(OfficeConstants.ERROR_REPARENT_NOT_ALLOWED_AS_FUTURE_APPLICABLE_HOLIDAYS_ARE_DIFFERENT_ON_PREVIOUS_AND_NEW_PARENT);
}
for (Holiday holiday : previousApplicableHolidays) {
HolidayBO applicableHoliday = (HolidayBO) holiday;
if (!possibleApplicableHolidays.contains(applicableHoliday)) {
throw new ApplicationException(OfficeConstants.ERROR_REPARENT_NOT_ALLOWED_AS_FUTURE_APPLICABLE_HOLIDAYS_ARE_DIFFERENT_ON_PREVIOUS_AND_NEW_PARENT);
}
}
}
use of org.mifos.application.holiday.business.Holiday 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;
}
use of org.mifos.application.holiday.business.Holiday 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.application.holiday.business.Holiday 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();
}
Aggregations