use of org.mifos.dto.domain.CustomerDto in project head by mifos.
the class CollectionSheetServiceFacadeWebTier method loadAllActiveBranchesAndSubsequentDataIfApplicable.
@Override
public CollectionSheetEntryFormDto loadAllActiveBranchesAndSubsequentDataIfApplicable(final UserContext userContext) {
final Short branchId = userContext.getBranchId();
final Short centerHierarchyExists = ClientRules.getCenterHierarchyExists() ? Constants.YES : Constants.NO;
List<OfficeDetailsDto> activeBranches = new ArrayList<OfficeDetailsDto>();
List<ListItem<Short>> paymentTypesDtoList = new ArrayList<ListItem<Short>>();
List<CustomerDto> customerList = new ArrayList<CustomerDto>();
List<PersonnelDto> loanOfficerList = new ArrayList<PersonnelDto>();
Short reloadFormAutomatically = Constants.YES;
final Short backDatedTransactionAllowed = Constants.NO;
try {
final List<PaymentTypeEntity> paymentTypesList = legacyMasterDao.findMasterDataEntitiesWithLocale(PaymentTypeEntity.class);
paymentTypesDtoList = convertToPaymentTypesListItemDto(paymentTypesList);
activeBranches = officePersistence.getActiveOffices(branchId);
if (activeBranches.size() == 1) {
loanOfficerList = legacyPersonnelDao.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId());
if (loanOfficerList.size() == 1) {
Short customerLevel;
if (centerHierarchyExists.equals(Constants.YES)) {
customerLevel = Short.valueOf(CustomerLevel.CENTER.getValue());
} else {
customerLevel = Short.valueOf(CustomerLevel.GROUP.getValue());
}
customerList = customerPersistence.getActiveParentList(loanOfficerList.get(0).getPersonnelId(), customerLevel, branchId);
if (customerList.size() == 1) {
reloadFormAutomatically = Constants.YES;
}
reloadFormAutomatically = Constants.NO;
}
}
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
return new CollectionSheetEntryFormDto(activeBranches, paymentTypesDtoList, loanOfficerList, customerList, reloadFormAutomatically, centerHierarchyExists, backDatedTransactionAllowed);
}
use of org.mifos.dto.domain.CustomerDto in project head by mifos.
the class CustomerServiceImpl method updateCenterStatus.
@Override
public final void updateCenterStatus(CenterBO center, CustomerStatus newStatus, CustomerStatusFlag customerStatusFlag, CustomerNoteEntity customerNote) throws CustomerException {
if (newStatus.isCenterInActive()) {
center.validateChangeToInActive();
List<CustomerDto> clientsThatAreNotClosedOrCanceled = this.customerDao.findClientsThatAreNotCancelledOrClosed(center.getSearchId(), center.getOffice().getOfficeId());
List<CustomerDto> groupsThatAreNotClosedOrCancelled = this.customerDao.findGroupsThatAreNotCancelledOrClosed(center.getSearchId(), center.getOffice().getOfficeId());
if (clientsThatAreNotClosedOrCanceled.size() > 0 || groupsThatAreNotClosedOrCancelled.size() > 0) {
final String errorMessage = messageLookupHelper.lookupLabel(ConfigurationConstants.GROUP);
throw new CustomerException(CustomerConstants.ERROR_STATE_CHANGE_EXCEPTION, new Object[] { errorMessage });
}
} else if (newStatus.isCenterActive()) {
center.validateChangeToActive();
center.validateLoanOfficerIsActive();
}
CustomerStatusFlagEntity customerStatusFlagEntity = populateCustomerStatusFlag(customerStatusFlag);
try {
hibernateTransactionHelper.startTransaction();
hibernateTransactionHelper.beginAuditLoggingFor(center);
center.updateCustomerStatus(newStatus, customerNote, customerStatusFlagEntity);
customerDao.save(center);
hibernateTransactionHelper.commitTransaction();
} catch (Exception e) {
this.hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
this.hibernateTransactionHelper.closeSession();
}
}
use of org.mifos.dto.domain.CustomerDto 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.dto.domain.CustomerDto 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;
}
use of org.mifos.dto.domain.CustomerDto in project head by mifos.
the class WebTierAccountServiceFacade method getActiveSavingsAccountsForClientByLoanId.
@Override
public List<SavingsDetailDto> getActiveSavingsAccountsForClientByLoanId(Integer loanAccountId) {
try {
AccountBO account = accountBusinessService.getAccount(loanAccountId);
CustomerDto customer = account.getCustomer().toCustomerDto();
List<SavingsDetailDto> savingsInUse = clientServiceFacade.retrieveSavingsInUseForClient(customer.getCustomerId());
List<SavingsDetailDto> accountsForTransfer = new ArrayList<SavingsDetailDto>();
if (savingsInUse != null) {
for (SavingsDetailDto savingsAccount : savingsInUse) {
if (savingsAccount.getAccountStateId().equals(AccountState.SAVINGS_ACTIVE.getValue())) {
accountsForTransfer.add(savingsAccount);
}
}
}
return accountsForTransfer;
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
}
}
Aggregations