Search in sources :

Example 16 with MonthlyOnLastDayOfMonthInterestScheduledEvent

use of org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent 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 17 with MonthlyOnLastDayOfMonthInterestScheduledEvent

use of org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent 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 18 with MonthlyOnLastDayOfMonthInterestScheduledEvent

use of org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent 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 19 with MonthlyOnLastDayOfMonthInterestScheduledEvent

use of org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent 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)

Example 20 with MonthlyOnLastDayOfMonthInterestScheduledEvent

use of org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent in project head by mifos.

the class MonthlyOnLastDayOfMonthInterestScheduledEventTest method shouldReturnDateWithLastDayOfMonthTwoMonthFromJan.

@Test
public void shouldReturnDateWithLastDayOfMonthTwoMonthFromJan() {
    // setup
    int every = 2;
    monthlyEvent = new MonthlyOnLastDayOfMonthInterestScheduledEvent(every);
    // exercise test
    LocalDate nextValidMatchingDate = monthlyEvent.nextMatchingDateFromAlreadyMatchingDate(jan31st);
    assertThat(nextValidMatchingDate, is(mar31st));
}
Also used : MonthlyOnLastDayOfMonthInterestScheduledEvent(org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)24 MonthlyOnLastDayOfMonthInterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent)24 LocalDate (org.joda.time.LocalDate)18 InterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent)12 DateTime (org.joda.time.DateTime)8 InterestCalculationPeriodResult (org.mifos.accounts.savings.interest.InterestCalculationPeriodResult)8 InterestCalculationPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestCalculationPeriodResultBuilder)8 InterestPostingPeriodResult (org.mifos.accounts.savings.interest.InterestPostingPeriodResult)8 InterestPostingPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestPostingPeriodResultBuilder)8 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)8 PersonnelBuilder (org.mifos.domain.builders.PersonnelBuilder)8 SavingsAccountBuilder (org.mifos.domain.builders.SavingsAccountBuilder)8 DailyInterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.internal.DailyInterestScheduledEvent)4 ArrayList (java.util.ArrayList)3 AccountBO (org.mifos.accounts.business.AccountBO)3 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)2 SavingsActivityEntity (org.mifos.accounts.savings.business.SavingsActivityEntity)2 Money (org.mifos.framework.util.helpers.Money)2 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)1 SavingsTrxnDetailEntity (org.mifos.accounts.savings.business.SavingsTrxnDetailEntity)1