Search in sources :

Example 61 with CustomerBO

use of org.mifos.customers.business.CustomerBO in project head by mifos.

the class CustomerServiceImpl method updateCenter.

@Override
public final void updateCenter(UserContext userContext, CenterUpdate centerUpdate) throws ApplicationException {
    CustomerBO center = customerDao.findCustomerById(centerUpdate.getCustomerId());
    center.validateVersion(centerUpdate.getVersionNum());
    center.setUserContext(userContext);
    if (!centerUpdate.getDisplayName().equals(center.getDisplayName())) {
        customerDao.validateCenterNameIsNotTakenForOffice(centerUpdate.getDisplayName(), center.getOfficeId());
    }
    assembleCustomerPostionsFromDto(centerUpdate.getCustomerPositions(), center);
    try {
        hibernateTransactionHelper.startTransaction();
        hibernateTransactionHelper.beginAuditLoggingFor(center);
        center.setDisplayName(centerUpdate.getDisplayName());
        updateLoanOfficerAndValidate(centerUpdate.getLoanOfficerId(), center);
        center.updateCenterDetails(userContext, centerUpdate);
        customerDao.save(center);
        hibernateTransactionHelper.commitTransaction();
    } catch (ApplicationException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw e;
    } catch (Exception e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerBO(org.mifos.customers.business.CustomerBO) 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 62 with CustomerBO

use of org.mifos.customers.business.CustomerBO in project head by mifos.

the class CustomerDaoHibernate method findCustomersThatAreNotClosedOrCanceled.

@SuppressWarnings("unchecked")
private List<CustomerDto> findCustomersThatAreNotClosedOrCanceled(Map<String, Object> queryParameters) {
    List<CustomerBO> queryResult = (List<CustomerBO>) genericDao.executeNamedQuery(NamedQueryConstants.GET_CHILDREN_OTHER_THAN_CLOSED_AND_CANCELLED, queryParameters);
    List<CustomerDto> customerDtos = new ArrayList<CustomerDto>();
    for (CustomerBO customerBO : queryResult) {
        CustomerDto customerDto = new CustomerDto(customerBO.getCustomerId(), customerBO.getDisplayName(), customerBO.getCustomerLevel().getId(), customerBO.getSearchId());
        customerDtos.add(customerDto);
    }
    return customerDtos;
}
Also used : ArrayList(java.util.ArrayList) CustomerDto(org.mifos.dto.domain.CustomerDto) CustomerBO(org.mifos.customers.business.CustomerBO) ArrayList(java.util.ArrayList) List(java.util.List)

Example 63 with CustomerBO

use of org.mifos.customers.business.CustomerBO in project head by mifos.

the class GroupBO method isSameCenter.

private boolean isSameCenter(final CenterBO center) {
    boolean isSame = false;
    CustomerBO parent = getParentCustomer();
    if (parent != null) {
        return parent.hasSameIdentityAs(center);
    }
    return isSame;
}
Also used : CustomerBO(org.mifos.customers.business.CustomerBO)

Example 64 with CustomerBO

use of org.mifos.customers.business.CustomerBO in project head by mifos.

the class GroupPerformanceHistoryEntity method getTotalOutStandingLoanAmount.

public Money getTotalOutStandingLoanAmount() throws CustomerException {
    Money amount = group.getOutstandingLoanAmount(getCurrency());
    List<CustomerBO> clients = getChildren();
    if (clients != null) {
        for (CustomerBO client : clients) {
            Money outstandingLoanAmount = client.getOutstandingLoanAmount(getCurrency());
            if (amount.getAmount().equals(BigDecimal.ZERO)) {
                amount = outstandingLoanAmount;
            } else {
                amount = amount.add(outstandingLoanAmount);
            }
        }
    }
    return amount;
}
Also used : Money(org.mifos.framework.util.helpers.Money) CustomerBO(org.mifos.customers.business.CustomerBO)

Example 65 with CustomerBO

use of org.mifos.customers.business.CustomerBO in project head by mifos.

the class CustomerDaoHibernate method findCustomersWithGivenPhoneNumber.

@SuppressWarnings("unchecked")
@Override
public List<CustomerDto> findCustomersWithGivenPhoneNumber(String phoneNumber) {
    Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("phoneNumberStripped", MifosStringUtils.removeNondigits(phoneNumber));
    List<CustomerBO> queryResult = (List<CustomerBO>) genericDao.executeNamedQuery("Customer.findCustomersWithGivenPhoneNumber", queryParameters);
    List<CustomerDto> customerDtos = new ArrayList<CustomerDto>();
    for (CustomerBO customerBO : queryResult) {
        CustomerDto customerDto = new CustomerDto(customerBO.getCustomerId(), customerBO.getDisplayName(), customerBO.getCustomerLevel().getId(), customerBO.getSearchId());
        customerDtos.add(customerDto);
    }
    return customerDtos;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CustomerDto(org.mifos.dto.domain.CustomerDto) CustomerBO(org.mifos.customers.business.CustomerBO) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

CustomerBO (org.mifos.customers.business.CustomerBO)138 ArrayList (java.util.ArrayList)39 Money (org.mifos.framework.util.helpers.Money)38 MifosUser (org.mifos.security.MifosUser)38 UserContext (org.mifos.security.util.UserContext)37 LocalDate (org.joda.time.LocalDate)35 MifosRuntimeException (org.mifos.core.MifosRuntimeException)31 AccountException (org.mifos.accounts.exceptions.AccountException)30 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)27 BusinessRuleException (org.mifos.service.BusinessRuleException)27 MeetingBO (org.mifos.application.meeting.business.MeetingBO)23 ClientBO (org.mifos.customers.client.business.ClientBO)23 PersistenceException (org.mifos.framework.exceptions.PersistenceException)22 DateTime (org.joda.time.DateTime)20 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)20 Date (java.util.Date)19 Test (org.junit.Test)19 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)18 LoanBO (org.mifos.accounts.loan.business.LoanBO)17 HashMap (java.util.HashMap)15