Search in sources :

Example 21 with CustomerDto

use of org.mifos.dto.domain.CustomerDto in project head by mifos.

the class CollectionSheetServiceFacadeWebTier method loadCustomersForBranchAndLoanOfficer.

@Override
public CollectionSheetEntryFormDto loadCustomersForBranchAndLoanOfficer(final Short personnelId, final Short officeId, final CollectionSheetEntryFormDto formDto) {
    Short customerLevel;
    if (formDto.getCenterHierarchyExists().equals(Constants.YES)) {
        customerLevel = Short.valueOf(CustomerLevel.CENTER.getValue());
    } else {
        customerLevel = Short.valueOf(CustomerLevel.GROUP.getValue());
    }
    List<CustomerDto> customerList = new ArrayList<CustomerDto>();
    try {
        customerList = customerPersistence.getActiveParentList(personnelId, customerLevel, officeId);
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
    return new CollectionSheetEntryFormDto(formDto.getActiveBranchesList(), formDto.getPaymentTypesList(), formDto.getLoanOfficerList(), customerList, formDto.getReloadFormAutomatically(), formDto.getCenterHierarchyExists(), formDto.getBackDatedTransactionAllowed());
}
Also used : ArrayList(java.util.ArrayList) CustomerDto(org.mifos.dto.domain.CustomerDto) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 22 with CustomerDto

use of org.mifos.dto.domain.CustomerDto in project head by mifos.

the class ProductDtoComparator method createEntryViewHierarchyFromCollectionSheetData.

private CollectionSheetEntryDto createEntryViewHierarchyFromCollectionSheetData(final List<CollectionSheetCustomerDto> collectionSheetCustomerHierarchy, final MifosCurrency currency) {
    final int countOfCustomers = collectionSheetCustomerHierarchy.size();
    CollectionSheetEntryDto parentView = null;
    for (CollectionSheetCustomerDto customer : collectionSheetCustomerHierarchy) {
        final CustomerDto parentCustomerDetail = new CustomerDto(customer.getCustomerId(), customer.getName(), customer.getParentCustomerId(), customer.getLevelId());
        CollectionSheetEntryDto childView = new CollectionSheetEntryDto(parentCustomerDetail, currency);
        childView.setAttendence(customer.getAttendanceId());
        childView.setCountOfCustomers(countOfCustomers);
        final Integer accountId = customer.getCollectionSheetCustomerAccount().getAccountId();
        final Integer customerId = customer.getCustomerId();
        final Short installmentId = null;
        final Integer actionDateId = null;
        final Date actionDate = null;
        final Money miscFee = new Money(currency, customer.getCollectionSheetCustomerAccount().getTotalCustomerAccountCollectionFee().toString());
        final Money miscFeePaid = new Money(currency, "0.0");
        final Money miscPenalty = new Money(currency, "0.0");
        final Money miscPenaltyPaid = new Money(currency, "0.0");
        final CustomerAccountDto customerAccountDetails = new CustomerAccountDto(customer.getCollectionSheetCustomerAccount().getAccountId(), customer.getCustomerId(), currency);
        customerAccountDetails.setAccountId(customer.getCollectionSheetCustomerAccount().getAccountId());
        // we only create one installment fee and set the total amount due
        // in the miscFee column for now
        final CollectionSheetEntryInstallmentDto installmentView = new CollectionSheetEntryCustomerAccountInstallmentDto(accountId, customerId, installmentId, actionDateId, actionDate, miscFee, miscFeePaid, miscPenalty, miscPenaltyPaid, currency);
        final List<CollectionSheetEntryInstallmentDto> installmentViewList = java.util.Arrays.asList(installmentView);
        customerAccountDetails.setAccountActionDates(installmentViewList);
        childView.setCustomerAccountDetails(customerAccountDetails);
        // saving accounts
        for (CollectionSheetCustomerSavingDto customerSavingDto : customer.getCollectionSheetCustomerSaving()) {
            final Integer savCustomerId = customerSavingDto.getCustomerId();
            final Integer savAccountId = customerSavingDto.getAccountId();
            final String savingProductShortName = customerSavingDto.getProductShortName();
            final Short savOfferingId = customerSavingDto.getProductId();
            final Short savingsTypeId = Short.valueOf("1");
            final Short recommendedAmntUnitId = customerSavingDto.getRecommendedAmountUnitId();
            final SavingsAccountDto savingsAccount = new SavingsAccountDto(savAccountId, savCustomerId, savingProductShortName, savOfferingId, savingsTypeId, recommendedAmntUnitId);
            final Short savInstallmentId = null;
            final Integer savActionDateId = null;
            final Date savActionDate = null;
            final Money savDeposit = new Money(currency, customerSavingDto.getTotalDepositAmount().toString());
            final Money savDepositPaid = new Money(currency, "0.0");
            final CollectionSheetEntryInstallmentDto accountTrxnDetail = new CollectionSheetEntrySavingsInstallmentDto(savAccountId, savCustomerId, savInstallmentId, savActionDateId, savActionDate, savDeposit, savDepositPaid);
            savingsAccount.addAccountTrxnDetail(accountTrxnDetail);
            childView.addSavingsAccountDetail(savingsAccount);
        }
        // special savings accounts to be paid individually by clients
        for (CollectionSheetCustomerSavingDto clientIndividualSavingsAccount : customer.getIndividualSavingAccounts()) {
            final Integer savCustomerId = clientIndividualSavingsAccount.getCustomerId();
            final Integer savAccountId = clientIndividualSavingsAccount.getAccountId();
            final String savingProductShortName = clientIndividualSavingsAccount.getProductShortName();
            final Short savOfferingId = clientIndividualSavingsAccount.getProductId();
            final Short savingsTypeId = Short.valueOf("1");
            final Short recommendedAmntUnitId = Short.valueOf("1");
            final SavingsAccountDto savingsAccount = new SavingsAccountDto(savAccountId, savCustomerId, savingProductShortName, savOfferingId, savingsTypeId, recommendedAmntUnitId);
            final Short savInstallmentId = null;
            final Integer savActionDateId = null;
            final Date savActionDate = null;
            final Money savDeposit = new Money(currency, clientIndividualSavingsAccount.getDepositDue().toString());
            final Money savDepositPaid = new Money(currency, clientIndividualSavingsAccount.getDepositPaid().toString());
            final CollectionSheetEntryInstallmentDto accountTrxnDetail = new CollectionSheetEntrySavingsInstallmentDto(savAccountId, savCustomerId, savInstallmentId, savActionDateId, savActionDate, savDeposit, savDepositPaid);
            savingsAccount.addAccountTrxnDetail(accountTrxnDetail);
            childView.addSavingsAccountDetail(savingsAccount);
        }
        // loan accounts
        for (CollectionSheetCustomerLoanDto customerLoanDto : customer.getCollectionSheetCustomerLoan()) {
            final Integer loanAccountId = customerLoanDto.getAccountId();
            final Integer loanCustomerId = customerLoanDto.getCustomerId();
            final String loanOfferingShortName = customerLoanDto.getProductShortName();
            final Short loanOfferingId = customerLoanDto.getProductId();
            final Short loanInstallmentId = null;
            final Integer loanActionDateId = null;
            final Date loanActionDate = null;
            final Short loanAccountState = customerLoanDto.getAccountStateId();
            final Short interestDeductedAtDisbursement = customerLoanDto.getPayInterestAtDisbursement();
            final Money loanAmount = new Money(currency, customerLoanDto.getTotalDisbursement().toString());
            final Money principal = new Money(currency, customerLoanDto.getTotalRepaymentDue().toString());
            final LoanAccountDto loanAccount = new LoanAccountDto(loanAccountId, loanCustomerId, loanOfferingShortName, loanOfferingId, loanAccountState, interestDeductedAtDisbursement, loanAmount);
            loanAccount.setAmountPaidAtDisbursement(customerLoanDto.getAmountDueAtDisbursement());
            final CollectionSheetEntryInstallmentDto accountTrxnDetail = new CollectionSheetEntryLoanInstallmentDto(loanAccountId, loanCustomerId, loanInstallmentId, loanActionDateId, loanActionDate, principal, new Money(currency), new Money(currency), new Money(currency), new Money(currency), new Money(currency), new Money(currency), new Money(currency), new Money(currency), new Money(currency), currency);
            loanAccount.addTrxnDetails(Arrays.asList(accountTrxnDetail));
            childView.addLoanAccountDetails(loanAccount);
        }
        // center-group-client hierarchy
        if (parentView == null) {
            parentView = childView;
        } else {
            addChildToAppropriateParent(parentView, childView);
        }
    }
    return parentView;
}
Also used : CollectionSheetEntryLoanInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryLoanInstallmentDto) CustomerAccountDto(org.mifos.customers.util.helpers.CustomerAccountDto) CustomerDto(org.mifos.dto.domain.CustomerDto) LoanAccountDto(org.mifos.accounts.loan.util.helpers.LoanAccountDto) Date(java.util.Date) SavingsAccountDto(org.mifos.accounts.savings.util.helpers.SavingsAccountDto) Money(org.mifos.framework.util.helpers.Money) CollectionSheetEntrySavingsInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntrySavingsInstallmentDto) CollectionSheetEntryDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryDto) CollectionSheetEntryCustomerAccountInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryCustomerAccountInstallmentDto) CollectionSheetEntryInstallmentDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryInstallmentDto)

