Search in sources :

Example 1 with SavingsTestHelper

use of org.mifos.accounts.savings.util.helpers.SavingsTestHelper in project head by mifos.

the class LegacyAccountDaoIntegrationTest method testGetActiveCustomerAndSavingsAccountIdsForGenerateMeetingTaskShouldReturnThreeCustomerAccountsAndOneSavingsAccount.

@Test
public void testGetActiveCustomerAndSavingsAccountIdsForGenerateMeetingTaskShouldReturnThreeCustomerAccountsAndOneSavingsAccount() throws Exception {
    // Superclass creates a center, a group, and a client that start meeting today
    // They should have 10 current or future meeting dates
    // Set time ahead 7 weeks to force regenerating customer schedules.
    savingsBO = new SavingsTestHelper().createSavingsAccount(createSavingsOffering("qqqqq"), group, AccountState.SAVINGS_ACTIVE, TestUtils.makeUser());
    new DateTimeService().setCurrentDateTime(new DateTime().plusWeeks(7));
    List<Integer> accountIds = legacyAccountDao.getActiveCustomerAndSavingsAccountIdsForGenerateMeetingTask();
    assertThat(accountIds.size(), is(4));
    assertThat(accountIds.contains(center.getCustomerAccount().getAccountId()), is(true));
    assertThat(accountIds.contains(group.getCustomerAccount().getAccountId()), is(true));
    assertThat(accountIds.contains(client.getCustomerAccount().getAccountId()), is(true));
    assertThat(accountIds.contains(savingsBO.getAccountId()), is(true));
}
Also used : DateTimeService(org.mifos.framework.util.DateTimeService) SavingsTestHelper(org.mifos.accounts.savings.util.helpers.SavingsTestHelper) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 2 with SavingsTestHelper

use of org.mifos.accounts.savings.util.helpers.SavingsTestHelper in project head by mifos.

the class SavingsPersistenceIntegrationTest method testRetrieveLastTransaction.

@Test
public void testRetrieveLastTransaction() throws Exception {
    try {
        SavingsTestHelper helper = new SavingsTestHelper();
        createInitialObjects();
        PersonnelBO createdBy = legacyPersonnelDao.getPersonnel(userContext.getId());
        savingsOffering = helper.createSavingsOffering("effwe", "231");
        savings = new SavingsBO(userContext, savingsOffering, group, AccountState.SAVINGS_ACTIVE, savingsOffering.getRecommendedAmount(), null);
        AccountPaymentEntity payment = helper.createAccountPaymentToPersist(savings, new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "700.0"), new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "1700.0"), helper.getDate("15/01/2006"), AccountActionTypes.SAVINGS_DEPOSIT.getValue(), savings, createdBy, group);
        AccountTestUtils.addAccountPayment(payment, savings);
        savings.save();
        StaticHibernateUtil.flushSession();
        payment = helper.createAccountPaymentToPersist(savings, new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "1000.0"), new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "2700.0"), helper.getDate("20/02/2006"), AccountActionTypes.SAVINGS_DEPOSIT.getValue(), savings, createdBy, group);
        AccountTestUtils.addAccountPayment(payment, savings);
        savings.update();
        StaticHibernateUtil.flushSession();
        savings = savingsDao.findById(savings.getAccountId());
        savings.setUserContext(userContext);
        payment = helper.createAccountPaymentToPersist(savings, new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "500.0"), new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "2200.0"), helper.getDate("10/03/2006"), AccountActionTypes.SAVINGS_WITHDRAWAL.getValue(), savings, createdBy, group);
        AccountTestUtils.addAccountPayment(payment, savings);
        savings.update();
        StaticHibernateUtil.flushSession();
        savings = savingsDao.findById(savings.getAccountId());
        savings.setUserContext(userContext);
        payment = helper.createAccountPaymentToPersist(savings, new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "1200.0"), new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "3400.0"), helper.getDate("15/03/2006"), AccountActionTypes.SAVINGS_DEPOSIT.getValue(), savings, createdBy, group);
        AccountTestUtils.addAccountPayment(payment, savings);
        savings.update();
        StaticHibernateUtil.flushSession();
        savings = savingsDao.findById(savings.getAccountId());
        savings.setUserContext(userContext);
        payment = helper.createAccountPaymentToPersist(savings, new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "2500.0"), new Money(Configuration.getInstance().getSystemConfig().getCurrency(), "900.0"), helper.getDate("25/03/2006"), AccountActionTypes.SAVINGS_WITHDRAWAL.getValue(), savings, createdBy, group);
        AccountTestUtils.addAccountPayment(payment, savings);
        savings.update();
        StaticHibernateUtil.flushSession();
        savings = savingsDao.findById(savings.getAccountId());
        savings.setUserContext(userContext);
        SavingsTrxnDetailEntity trxn = savingsPersistence.retrieveLastTransaction(savings.getAccountId(), helper.getDate("12/03/2006"));
        Assert.assertEquals(TestUtils.createMoney("500"), trxn.getAmount());
        group = savings.getCustomer();
        center = group.getParentCustomer();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsTrxnDetailEntity(org.mifos.accounts.savings.business.SavingsTrxnDetailEntity) SavingsTestHelper(org.mifos.accounts.savings.util.helpers.SavingsTestHelper) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test)

