Search in sources :

Example 1 with HolidayBuilder

use of org.mifos.domain.builders.HolidayBuilder in project head by mifos.

the class SavingsBOTest method generateNextSetOfMeetingDatesMoratoriumOn12thInstallment.

@Ignore
@Test
public void generateNextSetOfMeetingDatesMoratoriumOn12thInstallment() throws Exception {
    // setup
    Holiday moratorium = new HolidayBuilder().from(new DateMidnight().toDateTime().plusWeeks(11)).to(new DateMidnight().toDateTime().plusWeeks(11)).withRepaymentMoratoriumRule().build();
    List<Holiday> withMoratorium = new ArrayList<Holiday>();
    withMoratorium.add(moratorium);
    when(savingsAccountCustomer.getCustomerMeeting()).thenReturn(customerMeetingEntity);
    when(customerMeetingEntity.getMeeting()).thenReturn(defaultWeeklyCustomerMeeting);
    when(savingsAccountCustomer.getCustomerLevel()).thenReturn(customerLevelEntity);
    when(customerLevelEntity.getId()).thenReturn(CustomerLevel.CLIENT.getValue());
    // exercise test
    savingsAccount = savingsAccountBuilder.with(moratorium).buildForUnitTests();
    savingsAccount.generateNextSetOfMeetingDates(allWorkingDays, withMoratorium);
    // verify
    List<SavingsScheduleEntity> sortedSavingsSchedules = getSortedSavingsScheduleEntities();
    assertThat(sortedSavingsSchedules.size(), is(20));
    DateTime installmentDate = new DateMidnight().toDateTime();
    int installmentId = 1;
    for (SavingsScheduleEntity savingsScheduleEntity : getSortedSavingsScheduleEntities()) {
        if (installmentId < 12) {
            assertThat("Installment " + installmentId, savingsScheduleEntity.getActionDate(), is(installmentDate.toDate()));
        } else {
            // Second and later deposits are pushed out one week by the moratorium
            assertThat("Installment " + installmentId, savingsScheduleEntity.getActionDate(), is(installmentDate.plusWeeks(1).toDate()));
        }
        assertThat(savingsScheduleEntity.getDeposit(), is(new Money(TestUtils.RUPEE, "13.0")));
        assertThat(savingsScheduleEntity.getDepositPaid(), is(new Money(TestUtils.RUPEE, "0.0")));
        installmentDate = installmentDate.plusWeeks(1);
        installmentId++;
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) Holiday(org.mifos.application.holiday.business.Holiday) DateMidnight(org.joda.time.DateMidnight) ArrayList(java.util.ArrayList) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with HolidayBuilder

use of org.mifos.domain.builders.HolidayBuilder in project head by mifos.

the class SavingsBOTest method depositScheduleIsGeneratedOnCreationWithMoratoriumOnSecondScheduledDeposit.

/**
     * passing locally on eclipse but not on maven.
     */
@Ignore
@Test
public void depositScheduleIsGeneratedOnCreationWithMoratoriumOnSecondScheduledDeposit() {
    // setup
    Holiday moratorium = new HolidayBuilder().from(new DateMidnight().toDateTime().plusWeeks(1)).to(new DateMidnight().toDateTime().plusWeeks(1)).withRepaymentMoratoriumRule().build();
    when(savingsAccountCustomer.getCustomerMeeting()).thenReturn(customerMeetingEntity);
    when(customerMeetingEntity.getMeeting()).thenReturn(defaultWeeklyCustomerMeeting);
    when(savingsAccountCustomer.getCustomerLevel()).thenReturn(customerLevelEntity);
    when(customerLevelEntity.getId()).thenReturn(CustomerLevel.CLIENT.getValue());
    // exercise test
    savingsAccount = savingsAccountBuilder.with(moratorium).buildForUnitTests();
    // verify
    List<SavingsScheduleEntity> sortedSavingsSchedules = getSortedSavingsScheduleEntities();
    assertThat(sortedSavingsSchedules.size(), is(10));
    DateTime installmentDate = new DateMidnight().toDateTime();
    int installmentId = 1;
    for (SavingsScheduleEntity savingsScheduleEntity : sortedSavingsSchedules) {
        if (installmentId < 2) {
            assertThat("Installment " + installmentId, new LocalDate(savingsScheduleEntity.getActionDate()), is(new LocalDate(installmentDate.toDate())));
        } else {
            // Second and later deposits are pushed out one week by the moratorium
            assertThat("Installment " + installmentId, new LocalDate(savingsScheduleEntity.getActionDate()), is(new LocalDate(installmentDate.plusWeeks(1).toDate())));
        }
        assertThat(savingsScheduleEntity.getDeposit(), is(new Money(TestUtils.RUPEE, "13.0")));
        assertThat(savingsScheduleEntity.getDepositPaid(), is(new Money(TestUtils.RUPEE, "0.0")));
        installmentDate = installmentDate.plusWeeks(1);
        installmentId++;
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) Holiday(org.mifos.application.holiday.business.Holiday) DateMidnight(org.joda.time.DateMidnight) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) 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 3 with HolidayBuilder

use of org.mifos.domain.builders.HolidayBuilder in project head by mifos.

the class SavingsBOTest method generateNextSetOfMeetingDatesMoratoriumOn2ndInstallment.

/**
     * passing locally on eclipse but not on maven.
     */
@Ignore
@Test
public void generateNextSetOfMeetingDatesMoratoriumOn2ndInstallment() throws Exception {
    // setup
    Holiday moratorium = new HolidayBuilder().from(new DateMidnight().toDateTime().plusWeeks(1)).to(new DateMidnight().toDateTime().plusWeeks(1)).withRepaymentMoratoriumRule().build();
    List<Holiday> withMoratorium = new ArrayList<Holiday>();
    withMoratorium.add(moratorium);
    when(savingsAccountCustomer.getCustomerMeeting()).thenReturn(customerMeetingEntity);
    when(customerMeetingEntity.getMeeting()).thenReturn(defaultWeeklyCustomerMeeting);
    when(savingsAccountCustomer.getCustomerLevel()).thenReturn(customerLevelEntity);
    when(customerLevelEntity.getId()).thenReturn(CustomerLevel.CLIENT.getValue());
    // exercise test
    savingsAccount = savingsAccountBuilder.with(moratorium).buildForUnitTests();
    savingsAccount.generateNextSetOfMeetingDates(allWorkingDays, withMoratorium);
    // verify
    List<SavingsScheduleEntity> sortedSavingsSchedules = getSortedSavingsScheduleEntities();
    assertThat(sortedSavingsSchedules.size(), is(20));
    DateTime installmentDate = new DateMidnight().toDateTime();
    int installmentId = 1;
    for (SavingsScheduleEntity savingsScheduleEntity : getSortedSavingsScheduleEntities()) {
        if (installmentId < 2) {
            assertThat("Installment " + installmentId, savingsScheduleEntity.getActionDate(), is(installmentDate.toDate()));
        } else {
            // Second and later deposits are pushed out one week by the moratorium
            assertThat("Installment " + installmentId, savingsScheduleEntity.getActionDate(), is(installmentDate.plusWeeks(1).toDate()));
        }
        assertThat(savingsScheduleEntity.getDeposit(), is(new Money(TestUtils.RUPEE, "13.0")));
        assertThat(savingsScheduleEntity.getDepositPaid(), is(new Money(TestUtils.RUPEE, "0.0")));
        installmentDate = installmentDate.plusWeeks(1);
        installmentId++;
    }
}
Also used : Money(org.mifos.framework.util.helpers.Money) Holiday(org.mifos.application.holiday.business.Holiday) DateMidnight(org.joda.time.DateMidnight) ArrayList(java.util.ArrayList) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with HolidayBuilder

use of org.mifos.domain.builders.HolidayBuilder in project head by mifos.

the class LegacyAccountDaoIntegrationTest method testGetListOfAccountIdsHavingLoanSchedulesWithinAHoliday.

@Test
public void testGetListOfAccountIdsHavingLoanSchedulesWithinAHoliday() throws Exception {
    Set<HolidayBO> holidays;
    DateTime fromDate = new DateMidnight().toDateTime().plusDays(1);
    DateTime thruDate = new DateMidnight().toDateTime().plusDays(30);
    GenericDao genericDao = new GenericDaoHibernate();
    OfficeDao officeDao = new OfficeDaoHibernate(genericDao);
    HolidayDao holidayDao = new HolidayDaoHibernate(genericDao);
    OfficeBO sampleBranch = officeDao.findOfficeById(this.getBranchOffice().getOfficeId());
    holidays = new HashSet<HolidayBO>();
    holiday = new HolidayBuilder().withName("Welcome Holiday").from(fromDate).to(thruDate).build();
    holidayDao.save(holiday);
    holidays.add((HolidayBO) holiday);
    sampleBranch.setHolidays(holidays);
    new OfficePersistence().createOrUpdate(sampleBranch);
    StaticHibernateUtil.flushSession();
    List<Object[]> AccountIds = legacyAccountDao.getListOfAccountIdsHavingLoanSchedulesWithinAHoliday(holiday);
    Assert.assertNotNull(AccountIds);
    assertThat(AccountIds.size(), is(2));
}
Also used : GenericDaoHibernate(org.mifos.accounts.savings.persistence.GenericDaoHibernate) GenericDao(org.mifos.accounts.savings.persistence.GenericDao) DateTime(org.joda.time.DateTime) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) HolidayDaoHibernate(org.mifos.application.holiday.persistence.HolidayDaoHibernate) DateMidnight(org.joda.time.DateMidnight) OfficeBO(org.mifos.customers.office.business.OfficeBO) OfficeDao(org.mifos.customers.office.persistence.OfficeDao) HolidayBO(org.mifos.application.holiday.business.HolidayBO) OfficeDaoHibernate(org.mifos.customers.office.persistence.OfficeDaoHibernate) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Test(org.junit.Test)