Example 23 with CustomerDto

use of org.mifos.dto.domain.CustomerDto in project head by mifos.

the class StandardAccountServiceIntegrationTest method testMakePaymentForLoanAccount.

@Test
public void testMakePaymentForLoanAccount() throws Exception {
    String payemntAmount = "700";
    CustomerDto clientDto = new CustomerDto();
    clientDto.setCustomerId(client.getCustomerId());
    LocalDate paymentDate = new LocalDate();
    LocalDate receiptDate = new LocalDate().minusDays(3);
    String receiptNumber = "AA/03/UX-9Q";
    AccountPaymentParametersDto loanPayment = new AccountPaymentParametersDto(new UserReferenceDto(groupLoan.getPersonnel().getPersonnelId()), new AccountReferenceDto(groupLoan.getAccountId()), new BigDecimal(payemntAmount), paymentDate, defaultPaymentType, "comment", receiptDate, receiptNumber, clientDto);
    standardAccountService.makePayment(loanPayment);
    TestObjectFactory.updateObject(groupLoan);
    Assert.assertEquals("The amount returned for the payment should have been " + payemntAmount, Double.parseDouble(payemntAmount), groupLoan.getLastPmntAmnt());
    Assert.assertEquals(1, groupLoan.getAccountPayments().size());
    for (AccountPaymentEntity payment : groupLoan.getAccountPayments()) {
        Assert.assertEquals(TestUtils.createMoney(payemntAmount), payment.getAmount());
        Assert.assertEquals(paymentDate.toDateMidnight().toDate(), payment.getPaymentDate());
        Assert.assertEquals(defaultPaymentType.getName(), payment.getPaymentType().getName());
        Assert.assertEquals("comment", payment.getComment());
        Assert.assertEquals(groupLoan, payment.getAccount());
        Assert.assertEquals(groupLoan.getPersonnel(), payment.getCreatedByUser());
        Assert.assertEquals(receiptDate.toDateMidnight().toDate(), payment.getReceiptDate());
        Assert.assertEquals(receiptNumber, payment.getReceiptNumber());
        Assert.assertNull(payment.getCheckNumber());
        Assert.assertNull(payment.getBankName());
        Assert.assertNull(payment.getVoucherNumber());
        Assert.assertFalse(payment.isSavingsDeposit());
        Assert.assertFalse(payment.isSavingsWithdrawal());
        Assert.assertFalse(payment.isSavingsDepositOrWithdrawal());
        for (AccountTrxnEntity accountTrxn : payment.getAccountTrxns()) {
            Assert.assertEquals(group.getCustomerId(), accountTrxn.getCustomer().getCustomerId());
        }
    }
}
Also used : UserReferenceDto(org.mifos.dto.domain.UserReferenceDto) AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) AccountReferenceDto(org.mifos.dto.domain.AccountReferenceDto) CustomerDto(org.mifos.dto.domain.CustomerDto) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) AccountPaymentParametersDto(org.mifos.dto.domain.AccountPaymentParametersDto) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 24 with CustomerDto

