Search in sources :

Example 26 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class SavingsAccountSchedulesIntegrationTest method shouldNotGenerateSavingsAccountSchedulesForCenterWithoutActiveClients.

@Test
public void shouldNotGenerateSavingsAccountSchedulesForCenterWithoutActiveClients() throws Exception {
    createCenterAndGroupHierarchyWithNoClients(aWeeklyMeeting);
    SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().withMandatoryAmount("33.0").appliesToCentersOnly().buildForIntegrationTests();
    SavingsBO savingsAccount = new SavingsAccountBuilder().active().withActivationDate(mondayTwoWeeksAgo()).withSavingsProduct(savingsProduct).withCustomer(center).withCreatedBy(IntegrationTestObjectMother.testUser()).buildJointSavingsAccount();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
    List<AccountActionDateEntity> savingSchedules = savingsAccount.getAccountActionDatesSortedByInstallmentId();
    assertTrue(savingSchedules.isEmpty());
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) Test(org.junit.Test)

Example 27 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class SavingsAccountSchedulesIntegrationTest method shouldGenerateSavingsAccountSchedulesForGroupOnlyWhenUsingCompleteGroupSetting.

@Test
public void shouldGenerateSavingsAccountSchedulesForGroupOnlyWhenUsingCompleteGroupSetting() throws Exception {
    createCenterGroupClientHierarchy(aWeeklyMeeting);
    SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().withMandatoryAmount("33.0").appliesToGroupsOnly().trackedOnCompleteGroup().buildForIntegrationTests();
    SavingsBO savingsAccount = new SavingsAccountBuilder().active().withActivationDate(mondayTwoWeeksAgo()).withSavingsProduct(savingsProduct).withCustomer(group).withCreatedBy(IntegrationTestObjectMother.testUser()).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
    List<AccountActionDateEntity> savingSchedules = savingsAccount.getAccountActionDatesSortedByInstallmentId();
    for (AccountActionDateEntity savingSchedule : savingSchedules) {
        assertThat("saving schedule should be generated for group only and not any of its clients", savingSchedule.getCustomer().getCustomerId(), is(group.getCustomerId()));
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) Test(org.junit.Test)

Example 28 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class SavingsAccountSchedulesIntegrationTest method shouldGenerateSavingsAccountSchedulesForClient.

@Test
public void shouldGenerateSavingsAccountSchedulesForClient() throws Exception {
    createCenterGroupClientHierarchy(aWeeklyMeeting);
    SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().withMandatoryAmount("33.0").appliesToClientsOnly().buildForIntegrationTests();
    SavingsBO savingsAccount = new SavingsAccountBuilder().active().withActivationDate(mondayTwoWeeksAgo()).withSavingsProduct(savingsProduct).withCustomer(client).withCreatedBy(IntegrationTestObjectMother.testUser()).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
    List<AccountActionDateEntity> savingSchedules = savingsAccount.getAccountActionDatesSortedByInstallmentId();
    for (AccountActionDateEntity savingSchedule : savingSchedules) {
        assertThat("saving schedule should be generated for individual client savings account", savingSchedule.getCustomer().getCustomerId(), is(client.getCustomerId()));
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) Test(org.junit.Test)

Example 29 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class SavingsPersistenceIntegrationTest method testFindBySystemId.

@Test
public void testFindBySystemId() throws Exception {
    createInitialObjects();
    Date currentDate = new Date(System.currentTimeMillis());
    savingsOffering = TestObjectFactory.createSavingsProduct("SavingPrd1", "v1ws", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);
    savings = createSavingsAccount("kkk", savingsOffering);
    SavingsBO savings1 = savingsDao.findBySystemId(savings.getGlobalAccountNum());
    Assert.assertEquals(savings.getAccountId(), savings1.getAccountId());
    Assert.assertEquals(savingsOffering.getRecommendedAmount(), savings1.getRecommendedAmount());
}
Also used : SavingsBO(org.mifos.accounts.savings.business.SavingsBO) Date(java.util.Date) Test(org.junit.Test)

Example 30 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class SavingsPersistenceIntegrationTest method testFindById.

@Test
public void testFindById() throws Exception {
    createInitialObjects();
    Date currentDate = new Date(System.currentTimeMillis());
    savingsOffering = TestObjectFactory.createSavingsProduct("SavingPrd1", "xdsa", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);
    savings = createSavingsAccount("FFFF", savingsOffering);
    SavingsBO savings1 = savingsDao.findById(savings.getAccountId());
    Assert.assertEquals(savingsOffering.getRecommendedAmount(), savings1.getRecommendedAmount());
}
Also used : SavingsBO(org.mifos.accounts.savings.business.SavingsBO) Date(java.util.Date) Test(org.junit.Test)

Aggregations

SavingsBO (org.mifos.accounts.savings.business.SavingsBO)111 UserContext (org.mifos.security.util.UserContext)43 MifosRuntimeException (org.mifos.core.MifosRuntimeException)30 AccountException (org.mifos.accounts.exceptions.AccountException)28 LocalDate (org.joda.time.LocalDate)27 MifosUser (org.mifos.security.MifosUser)26 Test (org.junit.Test)25 Money (org.mifos.framework.util.helpers.Money)24 ArrayList (java.util.ArrayList)22 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)22 PersistenceException (org.mifos.framework.exceptions.PersistenceException)22 Date (java.util.Date)20 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)19 BusinessRuleException (org.mifos.service.BusinessRuleException)18 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)17 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)17 CustomerBO (org.mifos.customers.business.CustomerBO)15 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)14 ServiceException (org.mifos.framework.exceptions.ServiceException)13 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)12