Example 5 with HolidayBuilder

use of org.mifos.domain.builders.HolidayBuilder in project head by mifos.

the class LegacyAccountDaoIntegrationTest method testGetListOfAccountIdsHavingCustomerSchedulesWithinAHoliday.

@Test
public void testGetListOfAccountIdsHavingCustomerSchedulesWithinAHoliday() throws Exception {
    Set<HolidayBO> holidays;
    DateTime fromDate = new DateMidnight().toDateTime().plusDays(1);
    DateTime thruDate = new DateMidnight().toDateTime().plusDays(30);
    GenericDao genericDao = new GenericDaoHibernate();
    OfficeDao officeDao = new OfficeDaoHibernate(genericDao);
    HolidayDao holidayDao = new HolidayDaoHibernate(genericDao);
    OfficeBO sampleBranch = officeDao.findOfficeById(this.getBranchOffice().getOfficeId());
    holidays = new HashSet<HolidayBO>();
    holiday = new HolidayBuilder().withName("Welcome Holiday").from(fromDate).to(thruDate).build();
    holidayDao.save(holiday);
    holidays.add((HolidayBO) holiday);
    sampleBranch.setHolidays(holidays);
    new OfficePersistence().createOrUpdate(sampleBranch);
    StaticHibernateUtil.flushSession();
    List<Object[]> AccountIds = legacyAccountDao.getListOfAccountIdsHavingCustomerSchedulesWithinAHoliday(holiday);
    Assert.assertNotNull(AccountIds);
    assertThat(AccountIds.size(), is(3));
}
Also used : GenericDaoHibernate(org.mifos.accounts.savings.persistence.GenericDaoHibernate) GenericDao(org.mifos.accounts.savings.persistence.GenericDao) DateTime(org.joda.time.DateTime) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) HolidayDaoHibernate(org.mifos.application.holiday.persistence.HolidayDaoHibernate) DateMidnight(org.joda.time.DateMidnight) OfficeBO(org.mifos.customers.office.business.OfficeBO) OfficeDao(org.mifos.customers.office.persistence.OfficeDao) HolidayBO(org.mifos.application.holiday.business.HolidayBO) OfficeDaoHibernate(org.mifos.customers.office.persistence.OfficeDaoHibernate) HolidayBuilder(org.mifos.domain.builders.HolidayBuilder) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Test(org.junit.Test)

