Search in sources :

Example 6 with ClientCustActionForm

use of org.mifos.customers.client.struts.actionforms.ClientCustActionForm in project head by mifos.

the class PictureFormFile method preview.

@TransactionDemarcate(joinToken = true)
public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    String governmentId = actionForm.getGovernmentId();
    ClientNameDetailDto clientNameDetail = actionForm.getClientName();
    clientNameDetail.setNames(ClientRules.getNameSequence());
    String clientName = clientNameDetail.getDisplayName();
    String givenDateOfBirth = actionForm.getDateOfBirth();
    ClientNameDetailDto spouseName = actionForm.getSpouseName();
    spouseName.setNames(ClientRules.getNameSequence());
    DateTime dateOfBirth = new DateTime(DateUtils.getDateAsSentFromBrowser(givenDateOfBirth));
    ProcessRulesDto processRules = this.clientServiceFacade.previewClient(governmentId, dateOfBirth, clientName, actionForm.isDefaultFeeRemoved(), actionForm.getOfficeIdValue(), actionForm.getLoanOfficerIdValue());
    String pendingApprovalState = processRules.isClientPendingApprovalStateEnabled() ? CustomerConstants.YES : CustomerConstants.NO;
    SessionUtils.setAttribute(CustomerConstants.PENDING_APPROVAL_DEFINED, pendingApprovalState, request);
    Short officeId = actionForm.getOfficeIdValue();
    Short groupFlag = actionForm.getGroupFlagValue();
    String parentGroupId = actionForm.getParentGroupId();
    ClientFormCreationDto clientFormCreationDto = this.clientServiceFacade.retrieveClientFormCreationData(groupFlag, officeId, parentGroupId);
    InformationOrderServiceFacade informationOrderServiceFacade = ApplicationContextProvider.getBean(InformationOrderServiceFacade.class);
    SessionUtils.setCollectionAttribute("personalInformationOrder", informationOrderServiceFacade.getInformationOrder("CreateClient"), request);
    if (clientFormCreationDto.getFormedByPersonnelId() != null) {
        UserContext userContext = getUserContext(request);
        MeetingBO groupMeeting = customerDao.findCustomerById(Integer.valueOf(parentGroupId)).getCustomerMeetingValue();
        clientFormCreationDto.getParentCustomerMeeting().setMeetingSchedule(CustomerUIHelperFn.getMeetingSchedule(groupMeeting, userContext));
        SessionUtils.setAttribute("meeting", clientFormCreationDto.getParentCustomerMeeting(), request);
    }
    addWarningMessages(request, processRules, calculateAge(DateUtils.getDateAsSentFromBrowser(givenDateOfBirth)));
    actionForm.setEditFamily("edit");
    actionForm.setAge(calculateAge(DateUtils.getDateAsSentFromBrowser(givenDateOfBirth)));
    actionForm.setClientName(clientNameDetail);
    actionForm.setSpouseName(spouseName);
    return mapping.findForward(ActionForwards.preview_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) ProcessRulesDto(org.mifos.dto.domain.ProcessRulesDto) InformationOrderServiceFacade(org.mifos.platform.questionnaire.service.InformationOrderServiceFacade) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ClientFormCreationDto(org.mifos.dto.screen.ClientFormCreationDto) DateTime(org.joda.time.DateTime) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 7 with ClientCustActionForm

use of org.mifos.customers.client.struts.actionforms.ClientCustActionForm in project head by mifos.

the class PictureFormFile method cancel.

public ActionForward cancel(ActionMapping mapping, ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    String forward = null;
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    String fromPage = actionForm.getInput();
    if (ClientConstants.INPUT_PERSONAL_INFO.equals(fromPage) || ClientConstants.INPUT_MFI_INFO.equals(fromPage) || CenterConstants.INPUT_CREATE.equals(fromPage)) {
        actionForm.setEditFamily("notEdit");
        forward = ActionForwards.cancelCreate_success.toString();
    } else if (ClientConstants.INPUT_EDIT_PERSONAL_INFO.equals(fromPage) || ClientConstants.INPUT_EDIT_MFI_INFO.equals(fromPage) || ClientConstants.INPUT_EDIT_FAMILY_INFO.equals(fromPage)) {
        forward = ActionForwards.cancelEdit_success.toString();
    }
    return mapping.findForward(forward);
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm)