use of org.mifos.dto.domain.CustomerDto in project head by mifos.

the class CenterServiceFacadeWebTier method retrieveCenterDetailsForUpdate.

@Override
public CenterDto retrieveCenterDetailsForUpdate(Integer centerId) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    CustomerBO center = customerDao.findCustomerById(centerId);
    Short officeId = center.getOffice().getOfficeId();
    String searchId = center.getSearchId();
    Short loanOfficerId = extractLoanOfficerId(center);
    CenterCreation centerCreation = new CenterCreation(officeId, userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
    List<PersonnelDto> activeLoanOfficersForBranch = personnelDao.findActiveLoanOfficersForOffice(centerCreation);
    List<CustomerDto> customerList = customerDao.findClientsThatAreNotCancelledOrClosed(searchId, officeId);
    List<CustomerPositionDto> customerPositionDtos = generateCustomerPositionViews(center, userContext.getLocaleId());
    DateTime mfiJoiningDate = new DateTime();
    String mfiJoiningDateAsString = "";
    if (center.getMfiJoiningDate() != null) {
        mfiJoiningDate = new DateTime(center.getMfiJoiningDate());
        mfiJoiningDateAsString = DateUtils.getUserLocaleDate(userContext.getPreferredLocale(), center.getMfiJoiningDate().toString());
    }
    AddressDto address = null;
    if (center.getAddress() != null) {
        address = Address.toDto(center.getAddress());
    }
    return new CenterDto(loanOfficerId, center.getCustomerId(), center.getGlobalCustNum(), mfiJoiningDate, mfiJoiningDateAsString, center.getExternalId(), address, customerPositionDtos, customerList, activeLoanOfficersForBranch, true);
}
Also used : UserContext(org.mifos.security.util.UserContext) CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) CenterDto(org.mifos.dto.domain.CenterDto) MifosUser(org.mifos.security.MifosUser) CustomerAddressDto(org.mifos.dto.domain.CustomerAddressDto) AddressDto(org.mifos.dto.domain.AddressDto) DateTime(org.joda.time.DateTime) CenterCreation(org.mifos.dto.domain.CenterCreation) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto)