Example 3 with SavingsTestHelper

use of org.mifos.accounts.savings.util.helpers.SavingsTestHelper in project head by mifos.

the class SavingsPrdPersistenceIntegrationTest method testRetrieveSavingsAccountsForPrd.

@Test
public void testRetrieveSavingsAccountsForPrd() throws Exception {
    SavingsTestHelper helper = new SavingsTestHelper();
    createInitialObjects();
    savingsOffering = helper.createSavingsOffering("fsaf6", "ads6");
    UserContext userContext = new UserContext();
    userContext.setId(PersonnelConstants.SYSTEM_USER);
    savings = helper.createSavingsAccount("000100000000017", savingsOffering, group, AccountStates.SAVINGS_ACC_APPROVED, userContext);
    StaticHibernateUtil.flushSession();
    List<SavingsBO> savingsList = savingsProductDao.retrieveSavingsAccountsForPrd(savingsOffering.getPrdOfferingId());
    Assert.assertEquals(Integer.valueOf("1").intValue(), savingsList.size());
    savings = savingsDao.findById(savings.getAccountId());
}
Also used : UserContext(org.mifos.security.util.UserContext) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsTestHelper(org.mifos.accounts.savings.util.helpers.SavingsTestHelper) Test(org.junit.Test)

Example 4 with SavingsTestHelper

use of org.mifos.accounts.savings.util.helpers.SavingsTestHelper in project head by mifos.

the class PrdOfferingPersistenceIntegrationTest method testGetMaxPrdOfferingWithProduct.

@Test
public void testGetMaxPrdOfferingWithProduct() throws PersistenceException {
    SavingsOfferingBO savingsOffering = new SavingsTestHelper().createSavingsOffering("fsaf6", "ads6");
    Assert.assertNotNull(new PrdOfferingPersistence().getMaxPrdOffering());
    savingsOffering = null;
}
Also used : SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsTestHelper(org.mifos.accounts.savings.util.helpers.SavingsTestHelper) Test(org.junit.Test)

Example 5 with SavingsTestHelper

use of org.mifos.accounts.savings.util.helpers.SavingsTestHelper in project head by mifos.

the class PrdOfferingPersistenceIntegrationTest method testGetPrdOfferingNameCountWithSameName.

@Test
public void testGetPrdOfferingNameCountWithSameName() throws PersistenceException {
    SavingsOfferingBO savingsOffering = new SavingsTestHelper().createSavingsOffering("Savings product", "ads6");
    Assert.assertEquals(Integer.valueOf("1"), new PrdOfferingPersistence().getProductOfferingNameCount("Savings product"));
    savingsOffering = null;
}
Also used : SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsTestHelper(org.mifos.accounts.savings.util.helpers.SavingsTestHelper) Test(org.junit.Test)

Aggregations

SavingsTestHelper (org.mifos.accounts.savings.util.helpers.SavingsTestHelper)18 Test (org.junit.Test)14 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)8 MeetingBO (org.mifos.application.meeting.business.MeetingBO)6 Date (java.util.Date)4 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)4 Calendar (java.util.Calendar)3 GregorianCalendar (java.util.GregorianCalendar)3 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)3 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 ArrayList (java.util.ArrayList)1 DateTime (org.joda.time.DateTime)1 Days (org.joda.time.Days)1 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)1 SavingsTrxnDetailEntity (org.mifos.accounts.savings.business.SavingsTrxnDetailEntity)1 Holiday (org.mifos.application.holiday.business.Holiday)1 FiscalCalendarRules (org.mifos.config.FiscalCalendarRules)1 SavingsTransactionHistoryDto (org.mifos.dto.screen.SavingsTransactionHistoryDto)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1 DateTimeService (org.mifos.framework.util.DateTimeService)1