Search in sources :

Example 1 with CustomerDto

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);
}
Also used : ArrayList(java.util.ArrayList) CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) PaymentTypeEntity(org.mifos.application.master.business.PaymentTypeEntity) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with CustomerDto

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();
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) CustomerDto(org.mifos.dto.domain.CustomerDto) CustomerStatusFlagEntity(org.mifos.customers.business.CustomerStatusFlagEntity) 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 3 with CustomerDto

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;
}
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 4 with CustomerDto

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

Example 5 with CustomerDto

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);
    }
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) ServiceException(org.mifos.framework.exceptions.ServiceException) CustomerDto(org.mifos.dto.domain.CustomerDto) ArrayList(java.util.ArrayList) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

CustomerDto (org.mifos.dto.domain.CustomerDto)38 ArrayList (java.util.ArrayList)15 PersonnelDto (org.mifos.dto.domain.PersonnelDto)12 Test (org.junit.Test)11 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)10 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 UserReferenceDto (org.mifos.dto.domain.UserReferenceDto)7 DateTime (org.joda.time.DateTime)6 CustomerBO (org.mifos.customers.business.CustomerBO)6 AccountPaymentParametersDto (org.mifos.dto.domain.AccountPaymentParametersDto)6 AccountReferenceDto (org.mifos.dto.domain.AccountReferenceDto)6 MifosUser (org.mifos.security.MifosUser)6 UserContext (org.mifos.security.util.UserContext)6 Date (java.util.Date)5 LocalDate (org.joda.time.LocalDate)5 Money (org.mifos.framework.util.helpers.Money)5 HashMap (java.util.HashMap)4 LoanBO (org.mifos.accounts.loan.business.LoanBO)4 PaymentTypeDto (org.mifos.dto.domain.PaymentTypeDto)4 BigDecimal (java.math.BigDecimal)3