Search in sources :

Example 51 with SavingsScheduleEntity

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

the class SavingsBOMoreIntegrationTest method assertAllFutureSchedulesAreAsExpected.

private void assertAllFutureSchedulesAreAsExpected(SavingsBO savingsParam, Money expectedAmount) {
    LocalDate currentLocalDate = new LocalDate();
    Date currentDate = DateUtils.getDateFromLocalDate(currentLocalDate);
    Assert.assertNotNull(savingsParam.getAccountActionDates());
    assertThat(savingsParam.getAccountActionDates().size(), is(10));
    for (AccountActionDateEntity accountAction : savingsParam.getAccountActionDates()) {
        if (accountAction.getActionDate().compareTo(currentDate) >= 0 && !accountAction.isPaid()) {
            SavingsScheduleEntity savingsSchedule = (SavingsScheduleEntity) accountAction;
            assertThat(savingsSchedule.getDeposit(), is(expectedAmount));
        }
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) LocalDate(org.joda.time.LocalDate) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Date(java.util.Date) LocalDate(org.joda.time.LocalDate)

Example 52 with SavingsScheduleEntity

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

the class SavingsBOIntegrationTest method testGetDetailsOfInstallmentsInArrearsForSingleInstallmentDue.

@Test
public void testGetDetailsOfInstallmentsInArrearsForSingleInstallmentDue() throws Exception {
    savings = getSavingsAccount();
    AccountActionDateEntity accountActionDateEntity = savings.getAccountActionDate((short) 1);
    ((SavingsScheduleEntity) accountActionDateEntity).setActionDate(offSetCurrentDate(1));
    savings = (SavingsBO) saveAndFetch(savings);
    Assert.assertEquals(savings.getDetailsOfInstallmentsInArrears().size(), 1);
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Test(org.junit.Test)

Example 53 with SavingsScheduleEntity

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

the class SavingsBOIntegrationTest method testGetOverDueDepositAmountForMandatoryAccounts.

@Test
public void testGetOverDueDepositAmountForMandatoryAccounts() throws Exception {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    MeetingBO meetingIntCalc = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    MeetingBO meetingIntPost = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    SavingsOfferingBO savingsOffering = TestObjectFactory.createSavingsProduct("SavingPrd1", ApplicableTo.GROUPS, new Date(System.currentTimeMillis()), PrdStatus.SAVINGS_ACTIVE, 300.0, RecommendedAmountUnit.PER_INDIVIDUAL, 1.2, 200.0, 200.0, SavingsType.MANDATORY, InterestCalcType.MINIMUM_BALANCE, meetingIntCalc, meetingIntPost);
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    client1 = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
    savings = TestObjectFactory.createSavingsAccount("43245434", client1, Short.valueOf("16"), new Date(System.currentTimeMillis()), savingsOffering);
    Session session = StaticHibernateUtil.getSessionTL();
    StaticHibernateUtil.startTransaction();
    SavingsScheduleEntity accountActionDate = (SavingsScheduleEntity) savings.getAccountActionDate((short) 1);
    accountActionDate.setDepositPaid(TestUtils.createMoney("100.0"));
    session.update(savings);
    StaticHibernateUtil.flushSession();
    accountActionDate = (SavingsScheduleEntity) savings.getAccountActionDate((short) 3);
    Assert.assertEquals(getRoundedMoney(300.00), savings.getOverDueDepositAmount(accountActionDate.getActionDate()));
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Date(java.util.Date) Session(org.hibernate.Session) Test(org.junit.Test)

Example 54 with SavingsScheduleEntity

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

the class SavingsBOIntegrationTest method testGetTotalAmountDueForNextInstallmentWithPartialPayment.

@Test
public void testGetTotalAmountDueForNextInstallmentWithPartialPayment() throws Exception {
    savings = getSavingsAccount();
    SavingsScheduleEntity accountActionDateEntity = (SavingsScheduleEntity) savings.getAccountActionDate((short) 1);
    accountActionDateEntity.setDepositPaid(new Money(getCurrency(), "20.0"));
    savings = (SavingsBO) saveAndFetch(savings);
    Assert.assertEquals(savings.getTotalAmountDueForNextInstallment(), getRoundedMoney(180.0));
}
Also used : Money(org.mifos.framework.util.helpers.Money) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Test(org.junit.Test)

Example 55 with SavingsScheduleEntity

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

the class SavingsBOIntegrationTest method testGetTotalAmountDueWithPartialPayment.

@Test
public void testGetTotalAmountDueWithPartialPayment() throws Exception {
    savings = getSavingsAccount();
    SavingsScheduleEntity accountActionDateEntity = (SavingsScheduleEntity) savings.getAccountActionDate((short) 1);
    accountActionDateEntity.setDepositPaid(new Money(getCurrency(), "20.0"));
    accountActionDateEntity.setActionDate(offSetCurrentDate(1));
    savings = (SavingsBO) saveAndFetch(savings);
    Assert.assertEquals(savings.getTotalAmountDue(), TestUtils.createMoney(380.0));
}
Also used : Money(org.mifos.framework.util.helpers.Money) 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