Search in sources :

Example 61 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class CustomerPersistenceIntegrationTest method testFindBySystemId.

@Test
public void testFindBySystemId() throws Exception {
    center = createCenter();
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group_Active_test", CustomerStatus.GROUP_ACTIVE, center);
    GroupBO groupBO = (GroupBO) customerPersistence.findBySystemId(group.getGlobalCustNum());
    Assert.assertEquals(groupBO.getDisplayName(), group.getDisplayName());
}
Also used : GroupBO(org.mifos.customers.group.business.GroupBO) Test(org.junit.Test)

Example 62 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class CustomerPersistenceIntegrationTest method testGetTotalAmountForGroupForMultipleCurrencies.

/*
     * When trying to sum amounts across loans with different currencies, we should get an exception
     */
@Test
public void testGetTotalAmountForGroupForMultipleCurrencies() throws Exception {
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    configMgr.setProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES, TestUtils.EURO.getCurrencyCode());
    GroupBO group1;
    AccountBO account1;
    AccountBO account2;
    try {
        CustomerPersistence customerPersistence = new CustomerPersistence();
        meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
        center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
        group1 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
        account1 = getLoanAccount(group1, meeting, "adsfdsfsd", "3saf", TestUtils.RUPEE);
        account2 = getLoanAccount(group1, meeting, "adspp", "kkaf", TestUtils.EURO);
        try {
            customerPersistence.getTotalAmountForGroup(group1.getCustomerId(), AccountState.LOAN_ACTIVE_IN_GOOD_STANDING);
            Assert.fail("didn't get the expected CurrencyMismatchException");
        } catch (CurrencyMismatchException e) {
            // if we got here then we got the exception we were expecting
            Assert.assertNotNull(e);
        } catch (Exception e) {
            Assert.fail("didn't get the expected CurrencyMismatchException");
        }
    } finally {
        configMgr.clearProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES);
    }
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) CurrencyMismatchException(org.mifos.core.CurrencyMismatchException) GroupBO(org.mifos.customers.group.business.GroupBO) SystemException(org.mifos.framework.exceptions.SystemException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) CurrencyMismatchException(org.mifos.core.CurrencyMismatchException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager) Test(org.junit.Test)

Example 63 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class CustomerPersistenceIntegrationTest method testRetrieveAllLoanAccountUnderCustomer.

@Test
public void testRetrieveAllLoanAccountUnderCustomer() throws PersistenceException {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = createCenter("center");
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    CenterBO center1 = createCenter("center1");
    GroupBO group1 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center1);
    client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
    ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_ACTIVE, group);
    ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_ACTIVE, group1);
    account = getLoanAccount(group, meeting, "cdfggdfs", "1qdd");
    AccountBO account1 = getLoanAccount(client, meeting, "fdbdhgsgh", "54hg");
    AccountBO account2 = getLoanAccount(client2, meeting, "fasdfdsfasdf", "1qwe");
    AccountBO account3 = getLoanAccount(client3, meeting, "fdsgdfgfd", "543g");
    AccountBO account4 = getLoanAccount(group1, meeting, "fasdf23", "3fds");
    CustomerBOTestUtils.setCustomerStatus(client2, new CustomerStatusEntity(CustomerStatus.CLIENT_CLOSED));
    TestObjectFactory.updateObject(client2);
    client2 = TestObjectFactory.getClient(client2.getCustomerId());
    CustomerBOTestUtils.setCustomerStatus(client3, new CustomerStatusEntity(CustomerStatus.CLIENT_CANCELLED));
    TestObjectFactory.updateObject(client3);
    client3 = TestObjectFactory.getClient(client3.getCustomerId());
    List<AccountBO> loansForCenter = customerPersistence.retrieveAccountsUnderCustomer(center.getSearchId(), Short.valueOf("3"), Short.valueOf("1"));
    Assert.assertEquals(3, loansForCenter.size());
    List<AccountBO> loansForGroup = customerPersistence.retrieveAccountsUnderCustomer(group.getSearchId(), Short.valueOf("3"), Short.valueOf("1"));
    Assert.assertEquals(3, loansForGroup.size());
    List<AccountBO> loansForClient = customerPersistence.retrieveAccountsUnderCustomer(client.getSearchId(), Short.valueOf("3"), Short.valueOf("1"));
    Assert.assertEquals(1, loansForClient.size());
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ClientBO(org.mifos.customers.client.business.ClientBO) CenterBO(org.mifos.customers.center.business.CenterBO) GroupBO(org.mifos.customers.group.business.GroupBO) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) Test(org.junit.Test)

Example 64 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class CustomerPersistenceIntegrationTest method testGetTotalAmountForGroup.

@Ignore
@Test
public void testGetTotalAmountForGroup() throws Exception {
    CustomerPersistence customerPersistence = new CustomerPersistence();
    meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    GroupBO group1 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
    AccountBO account1 = getLoanAccount(group1, meeting, "adsfdsfsd", "3saf");
    AccountBO account2 = getLoanAccount(group1, meeting, "adspp", "kkaf");
    Money amount = customerPersistence.getTotalAmountForGroup(group1.getCustomerId(), AccountState.LOAN_ACTIVE_IN_GOOD_STANDING);
    Assert.assertEquals(new Money(getCurrency(), "600"), amount);
    AccountBO account3 = getLoanAccountInActiveBadStanding(group1, meeting, "adsfdsfsd1", "4sa");
    AccountBO account4 = getLoanAccountInActiveBadStanding(group1, meeting, "adspp2", "kaf5");
    Money amount2 = customerPersistence.getTotalAmountForGroup(group1.getCustomerId(), AccountState.LOAN_ACTIVE_IN_BAD_STANDING);
    Assert.assertEquals(new Money(getCurrency(), "600"), amount2);
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) Money(org.mifos.framework.util.helpers.Money) GroupBO(org.mifos.customers.group.business.GroupBO) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 65 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class CustomerPersistenceIntegrationTest method testGetBySystemId.

@Test
public void testGetBySystemId() throws Exception {
    center = createCenter();
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group_Active_test", CustomerStatus.GROUP_ACTIVE, center);
    GroupBO groupBO = (GroupBO) customerPersistence.findBySystemId(group.getGlobalCustNum(), group.getCustomerLevel().getId());
    Assert.assertEquals(groupBO.getDisplayName(), group.getDisplayName());
}
Also used : GroupBO(org.mifos.customers.group.business.GroupBO) Test(org.junit.Test)

Aggregations

GroupBO (org.mifos.customers.group.business.GroupBO)84 Test (org.junit.Test)56 CenterBO (org.mifos.customers.center.business.CenterBO)45 GroupBuilder (org.mifos.domain.builders.GroupBuilder)42 CenterBuilder (org.mifos.domain.builders.CenterBuilder)36 CustomerException (org.mifos.customers.exceptions.CustomerException)23 ClientBO (org.mifos.customers.client.business.ClientBO)22 ArrayList (java.util.ArrayList)16 OfficeBO (org.mifos.customers.office.business.OfficeBO)16 MeetingBO (org.mifos.application.meeting.business.MeetingBO)15 ClientBuilder (org.mifos.domain.builders.ClientBuilder)15 DateTime (org.joda.time.DateTime)14 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)12 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)11 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)11 UserContext (org.mifos.security.util.UserContext)11 LocalDate (org.joda.time.LocalDate)10 MifosRuntimeException (org.mifos.core.MifosRuntimeException)10 ApplicationException (org.mifos.framework.exceptions.ApplicationException)10 Date (java.util.Date)9