Search in sources :

Example 31 with AccountBO

use of org.mifos.accounts.business.AccountBO in project head by mifos.

the class CustomerAccountCreationTest method customerAccountCanBeCreatedWithAccountFees.

@Test
public void customerAccountCanBeCreatedWithAccountFees() throws Exception {
    // setup
    FeeBO fee = new FeeBuilder().appliesToAllCustomers().periodic().with(new MeetingBuilder().periodicFeeMeeting().weekly().every(1)).build();
    AccountFeesEntity accountFee = new AccountFeesEntity(null, fee, Double.valueOf("25.0"));
    accountFees = new ArrayList<AccountFeesEntity>();
    accountFees.add(accountFee);
    customer = new CenterBuilder().inActive().build();
    // exercise test
    customerAccount = CustomerAccountBO.createNew(customer, accountFees, customerMeeting, applicableCalendarEvents);
    // verification
    assertThat(customerAccount.getAccountFees(), hasItem(accountFee));
    assertThat(accountFee.getAccount(), is((AccountBO) customerAccount));
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) AccountBO(org.mifos.accounts.business.AccountBO) FeeBuilder(org.mifos.domain.builders.FeeBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder) FeeBO(org.mifos.accounts.fees.business.FeeBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 32 with AccountBO

use of org.mifos.accounts.business.AccountBO in project head by mifos.

the class CustomerBOIntegrationTest method testGetOutstandingLoanAmount.

@Test
public void testGetOutstandingLoanAmount() {
    createInitialObjects();
    accountBO = getLoanAccount(group, meeting);
    StaticHibernateUtil.flushSession();
    group = TestObjectFactory.getGroup(group.getCustomerId());
    Assert.assertEquals(new Money(getCurrency(), "300.0"), group.getOutstandingLoanAmount(getCurrency()));
    StaticHibernateUtil.flushSession();
    center = TestObjectFactory.getCenter(center.getCustomerId());
    group = TestObjectFactory.getGroup(group.getCustomerId());
    client = TestObjectFactory.getClient(client.getCustomerId());
    accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountBO(org.mifos.accounts.business.AccountBO) Test(org.junit.Test)

Example 33 with AccountBO

use of org.mifos.accounts.business.AccountBO in project head by mifos.

the class CustomerPersistenceIntegrationTest method testGetTotalAmountForAllClientsOfGroupForSingleCurrency.

@Test
public void testGetTotalAmountForAllClientsOfGroupForSingleCurrency() throws Exception {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = createCenter("new_center");
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
    AccountBO clientAccount1 = getLoanAccount(client, meeting, "fdbdhgsgh", "54hg", TestUtils.RUPEE);
    AccountBO clientAccount2 = getLoanAccount(client, meeting, "fasdfdsfasdf", "1qwe", TestUtils.RUPEE);
    Money amount = customerPersistence.getTotalAmountForAllClientsOfGroup(group.getOffice().getOfficeId(), AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, group.getSearchId() + ".%");
    Assert.assertEquals(new Money(TestUtils.RUPEE, "600"), amount);
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) Money(org.mifos.framework.util.helpers.Money) MeetingBO(org.mifos.application.meeting.business.MeetingBO) Test(org.junit.Test)

Example 34 with AccountBO

use of org.mifos.accounts.business.AccountBO in project head by mifos.

the class CustomerPersistenceIntegrationTest method testRetrieveAllSavingsAccountUnderCustomer.

@Test
public void testRetrieveAllSavingsAccountUnderCustomer() throws Exception {
    center = createCenter("new_center");
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    CenterBO center1 = createCenter("new_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_CLOSED, group);
    ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_CANCELLED, group1);
    account = getSavingsAccount(center, "Savings Prd1", "Abc1");
    AccountBO account1 = getSavingsAccount(client, "Savings Prd2", "Abc2");
    AccountBO account2 = getSavingsAccount(client2, "Savings Prd3", "Abc3");
    AccountBO account3 = getSavingsAccount(client3, "Savings Prd4", "Abc4");
    AccountBO account4 = getSavingsAccount(group1, "Savings Prd5", "Abc5");
    AccountBO account5 = getSavingsAccount(group, "Savings Prd6", "Abc6");
    AccountBO account6 = getSavingsAccount(center1, "Savings Prd7", "Abc7");
    List<AccountBO> savingsForCenter = customerPersistence.retrieveAccountsUnderCustomer(center.getSearchId(), Short.valueOf("3"), Short.valueOf("2"));
    Assert.assertEquals(4, savingsForCenter.size());
    List<AccountBO> savingsForGroup = customerPersistence.retrieveAccountsUnderCustomer(group.getSearchId(), Short.valueOf("3"), Short.valueOf("2"));
    Assert.assertEquals(3, savingsForGroup.size());
    List<AccountBO> savingsForClient = customerPersistence.retrieveAccountsUnderCustomer(client.getSearchId(), Short.valueOf("3"), Short.valueOf("2"));
    Assert.assertEquals(1, savingsForClient.size());
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) ClientBO(org.mifos.customers.client.business.ClientBO) CenterBO(org.mifos.customers.center.business.CenterBO) GroupBO(org.mifos.customers.group.business.GroupBO) Test(org.junit.Test)

Example 35 with AccountBO

use of org.mifos.accounts.business.AccountBO in project head by mifos.

the class CustomerPersistenceIntegrationTest method testGetCustomerAccountsForFee.

@Test
public void testGetCustomerAccountsForFee() throws Exception {
    groupAccount = getLoanAccount();
    FeeBO periodicFee = TestObjectFactory.createPeriodicAmountFee("ClientPeridoicFee", FeeCategory.CENTER, "5", RecurrenceType.WEEKLY, Short.valueOf("1"));
    AccountFeesEntity accountFee = new AccountFeesEntity(center.getCustomerAccount(), periodicFee, ((AmountFeeBO) periodicFee).getFeeAmount().getAmountDoubleValue());
    CustomerAccountBO customerAccount = center.getCustomerAccount();
    AccountTestUtils.addAccountFees(accountFee, customerAccount);
    TestObjectFactory.updateObject(customerAccount);
    StaticHibernateUtil.flushSession();
    // check for the account fee
    List<AccountBO> accountList = new CustomerPersistence().getCustomerAccountsForFee(periodicFee.getFeeId());
    Assert.assertNotNull(accountList);
    Assert.assertEquals(1, accountList.size());
    Assert.assertTrue(accountList.get(0) instanceof CustomerAccountBO);
    // get all objects again
    groupAccount = TestObjectFactory.getObject(LoanBO.class, groupAccount.getAccountId());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    center = TestObjectFactory.getCustomer(center.getCustomerId());
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Test(org.junit.Test)

Aggregations

AccountBO (org.mifos.accounts.business.AccountBO)106 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)39 LoanBO (org.mifos.accounts.loan.business.LoanBO)35 ArrayList (java.util.ArrayList)30 Money (org.mifos.framework.util.helpers.Money)30 UserContext (org.mifos.security.util.UserContext)29 Test (org.junit.Test)27 MifosRuntimeException (org.mifos.core.MifosRuntimeException)26 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)20 ServiceException (org.mifos.framework.exceptions.ServiceException)19 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)18 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)16 AccountException (org.mifos.accounts.exceptions.AccountException)15 MifosUser (org.mifos.security.MifosUser)14 Date (java.util.Date)13 LocalDate (org.joda.time.LocalDate)12 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)12 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)11 PersistenceException (org.mifos.framework.exceptions.PersistenceException)10 FeeBO (org.mifos.accounts.fees.business.FeeBO)9