use of org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent in project head by mifos.
the class MonthlyOnLastDayOfMonthInterestScheduledEventTest method shouldReturnAllMatchingMonthlyDatesStartingFromFiscalStartDateUpToCutOffDate.
@Test
public void shouldReturnAllMatchingMonthlyDatesStartingFromFiscalStartDateUpToCutOffDate() {
// setup
int every = 1;
monthlyEvent = new MonthlyOnLastDayOfMonthInterestScheduledEvent(every);
// exercise test
List<LocalDate> nextValidMatchingDate = monthlyEvent.findAllMatchingDatesFromBaseDateUpToAndIncludingNearestMatchingEndDate(startOfFiscalYear, cutOffDate);
assertThat(nextValidMatchingDate, hasItem(jan31st));
assertThat(nextValidMatchingDate, hasItem(feb28th));
assertThat(nextValidMatchingDate, hasItem(mar31st));
assertThat(nextValidMatchingDate, hasItem(apr30));
assertThat(nextValidMatchingDate, hasItem(may31st));
assertThat(nextValidMatchingDate, hasItem(jun30th));
assertThat(nextValidMatchingDate, hasItem(jul31st));
assertThat(nextValidMatchingDate, hasItem(aug31st));
assertThat(nextValidMatchingDate, hasItem(sep30th));
assertThat(nextValidMatchingDate, hasItem(oct31st));
assertThat(nextValidMatchingDate, hasItem(nov30th));
assertThat(nextValidMatchingDate, hasItem(dec31st));
}
use of org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent in project head by mifos.
the class MonthlyOnLastDayOfMonthInterestScheduledEventTest method shouldReturnFalseForInvalidMatch.
@Test
public void shouldReturnFalseForInvalidMatch() {
// setup
int every = 2;
monthlyEvent = new MonthlyOnLastDayOfMonthInterestScheduledEvent(every);
// exercise test
boolean isMatch = monthlyEvent.isAMatchingDate(jan1st, jan31st);
assertFalse(isMatch);
}
use of org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent in project head by mifos.
the class MonthlyOnLastDayOfMonthInterestScheduledEventTest method shouldReturnTrueForMatchingDateInSameMonth.
@Test
public void shouldReturnTrueForMatchingDateInSameMonth() {
// setup
int every = 1;
monthlyEvent = new MonthlyOnLastDayOfMonthInterestScheduledEvent(every);
// exercise test
boolean isMatch = monthlyEvent.isAMatchingDate(jan1st, jan31st);
assertTrue(isMatch);
}
use of org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent in project head by mifos.
the class SavingsPostInterestTest method whenPostingInterestASavingsAcitvityIsAddedWithCorrectDetails.
@Test
public void whenPostingInterestASavingsAcitvityIsAddedWithCorrectDetails() {
// 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
List<SavingsActivityEntity> savingsActivityityDetails = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
SavingsActivityEntity interestPostingActivity = savingsActivityityDetails.get(0);
assertThat(interestPostingActivity.getAccount(), is((AccountBO) savingsAccount));
assertThat(interestPostingActivity.getActivity().getId(), is(AccountActionTypes.SAVINGS_INTEREST_POSTING.getValue()));
assertThat(interestPostingActivity.getAmount(), is(TestUtils.createMoney("100")));
assertThat(datePartOf(interestPostingActivity.getTrxnCreatedDate()), is(nextInterestPostingDate.toLocalDate()));
}
use of org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent in project head by mifos.
the class SavingsPostInterestTest method whenPostingInterestSavingsAccountBalanceIsUpdatedWithAmountToBePosted.
@Test
public void whenPostingInterestSavingsAccountBalanceIsUpdatedWithAmountToBePosted() {
// 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
assertThat(savingsAccount.getSavingsBalance(), is(TestUtils.createMoney("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
assertThat(savingsAccount.getSavingsBalance(), is(TestUtils.createMoney("100")));
}
Aggregations