Search in sources :

Example 21 with ClientNameDetailDto

use of org.mifos.dto.screen.ClientNameDetailDto in project head by mifos.

the class ClientServiceFacadeWebTier method createNewClient.

@Override
public CustomerDetailsDto createNewClient(ClientCreationDetail clientCreationDetail, MeetingDto meetingDto, List<SavingsDetailDto> allowedSavingProducts) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    OfficeBO userOffice = this.officeDao.findOfficeById(userContext.getBranchId());
    userContext.setBranchGlobalNum(userOffice.getGlobalOfficeNum());
    try {
        ClientBO client = null;
        List<AccountFeesEntity> feesForCustomerAccount = convertFeeViewsToAccountFeeEntities(clientCreationDetail.getFeesToApply());
        List<SavingsOfferingBO> selectedOfferings = new ArrayList<SavingsOfferingBO>();
        for (Short productId : clientCreationDetail.getSelectedSavingProducts()) {
            if (productId != null) {
                for (SavingsDetailDto savingsOffering : allowedSavingProducts) {
                    if (productId.equals(savingsOffering.getPrdOfferingId())) {
                        SavingsOfferingBO savingsProduct = savingsProductDao.findById(productId.intValue());
                        selectedOfferings.add(savingsProduct);
                    }
                }
            }
        }
        List<ClientInitialSavingsOfferingEntity> offeringsAssociatedInCreate = new ArrayList<ClientInitialSavingsOfferingEntity>();
        for (SavingsOfferingBO offering : selectedOfferings) {
            offeringsAssociatedInCreate.add(new ClientInitialSavingsOfferingEntity(null, offering));
        }
        Short personnelId = null;
        Short officeId = null;
        ClientNameDetailDto spouseNameDetailView = null;
        if (ClientRules.isFamilyDetailsRequired()) {
        //                actionForm.setFamilyDateOfBirth();
        //                actionForm.constructFamilyDetails();
        } else {
            spouseNameDetailView = clientCreationDetail.getSpouseFatherName();
        }
        String secondMiddleName = null;
        ClientNameDetailEntity clientNameDetailEntity = new ClientNameDetailEntity(null, secondMiddleName, clientCreationDetail.getClientNameDetailDto());
        ClientNameDetailEntity spouseFatherNameDetailEntity = null;
        if (spouseNameDetailView != null) {
            spouseFatherNameDetailEntity = new ClientNameDetailEntity(null, secondMiddleName, spouseNameDetailView);
        }
        ClientDetailEntity clientDetailEntity = new ClientDetailEntity();
        clientDetailEntity.updateClientDetails(clientCreationDetail.getClientPersonalDetailDto());
        DateTime dob = new DateTime(clientCreationDetail.getDateOfBirth());
        boolean trainedBool = clientCreationDetail.isTrained();
        DateTime trainedDateTime = null;
        if (clientCreationDetail.getTrainedDate() != null) {
            trainedDateTime = new DateTime(clientCreationDetail.getTrainedDate());
        }
        String clientFirstName = clientCreationDetail.getClientNameDetailDto().getFirstName();
        String clientLastName = clientCreationDetail.getClientNameDetailDto().getLastName();
        String secondLastName = clientCreationDetail.getClientNameDetailDto().getSecondLastName();
        CustomerStatus clientStatus = CustomerStatus.fromInt(clientCreationDetail.getClientStatus());
        PersonnelBO formedBy = this.personnelDao.findPersonnelById(clientCreationDetail.getFormedBy());
        Address address = null;
        if (clientCreationDetail.getAddress() != null) {
            AddressDto dto = clientCreationDetail.getAddress();
            address = new Address(dto.getLine1(), dto.getLine2(), dto.getLine3(), dto.getCity(), dto.getState(), dto.getCountry(), dto.getZip(), dto.getPhoneNumber());
        }
        if (YesNoFlag.YES.getValue().equals(clientCreationDetail.getGroupFlag())) {
            Integer parentGroupId = Integer.parseInt(clientCreationDetail.getParentGroupId());
            CustomerBO group = this.customerDao.findCustomerById(parentGroupId);
            if (group.getPersonnel() != null) {
                personnelId = group.getPersonnel().getPersonnelId();
            }
            officeId = group.getOffice().getOfficeId();
            client = ClientBO.createNewInGroupHierarchy(userContext, clientCreationDetail.getClientName(), clientStatus, new DateTime(clientCreationDetail.getMfiJoiningDate()), group, formedBy, clientNameDetailEntity, dob, clientCreationDetail.getGovernmentId(), trainedBool, trainedDateTime, clientCreationDetail.getGroupFlag(), clientFirstName, clientLastName, secondLastName, spouseFatherNameDetailEntity, clientDetailEntity, offeringsAssociatedInCreate, clientCreationDetail.getExternalId(), address, clientCreationDetail.getActivationDate());
            if (ClientRules.isFamilyDetailsRequired()) {
                client.setFamilyAndNameDetailSets(clientCreationDetail.getFamilyNames(), clientCreationDetail.getFamilyDetails());
            }
            this.customerService.createClient(client, client.getCustomerMeetingValue(), feesForCustomerAccount, selectedOfferings);
        } else {
            personnelId = clientCreationDetail.getLoanOfficerId();
            officeId = clientCreationDetail.getOfficeId();
            PersonnelBO loanOfficer = this.personnelDao.findPersonnelById(personnelId);
            OfficeBO office = this.officeDao.findOfficeById(officeId);
            int lastSearchIdCustomerValue = customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(officeId);
            MeetingBO clientMeeting = null;
            if (meetingDto != null) {
                clientMeeting = new MeetingFactory().create(meetingDto);
                clientMeeting.setUserContext(userContext);
            }
            client = ClientBO.createNewOutOfGroupHierarchy(userContext, clientCreationDetail.getClientName(), clientStatus, new DateTime(clientCreationDetail.getMfiJoiningDate()), office, loanOfficer, clientMeeting, formedBy, clientNameDetailEntity, dob, clientCreationDetail.getGovernmentId(), trainedBool, trainedDateTime, clientCreationDetail.getGroupFlag(), clientFirstName, clientLastName, secondLastName, spouseFatherNameDetailEntity, clientDetailEntity, offeringsAssociatedInCreate, clientCreationDetail.getExternalId(), address, lastSearchIdCustomerValue);
            if (ClientRules.isFamilyDetailsRequired()) {
                client.setFamilyAndNameDetailSets(clientCreationDetail.getFamilyNames(), clientCreationDetail.getFamilyDetails());
            }
            try {
                personnelDao.checkAccessPermission(userContext, client.getOfficeId(), client.getLoanOfficerId());
            } catch (AccountException e) {
                throw new MifosRuntimeException("Access denied!", e);
            }
            this.customerService.createClient(client, clientMeeting, feesForCustomerAccount, selectedOfferings);
        }
        clientPhotoService.create(client.getCustomerId().longValue(), clientCreationDetail.getPicture());
        return new CustomerDetailsDto(client.getCustomerId(), client.getGlobalCustNum());
    } catch (CustomerException e) {
        throw new BusinessRuleException(e.getKey(), e.getValues(), e);
    }
}
Also used : Address(org.mifos.framework.business.util.Address) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ClientBO(org.mifos.customers.client.business.ClientBO) ArrayList(java.util.ArrayList) ClientInitialSavingsOfferingEntity(org.mifos.customers.client.business.ClientInitialSavingsOfferingEntity) MeetingFactory(org.mifos.application.meeting.business.MeetingFactory) DateTime(org.joda.time.DateTime) BusinessRuleException(org.mifos.service.BusinessRuleException) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientNameDetailEntity(org.mifos.customers.client.business.ClientNameDetailEntity) ClientDetailEntity(org.mifos.customers.client.business.ClientDetailEntity) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) CustomerException(org.mifos.customers.exceptions.CustomerException) UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) CustomerAddressDto(org.mifos.dto.domain.CustomerAddressDto) AddressDto(org.mifos.dto.domain.AddressDto) AccountException(org.mifos.accounts.exceptions.AccountException) CustomerStatus(org.mifos.customers.util.helpers.CustomerStatus) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 22 with ClientNameDetailDto

