Search in sources :

Example 1 with CenterCustActionForm

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());
}
Also used : CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) ActionForwards(org.mifos.application.util.helpers.ActionForwards) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with CenterCustActionForm

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());
}
Also used : CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) UserContext(org.mifos.security.util.UserContext) CenterCreation(org.mifos.dto.domain.CenterCreation) CenterFormCreationDto(org.mifos.dto.screen.CenterFormCreationDto) DateTime(org.joda.time.DateTime) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with CenterCustActionForm

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());
}
Also used : CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) Address(org.mifos.framework.business.util.Address) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) AddressDto(org.mifos.dto.domain.AddressDto) LocalDate(org.joda.time.LocalDate) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) MeetingDto(org.mifos.dto.domain.MeetingDto) CenterCreationDetail(org.mifos.dto.domain.CenterCreationDetail) BusinessRuleException(org.mifos.service.BusinessRuleException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with CenterCustActionForm

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());
}
Also used : CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) CenterBO(org.mifos.customers.center.business.CenterBO) CenterDto(org.mifos.dto.domain.CenterDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 5 with CenterCustActionForm

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());
}
Also used : CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) Test(org.junit.Test)

Aggregations

CenterCustActionForm (org.mifos.customers.center.struts.actionforms.CenterCustActionForm)11 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)8 Test (org.junit.Test)3 CenterBO (org.mifos.customers.center.business.CenterBO)3 ApplicationException (org.mifos.framework.exceptions.ApplicationException)3 MeetingBO (org.mifos.application.meeting.business.MeetingBO)2 CustomerSearch (org.mifos.application.servicefacade.CustomerSearch)2 AddressDto (org.mifos.dto.domain.AddressDto)2 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ActionForward (org.apache.struts.action.ActionForward)1 DateTime (org.joda.time.DateTime)1 LocalDate (org.joda.time.LocalDate)1 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)1 ActionForwards (org.mifos.application.util.helpers.ActionForwards)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 FeeBuilder (org.mifos.domain.builders.FeeBuilder)1