Aggregations

HolidayBuilder (org.mifos.domain.builders.HolidayBuilder)35 Test (org.junit.Test)34 Holiday (org.mifos.application.holiday.business.Holiday)28 DateTime (org.joda.time.DateTime)16 Ignore (org.junit.Ignore)7 OfficeBO (org.mifos.customers.office.business.OfficeBO)7 DateMidnight (org.joda.time.DateMidnight)6 HolidayBO (org.mifos.application.holiday.business.HolidayBO)4 ArrayList (java.util.ArrayList)3 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)3 Money (org.mifos.framework.util.helpers.Money)3 LocalDate (org.joda.time.LocalDate)2 GenericDao (org.mifos.accounts.savings.persistence.GenericDao)2 GenericDaoHibernate (org.mifos.accounts.savings.persistence.GenericDaoHibernate)2 HolidayDao (org.mifos.application.holiday.persistence.HolidayDao)2 HolidayDaoHibernate (org.mifos.application.holiday.persistence.HolidayDaoHibernate)2 OfficeDao (org.mifos.customers.office.persistence.OfficeDao)2 OfficeDaoHibernate (org.mifos.customers.office.persistence.OfficeDaoHibernate)2 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)2 OfficeBuilder (org.mifos.domain.builders.OfficeBuilder)2