Search in sources :

Example 56 with ClientBO

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

the class LoanAccountServiceFacadeWebTier method retrieveMultipleLoanAccountDetails.

@Override
public MultipleLoanAccountDetailsDto retrieveMultipleLoanAccountDetails(String searchId, Short branchId, Integer productId) {
    List<ClientBO> clients = this.customerDao.findActiveClientsUnderParent(searchId, branchId);
    if (clients.isEmpty()) {
        throw new BusinessRuleException(LoanConstants.NOSEARCHRESULTS);
    }
    LoanOfferingBO loanOffering = this.loanProductDao.findById(productId);
    // FIXME - Refactor MultipleLoanCreationDto into proper Dto
    List<MultipleLoanCreationDto> multipleLoanDetails = buildClientViewHelper(loanOffering, clients);
    List<ValueListElement> allLoanPruposes = this.loanProductDao.findAllLoanPurposes();
    boolean loanPendingApprovalStateEnabled = ProcessFlowRules.isLoanPendingApprovalStateEnabled();
    return new MultipleLoanAccountDetailsDto(allLoanPruposes, loanPendingApprovalStateEnabled);
}
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) ValueListElement(org.mifos.dto.domain.ValueListElement)

Example 57 with ClientBO

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

the class CustomerServiceImpl method updateCustomerStatus.

@Override
public final void updateCustomerStatus(UserContext userContext, CustomerStatusUpdate customerStatusUpdate) throws CustomerException {
    CustomerBO customer = this.customerDao.findCustomerById(customerStatusUpdate.getCustomerId());
    customer.validateVersion(customerStatusUpdate.getVersionNum());
    customer.updateDetails(userContext);
    checkPermission(customer, userContext, customerStatusUpdate.getNewStatus(), customerStatusUpdate.getCustomerStatusFlag());
    Short oldStatusId = customer.getCustomerStatus().getId();
    CustomerStatus oldStatus = CustomerStatus.fromInt(oldStatusId);
    PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
    CustomerNoteEntity customerNote = new CustomerNoteEntity(customerStatusUpdate.getNotes(), new Date(), loggedInUser, customer);
    if (customer.isGroup()) {
        GroupBO group = (GroupBO) customer;
        updateGroupStatus(group, oldStatus, customerStatusUpdate.getNewStatus(), customerStatusUpdate.getCustomerStatusFlag(), customerNote);
    } else if (customer.isClient()) {
        ClientBO client = (ClientBO) customer;
        updateClientStatus(client, oldStatus, customerStatusUpdate.getNewStatus(), customerStatusUpdate.getCustomerStatusFlag(), customerNote);
    } else {
        CenterBO center = (CenterBO) customer;
        updateCenterStatus(center, customerStatusUpdate.getNewStatus(), customerStatusUpdate.getCustomerStatusFlag(), customerNote);
    }
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CustomerStatus(org.mifos.customers.util.helpers.CustomerStatus) ClientBO(org.mifos.customers.client.business.ClientBO) CustomerBO(org.mifos.customers.business.CustomerBO) GroupBO(org.mifos.customers.group.business.GroupBO) CenterBO(org.mifos.customers.center.business.CenterBO) Date(java.util.Date) LocalDate(org.joda.time.LocalDate)

Example 58 with ClientBO

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

the class CustomerServiceImpl method updateClientMfiInfo.

@Override
public final void updateClientMfiInfo(UserContext userContext, ClientMfiInfoUpdate clientMfiInfoUpdate) throws CustomerException {
    ClientBO client = (ClientBO) this.customerDao.findCustomerById(clientMfiInfoUpdate.getClientId());
    client.validateVersion(clientMfiInfoUpdate.getOrginalClientVersionNumber());
    client.updateDetails(userContext);
    try {
        hibernateTransactionHelper.startTransaction();
        hibernateTransactionHelper.beginAuditLoggingFor(client);
        PersonnelBO personnel = this.personnelDao.findPersonnelById(clientMfiInfoUpdate.getPersonnelId());
        client.updateMfiInfo(personnel, clientMfiInfoUpdate);
        customerDao.save(client);
        hibernateTransactionHelper.commitTransaction();
    } catch (CustomerException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw e;
    } catch (Exception e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ClientBO(org.mifos.customers.client.business.ClientBO) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) BusinessRuleException(org.mifos.service.BusinessRuleException) CustomerException(org.mifos.customers.exceptions.CustomerException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountException(org.mifos.accounts.exceptions.AccountException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 59 with ClientBO

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

the class CustomerServiceImpl method transferGroupTo.

@Override
public final String transferGroupTo(GroupBO group, OfficeBO transferToOffice) throws CustomerException {
    group.validateNewOffice(transferToOffice);
    group.validateNoActiveAccountsExist();
    customerDao.validateGroupNameIsNotTakenForOffice(group.getDisplayName(), transferToOffice.getOfficeId());
    try {
        hibernateTransactionHelper.startTransaction();
        hibernateTransactionHelper.beginAuditLoggingFor(group);
        group.makeCustomerMovementEntries(transferToOffice);
        group.setPersonnel(null);
        if (group.isActive()) {
            group.setCustomerStatus(new CustomerStatusEntity(CustomerStatus.GROUP_HOLD));
        }
        CustomerBO oldParentOfGroup = group.getParentCustomer();
        if (oldParentOfGroup != null) {
            oldParentOfGroup.incrementChildCount();
            customerDao.save(oldParentOfGroup);
        }
        this.hibernateTransactionHelper.flushSession();
        group.generateSearchId();
        group.setUpdateDetails();
        customerDao.save(group);
        Set<CustomerBO> clients = group.getChildren();
        if (clients != null) {
            for (CustomerBO client : clients) {
                client.setUserContext(group.getUserContext());
                ((ClientBO) client).handleGroupTransfer();
                client.setUpdateDetails();
                customerDao.save(client);
            }
        }
        hibernateTransactionHelper.commitTransaction();
        return group.getGlobalCustNum();
    } catch (Exception e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : ClientBO(org.mifos.customers.client.business.ClientBO) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) BusinessRuleException(org.mifos.service.BusinessRuleException) CustomerException(org.mifos.customers.exceptions.CustomerException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountException(org.mifos.accounts.exceptions.AccountException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 60 with ClientBO

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

the class CustomerServiceImpl method updateClientFamilyInfo.

@Override
public void updateClientFamilyInfo(UserContext userContext, ClientFamilyInfoUpdate clientFamilyInfoUpdate) throws CustomerException {
    ClientBO client = (ClientBO) this.customerDao.findCustomerById(clientFamilyInfoUpdate.getCustomerId());
    client.validateVersion(clientFamilyInfoUpdate.getOldVersionNum());
    client.updateDetails(userContext);
    try {
        hibernateTransactionHelper.startTransaction();
        hibernateTransactionHelper.beginAuditLoggingFor(client);
        client.updateFamilyInfo(clientFamilyInfoUpdate);
        customerDao.save(client);
        hibernateTransactionHelper.commitTransaction();
    } catch (Exception e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : ClientBO(org.mifos.customers.client.business.ClientBO) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) BusinessRuleException(org.mifos.service.BusinessRuleException) CustomerException(org.mifos.customers.exceptions.CustomerException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountException(org.mifos.accounts.exceptions.AccountException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

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