Search in sources :

Example 1 with CollectionSheetCustomerSavingDto

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

the class SavingsDaoHibernateIntegrationTest method testShouldFindOnlyMandatorySavingsAccountsForCentersOrGroupThatToBePaidIndividuallyByTheirClients.

@Test
public void testShouldFindOnlyMandatorySavingsAccountsForCentersOrGroupThatToBePaidIndividuallyByTheirClients() {
    // setup
    savingsProduct = new SavingsProductBuilder().voluntary().appliesToGroupsOnly().withShortName("SP1").buildForIntegrationTests();
    savingsAccount = new SavingsAccountBuilder().completeGroup().perIndividual().withSavingsProduct(savingsProduct).withCustomer(group).withCreatedBy(IntegrationTestObjectMother.testUser()).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
    secondSavingsProduct = new SavingsProductBuilder().mandatory().withShortName("SP2").appliesToCentersOnly().withName("testSavingPrd2").buildForIntegrationTests();
    secondSavingsAccount = new SavingsAccountBuilder().withSavingsProduct(secondSavingsProduct).withCustomer(center).withCreatedBy(IntegrationTestObjectMother.testUser()).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(secondSavingsProduct, secondSavingsAccount);
    // exercise test
    List<CollectionSheetCustomerSavingDto> mandatorySavingAccounts = savingsDao.findAllMandatorySavingAccountsForIndividualChildrenOfCentersOrGroupsWithPerIndividualStatusForCustomerHierarchy(customerHierarchyParams);
    // verification
    assertThat(mandatorySavingAccounts.size(), is(1));
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) CollectionSheetCustomerSavingDto(org.mifos.application.servicefacade.CollectionSheetCustomerSavingDto) Test(org.junit.Test)

Example 2 with CollectionSheetCustomerSavingDto

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

the class CollectionSheetDaoHibernate method convertListToMapGroupedByCustomerId.

private Map<Integer, List<CollectionSheetCustomerSavingDto>> convertListToMapGroupedByCustomerId(final List<CollectionSheetCustomerSavingDto> allSavingsAccounts) {
    final Map<Integer, List<CollectionSheetCustomerSavingDto>> savingsGroupedByCustomerId = new HashMap<Integer, List<CollectionSheetCustomerSavingDto>>();
    for (CollectionSheetCustomerSavingDto savingsAccountDto : allSavingsAccounts) {
        final Integer customerId = savingsAccountDto.getCustomerId();
        if (savingsGroupedByCustomerId.containsKey(customerId)) {
            savingsGroupedByCustomerId.get(customerId).add(savingsAccountDto);
        } else {
            List<CollectionSheetCustomerSavingDto> savingsDtoList = new ArrayList<CollectionSheetCustomerSavingDto>();
            savingsDtoList.add(savingsAccountDto);
            savingsGroupedByCustomerId.put(customerId, savingsDtoList);
        }
    }
    return savingsGroupedByCustomerId;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CollectionSheetCustomerSavingDto(org.mifos.application.servicefacade.CollectionSheetCustomerSavingDto)

Example 3 with CollectionSheetCustomerSavingDto

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

the class SavingsDaoHibernateIntegrationTest method testShouldFindOnlyVoluntarySavingsAccountsForIndividualClientsOfTheVoluntaryCentersOrVoluntaryGroupsWithPerIndividualStatus.

@Test
public void testShouldFindOnlyVoluntarySavingsAccountsForIndividualClientsOfTheVoluntaryCentersOrVoluntaryGroupsWithPerIndividualStatus() {
    // setup
    savingsProduct = new SavingsProductBuilder().voluntary().withShortName("SP1").appliesToGroupsOnly().buildForIntegrationTests();
    savingsAccount = new SavingsAccountBuilder().completeGroup().perIndividual().withSavingsProduct(savingsProduct).withCustomer(group).withCreatedBy(IntegrationTestObjectMother.testUser()).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
    secondSavingsProduct = new SavingsProductBuilder().mandatory().withShortName("SP2").appliesToCentersOnly().withName("testSavingPrd2").buildForIntegrationTests();
    secondSavingsAccount = new SavingsAccountBuilder().withSavingsProduct(secondSavingsProduct).withCustomer(center).withCreatedBy(IntegrationTestObjectMother.testUser()).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(secondSavingsProduct, secondSavingsAccount);
    // exercise test
    List<CollectionSheetCustomerSavingDto> voluntarySavingAccountsForPaymentByIndividuals = savingsDao.findAllVoluntarySavingAccountsForIndividualChildrenOfCentersOrGroupsWithPerIndividualStatusForCustomerHierarchy(customerHierarchyParams);
    // verification
    assertThat(voluntarySavingAccountsForPaymentByIndividuals.size(), is(1));
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) CollectionSheetCustomerSavingDto(org.mifos.application.servicefacade.CollectionSheetCustomerSavingDto) Test(org.junit.Test)

Example 4 with CollectionSheetCustomerSavingDto

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

the class SavingsDaoHibernateIntegrationTest method testShouldFindExistingMandatorySavingsAccountsForGroupsWithCompleteGroupStatusWhenCenterIsTopOfCustomerHierarchy.

@Test
public void testShouldFindExistingMandatorySavingsAccountsForGroupsWithCompleteGroupStatusWhenCenterIsTopOfCustomerHierarchy() {
    // setup
    savingsProduct = new SavingsProductBuilder().mandatory().appliesToGroupsOnly().buildForIntegrationTests();
    savingsAccount = new SavingsAccountBuilder().withSavingsProduct(savingsProduct).withCustomer(group).withCreatedBy(IntegrationTestObjectMother.testUser()).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
    // exercise test
    List<CollectionSheetCustomerSavingDto> mandatorySavingAccounts = savingsDao.findAllMandatorySavingAccountsForClientsOrGroupsWithCompleteGroupStatusForCustomerHierarchy(customerHierarchyParams);
    // verification
    assertThat(mandatorySavingAccounts.size(), is(1));
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) CollectionSheetCustomerSavingDto(org.mifos.application.servicefacade.CollectionSheetCustomerSavingDto) Test(org.junit.Test)

Example 5 with CollectionSheetCustomerSavingDto

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

the class SavingsDaoHibernateIntegrationTest method testShouldFindExistingMandatorySavingsAccountsForClientsWhenCenterIsTopOfCustomerHierarchy.

@Test
public void testShouldFindExistingMandatorySavingsAccountsForClientsWhenCenterIsTopOfCustomerHierarchy() {
    // setup
    savingsProduct = new SavingsProductBuilder().mandatory().appliesToClientsOnly().buildForIntegrationTests();
    savingsAccount = new SavingsAccountBuilder().withSavingsProduct(savingsProduct).withCustomer(client).withCreatedBy(IntegrationTestObjectMother.testUser()).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
    // exercise test
    List<CollectionSheetCustomerSavingDto> mandatorySavingAccounts = savingsDao.findAllMandatorySavingAccountsForClientsOrGroupsWithCompleteGroupStatusForCustomerHierarchy(customerHierarchyParams);
    // verification
    assertThat(mandatorySavingAccounts.size(), is(1));
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) CollectionSheetCustomerSavingDto(org.mifos.application.servicefacade.CollectionSheetCustomerSavingDto) Test(org.junit.Test)

Aggregations

CollectionSheetCustomerSavingDto (org.mifos.application.servicefacade.CollectionSheetCustomerSavingDto)5 Test (org.junit.Test)4 SavingsAccountBuilder (org.mifos.domain.builders.SavingsAccountBuilder)4 SavingsProductBuilder (org.mifos.domain.builders.SavingsProductBuilder)4 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1