Search in sources :

Example 1 with ProcessRulesDto

use of org.mifos.dto.domain.ProcessRulesDto in project head by mifos.

the class ClientServiceFacadeWebTier method previewClient.

@Override
public ProcessRulesDto previewClient(String governmentId, DateTime dateOfBirth, String clientName, boolean defaultFeeRemoval, Short officeId, Short loanOfficerId) {
    try {
        MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        UserContext userContext = toUserContext(user);
        boolean clientPendingApprovalStateEnabled = ProcessFlowRules.isClientPendingApprovalStateEnabled();
        boolean governmentIdValidationFailing = false;
        boolean duplicateNameOnClosedClient = false;
        boolean duplicateNameOnBlackListedClient = false;
        boolean governmentIdValidationUnclosedFailing = false;
        boolean duplicateNameOnClient = false;
        List<ClientBO> matchedClients = new ArrayList<ClientBO>();
        List<ClientBO> temp;
        if (defaultFeeRemoval) {
            customerDao.checkPermissionForDefaultFeeRemoval(userContext, officeId, loanOfficerId);
        }
        if (StringUtils.isNotBlank(governmentId)) {
            temp = this.customerDao.validateGovernmentIdForUnclosedClient(governmentId);
            if (temp != null) {
                matchedClients.addAll(temp);
            }
            governmentIdValidationUnclosedFailing = temp != null && temp.size() > 0;
            if (!governmentIdValidationUnclosedFailing) {
                temp = this.customerDao.validateGovernmentIdForClient(governmentId);
                if (temp != null) {
                    matchedClients.addAll(temp);
                }
                governmentIdValidationFailing = temp != null && temp.size() > 0;
            }
        }
        if (!governmentIdValidationFailing && !governmentIdValidationUnclosedFailing) {
            temp = this.customerDao.validateForBlackListedClientsOnNameAndDob(clientName, dateOfBirth);
            if (temp != null) {
                matchedClients.addAll(temp);
            }
            duplicateNameOnBlackListedClient = temp != null && temp.size() > 0;
            if (!duplicateNameOnBlackListedClient) {
                temp = this.customerDao.validateForClosedClientsOnNameAndDob(clientName, dateOfBirth);
                if (temp != null) {
                    matchedClients.addAll(temp);
                }
                duplicateNameOnClosedClient = temp != null && temp.size() > 0;
                if (!duplicateNameOnClosedClient) {
                    temp = this.customerDao.validateForClientsOnName(clientName);
                    if (temp != null) {
                        matchedClients.addAll(temp);
                    }
                    duplicateNameOnClient = temp != null && temp.size() > 0;
                }
            }
        }
        List<MatchedClientDto> matched = new ArrayList<MatchedClientDto>();
        for (ClientBO client : matchedClients) {
            matched.add(new MatchedClientDto(client.getGlobalCustNum(), client.getDisplayName(), client.getAddress().getPhoneNumber(), client.getGovernmentId(), client.getDisplayAddress(), client.getOffice().getOfficeName(), client.getOffice().getGlobalOfficeNum()));
        }
        return new ProcessRulesDto(clientPendingApprovalStateEnabled, governmentIdValidationFailing, duplicateNameOnClosedClient, duplicateNameOnBlackListedClient, governmentIdValidationUnclosedFailing, duplicateNameOnClient, matched);
    } catch (CustomerException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : ProcessRulesDto(org.mifos.dto.domain.ProcessRulesDto) CustomerException(org.mifos.customers.exceptions.CustomerException) BusinessRuleException(org.mifos.service.BusinessRuleException) UserContext(org.mifos.security.util.UserContext) ClientBO(org.mifos.customers.client.business.ClientBO) MatchedClientDto(org.mifos.dto.domain.MatchedClientDto) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser)

Example 2 with ProcessRulesDto

use of org.mifos.dto.domain.ProcessRulesDto 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 3 with ProcessRulesDto

use of org.mifos.dto.domain.ProcessRulesDto in project head by mifos.

the class PictureFormFile method previewPersonalInfo.

@TransactionDemarcate(joinToken = true)
public ActionForward previewPersonalInfo(ActionMapping mapping, ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    actionForm.setAge(calculateAge(DateUtils.getDateAsSentFromBrowser(actionForm.getDateOfBirth())));
    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());
    addWarningMessages(request, processRules, calculateAge(DateUtils.getDateAsSentFromBrowser(actionForm.getDateOfBirth())));
    return mapping.findForward(ActionForwards.previewPersonalInfo_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) ProcessRulesDto(org.mifos.dto.domain.ProcessRulesDto) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) DateTime(org.joda.time.DateTime) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

ProcessRulesDto (org.mifos.dto.domain.ProcessRulesDto)3 DateTime (org.joda.time.DateTime)2 ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)2 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)2 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)2 UserContext (org.mifos.security.util.UserContext)2 ArrayList (java.util.ArrayList)1 MeetingBO (org.mifos.application.meeting.business.MeetingBO)1 ClientBO (org.mifos.customers.client.business.ClientBO)1 CustomerException (org.mifos.customers.exceptions.CustomerException)1 MatchedClientDto (org.mifos.dto.domain.MatchedClientDto)1 ClientFormCreationDto (org.mifos.dto.screen.ClientFormCreationDto)1 InformationOrderServiceFacade (org.mifos.platform.questionnaire.service.InformationOrderServiceFacade)1 MifosUser (org.mifos.security.MifosUser)1 BusinessRuleException (org.mifos.service.BusinessRuleException)1