use of org.joda.time.DateMidnight in project head by mifos.
the class XlsClientsImporter method validateAge.
private void validateAge(final Date dateOfBirth) throws CellException, ConfigurationException {
final DateMidnight dob = new DateMidnight(dateOfBirth);
final DateTime now = new DateTime();
final Years age = Years.yearsBetween(dob, now);
final int minimumAge = ClientRules.getMinimumAge();
final int maximumAge = ClientRules.getMaximumAge();
if (age.getYears() < 0) {
throw new CellException(getMessage(XlsMessageConstants.FUTURE_DATE));
} else if (ClientRules.isAgeCheckEnabled() && !ClientRules.isAgeCheckWarningInsteadOfErrorEnabled() && (age.getYears() < minimumAge || age.getYears() > maximumAge)) {
throw new CellException(getMessage(XlsMessageConstants.INVALID_AGE, new Object[] { minimumAge, maximumAge }));
}
}
use of org.joda.time.DateMidnight in project head by mifos.
the class LegacyAccountDaoIntegrationTest method testGetLoanSchedulesForAccountThatAreWithinDates.
@Test
public void testGetLoanSchedulesForAccountThatAreWithinDates() throws Exception {
DateTime fromDate = new DateMidnight().toDateTime().plusDays(1);
DateTime thruDate = new DateMidnight().toDateTime().plusDays(30);
List<LoanScheduleEntity> affectedDates = legacyAccountDao.getLoanSchedulesForAccountThatAreWithinDates(groupLoan.getAccountId(), fromDate, thruDate);
Assert.assertNotNull(affectedDates);
Assert.assertEquals(4, affectedDates.size());
}
use of org.joda.time.DateMidnight in project head by mifos.
the class LegacyAccountDaoIntegrationTest method testGetSavingsSchedulesForAccountThatAreWithinDates.
@Test
public void testGetSavingsSchedulesForAccountThatAreWithinDates() throws Exception {
savingsBO = new TestCollectionSheetRetrieveSavingsAccountsUtils().createSavingsAccount(group, "clm", "3.0", false, false);
DateTime fromDate = new DateMidnight().toDateTime().plusDays(1);
DateTime thruDate = new DateMidnight().toDateTime().plusDays(37);
List<SavingsScheduleEntity> affectedDates = legacyAccountDao.getSavingsSchedulesForAccountThatAreWithinDates(savingsBO.getAccountId(), fromDate, thruDate);
Assert.assertNotNull(affectedDates);
Assert.assertEquals(5, affectedDates.size());
}
use of org.joda.time.DateMidnight in project head by mifos.
the class TestUtils method assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek.
public static void assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(CustomerBO customer, WeekDay expectedDayOfWeek) {
Set<AccountActionDateEntity> customerSchedules = customer.getCustomerAccount().getAccountActionDates();
for (AccountActionDateEntity accountActionDateEntity : customerSchedules) {
CustomerScheduleEntity customerSchedule = (CustomerScheduleEntity) accountActionDateEntity;
LocalDate scheduledDate = new LocalDate(customerSchedule.getActionDate());
DateTime endOfCurrentInstallmentPeriod = TestUtils.nearestDateMatchingPeriodStartingOn(new DateMidnight().toDateTime(), customer.getCustomerMeetingValue());
if (scheduledDate.isAfter(new LocalDate(endOfCurrentInstallmentPeriod))) {
assertThat(scheduledDate.dayOfWeek().get(), is(WeekDay.getJodaDayOfWeekThatMatchesMifosWeekDay(expectedDayOfWeek.getValue())));
}
}
}
use of org.joda.time.DateMidnight in project head by mifos.
the class HolidayServiceFacadeWebTierTest method validateDisbursementDateIsNotInHolidayShouldThrowExceptionWhenDateIsInAHoliday.
@Test
public void validateDisbursementDateIsNotInHolidayShouldThrowExceptionWhenDateIsInAHoliday() throws Exception {
DateTime disbursementDate = new DateMidnight().toDateTime().withDayOfWeek(DayOfWeek.monday());
List<Holiday> holidays = new ArrayList<Holiday>();
Holiday holiday = new HolidayBuilder().from(disbursementDate.minusDays(1)).to(disbursementDate.plusDays(6)).build();
holidays.add(holiday);
try {
when(holidayDao.findAllHolidaysFromDateAndNext(officeId, new LocalDate(disbursementDate).toString())).thenReturn(holidays);
holidayServiceFacade.validateDisbursementDateForNewLoan(officeId, disbursementDate);
fail("Should have thrown BusinessRuleException");
} catch (BusinessRuleException e) {
assertThat(e.getMessageKey(), is(LoanExceptionConstants.DISBURSEMENTDATE_MUST_NOT_BE_IN_A_HOLIDAY));
}
}
Aggregations