use of org.mifos.domain.builders.PersonnelBuilder 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.domain.builders.PersonnelBuilder 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)));
}
use of org.mifos.domain.builders.PersonnelBuilder in project head by mifos.
the class SavingsPostInterestTest method whenPostingInterestASavingsAcitvityIsAddedForInterestPostingEvent.
@Test
public void whenPostingInterestASavingsAcitvityIsAddedForInterestPostingEvent() {
// setup
InterestScheduledEvent postingSchedule = new MonthlyOnLastDayOfMonthInterestScheduledEvent(1);
DateTime activationDate = new DateTime().withDate(2010, 7, 20);
savingsAccount = new SavingsAccountBuilder().active().withActivationDate(activationDate).withSavingsProduct(savingsProduct).withCustomer(client).build();
// pre verification
List<SavingsActivityEntity> preSavingsActivityityDetails = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
assertThat(preSavingsActivityityDetails.size(), is(0));
InterestCalculationPeriodResult calculationPeriod = new InterestCalculationPeriodResultBuilder().withCalculatedInterest("100").build();
InterestPostingPeriodResult interestPostingPeriodResult = new InterestPostingPeriodResultBuilder().with(calculationPeriod).build();
PersonnelBO createdBy = new PersonnelBuilder().build();
// exercise
savingsAccount.postInterest(postingSchedule, interestPostingPeriodResult, createdBy);
// verification
List<SavingsActivityEntity> savingsActivityityDetails = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
assertThat(savingsActivityityDetails.size(), is(1));
}
use of org.mifos.domain.builders.PersonnelBuilder in project head by mifos.
the class SavingsCloseTest method whenClosingAccountShouldWithdrawRemainingBalanceOnAccount.
@Test
public void whenClosingAccountShouldWithdrawRemainingBalanceOnAccount() {
Money remainingBalance = TestUtils.createMoney("100");
savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(remainingBalance).build();
AccountPaymentEntity payment = new AccountPaymentEntityBuilder().with(savingsAccount).with(remainingBalance).build();
AccountNotesEntity notes = new AccountNotesEntityBuilder().build();
CustomerBO customer = new ClientBuilder().buildForUnitTests();
PersonnelBO loggedInUser = new PersonnelBuilder().build();
// pre verification
assertTrue(savingsAccount.getAccountPayments().isEmpty());
// exercise test
savingsAccount.closeAccount(payment, notes, customer, loggedInUser);
// verification
assertFalse(savingsAccount.getAccountPayments().isEmpty());
AccountPaymentEntity withdrawalPayment = savingsAccount.getAccountPayments().get(0);
assertThat(withdrawalPayment.getAmount(), is(TestUtils.createMoney("100")));
}
use of org.mifos.domain.builders.PersonnelBuilder in project head by mifos.
the class SavingsCloseTest method whenClosingAccountShouldSetClosedDate.
@Test
public void whenClosingAccountShouldSetClosedDate() {
Money remainingBalance = TestUtils.createMoney("100");
savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(remainingBalance).build();
AccountPaymentEntity payment = new AccountPaymentEntityBuilder().with(savingsAccount).with(remainingBalance).build();
AccountNotesEntity notes = new AccountNotesEntityBuilder().build();
CustomerBO customer = new ClientBuilder().buildForUnitTests();
PersonnelBO loggedInUser = new PersonnelBuilder().build();
// exercise test
savingsAccount.closeAccount(payment, notes, customer, loggedInUser);
// verification
assertThat(new LocalDate(savingsAccount.getClosedDate()), is(new LocalDate()));
}
Aggregations