Example 8 with ClientCustActionForm

use of org.mifos.customers.client.struts.actionforms.ClientCustActionForm in project head by mifos.

the class PictureFormFile method addFile.

@TransactionDemarcate(joinToken = true)
public ActionForward addFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    FormFile file = actionForm.getSelectedFile();
    String fileName = actionForm.getSelectedFile().getFileName();
    String fileContentType = actionForm.getSelectedFile().getContentType();
    Integer fileSize = actionForm.getSelectedFile().getFileSize();
    String fileDescription = actionForm.getSelectedFileDescription();
    if (file != null) {
        actionForm.getFiles().add(file);
        actionForm.getFilesMetadata().add(new UploadedFileDto(fileName, fileContentType, fileSize, fileDescription));
    }
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) UploadedFileDto(org.mifos.dto.screen.UploadedFileDto) FormFile(org.apache.struts.upload.FormFile) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 9 with ClientCustActionForm

use of org.mifos.customers.client.struts.actionforms.ClientCustActionForm in project head by mifos.

the class ClientCustActionStrutsTest method testCreateSuccessWithAssociatedSavingsOfferings.

@Test
public void testCreateSuccessWithAssociatedSavingsOfferings() throws Exception {
    SecurityContext securityContext = new SecurityContextImpl();
    MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
    Authentication authentication = new TestingAuthenticationToken(principal, principal);
    securityContext.setAuthentication(authentication);
    SecurityContextHolder.setContext(securityContext);
    savingsOffering1 = TestObjectFactory.createSavingsProduct("savingsPrd1", "s1", SavingsType.MANDATORY, ApplicableTo.CLIENTS, new Date(System.currentTimeMillis()));
    List<FeeDto> feesToRemove = getFees(RecurrenceType.WEEKLY);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("officeId", "3");
    addRequestParameter("groupFlag", "0");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    flowKey = (String) request.getAttribute(Constants.CURRENTFLOWKEY);
    List<BusinessActivityEntity> povertyStatus = (List<BusinessActivityEntity>) SessionUtils.getAttribute(ClientConstants.POVERTY_STATUS, request);
    List<CustomFieldDto> customFieldDefs = getCustomFieldFromSession();
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "next");
    addRequestParameter("officeId", "3");
    addRequestParameter("clientName.salutation", "1");
    addRequestParameter("clientName.firstName", "Client");
    addRequestParameter("clientName.lastName", "LastName");
    addRequestParameter("spouseName.firstName", "Spouse");
    addRequestParameter("spouseName.lastName", "LastName");
    addRequestParameter("spouseName.nameType", "1");
    addRequestDateParameter("dateOfBirth", "20/3/1987");
    addRequestParameter("clientDetailView.gender", "1");
    addRequestParameter("input", "personalInfo");
    addRequestParameter("customerDetail.povertyStatus", povertyStatus.get(0).getId().toString());
    int i = 0;
    for (CustomFieldDto customFieldDef : customFieldDefs) {
        addRequestParameter("customField[" + i + "].fieldId", customFieldDef.getFieldId().toString());
        addRequestParameter("customField[" + i + "].fieldValue", "Req");
        i++;
    }
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    List<SavingsDetailDto> savingsOfferingList = getSavingsOfferingsFromSession();
    SavingsDetailDto savingsOffering = savingsOfferingList.get(0);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("input", "mfiInfo");
    addRequestParameter("loanOfficerId", "1");
    addRequestParameter("formedByPersonnel", "1");
    addRequestParameter("savingsOffering[0]", savingsOffering.getPrdOfferingId().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.preview_success.toString());
    MeetingBO weeklyMeeting = new MeetingBuilder().weekly().every(1).occuringOnA(WeekDay.WEDNESDAY).build();
    SessionUtils.setAttribute(CustomerConstants.CUSTOMER_MEETING, weeklyMeeting, request);
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "create");
    addRequestParameter("input", "create");
    addRequestParameter("status", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.create_success.toString());
    ClientCustActionForm actionForm = (ClientCustActionForm) request.getSession().getAttribute("clientCustActionForm");
    client = TestObjectFactory.getClient(actionForm.getCustomerIdAsInt());
    Assert.assertNotNull(client);
    Assert.assertNotNull(client.getOfferingsAssociatedInCreate());
    Assert.assertEquals(1, client.getOfferingsAssociatedInCreate().size());
    for (ClientInitialSavingsOfferingEntity offering : client.getOfferingsAssociatedInCreate()) {
        Assert.assertEquals(savingsOffering1.getPrdOfferingId(), offering.getSavingsOffering().getPrdOfferingId());
        Assert.assertTrue(true);
    }
    removeFees(feesToRemove);
    savingsOffering1 = (SavingsOfferingBO) TestObjectFactory.getObject(SavingsOfferingBO.class, savingsOffering.getPrdOfferingId());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) BusinessActivityEntity(org.mifos.application.master.business.BusinessActivityEntity) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) FeeDto(org.mifos.accounts.fees.business.FeeDto) MifosUser(org.mifos.security.MifosUser) MifosUserBuilder(org.mifos.builders.MifosUserBuilder) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) ClientInitialSavingsOfferingEntity(org.mifos.customers.client.business.ClientInitialSavingsOfferingEntity) Date(java.util.Date) Authentication(org.springframework.security.core.Authentication) SecurityContext(org.springframework.security.core.context.SecurityContext) List(java.util.List) ArrayList(java.util.ArrayList) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) Test(org.junit.Test)

