Search in sources :

Example 66 with ClientBO

use of org.mifos.customers.client.business.ClientBO in project head by mifos.

the class MultipleLoanAccountsCreationAction method get.

@TransactionDemarcate(joinToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    MultipleLoanAccountsCreationActionForm loanActionForm = (MultipleLoanAccountsCreationActionForm) form;
    String searchId = loanActionForm.getCenterSearchId();
    Short branchId = getShortValue(loanActionForm.getBranchOfficeId());
    Integer productId = Integer.parseInt(loanActionForm.getPrdOfferingId());
    MultipleLoanAccountDetailsDto multipleLoanDetails = this.loanAccountServiceFacade.retrieveMultipleLoanAccountDetails(searchId, branchId, productId);
    List<ClientBO> clients = this.customerDao.findActiveClientsUnderParent(searchId, branchId);
    if (clients.isEmpty()) {
        throw new BusinessRuleException(LoanConstants.NOSEARCHRESULTS);
    }
    LoanOfferingBO loanOffering = this.loanProductDao.findById(productId);
    List<MultipleLoanCreationDto> multipleLoanDetailsXX = buildClientViewHelper(loanOffering, clients);
    loanActionForm.setClientDetails(multipleLoanDetailsXX);
    SessionUtils.setAttribute(LoanConstants.LOANOFFERING, loanOffering, request);
    SessionUtils.setCollectionAttribute(MasterConstants.BUSINESS_ACTIVITIES, multipleLoanDetails.getAllLoanPruposes(), request);
    SessionUtils.setAttribute(CustomerConstants.PENDING_APPROVAL_DEFINED, multipleLoanDetails.isLoanPendingApprovalStateEnabled(), request);
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) MultipleLoanAccountDetailsDto(org.mifos.dto.screen.MultipleLoanAccountDetailsDto) ClientBO(org.mifos.customers.client.business.ClientBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) MultipleLoanCreationDto(org.mifos.accounts.loan.util.helpers.MultipleLoanCreationDto) MultipleLoanAccountsCreationActionForm(org.mifos.accounts.loan.struts.actionforms.MultipleLoanAccountsCreationActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 67 with ClientBO

use of org.mifos.customers.client.business.ClientBO in project head by mifos.

the class CenterServiceFacadeWebTier method initializeClientStates.

@Override
public void initializeClientStates(String clientGlobalNum) {
    ClientBO client = this.customerDao.findClientBySystemId(clientGlobalNum);
    try {
        List<ListElement> savingsStatesList = new ArrayList<ListElement>();
        AccountStateMachines.getInstance().initializeClientStates();
        List<CustomerStatusEntity> statusList = AccountStateMachines.getInstance().getClientStatusList(client.getCustomerStatus());
        for (CustomerStatusEntity customerState : statusList) {
            savingsStatesList.add(new ListElement(customerState.getId().intValue(), customerState.getName()));
        }
    } catch (StatesInitializationException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : ClientBO(org.mifos.customers.client.business.ClientBO) ArrayList(java.util.ArrayList) ListElement(org.mifos.dto.screen.ListElement) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 68 with ClientBO

use of org.mifos.customers.client.business.ClientBO in project head by mifos.

the class CustomerPersistence method findBySystemId.

/**
     * @deprecated use {@link CustomerDao#findCenterBySystemId(String)}.
     */
@Deprecated
public CustomerBO findBySystemId(final String globalCustNum, final Short levelId) throws PersistenceException {
    Map<String, String> queryParameters = new HashMap<String, String>();
    CustomerBO customer = null;
    queryParameters.put("globalCustNum", globalCustNum);
    if (levelId.shortValue() == CustomerLevel.CENTER.getValue()) {
        List<CenterBO> queryResult = executeNamedQuery(NamedQueryConstants.GET_CENTER_BY_SYSTEMID, queryParameters);
        if (null != queryResult && queryResult.size() > 0) {
            customer = queryResult.get(0);
            initializeCustomer(customer);
        }
    } else if (levelId.shortValue() == CustomerLevel.GROUP.getValue()) {
        List<GroupBO> queryResult = executeNamedQuery(NamedQueryConstants.GET_GROUP_BY_SYSTEMID, queryParameters);
        if (null != queryResult && queryResult.size() > 0) {
            customer = queryResult.get(0);
            initializeCustomer(customer);
        }
    } else if (levelId.shortValue() == CustomerLevel.CLIENT.getValue()) {
        List<ClientBO> queryResult = executeNamedQuery(NamedQueryConstants.GET_CLIENT_BY_SYSTEMID, queryParameters);
        if (null != queryResult && queryResult.size() > 0) {
            customer = queryResult.get(0);
            initializeCustomer(customer);
        }
    }
    return customer;
}
Also used : HashMap(java.util.HashMap) ClientBO(org.mifos.customers.client.business.ClientBO) CustomerBO(org.mifos.customers.business.CustomerBO) CenterBO(org.mifos.customers.center.business.CenterBO) List(java.util.List) ArrayList(java.util.ArrayList)

Example 69 with ClientBO

use of org.mifos.customers.client.business.ClientBO in project head by mifos.

the class PictureFormFile method editPersonalInfo.

@TransactionDemarcate(joinToken = true)
public ActionForward editPersonalInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientCustActionForm actionForm = (ClientCustActionForm) form;
    actionForm.clearMostButNotAllFieldsOnActionForm();
    ClientBO clientFromSession = getClientFromSession(request);
    final String clientSystemId = clientFromSession.getGlobalCustNum();
    ClientBO client = this.customerDao.findClientBySystemId(clientSystemId);
    short loanOfficerId = client.getCreatedBy();
    String clientStatus = client.getCustomerStatus().getName();
    ClientPersonalInfoDto personalInfo = this.clientServiceFacade.retrieveClientPersonalInfoForUpdate(clientSystemId, clientStatus, loanOfficerId);
    SessionUtils.setCollectionAttribute(ClientConstants.SALUTATION_ENTITY, personalInfo.getClientDropdowns().getSalutations(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.GENDER_ENTITY, personalInfo.getClientDropdowns().getGenders(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.MARITAL_STATUS_ENTITY, personalInfo.getClientDropdowns().getMaritalStatuses(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.CITIZENSHIP_ENTITY, personalInfo.getClientDropdowns().getCitizenship(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.ETHNICITY_ENTITY, personalInfo.getClientDropdowns().getEthnicity(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.EDUCATION_LEVEL_ENTITY, personalInfo.getClientDropdowns().getEducationLevels(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.BUSINESS_ACTIVITIES_ENTITY, personalInfo.getClientDropdowns().getBusinessActivity(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.POVERTY_STATUS, personalInfo.getClientDropdowns().getPoverty(), request);
    SessionUtils.setCollectionAttribute(ClientConstants.HANDICAPPED_ENTITY, personalInfo.getClientDropdowns().getHandicapped(), request);
    UserContext userContext = getUserContext(request);
    List<SpouseFatherLookupEntity> spouseFather = legacyMasterDao.findMasterDataEntitiesWithLocale(SpouseFatherLookupEntity.class);
    SessionUtils.setCollectionAttribute(ClientConstants.SPOUSE_FATHER_ENTITY, spouseFather, request);
    SessionUtils.setAttribute("CanEditPhoneNumber", ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId()), request);
    InformationOrderServiceFacade informationOrderServiceFacade = ApplicationContextProvider.getBean(InformationOrderServiceFacade.class);
    SessionUtils.setCollectionAttribute("personalInformationOrder", informationOrderServiceFacade.getInformationOrder("CreateClient"), request);
    boolean isFamilyDetailsRequired = personalInfo.getClientRules().isFamilyDetailsRequired();
    SessionUtils.setAttribute(ClientConstants.ARE_FAMILY_DETAILS_REQUIRED, isFamilyDetailsRequired, request);
    if (isFamilyDetailsRequired) {
        SessionUtils.setAttribute(ClientConstants.ARE_FAMILY_DETAILS_MANDATORY, isFamilyDetailsMandatory(), request);
        SessionUtils.setAttribute(ClientConstants.ARE_FAMILY_DETAILS_HIDDEN, false, request);
    } else {
        SessionUtils.setAttribute(ClientConstants.ARE_FAMILY_DETAILS_MANDATORY, isSpouseFatherInformationMandatory(), request);
        SessionUtils.setAttribute(ClientConstants.ARE_FAMILY_DETAILS_HIDDEN, isSpouseFatherInformationHidden(), request);
    }
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<CustomFieldDto>(), request);
    // customer specific
    actionForm.setCustomerId(personalInfo.getCustomerDetail().getCustomerId().toString());
    actionForm.setLoanOfficerId(personalInfo.getCustomerDetail().getLoanOfficerIdAsString());
    actionForm.setGlobalCustNum(personalInfo.getCustomerDetail().getGlobalCustNum());
    actionForm.setExternalId(personalInfo.getCustomerDetail().getExternalId());
    actionForm.setAddress(Address.toAddress(client.getAddress()));
    // client specific
    actionForm.setGovernmentId(personalInfo.getClientDetail().getGovernmentId());
    actionForm.setDateOfBirth(personalInfo.getClientDetail().getDateOfBirth());
    actionForm.setClientDetailView(personalInfo.getClientDetail().getCustomerDetail());
    ClientNameDetailDto clientName = personalInfo.getClientDetail().getClientName();
    clientName.setNames(ClientRules.getNameSequence());
    actionForm.setClientName(clientName);
    String photoDelete = request.getParameter("photoDelete");
    if (photoDelete != null && photoDelete.equals("true")) {
        ApplicationContextProvider.getBean(ClientPhotoService.class).delete(client.getCustomerId().longValue());
    }
    boolean isPhotoFieldHidden = FieldConfig.getInstance().isFieldHidden("Client.Photo");
    SessionUtils.setAttribute(ClientConstants.IS_PHOTO_FIELD_HIDDEN, isPhotoFieldHidden, request);
    if (!isPhotoFieldHidden) {
        ClientPhotoDto clientPhotoDto = this.clientServiceFacade.getClientPhoto(client.getCustomerId().longValue());
        if (clientPhotoDto != null) {
            FormFile formFile = new PictureFormFile(clientPhotoDto.getContentType(), clientPhotoDto.getOut(), client.getCustomerId().toString(), clientPhotoDto.getContentLength().intValue());
            actionForm.setPicture(formFile);
        } else {
            actionForm.setPicture(null);
        }
    } else {
        actionForm.setPicture(null);
    }
    ClientNameDetailDto spouseName = personalInfo.getClientDetail().getSpouseName();
    if (spouseName != null) {
        spouseName.setNames(ClientRules.getNameSequence());
        actionForm.setSpouseName(spouseName);
    }
    actionForm.setSpouseName(spouseName);
    actionForm.setCustomFields(new ArrayList<CustomFieldDto>());
    SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, client, request);
    return mapping.findForward(ActionForwards.editPersonalInfo_success.toString());
}
Also used : ClientCustActionForm(org.mifos.customers.client.struts.actionforms.ClientCustActionForm) ClientPhotoService(org.mifos.framework.image.service.ClientPhotoService) UserContext(org.mifos.security.util.UserContext) ClientBO(org.mifos.customers.client.business.ClientBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) FormFile(org.apache.struts.upload.FormFile) InformationOrderServiceFacade(org.mifos.platform.questionnaire.service.InformationOrderServiceFacade) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) SpouseFatherLookupEntity(org.mifos.application.master.business.SpouseFatherLookupEntity) ClientPersonalInfoDto(org.mifos.dto.screen.ClientPersonalInfoDto) ClientPhotoDto(org.mifos.dto.screen.ClientPhotoDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 70 with ClientBO

use of org.mifos.customers.client.business.ClientBO in project head by mifos.

the class ClientTransferAction method transferToBranch.

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward transferToBranch(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ClientTransferActionForm actionForm = (ClientTransferActionForm) form;
    ClientBO clientInSession = (ClientBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    String globalCustNum = this.clientServiceFacade.transferClientToBranch(clientInSession.getGlobalCustNum(), actionForm.getOfficeIdValue());
    ClientBO client = this.customerDao.findClientBySystemId(globalCustNum);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, client, request);
    return mapping.findForward(ActionForwards.update_success.toString());
}
Also used : ClientTransferActionForm(org.mifos.customers.client.struts.actionforms.ClientTransferActionForm) ClientBO(org.mifos.customers.client.business.ClientBO) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

ClientBO (org.mifos.customers.client.business.ClientBO)93 ArrayList (java.util.ArrayList)27 Test (org.junit.Test)27 CustomerException (org.mifos.customers.exceptions.CustomerException)25 CustomerBO (org.mifos.customers.business.CustomerBO)23 GroupBO (org.mifos.customers.group.business.GroupBO)22 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)22 UserContext (org.mifos.security.util.UserContext)21 MifosRuntimeException (org.mifos.core.MifosRuntimeException)19 CenterBO (org.mifos.customers.center.business.CenterBO)19 BusinessRuleException (org.mifos.service.BusinessRuleException)17 ClientBuilder (org.mifos.domain.builders.ClientBuilder)16 PersistenceException (org.mifos.framework.exceptions.PersistenceException)16 OfficeBO (org.mifos.customers.office.business.OfficeBO)14 GroupBuilder (org.mifos.domain.builders.GroupBuilder)14 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)14 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)14 Date (java.util.Date)13 DateTime (org.joda.time.DateTime)13 AccountException (org.mifos.accounts.exceptions.AccountException)13