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