use of org.mifos.dto.screen.ClientNameDetailDto in project head by mifos.

the class ClientBO method toClientNameDetailViews.

public final List<ClientNameDetailDto> toClientNameDetailViews() {
    List<ClientNameDetailDto> clientNameDetailDtos = new ArrayList<ClientNameDetailDto>();
    for (ClientNameDetailEntity clientNameDetail : getNameDetailSet()) {
        ClientNameDetailDto clientNameDetailDto = clientNameDetail.toDto();
        clientNameDetailDtos.add(clientNameDetailDto);
    }
    return clientNameDetailDtos;
}
Also used : ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ArrayList(java.util.ArrayList)

Example 23 with ClientNameDetailDto

use of org.mifos.dto.screen.ClientNameDetailDto in project head by mifos.

the class ClientNameDetailEntity method toDto.

public ClientNameDetailDto toDto() {
    ClientNameDetailDto clientNameDetail = new ClientNameDetailDto(this.nameType, this.salutation, new StringBuilder(this.displayName), this.name.getFirstName(), this.name.getMiddleName(), this.name.getLastName(), this.name.getSecondLastName(), this.customerNameId);
    clientNameDetail.setNames(ClientRules.getNameSequence());
    return clientNameDetail;
}
Also used : ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto)

Example 24 with ClientNameDetailDto

use of org.mifos.dto.screen.ClientNameDetailDto 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 25 with ClientNameDetailDto

use of org.mifos.dto.screen.ClientNameDetailDto 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

ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)41 ClientPersonalDetailDto (org.mifos.dto.screen.ClientPersonalDetailDto)26 CustomerException (org.mifos.customers.exceptions.CustomerException)15 Test (org.junit.Test)14 ClientBO (org.mifos.customers.client.business.ClientBO)14 ArrayList (java.util.ArrayList)12 ClientFamilyDetailDto (org.mifos.dto.screen.ClientFamilyDetailDto)10 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)9 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)8 Address (org.mifos.framework.business.util.Address)8 ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)7 OfficeBO (org.mifos.customers.office.business.OfficeBO)7 AddressDto (org.mifos.dto.domain.AddressDto)7 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)7 DateTime (org.joda.time.DateTime)6 MeetingBO (org.mifos.application.meeting.business.MeetingBO)6 UserContext (org.mifos.security.util.UserContext)6 InputStream (java.io.InputStream)5 ClientCreationDetail (org.mifos.dto.domain.ClientCreationDetail)5 MeetingDto (org.mifos.dto.domain.MeetingDto)5