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));
}
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();
}
}
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());
}
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;
}
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;
}
Aggregations