use of org.mifos.dto.domain.HolidayDetails in project head by mifos.
the class HolidayServiceIntegrationTest method shouldCreateHolidayAgainstOfficesOfDifferentLevelThatDoNotExistInSameOfficeHierarchySubTree_Allbranches.
@Test
public void shouldCreateHolidayAgainstOfficesOfDifferentLevelThatDoNotExistInSameOfficeHierarchySubTree_Allbranches() throws Exception {
// setup
HolidayDetails holidayDetails = new HolidayDetails("test", new DateTime().plusDays(1).toDate(), new DateTime().plusDays(1).toDate(), RepaymentRuleTypes.NEXT_MEETING_OR_REPAYMENT.getValue());
List<Short> officeIds = Arrays.asList(branch1.getOfficeId(), branch2.getOfficeId(), branch3.getOfficeId());
// exercise test
holidayService.create(holidayDetails, officeIds);
}
use of org.mifos.dto.domain.HolidayDetails in project head by mifos.
the class HolidayServiceFacadeWebTier method holidaysByYear.
@Override
public Map<String, List<OfficeHoliday>> holidaysByYear() {
List<HolidayBO> holidays = this.holidayDao.findAllHolidays();
Map<String, List<OfficeHoliday>> holidaysByYear = new TreeMap<String, List<OfficeHoliday>>();
for (HolidayBO holiday : holidays) {
HolidayDetails holidayDetail = new HolidayDetails(holiday.getHolidayName(), holiday.getHolidayFromDate(), holiday.getHolidayThruDate(), holiday.getRepaymentRuleType().getValue());
String holidayRepaymentRuleName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(holiday.getRepaymentRuleType().getPropertiesKey());
holidayDetail.setRepaymentRuleName(holidayRepaymentRuleName);
int year = holiday.getThruDate().getYear();
List<OfficeHoliday> holidaysInYear = holidaysByYear.get(Integer.toString(year));
if (holidaysInYear == null) {
holidaysInYear = new LinkedList<OfficeHoliday>();
}
holidaysInYear.add(new OfficeHoliday(holidayDetail, this.holidayDao.applicableOffices(holiday.getId())));
holidaysByYear.put(Integer.toString(year), holidaysInYear);
}
sortValuesByFromDate(holidaysByYear);
return holidaysByYear;
}
use of org.mifos.dto.domain.HolidayDetails in project head by mifos.
the class HolidayDaoHibernateIntegrationTest method shouldThrowExceptionWhenFutureHolidaysApplicableToNewParentOfficeDifferFromPreviousParentOffice.
@Test
public void shouldThrowExceptionWhenFutureHolidaysApplicableToNewParentOfficeDifferFromPreviousParentOffice() throws Exception {
OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
// setup
createOfficeHierarchyUnderHeadOffice(headOffice);
DateTime tomorrow = new DateTime().plusDays(1);
HolidayDetails holidayDetails = new HolidayBuilder().withName("areaOffice2Holiday").from(tomorrow).to(tomorrow).buildDto();
IntegrationTestObjectMother.createHoliday(holidayDetails, Arrays.asList(areaOffice2.getOfficeId()));
HolidayDetails branchOnlyHolidayDetails = new HolidayBuilder().withName("branchOnlyHoliday").from(tomorrow).to(tomorrow).buildDto();
IntegrationTestObjectMother.createHoliday(branchOnlyHolidayDetails, Arrays.asList(branch1.getOfficeId()));
// refetch
branch1 = IntegrationTestObjectMother.findOfficeById(branch1.getOfficeId());
// exercise test
try {
holidayDao.validateNoExtraFutureHolidaysApplicableOnParentOffice(branch1.getParentOffice().getOfficeId(), areaOffice2.getOfficeId());
fail("shouldThrowExceptionWhenFutureHolidaysApplicableToNewParentOfficeDifferFromPreviousParentOffice");
} catch (ApplicationException e) {
assertThat(e.getKey(), is(OfficeConstants.ERROR_REPARENT_NOT_ALLOWED_AS_FUTURE_APPLICABLE_HOLIDAYS_ARE_DIFFERENT_ON_PREVIOUS_AND_NEW_PARENT));
}
}
use of org.mifos.dto.domain.HolidayDetails in project head by mifos.
the class PreviewHolidayController method processFormSubmit.
@RequestMapping(method = RequestMethod.POST)
public ModelAndView processFormSubmit(@RequestParam(value = EDIT_PARAM, required = false) String edit, @RequestParam(value = CANCEL_PARAM, required = false) String cancel, @ModelAttribute("formBean") HolidayFormBean formBean, BindingResult result, SessionStatus status) {
String viewName = REDIRECT_TO_ADMIN_SCREEN;
ModelAndView modelAndView = new ModelAndView();
if (StringUtils.isNotBlank(edit)) {
viewName = "defineNewHoliday";
modelAndView.setViewName(viewName);
modelAndView.addObject("formBean", formBean);
} else if (StringUtils.isNotBlank(cancel)) {
modelAndView.setViewName("redirect:viewHolidays.ftl");
status.setComplete();
} else if (result.hasErrors()) {
modelAndView.setViewName("previewHoliday");
} else {
HolidayDetails holidayDetail = holidayAssembler.translateHolidayFormBeanToDto(formBean);
List<Short> branchIds = holidayAssembler.convertToIds(formBean.getSelectedOfficeIds());
this.holidayServiceFacade.createHoliday(holidayDetail, branchIds);
viewName = REDIRECT_TO_ADMIN_SCREEN;
modelAndView.setViewName(viewName);
status.setComplete();
}
return modelAndView;
}
use of org.mifos.dto.domain.HolidayDetails in project head by mifos.
the class CenterScheduleCreationUsingCustomerServiceIntegrationTest method saveHoliday.
private void saveHoliday(DateTime start, DateTime through, RepaymentRuleTypes rule) throws Exception {
HolidayDetails holidayDetails = new HolidayDetails("testHoliday", start.toDate(), through.toDate(), rule.getValue());
List<Short> officeIds = new LinkedList<Short>();
officeIds.add((short) 1);
IntegrationTestObjectMother.createHoliday(holidayDetails, officeIds);
}
Aggregations