Search in sources :

Example 36 with CustomerException

use of org.mifos.customers.exceptions.CustomerException 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 37 with CustomerException

use of org.mifos.customers.exceptions.CustomerException in project head by mifos.

the class ClientServiceFacadeWebTier method updateFamilyInfo.

@Override
public void updateFamilyInfo(ClientFamilyInfoUpdate clientFamilyInfoUpdate) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    try {
        this.customerService.updateClientFamilyInfo(userContext, clientFamilyInfoUpdate);
    } catch (CustomerException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) BusinessRuleException(org.mifos.service.BusinessRuleException) UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser)

Example 38 with CustomerException

use of org.mifos.customers.exceptions.CustomerException in project head by mifos.

the class ClientServiceFacadeWebTier method retreiveClientDetailsForRemovalFromGroup.

@Override
public ClientRemovalFromGroupDto retreiveClientDetailsForRemovalFromGroup(String globalCustNum) {
    try {
        MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        UserContext userContext = toUserContext(user);
        ClientBO client = this.customerDao.findClientBySystemId(globalCustNum);
        client.updateDetails(userContext);
        client.checkIfClientIsATitleHolder();
        List<OfficeDetailsDto> activeBranches = this.officeDao.findActiveBranches(userContext.getBranchId());
        boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
        boolean isActive = client.isActive();
        Short loanOfficerId = client.getPersonnel().getPersonnelId();
        CenterCreation clientDetails = new CenterCreation(client.getOfficeId(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
        List<PersonnelDto> loanOfficers = this.personnelDao.findActiveLoanOfficersForOffice(clientDetails);
        return new ClientRemovalFromGroupDto(client.getGlobalCustNum(), isActive, isCenterHierarchyExists, loanOfficerId, loanOfficers, activeBranches);
    } catch (CustomerException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : ClientRemovalFromGroupDto(org.mifos.dto.screen.ClientRemovalFromGroupDto) CustomerException(org.mifos.customers.exceptions.CustomerException) UserContext(org.mifos.security.util.UserContext) ClientBO(org.mifos.customers.client.business.ClientBO) PersonnelDto(org.mifos.dto.domain.PersonnelDto) MifosUser(org.mifos.security.MifosUser) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) BusinessRuleException(org.mifos.service.BusinessRuleException) CenterCreation(org.mifos.dto.domain.CenterCreation)

Example 39 with CustomerException

use of org.mifos.customers.exceptions.CustomerException in project head by mifos.

the class ClientBO method createDepositSchedule.

/**
     * delete when usage in constructor is removed...
     */
@Deprecated
public void createDepositSchedule(final List<Days> workingDays, final List<Holiday> holidays) throws CustomerException {
    try {
        if (getParentCustomer() != null) {
            List<SavingsBO> savingsList = getCustomerPersistence().retrieveSavingsAccountForCustomer(getParentCustomer().getCustomerId());
            if (getParentCustomer().getParentCustomer() != null) {
                savingsList.addAll(getCustomerPersistence().retrieveSavingsAccountForCustomer(getParentCustomer().getParentCustomer().getCustomerId()));
            }
            for (SavingsBO savings : savingsList) {
                savings.setUserContext(getUserContext());
                savings.generateAndUpdateDepositActionsForClient(this, workingDays, holidays);
            }
        }
    } catch (PersistenceException pe) {
        throw new CustomerException(pe);
    } catch (AccountException ae) {
        throw new CustomerException(ae);
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) AccountException(org.mifos.accounts.exceptions.AccountException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) SavingsBO(org.mifos.accounts.savings.business.SavingsBO)

Example 40 with CustomerException

use of org.mifos.customers.exceptions.CustomerException in project head by mifos.

the class ClientBO method updatePersonalInfo.

public void updatePersonalInfo(ClientPersonalInfoUpdate personalInfo) throws CustomerException {
    this.governmentId = personalInfo.getGovernmentId();
    try {
        setDateOfBirth(DateUtils.getDateAsSentFromBrowser(personalInfo.getDateOfBirth()));
    } catch (InvalidDateException e) {
        throw new CustomerException(ClientConstants.INVALID_DOB_EXCEPTION);
    }
    ClientNameDetailDto clientName = personalInfo.getClientNameDetails();
    this.getClientName().updateNameDetails(clientName);
    this.firstName = clientName.getFirstName();
    this.lastName = clientName.getLastName();
    this.secondLastName = clientName.getSecondLastName();
    if (personalInfo.getSpouseFather() != null) {
        // can be null when family details configuration is turned on
        if (this.getSpouseName() != null) {
            this.getSpouseName().updateNameDetails(personalInfo.getSpouseFather());
        } else {
            ClientNameDetailEntity spouseFatherNameDetailEntity = new ClientNameDetailEntity(this, personalInfo.getSpouseFather().getSecondLastName(), personalInfo.getSpouseFather());
            addNameDetailSet(spouseFatherNameDetailEntity);
        }
    }
    this.updateClientDetails(personalInfo.getClientDetail());
    setDisplayName(personalInfo.getClientDisplayName());
    Address address = null;
    if (personalInfo.getAddress() != null) {
        ;
    }
    {
        address = new Address(personalInfo.getAddress().getLine1(), personalInfo.getAddress().getLine2(), personalInfo.getAddress().getLine3(), personalInfo.getAddress().getCity(), personalInfo.getAddress().getState(), personalInfo.getAddress().getCountry(), personalInfo.getAddress().getZip(), personalInfo.getAddress().getPhoneNumber());
        updateAddress(address);
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) Address(org.mifos.framework.business.util.Address) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto)

Aggregations

CustomerException (org.mifos.customers.exceptions.CustomerException)103 Test (org.junit.Test)52 UserContext (org.mifos.security.util.UserContext)29 ClientBO (org.mifos.customers.client.business.ClientBO)23 GroupBuilder (org.mifos.domain.builders.GroupBuilder)21 PersistenceException (org.mifos.framework.exceptions.PersistenceException)21 BusinessRuleException (org.mifos.service.BusinessRuleException)21 CenterBO (org.mifos.customers.center.business.CenterBO)20 GroupBO (org.mifos.customers.group.business.GroupBO)20 AccountException (org.mifos.accounts.exceptions.AccountException)18 CenterBuilder (org.mifos.domain.builders.CenterBuilder)18 ArrayList (java.util.ArrayList)17 MifosRuntimeException (org.mifos.core.MifosRuntimeException)14 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)13 ClientNameDetailDto (org.mifos.dto.screen.ClientNameDetailDto)13 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)12 MeetingBO (org.mifos.application.meeting.business.MeetingBO)12 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)12 MifosUser (org.mifos.security.MifosUser)11 DateTime (org.joda.time.DateTime)10