Search in sources :

Example 16 with InterestScheduledEvent

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)));
}
Also used : DailyInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.DailyInterestScheduledEvent) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) LocalDate(org.joda.time.LocalDate) DailyInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.DailyInterestScheduledEvent) Test(org.junit.Test)

Example 17 with InterestScheduledEvent

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)));
}
Also used : MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) DailyInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.DailyInterestScheduledEvent) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 18 with InterestScheduledEvent

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)));
}
Also used : MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) DailyInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.DailyInterestScheduledEvent) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 19 with InterestScheduledEvent

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)));
}
Also used : MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) DailyInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.DailyInterestScheduledEvent) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 20 with InterestScheduledEvent

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)));
}
Also used : MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) DailyInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.DailyInterestScheduledEvent) InterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent) MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Aggregations

InterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent)23 LocalDate (org.joda.time.LocalDate)19 Test (org.junit.Test)13 MonthlyOnLastDayOfMonthInterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent)13 DateTime (org.joda.time.DateTime)12 InterestPostingPeriodResult (org.mifos.accounts.savings.interest.InterestPostingPeriodResult)11 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)9 InterestCalculationPeriodResult (org.mifos.accounts.savings.interest.InterestCalculationPeriodResult)8 InterestCalculationPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestCalculationPeriodResultBuilder)8 InterestPostingPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestPostingPeriodResultBuilder)8 PersonnelBuilder (org.mifos.domain.builders.PersonnelBuilder)8 SavingsAccountBuilder (org.mifos.domain.builders.SavingsAccountBuilder)8 SavingsInterestScheduledEventFactory (org.mifos.accounts.savings.interest.schedule.SavingsInterestScheduledEventFactory)7 ArrayList (java.util.ArrayList)6 Date (java.util.Date)5 DailyInterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.internal.DailyInterestScheduledEvent)5 Money (org.mifos.framework.util.helpers.Money)5 CalendarPeriod (org.mifos.accounts.savings.interest.CalendarPeriod)4 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)3 AccountBO (org.mifos.accounts.business.AccountBO)3