use of org.mifos.customers.center.struts.actionforms.CenterCustActionForm in project head by mifos.
the class CenterCustAction method cancel.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward cancel(ActionMapping mapping, ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) {
CenterCustActionForm actionForm = (CenterCustActionForm) form;
ActionForwards forward = null;
if (actionForm.getInput().equals(Methods.create.toString())) {
forward = ActionForwards.cancel_success;
} else if (actionForm.getInput().equals(Methods.manage.toString())) {
forward = ActionForwards.editcancel_success;
}
return mapping.findForward(forward.toString());
}
use of org.mifos.customers.center.struts.actionforms.CenterCustActionForm in project head by mifos.
the class CenterCustAction method load.
@TransactionDemarcate(saveToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
CenterCustActionForm actionForm = (CenterCustActionForm) form;
actionForm.clearActionFormFields();
SessionUtils.removeAttribute(CustomerConstants.CUSTOMER_MEETING, request);
UserContext userContext = getUserContext(request);
CenterCreation centerCreationDto = new CenterCreation(actionForm.getOfficeIdValue(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
CenterFormCreationDto centerFormCreation = this.centerServiceFacade.retrieveCenterFormCreationData(centerCreationDto);
// SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<Serializable>(), request);
SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, centerFormCreation.getActiveLoanOfficersForBranch(), request);
SessionUtils.setCollectionAttribute(CustomerConstants.ADDITIONAL_FEES_LIST, centerFormCreation.getAdditionalFees(), request);
// actionForm.setCustomFields(centerFormCreation.getCustomFieldViews());
actionForm.setDefaultFees(centerFormCreation.getDefaultFees());
DateTime today = new DateTime().toDateMidnight().toDateTime();
actionForm.setMfiJoiningDate(today.getDayOfMonth(), today.getMonthOfYear(), today.getYear());
return mapping.findForward(ActionForwards.load_success.toString());
}
use of org.mifos.customers.center.struts.actionforms.CenterCustActionForm in project head by mifos.
the class CenterCustAction method create.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
CenterCustActionForm actionForm = (CenterCustActionForm) form;
MeetingBO meeting = (MeetingBO) SessionUtils.getAttribute(CustomerConstants.CUSTOMER_MEETING, request);
LocalDate mfiJoiningDate = new LocalDate(CalendarUtils.getDateFromString(actionForm.getMfiJoiningDate(), getUserContext(request).getPreferredLocale()));
Address address = actionForm.getAddress();
AddressDto addressDto = Address.toDto(address);
MeetingDto meetingDto = meeting.toDto();
List<CreateAccountFeeDto> accountFeesToBeApplied = new ArrayList<CreateAccountFeeDto>();
List<ApplicableAccountFeeDto> feesToBeApplied = actionForm.getFeesToApply();
for (ApplicableAccountFeeDto feeDto : feesToBeApplied) {
accountFeesToBeApplied.add(new CreateAccountFeeDto(feeDto.getFeeId(), feeDto.getAmount()));
}
try {
CenterCreationDetail centerCreationDetail = new CenterCreationDetail(mfiJoiningDate, actionForm.getDisplayName(), actionForm.getExternalId(), addressDto, actionForm.getLoanOfficerIdValue(), actionForm.getOfficeIdValue(), accountFeesToBeApplied);
CustomerDetailsDto centerDetails = this.centerServiceFacade.createNewCenter(centerCreationDetail, meetingDto);
createCenterQuestionnaire.saveResponses(request, actionForm, centerDetails.getId());
actionForm.setCustomerId(centerDetails.getId().toString());
actionForm.setGlobalCustNum(centerDetails.getGlobalCustNum());
} catch (BusinessRuleException e) {
throw new ApplicationException(e.getMessageKey(), e.getMessageValues());
}
return mapping.findForward(ActionForwards.create_success.toString());
}
use of org.mifos.customers.center.struts.actionforms.CenterCustActionForm in project head by mifos.
the class CenterCustAction method manage.
// NOTE edit center details
@TransactionDemarcate(joinToken = true)
public ActionForward manage(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
CenterCustActionForm actionForm = (CenterCustActionForm) form;
actionForm.clearActionFormFields();
CenterBO center = (CenterBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
final Integer centerId = center.getCustomerId();
center = this.customerDao.findCenterBySystemId(center.getGlobalCustNum());
SessionUtils.setAttribute(Constants.BUSINESS_KEY, null, request);
CenterDto centerDto = this.centerServiceFacade.retrieveCenterDetailsForUpdate(centerId);
actionForm.setLoanOfficerId(centerDto.getLoanOfficerIdAsString());
actionForm.setCustomerId(centerDto.getCustomerIdAsString());
actionForm.setGlobalCustNum(centerDto.getGlobalCustNum());
actionForm.setExternalId(centerDto.getExternalId());
actionForm.setMfiJoiningDate(centerDto.getMfiJoiningDateAsString());
actionForm.setMfiJoiningDate(centerDto.getMfiJoiningDate().getDayOfMonth(), centerDto.getMfiJoiningDate().getMonthOfYear(), centerDto.getMfiJoiningDate().getYear());
actionForm.setAddress(center.getAddress());
actionForm.setCustomerPositions(centerDto.getCustomerPositionViews());
actionForm.setCustomFields(new ArrayList<CustomFieldDto>());
SessionUtils.setAttribute(Constants.BUSINESS_KEY, center, request);
SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, centerDto.getActiveLoanOfficersForBranch(), request);
SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<CustomFieldDto>(), request);
SessionUtils.setCollectionAttribute(CustomerConstants.POSITIONS, centerDto.getCustomerPositionViews(), request);
SessionUtils.setCollectionAttribute(CustomerConstants.CLIENT_LIST, centerDto.getClientList(), request);
return mapping.findForward(ActionForwards.manage_success.toString());
}
use of org.mifos.customers.center.struts.actionforms.CenterCustActionForm in project head by mifos.
the class CenterActionStrutsTest method testManage.
@Test
public void testManage() throws Exception {
createAndSetCenterInSession();
setRequestPathInfo("/centerCustAction.do");
addRequestParameter("method", "manage");
addRequestParameter("officeId", "3");
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
actionPerform();
verifyNoActionErrors();
verifyNoActionMessages();
verifyForward(ActionForwards.manage_success.toString());
Assert.assertNotNull(SessionUtils.getAttribute(CustomerConstants.LOAN_OFFICER_LIST, request));
Assert.assertNotNull(SessionUtils.getAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, request));
Assert.assertNotNull(SessionUtils.getAttribute(CustomerConstants.CLIENT_LIST, request));
Assert.assertNotNull(SessionUtils.getAttribute(CustomerConstants.POSITIONS, request));
CenterCustActionForm actionForm = (CenterCustActionForm) request.getSession().getAttribute("centerCustActionForm");
Assert.assertEquals(center.getPersonnel().getPersonnelId(), actionForm.getLoanOfficerIdValue());
}
Aggregations