use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class SavingsBOMoreIntegrationTest method changingSavingsAccountToInactiveRemovesRecommendedAmountsFromFutureInstallments.
@Test
public void changingSavingsAccountToInactiveRemovesRecommendedAmountsFromFutureInstallments() throws Exception {
assertAllFutureSchedulesAreAsExpected(savings, recommendedAmount);
//
PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
savings.changeStatus(AccountState.SAVINGS_INACTIVE, null, "Make Inactive", loggedInUser);
savings.save();
StaticHibernateUtil.flushSession();
// refresh hibernate data
savings = (SavingsBO) legacyAccountDao.getAccount(savings.getAccountId());
Money zero = new Money(Money.getDefaultCurrency());
assertAllFutureSchedulesAreAsExpected(savings, zero);
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class SavingsBOMoreIntegrationTest method changingSavingsAccountFromInactiveToActiveResetsRecommendedAmountsFromFutureInstallments.
@Test
public void changingSavingsAccountFromInactiveToActiveResetsRecommendedAmountsFromFutureInstallments() throws Exception {
//make inactive first
PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
savings.changeStatus(AccountState.SAVINGS_INACTIVE, null, "Make Inactive", loggedInUser);
savings.save();
StaticHibernateUtil.flushSession();
// refresh hibernate data
savings = (SavingsBO) legacyAccountDao.getAccount(savings.getAccountId());
Money zero = new Money(Money.getDefaultCurrency());
assertAllFutureSchedulesAreAsExpected(savings, zero);
//make active again
savings.changeStatus(AccountState.SAVINGS_ACTIVE, null, "Make Active Again", loggedInUser);
savings.save();
StaticHibernateUtil.flushSession();
// refresh hibernate data
savings = (SavingsBO) legacyAccountDao.getAccount(savings.getAccountId());
assertAllFutureSchedulesAreAsExpected(savings, recommendedAmount);
}
use of org.mifos.customers.personnel.business.PersonnelBO 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.customers.personnel.business.PersonnelBO in project head by mifos.
the class SavingsPostInterestTest method whenPostingInterestASingleAccountPaymentIsMade.
@Test
public void whenPostingInterestASingleAccountPaymentIsMade() {
// setup
InterestScheduledEvent postingSchedule = new MonthlyOnLastDayOfMonthInterestScheduledEvent(1);
Money interestToBePosted = TestUtils.createMoney("100");
DateTime activationDate = new DateTime().withDate(2010, 7, 20);
DateTime nextInterestPostingDate = new DateTime().withDate(2010, 7, 31);
savingsAccount = new SavingsAccountBuilder().active().withActivationDate(activationDate).withNextInterestPostingDateOf(nextInterestPostingDate).withSavingsProduct(savingsProduct).withCustomer(client).build();
// pre verification
assertTrue(savingsAccount.getAccountPayments().isEmpty());
InterestCalculationPeriodResult calculationPeriod = new InterestCalculationPeriodResultBuilder().withCalculatedInterest("100").build();
InterestPostingPeriodResult interestPostingPeriodResult = new InterestPostingPeriodResultBuilder().from(nextInterestPostingDate.toLocalDate()).to(nextInterestPostingDate.toLocalDate()).with(calculationPeriod).build();
PersonnelBO createdBy = new PersonnelBuilder().build();
// exercise
savingsAccount.postInterest(postingSchedule, interestPostingPeriodResult, createdBy);
// verification
assertFalse(savingsAccount.getAccountPayments().isEmpty());
AccountPaymentEntity interestPostingPayment = savingsAccount.getAccountPayments().get(0);
assertThat(interestPostingPayment.getAccount(), is((AccountBO) savingsAccount));
assertThat(interestPostingPayment.getAmount(), is(interestToBePosted));
assertThat(interestPostingPayment.getPaymentType().getId(), is(SavingsConstants.DEFAULT_PAYMENT_TYPE));
assertThat(new LocalDate(interestPostingPayment.getPaymentDate()), is(nextInterestPostingDate.toLocalDate()));
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class SavingsPostInterestTest method whenPostingInterestNextInterestPostingDateIsPopulatedWithNextPostingDate.
@Test
public void whenPostingInterestNextInterestPostingDateIsPopulatedWithNextPostingDate() {
// setup
InterestScheduledEvent postingSchedule = new MonthlyOnLastDayOfMonthInterestScheduledEvent(1);
DateTime activationDate = new DateTime().withDate(2010, 7, 20);
DateTime nextInterestPostingDate = new DateTime().withDate(2010, 7, 31);
savingsAccount = new SavingsAccountBuilder().active().withActivationDate(activationDate).withNextInterestPostingDateOf(nextInterestPostingDate).withSavingsProduct(savingsProduct).withCustomer(client).build();
// pre verification
assertThat(new LocalDate(savingsAccount.getNextIntPostDate()), is(nextInterestPostingDate.toLocalDate()));
InterestCalculationPeriodResult calculationPeriod = new InterestCalculationPeriodResultBuilder().withCalculatedInterest("100").build();
InterestPostingPeriodResult interestPostingPeriodResult = new InterestPostingPeriodResultBuilder().from(nextInterestPostingDate.toLocalDate()).to(nextInterestPostingDate.toLocalDate()).with(calculationPeriod).build();
PersonnelBO createdBy = new PersonnelBuilder().build();
// exercise
savingsAccount.postInterest(postingSchedule, interestPostingPeriodResult, createdBy);
// verification
assertThat(new LocalDate(savingsAccount.getNextIntPostDate()), is(endOfMonthAfter(nextInterestPostingDate)));
}
Aggregations