Example 10 with ClientCustActionForm

use of org.mifos.customers.client.struts.actionforms.ClientCustActionForm in project head by mifos.

the class ClientCustActionStrutsTest method testLoadClientUnderGroup_FeeDifferentFrequecny.

@Test
public void testLoadClientUnderGroup_FeeDifferentFrequecny() throws Exception {
    createGroupWithoutFee();
    List<FeeDto> fees = getFees(RecurrenceType.MONTHLY);
    StaticHibernateUtil.flushAndClearSession();
    setRequestPathInfo("/clientCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("parentGroupId", group.getCustomerId().toString());
    addRequestParameter("groupFlag", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.load_success.toString());
    ClientCustActionForm actionForm = (ClientCustActionForm) request.getSession().getAttribute("clientCustActionForm");
    Assert.assertEquals(actionForm.getFormedByPersonnelValue(), group.getCustomerFormedByPersonnel().getPersonnelId());
    List<FeeDto> additionalFees = (List<FeeDto>) SessionUtils.getAttribute(CustomerConstants.ADDITIONAL_FEES_LIST, request);
    Assert.assertEquals(0, additionalFees.size());
    group = (GroupBO) StaticHibernateUtil.getSessionTL().get(GroupBO.class, group.getCustomerId());
    removeFees(fees);
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) FeeDto(org.mifos.accounts.fees.business.FeeDto) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)29 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)21 ArrayList (java.util.ArrayList)10 List (java.util.List)8 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)8 Test (org.junit.Test)7 ClientBO (org.mifos.customers.client.business.ClientBO)7 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)7 BusinessActivityEntity (org.mifos.application.master.business.BusinessActivityEntity)5 MeetingBO (org.mifos.application.meeting.business.MeetingBO)5 UserContext (org.mifos.security.util.UserContext)5 FormFile (org.apache.struts.upload.FormFile)4 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)4 InformationOrderServiceFacade (org.mifos.platform.questionnaire.service.InformationOrderServiceFacade)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)3 DateTime (org.joda.time.DateTime)3 FeeDto (org.mifos.accounts.fees.business.FeeDto)3 SpouseFatherLookupEntity (org.mifos.application.master.business.SpouseFatherLookupEntity)3 SavingsDetailDto (org.mifos.dto.domain.SavingsDetailDto)3