use of org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent in project head by mifos.
the class CalendarPeriodHelperTest method shouldDetermineLowerAndUpperDateRangesForDailyScheduledEvent.
@Test
public void shouldDetermineLowerAndUpperDateRangesForDailyScheduledEvent() {
// setup
LocalDate firstDepositDate = new LocalDate().withYear(2010).withMonthOfYear(9).withDayOfMonth(1);
InterestScheduledEvent every14Days = new DailyInterestScheduledEvent(14);
// exercise test
List<CalendarPeriod> validIntervals = this.calendarPeriodHelper.determineAllPossiblePeriods(firstDepositDate, every14Days, october5th);
// verification
assertFalse(validIntervals.isEmpty());
assertThat(validIntervals.get(0).getStartDate(), is(new LocalDate().withYear(2010).withMonthOfYear(9).withDayOfMonth(1)));
assertThat(validIntervals.get(0).getEndDate(), is(new LocalDate().withYear(2010).withMonthOfYear(9).withDayOfMonth(9)));
assertThat(validIntervals.get(1).getStartDate(), is(new LocalDate().withYear(2010).withMonthOfYear(9).withDayOfMonth(10)));
assertThat(validIntervals.get(1).getEndDate(), is(new LocalDate().withYear(2010).withMonthOfYear(9).withDayOfMonth(23)));
}
use of org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent in project head by mifos.
the class CalendarPeriodHelperTest method shouldDetermineAllPossiblePostingIntervals.
@Test
public void shouldDetermineAllPossiblePostingIntervals() {
// setup
LocalDate march1st = new LocalDate().withYear(2010).withMonthOfYear(3).withDayOfMonth(1);
LocalDate endOfYear = new LocalDate().withYear(2010).withMonthOfYear(12).withDayOfMonth(31);
InterestScheduledEvent postingSixMonthly = new MonthlyOnLastDayOfMonthInterestScheduledEvent(6);
// exercise test
List<CalendarPeriod> validIntervals = this.calendarPeriodHelper.determineAllPossiblePeriods(march1st, postingSixMonthly, endOfYear);
// verification
assertFalse(validIntervals.isEmpty());
assertThat(validIntervals.get(0).getStartDate(), is(march1st));
assertThat(validIntervals.get(0).getEndDate(), is(new LocalDate().withYear(2010).withMonthOfYear(6).withDayOfMonth(30)));
assertThat(validIntervals.get(1).getStartDate(), is(new LocalDate().withYear(2010).withMonthOfYear(7).withDayOfMonth(1)));
assertThat(validIntervals.get(1).getEndDate(), is(new LocalDate().withYear(2010).withMonthOfYear(12).withDayOfMonth(31)));
}
use of org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent in project head by mifos.
the class CalendarPeriodHelperTest method shouldDetermineLowerAndUpperDateRangesWithFirstDepositDateWithinFirstCalculationPeriod.
@Test
public void shouldDetermineLowerAndUpperDateRangesWithFirstDepositDateWithinFirstCalculationPeriod() {
// setup
LocalDate firstDepositDate = new LocalDate().withYear(2010).withMonthOfYear(1).withDayOfMonth(7);
InterestScheduledEvent endOfMonthEveryThreeMonths = new MonthlyOnLastDayOfMonthInterestScheduledEvent(3);
// exercise test
List<CalendarPeriod> validIntervals = this.calendarPeriodHelper.determineAllPossiblePeriods(firstDepositDate, endOfMonthEveryThreeMonths, september30th);
// verification
assertFalse(validIntervals.isEmpty());
assertThat(validIntervals.get(0).getStartDate(), is(firstDepositDate));
assertThat(validIntervals.get(0).getEndDate(), is(new LocalDate().withYear(2010).withMonthOfYear(3).withDayOfMonth(31)));
assertThat(validIntervals.get(1).getStartDate(), is(new LocalDate().withYear(2010).withMonthOfYear(4).withDayOfMonth(1)));
assertThat(validIntervals.get(1).getEndDate(), is(new LocalDate().withYear(2010).withMonthOfYear(6).withDayOfMonth(30)));
assertThat(validIntervals.get(2).getStartDate(), is(new LocalDate().withYear(2010).withMonthOfYear(7).withDayOfMonth(1)));
assertThat(validIntervals.get(2).getEndDate(), is(new LocalDate().withYear(2010).withMonthOfYear(9).withDayOfMonth(30)));
}
use of org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent in project head by mifos.
the class CalendarPeriodHelperTest method shouldDetermineLowerAndUpperDateRangesWhenFirstDepositDateIsNotWithinFirstCalculationPeriod.
@Test
public void shouldDetermineLowerAndUpperDateRangesWhenFirstDepositDateIsNotWithinFirstCalculationPeriod() {
// setup
LocalDate firstDepositDate = new LocalDate().withYear(2010).withMonthOfYear(5).withDayOfMonth(21);
InterestScheduledEvent endOfMonthEveryThreeMonths = new MonthlyOnLastDayOfMonthInterestScheduledEvent(3);
// exercise test
List<CalendarPeriod> validIntervals = this.calendarPeriodHelper.determineAllPossiblePeriods(firstDepositDate, endOfMonthEveryThreeMonths, september30th);
// verification
assertFalse(validIntervals.isEmpty());
assertThat(validIntervals.get(0).getStartDate(), is(firstDepositDate));
assertThat(validIntervals.get(0).getEndDate(), is(new LocalDate().withYear(2010).withMonthOfYear(6).withDayOfMonth(30)));
assertThat(validIntervals.get(1).getStartDate(), is(new LocalDate().withYear(2010).withMonthOfYear(7).withDayOfMonth(1)));
assertThat(validIntervals.get(1).getEndDate(), is(new LocalDate().withYear(2010).withMonthOfYear(9).withDayOfMonth(30)));
}
use of org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent in project head by mifos.
the class CalendarPeriodHelperTest method shouldDetermineLowerAndUpperDateRangesWhenFirstDepositDateIsInDifferentYear.
@Test
public void shouldDetermineLowerAndUpperDateRangesWhenFirstDepositDateIsInDifferentYear() {
// setup
LocalDate firstDepositDate = new LocalDate().withYear(2009).withMonthOfYear(8).withDayOfMonth(21);
InterestScheduledEvent endOfMonthEveryThreeMonths = new MonthlyOnLastDayOfMonthInterestScheduledEvent(3);
// exercise test
List<CalendarPeriod> validIntervals = this.calendarPeriodHelper.determineAllPossiblePeriods(firstDepositDate, endOfMonthEveryThreeMonths, september30th);
// verification
assertFalse(validIntervals.isEmpty());
assertThat(validIntervals.get(0).getStartDate(), is(firstDepositDate));
assertThat(validIntervals.get(0).getEndDate(), is(new LocalDate().withYear(2009).withMonthOfYear(9).withDayOfMonth(30)));
assertThat(validIntervals.get(1).getStartDate(), is(new LocalDate().withYear(2009).withMonthOfYear(10).withDayOfMonth(1)));
assertThat(validIntervals.get(1).getEndDate(), is(new LocalDate().withYear(2009).withMonthOfYear(12).withDayOfMonth(31)));
assertThat(validIntervals.get(2).getStartDate(), is(new LocalDate().withYear(2010).withMonthOfYear(1).withDayOfMonth(1)));
assertThat(validIntervals.get(2).getEndDate(), is(new LocalDate().withYear(2010).withMonthOfYear(3).withDayOfMonth(31)));
assertThat(validIntervals.get(3).getStartDate(), is(new LocalDate().withYear(2010).withMonthOfYear(4).withDayOfMonth(1)));
assertThat(validIntervals.get(3).getEndDate(), is(new LocalDate().withYear(2010).withMonthOfYear(6).withDayOfMonth(30)));
assertThat(validIntervals.get(4).getStartDate(), is(new LocalDate().withYear(2010).withMonthOfYear(7).withDayOfMonth(1)));
assertThat(validIntervals.get(4).getEndDate(), is(new LocalDate().withYear(2010).withMonthOfYear(9).withDayOfMonth(30)));
}
Aggregations