Search in sources :

Example 36 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class SavingsBOIntegrationTest method testGetDetailsOfInstallmentsInArrearsWithPaymentDone.

@Test
public void testGetDetailsOfInstallmentsInArrearsWithPaymentDone() throws Exception {
    savings = getSavingsAccount();
    AccountActionDateEntity accountActionDateEntity = savings.getAccountActionDate(Short.valueOf("1"));
    ((SavingsScheduleEntity) accountActionDateEntity).setActionDate(offSetCurrentDate(1));
    accountActionDateEntity.setPaymentStatus(PaymentStatus.PAID);
    savings = (SavingsBO) saveAndFetch(savings);
    Assert.assertEquals(savings.getDetailsOfInstallmentsInArrears().size(), 0);
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Test(org.junit.Test)

Example 37 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class SavingsBOIntegrationTest method testIsTrxnDateValid_AfterFirstMeeting.

@Test
public void testIsTrxnDateValid_AfterFirstMeeting() throws Exception {
    createInitialObjects();
    savingsOffering = TestObjectFactory.createSavingsProduct("dfasdasd1", "sad1", RecommendedAmountUnit.COMPLETE_GROUP);
    savings = helper.createSavingsAccount(savingsOffering, group, AccountState.SAVINGS_ACTIVE, userContext);
    savings = TestObjectFactory.getObject(SavingsBO.class, savings.getAccountId());
    int i = -5;
    for (AccountActionDateEntity actionDate : savings.getAccountActionDates()) {
        ((SavingsScheduleEntity) actionDate).setActionDate(offSetCurrentDate(i--));
    }
    savings.update();
    savings = TestObjectFactory.getObject(SavingsBO.class, savings.getAccountId());
    java.util.Date trxnDate = offSetCurrentDate(-5);
    Date meetingDate = new CustomerPersistence().getLastMeetingDateForCustomer(savings.getCustomer().getCustomerId());
    boolean repaymentIndependentOfMeetingEnabled = new ConfigurationPersistence().isRepaymentIndepOfMeetingEnabled();
    if (AccountingRules.isBackDatedTxnAllowed()) {
        Assert.assertTrue(savings.isTrxnDateValid(trxnDate, meetingDate, repaymentIndependentOfMeetingEnabled));
    } else {
        Assert.assertFalse(savings.isTrxnDateValid(trxnDate, meetingDate, repaymentIndependentOfMeetingEnabled));
    }
    group = TestObjectFactory.getGroup(group.getCustomerId());
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) Date(java.util.Date) ConfigurationPersistence(org.mifos.config.persistence.ConfigurationPersistence) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Date(java.util.Date) Test(org.junit.Test)

Example 38 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity in project head by mifos.

the class SavingsScheduleIntegrationTest method createWeeklySavingScheduleSecondInstallmentFallsInNextMeetingHoliday.

@Ignore
@Test
public void createWeeklySavingScheduleSecondInstallmentFallsInNextMeetingHoliday() throws Exception {
    buildAndPersistHoliday(expectedFirstDepositDate.plusWeeks(1), expectedFirstDepositDate.plusWeeks(1), RepaymentRuleTypes.NEXT_MEETING_OR_REPAYMENT);
    createClientSavingsAccount();
    short installmentId = 1;
    DateTime installmentDate = expectedFirstDepositDate;
    for (AccountActionDateEntity accountActionDate : getActionDatesSortedByDate(savingsAccount)) {
        SavingsScheduleEntity scheduleEntity = (SavingsScheduleEntity) accountActionDate;
        assertThat(scheduleEntity.getInstallmentId(), is(installmentId));
        if (installmentId == 2) {
            // only second installment pushed out one week.
            assertThat(new LocalDate(scheduleEntity.getActionDate()), is(new LocalDate(installmentDate.plusWeeks(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 39 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity 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 40 with AccountActionDateEntity

use of org.mifos.accounts.business.AccountActionDateEntity 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)

Aggregations

AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)211 Money (org.mifos.framework.util.helpers.Money)80 Test (org.junit.Test)69 ArrayList (java.util.ArrayList)58 LocalDate (org.joda.time.LocalDate)42 Date (java.util.Date)39 DateTime (org.joda.time.DateTime)33 MeetingBO (org.mifos.application.meeting.business.MeetingBO)33 AccountException (org.mifos.accounts.exceptions.AccountException)24 PaymentData (org.mifos.accounts.util.helpers.PaymentData)24 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)21 Date (java.sql.Date)19 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)19 LoanBO (org.mifos.accounts.loan.business.LoanBO)17 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)15 LoanScheduleEntity (org.mifos.accounts.loan.business.LoanScheduleEntity)14 UserContext (org.mifos.security.util.UserContext)14 Calendar (java.util.Calendar)13 GregorianCalendar (java.util.GregorianCalendar)13 CenterBuilder (org.mifos.domain.builders.CenterBuilder)13