Example 25 with CustomerDto

use of org.mifos.dto.domain.CustomerDto in project head by mifos.

the class CustomerPersistence method phoneNumberSearch.

private QueryResult phoneNumberSearch(final String searchString, final Short officeId, final Short userId) throws HibernateSearchException, SystemException, PersistenceException {
    String phoneNumberWithStrippedNonnumerics = MifosStringUtils.removeNondigits(searchString);
    if (phoneNumberWithStrippedNonnumerics.isEmpty()) {
        return null;
    }
    List<CustomerDto> customersWithThisPhoneNumber = new CustomerDaoHibernate((new GenericDaoHibernate())).findCustomersWithGivenPhoneNumber(phoneNumberWithStrippedNonnumerics);
    if (customersWithThisPhoneNumber == null || customersWithThisPhoneNumber.isEmpty()) {
        return null;
    }
    SearchTemplate template = new SearchTemplate(phoneNumberWithStrippedNonnumerics, officeId, userId);
    template.queryNoOfficeCount = NamedQueryConstants.CUSTOMER_PHONE_SEARCH_NOOFFICEID_COUNT;
    template.queryNoOffice = NamedQueryConstants.CUSTOMER_PHONE_SEARCH_NOOFFICEID;
    template.queryNormalCount = NamedQueryConstants.CUSTOMER_PHONE_SEARCH_COUNT;
    template.queryNormal = NamedQueryConstants.CUSTOMER_PHONE_SEARCH;
    template.queryNonOfficerCount = NamedQueryConstants.CUSTOMER_PHONE_SEARCH_COUNT_NONLO;
    template.queryNonOfficer = NamedQueryConstants.CUSTOMER_PHONE_SEARCH_NONLO;
    return template.doSearch();
}
Also used : GenericDaoHibernate(org.mifos.accounts.savings.persistence.GenericDaoHibernate) CustomerDto(org.mifos.dto.domain.CustomerDto) CollectionSheetCustomerDto(org.mifos.application.servicefacade.CollectionSheetCustomerDto)

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