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();
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations