Search in sources :

Example 1 with CollectionSheetCustomerAccountCollectionDto

use of org.mifos.application.servicefacade.CollectionSheetCustomerAccountCollectionDto in project head by mifos.

the class CollectionSheetDaoHibernateIntegrationTest method testShouldFindOutstandingFeesForCustomerAccountsXXX.

@Test
@Ignore
public void testShouldFindOutstandingFeesForCustomerAccountsXXX() {
    // setup
    final Short branchId = center.getOffice().getOfficeId();
    final String searchId = center.getSearchId() + ".%";
    final LocalDate transactionDate = new LocalDate();
    // exercise test
    Map<Integer, List<CollectionSheetCustomerAccountCollectionDto>> allOutstandingFeesByCustomerId = collectionSheetDao.findOutstandingFeesForCustomerAccountOnCustomerHierarchy(branchId, searchId, transactionDate, center.getCustomerId());
    // verification
    Assert.assertNotNull(allOutstandingFeesByCustomerId);
    final List<CollectionSheetCustomerAccountCollectionDto> accountCollectionFees = allOutstandingFeesByCustomerId.get(group.getCustomerId());
    Assert.assertNotNull(accountCollectionFees);
    Assert.assertThat(accountCollectionFees.size(), is(1));
    Assert.assertThat(accountCollectionFees.get(0).getAccountId(), is(group.getCustomerAccount().getAccountId()));
    Assert.assertThat(accountCollectionFees.get(0).getCustomerId(), is(group.getCustomerId()));
    Assert.assertThat(accountCollectionFees.get(0).getMiscFeesDue(), is(new BigDecimal("0")));
    Assert.assertThat(accountCollectionFees.get(0).getMiscFeesPaid(), is(new BigDecimal("0")));
    Assert.assertThat(accountCollectionFees.get(0).getAccountCollectionPayment(), is(Double.valueOf("0.0")));
}
Also used : CollectionSheetCustomerAccountCollectionDto(org.mifos.application.servicefacade.CollectionSheetCustomerAccountCollectionDto) List(java.util.List) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with CollectionSheetCustomerAccountCollectionDto

use of org.mifos.application.servicefacade.CollectionSheetCustomerAccountCollectionDto in project head by mifos.

the class CollectionSheetDaoHibernateIntegrationTest method testShouldFindAccountCollectionFeesForCustomerAccounts.

@Test
@Ignore
public void testShouldFindAccountCollectionFeesForCustomerAccounts() {
    // setup
    final Short branchId = center.getOffice().getOfficeId();
    final String searchId = center.getSearchId() + ".%";
    final LocalDate transactionDate = new LocalDate();
    // exercise test
    Map<Integer, List<CollectionSheetCustomerAccountCollectionDto>> allCustomerAccountCollectionFees = collectionSheetDao.findAccountCollectionsOnCustomerAccount(branchId, searchId, transactionDate, center.getCustomerId());
    // verification
    Assert.assertNotNull(allCustomerAccountCollectionFees);
    final List<CollectionSheetCustomerAccountCollectionDto> accountCollections = allCustomerAccountCollectionFees.get(group.getCustomerId());
    Assert.assertNotNull(accountCollections);
    Assert.assertThat(accountCollections.size(), is(1));
    Assert.assertThat(accountCollections.get(0).getAccountId(), is(group.getCustomerAccount().getAccountId()));
    Assert.assertThat(accountCollections.get(0).getCustomerId(), is(group.getCustomerId()));
    Assert.assertThat(accountCollections.get(0).getMiscFeesDue(), is(new BigDecimal("0.0000")));
    Assert.assertThat(accountCollections.get(0).getMiscFeesPaid(), is(new BigDecimal("0.0000")));
    Assert.assertThat(accountCollections.get(0).getAccountCollectionPayment(), is(Double.valueOf("0.0")));
}
Also used : CollectionSheetCustomerAccountCollectionDto(org.mifos.application.servicefacade.CollectionSheetCustomerAccountCollectionDto) List(java.util.List) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with CollectionSheetCustomerAccountCollectionDto

use of org.mifos.application.servicefacade.CollectionSheetCustomerAccountCollectionDto in project head by mifos.

the class CollectionSheetDaoHibernate method findOutstandingFeesForCustomerAccountOnCustomerHierarchy.

@Override
@SuppressWarnings("unchecked")
public Map<Integer, List<CollectionSheetCustomerAccountCollectionDto>> findOutstandingFeesForCustomerAccountOnCustomerHierarchy(final Short branchId, final String searchId, final LocalDate transactionDate, final Integer customerAtTopOfHierarchyId) {
    final Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("CUSTOMER_ID", customerAtTopOfHierarchyId);
    queryParameters.put("TRANSACTION_DATE", transactionDate.toString());
    final Map<Integer, List<CollectionSheetCustomerAccountCollectionDto>> accountCollectionsOnCustomerAccountGroupedByCustomerId = new HashMap<Integer, List<CollectionSheetCustomerAccountCollectionDto>>();
    final CollectionSheetCustomerAccountCollectionDto accountCollectionFeeForHierarchyCustomer = execUniqueResultNamedQueryWithResultTransformer("findOutstandingCustomerAccountFeesForTopCustomerOfHierarchyAsDto", queryParameters, CollectionSheetCustomerAccountCollectionDto.class);
    if (accountCollectionFeeForHierarchyCustomer != null) {
        accountCollectionsOnCustomerAccountGroupedByCustomerId.put(customerAtTopOfHierarchyId, Arrays.asList(accountCollectionFeeForHierarchyCustomer));
    }
    final Map<String, Object> withinHierarchyQueryParameters = new HashMap<String, Object>();
    withinHierarchyQueryParameters.put("BRANCH_ID", branchId);
    withinHierarchyQueryParameters.put("SEARCH_ID", searchId);
    withinHierarchyQueryParameters.put("TRANSACTION_DATE", transactionDate.toString());
    final List<CollectionSheetCustomerAccountCollectionDto> customerAccountFees = executeNamedQueryWithResultTransformer("findOutstandingFeesForCustomerAccountOnCustomerHierarchyAsDto", withinHierarchyQueryParameters, CollectionSheetCustomerAccountCollectionDto.class);
    if (customerAccountFees == null) {
        return accountCollectionsOnCustomerAccountGroupedByCustomerId;
    }
    for (CollectionSheetCustomerAccountCollectionDto accountCollectionFee : customerAccountFees) {
        final Integer customerId = accountCollectionFee.getCustomerId();
        if (accountCollectionsOnCustomerAccountGroupedByCustomerId.containsKey(customerId)) {
            final List<CollectionSheetCustomerAccountCollectionDto> customerAccountFeesList = accountCollectionsOnCustomerAccountGroupedByCustomerId.get(customerId);
            customerAccountFeesList.add(accountCollectionFee);
        } else {
            final List<CollectionSheetCustomerAccountCollectionDto> customerAccountFeesList = new ArrayList<CollectionSheetCustomerAccountCollectionDto>();
            customerAccountFeesList.add(accountCollectionFee);
            accountCollectionsOnCustomerAccountGroupedByCustomerId.put(customerId, customerAccountFeesList);
        }
    }
    return accountCollectionsOnCustomerAccountGroupedByCustomerId;
}
Also used : HashMap(java.util.HashMap) CollectionSheetCustomerAccountCollectionDto(org.mifos.application.servicefacade.CollectionSheetCustomerAccountCollectionDto) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with CollectionSheetCustomerAccountCollectionDto

use of org.mifos.application.servicefacade.CollectionSheetCustomerAccountCollectionDto in project head by mifos.

the class CollectionSheetDaoHibernate method findAccountCollectionsOnCustomerAccount.

