Search in sources :

Example 16 with SavingsScheduleEntity

use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.

the class SavingsScheduleIntegrationTest method createWeeklySavingScheduleSecondInstallmentFallsInNextWorkingDayHoliday.

@Ignore
@Test
public void createWeeklySavingScheduleSecondInstallmentFallsInNextWorkingDayHoliday() throws Exception {
    // One-day holiday on the second deposit date, Monday
    buildAndPersistHoliday(expectedFirstDepositDate.plusWeeks(1), expectedFirstDepositDate.plusWeeks(1), RepaymentRuleTypes.NEXT_WORKING_DAY);
    createClientSavingsAccount();
    short installmentId = 1;
    DateTime installmentDate = expectedFirstDepositDate;
    for (AccountActionDateEntity accountActionDate : getActionDatesSortedByDate(savingsAccount)) {
        SavingsScheduleEntity scheduleEntity = (SavingsScheduleEntity) accountActionDate;
        assertThat(scheduleEntity.getInstallmentId(), is(installmentId));
        if (installmentId == 2) {
            assertThat(new LocalDate(scheduleEntity.getActionDate()), //Tuesday after holiday
            is(new LocalDate(installmentDate.plusDays(1).toDate())));
        } else {
            assertThat(new LocalDate(scheduleEntity.getActionDate()), is(new LocalDate(installmentDate.toDate())));
        }
        assertThat(scheduleEntity.getDeposit().getAmountDoubleValue(), is(13.0));
        installmentId++;
        installmentDate = installmentDate.plusWeeks(1);
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 17 with SavingsScheduleEntity

use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.

the class SavingsScheduleIntegrationTest method createWeeklySavingScheduleSecondInstallmentFallsInMoratorium.

@Ignore
@Test
public void createWeeklySavingScheduleSecondInstallmentFallsInMoratorium() throws Exception {
    buildAndPersistHoliday(expectedFirstDepositDate.plusWeeks(1), expectedFirstDepositDate.plusWeeks(1), RepaymentRuleTypes.REPAYMENT_MORATORIUM);
    createClientSavingsAccount();
    short installmentId = 1;
    DateTime installmentDate = expectedFirstDepositDate;
    for (AccountActionDateEntity accountActionDate : getActionDatesSortedByDate(savingsAccount)) {
        SavingsScheduleEntity scheduleEntity = (SavingsScheduleEntity) accountActionDate;
        assertThat(scheduleEntity.getInstallmentId(), is(installmentId));
        if (installmentId < 2) {
            assertThat(new LocalDate(scheduleEntity.getActionDate()), is(new LocalDate(installmentDate.toDate())));
        } else {
            // second and following dates pushed out one week.
            assertThat(new LocalDate(scheduleEntity.getActionDate()), is(new LocalDate(installmentDate.plusWeeks(1).toDate())));
        }
        assertThat(scheduleEntity.getDeposit().getAmountDoubleValue(), is(13.0));
        installmentId++;
        installmentDate = installmentDate.plusWeeks(1);
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 18 with SavingsScheduleEntity

use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.

the class SavingsBOIntegrationTest method testGetTotalAmountDueForCenter.

@Test
public void testGetTotalAmountDueForCenter() throws Exception {
    savings = getSavingsAccountForCenter();
    Money dueAmount = new Money(getCurrency());
    for (AccountActionDateEntity actionDate : savings.getAccountActionDates()) {
        dueAmount = dueAmount.add(((SavingsScheduleEntity) actionDate).getDeposit());
        break;
    }
    dueAmount = dueAmount.add(dueAmount);
    Assert.assertEquals(dueAmount, savings.getTotalAmountDue());
}
Also used : Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Test(org.junit.Test)

Example 19 with SavingsScheduleEntity

use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.

the class SavingsBOIntegrationTest method testGetTotalAmountDueForTwoInstallmentsDue.

@Test
public void testGetTotalAmountDueForTwoInstallmentsDue() throws Exception {
    savings = getSavingsAccount();
    AccountActionDateEntity accountActionDateEntity = savings.getAccountActionDate((short) 1);
    ((SavingsScheduleEntity) accountActionDateEntity).setActionDate(offSetCurrentDate(2));
    AccountActionDateEntity accountActionDateEntity2 = savings.getAccountActionDate((short) 2);
    ((SavingsScheduleEntity) accountActionDateEntity2).setActionDate(offSetCurrentDate(1));
    savings = (SavingsBO) saveAndFetch(savings);
    Assert.assertEquals(savings.getTotalAmountInArrears(), TestUtils.createMoney(400.0));
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Test(org.junit.Test)

Example 20 with SavingsScheduleEntity

use of org.mifos.accounts.savings.business.SavingsScheduleEntity in project head by mifos.

the class SavingsBOIntegrationTest method testGetTotalAmountDueForTwoInstallments.

@Test
public void testGetTotalAmountDueForTwoInstallments() throws Exception {
    savings = getSavingsAccount();
    AccountActionDateEntity accountActionDateEntity = savings.getAccountActionDate((short) 1);
    ((SavingsScheduleEntity) accountActionDateEntity).setActionDate(offSetCurrentDate(2));
    AccountActionDateEntity accountActionDateEntity2 = savings.getAccountActionDate((short) 2);
    ((SavingsScheduleEntity) accountActionDateEntity2).setActionDate(offSetCurrentDate(1));
    savings = (SavingsBO) saveAndFetch(savings);
    Assert.assertEquals(savings.getTotalAmountDue(), TestUtils.createMoney(600.0));
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Test(org.junit.Test)

Aggregations

SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)56 Test (org.junit.Test)48 Money (org.mifos.framework.util.helpers.Money)33 DateTime (org.joda.time.DateTime)32 Date (java.util.Date)27 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)19 SavingsScheduleBuilder (org.mifos.domain.builders.SavingsScheduleBuilder)18 LocalDate (org.joda.time.LocalDate)13 Ignore (org.junit.Ignore)13 DateMidnight (org.joda.time.DateMidnight)6 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)5 ArrayList (java.util.ArrayList)4 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)3 Holiday (org.mifos.application.holiday.business.Holiday)3 MeetingBO (org.mifos.application.meeting.business.MeetingBO)3 HolidayBuilder (org.mifos.domain.builders.HolidayBuilder)3 SavingsProductBuilder (org.mifos.domain.builders.SavingsProductBuilder)3 Session (org.hibernate.Session)2 AccountTrxnEntity (org.mifos.accounts.business.AccountTrxnEntity)2 UserContext (org.mifos.security.util.UserContext)2