Search in sources :

Example 11 with DateMidnight

use of org.joda.time.DateMidnight in project head by mifos.

the class SavingsBOTest method setupForEachTest.

@Before
public void setupForEachTest() {
    savingsAccountBuilder = new SavingsAccountBuilder().withCustomer(savingsAccountCustomer).withPaymentStrategy(paymentStrategy).withTransactionHelper(savingsTransactionActivityHelper).withCustomerDao(customerDao).withSavingsOfficer(savingsOfficer);
    allWorkingDays = Arrays.asList(DayOfWeek.mondayAsDay(), DayOfWeek.tuesdayAsDay(), DayOfWeek.wednesdayAsDay(), DayOfWeek.thursdayAsDay(), DayOfWeek.fridayAsDay(), DayOfWeek.saturdayAsDay(), DayOfWeek.sundayAsDay());
    emptyListOfHolidays = new ArrayList<Holiday>();
    defaultWeeklyCustomerMeeting = new MeetingBuilder().every(1).weekly().startingFrom(new DateMidnight().toDate()).build();
}
Also used : Holiday(org.mifos.application.holiday.business.Holiday) DateMidnight(org.joda.time.DateMidnight) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) Before(org.junit.Before)

Example 12 with DateMidnight

use of org.joda.time.DateMidnight 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 13 with DateMidnight

use of org.joda.time.DateMidnight 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 14 with DateMidnight

use of org.joda.time.DateMidnight in project head by mifos.

the class SavingsBOTest method generateNextSetOfMeetingDatesNoHoliday.

@Ignore
@Test
public void generateNextSetOfMeetingDatesNoHoliday() throws Exception {
    // setup
    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.buildForUnitTests();
    savingsAccount.generateNextSetOfMeetingDates(allWorkingDays, emptyListOfHolidays);
    // verify
    List<SavingsScheduleEntity> sortedSavingsSchedules = getSortedSavingsScheduleEntities();
    assertThat(sortedSavingsSchedules.size(), is(20));
    DateTime installmentDate = new DateMidnight().toDateTime();
    int installmentId = 1;
    for (SavingsScheduleEntity savingsScheduleEntity : getSortedSavingsScheduleEntities()) {
        assertThat(savingsScheduleEntity.getActionDate(), is(installmentDate.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) DateMidnight(org.joda.time.DateMidnight) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 15 with DateMidnight

use of org.joda.time.DateMidnight in project head by mifos.

the class LegacyAccountDaoIntegrationTest method testGetCustomerSchedulesForAccountThatAreWithinDates.

@Test
public void testGetCustomerSchedulesForAccountThatAreWithinDates() throws Exception {
    DateTime fromDate = new DateMidnight().toDateTime().plusDays(1);
    DateTime thruDate = new DateMidnight().toDateTime().plusDays(23);
    List<CustomerScheduleEntity> affectedDates = legacyAccountDao.getCustomerSchedulesForAccountThatAreWithinDates(center.getCustomerAccount().getAccountId(), fromDate, thruDate);
    Assert.assertNotNull(affectedDates);
    Assert.assertEquals(3, affectedDates.size());
}
Also used : DateMidnight(org.joda.time.DateMidnight) CustomerScheduleEntity(org.mifos.customers.business.CustomerScheduleEntity) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

DateMidnight (org.joda.time.DateMidnight)70 DateTime (org.joda.time.DateTime)33 Test (org.junit.Test)27 ArrayList (java.util.ArrayList)10 Money (org.mifos.framework.util.helpers.Money)10 Ignore (org.junit.Ignore)8 MeetingBO (org.mifos.application.meeting.business.MeetingBO)8 LocalDate (org.joda.time.LocalDate)6 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)6 Holiday (org.mifos.application.holiday.business.Holiday)6 Date (java.util.Date)5 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)5 OfficeBO (org.mifos.customers.office.business.OfficeBO)5 HolidayBuilder (org.mifos.domain.builders.HolidayBuilder)5 AggregationInterval (org.apereo.portal.events.aggr.AggregationInterval)4 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)4 UserContext (org.mifos.security.util.UserContext)4 DateTimeZone (org.joda.time.DateTimeZone)3 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)3 Before (org.junit.Before)3