@Override
@SuppressWarnings("unchecked")
public Map<Integer, List<CollectionSheetCustomerAccountCollectionDto>> findAccountCollectionsOnCustomerAccount(final Short branchId, final String searchId, final LocalDate transactionDate, final Integer customerAtTopOfHierarchyId) {
    final Map<String, Object> queryParameters = new HashMap<String, Object>();
    queryParameters.put("CUSTOMER_ID", customerAtTopOfHierarchyId);
    queryParameters.put("TRANSACTION_DATE", transactionDate.toString());
    final Map<Integer, List<CollectionSheetCustomerAccountCollectionDto>> accountCollectionsOnCustomerAccountGroupedByCustomerId = new HashMap<Integer, List<CollectionSheetCustomerAccountCollectionDto>>();
    CollectionSheetCustomerAccountCollectionDto accountCollectionFeeForHierarchyCustomer = execUniqueResultNamedQueryWithResultTransformer("findAccountCollectionsOnCustomerAccountForTopCustomerOfHierarchy", queryParameters, CollectionSheetCustomerAccountCollectionDto.class);
    if (accountCollectionFeeForHierarchyCustomer != null) {
        accountCollectionsOnCustomerAccountGroupedByCustomerId.put(customerAtTopOfHierarchyId, Arrays.asList(accountCollectionFeeForHierarchyCustomer));
    }
    final Map<String, Object> withinHierarchyQueryParameters = new HashMap<String, Object>();
    withinHierarchyQueryParameters.put("BRANCH_ID", branchId);
    withinHierarchyQueryParameters.put("SEARCH_ID", searchId);
    withinHierarchyQueryParameters.put("TRANSACTION_DATE", transactionDate.toString());
    final List<CollectionSheetCustomerAccountCollectionDto> customerAccountFees = executeNamedQueryWithResultTransformer("findAccountCollectionsOnCustomerAccountForCustomerHierarchyAsDto", withinHierarchyQueryParameters, CollectionSheetCustomerAccountCollectionDto.class);
    for (CollectionSheetCustomerAccountCollectionDto accountCollectionFee : customerAccountFees) {
        final Integer customerId = accountCollectionFee.getCustomerId();
        if (accountCollectionsOnCustomerAccountGroupedByCustomerId.containsKey(customerId)) {
            final List<CollectionSheetCustomerAccountCollectionDto> customerAccountFeesList = accountCollectionsOnCustomerAccountGroupedByCustomerId.get(customerId);
            Comparator<CollectionSheetCustomerAccountCollectionDto> comparator = new Comparator<CollectionSheetCustomerAccountCollectionDto>() {

                @Override
                public int compare(CollectionSheetCustomerAccountCollectionDto cseDto1, CollectionSheetCustomerAccountCollectionDto cseDto2) {
                    return cseDto1.getAccountId().compareTo(cseDto2.getAccountId());
                }
            };
            Collections.sort(customerAccountFeesList, comparator);
            if (Collections.binarySearch(customerAccountFeesList, accountCollectionFee, comparator) < 0) {
                customerAccountFeesList.add(accountCollectionFee);
            }
        } else {
            final List<CollectionSheetCustomerAccountCollectionDto> customerAccountFeesList = new ArrayList<CollectionSheetCustomerAccountCollectionDto>();
            customerAccountFeesList.add(accountCollectionFee);
            accountCollectionsOnCustomerAccountGroupedByCustomerId.put(customerId, customerAccountFeesList);
        }
    }
    return accountCollectionsOnCustomerAccountGroupedByCustomerId;
}
Also used : HashMap(java.util.HashMap) CollectionSheetCustomerAccountCollectionDto(org.mifos.application.servicefacade.CollectionSheetCustomerAccountCollectionDto) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Comparator(java.util.Comparator)

Aggregations

List (java.util.List)4 CollectionSheetCustomerAccountCollectionDto (org.mifos.application.servicefacade.CollectionSheetCustomerAccountCollectionDto)4 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LocalDate (org.joda.time.LocalDate)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 Comparator (java.util.Comparator)1