List of usage examples for org.joda.time LocalDate isEqual
public boolean isEqual(ReadablePartial partial)
From source file:org.mifos.accounts.savings.interest.CalendarPeriod.java
License:Open Source License
/** * checks that <code>date</code> occurs within the {@link CalendarPeriod} with startDate and endDate inclusive. *//* ww w. j av a 2 s . c o m*/ public boolean contains(LocalDate date) { return (date.isEqual(this.startDate) || date.isAfter(this.startDate)) && (date.isEqual(this.endDate) || date.isBefore(endDate)); }
From source file:org.mifos.accounts.savings.interest.CalendarPeriodHelper.java
License:Open Source License
/** * determines all possible periods from the start of the fiscal year of the accounts first activity date. *//*ww w . j av a 2 s . com*/ public List<CalendarPeriod> determineAllPossiblePeriods(LocalDate firstActivityDate, InterestScheduledEvent interestCalculationEvent, LocalDate endDateOfLastPeriod) { List<CalendarPeriod> validIntervals = new ArrayList<CalendarPeriod>(); // fiscal start of year is jan-01 so begin at jan-01 of first deposit. LocalDate startOfFiscalYearOfFirstDeposit = new LocalDate( new DateTime().withYearOfEra(firstActivityDate.getYear()).withMonthOfYear(1).withDayOfMonth(1)); List<LocalDate> allMatchingDates = interestCalculationEvent .findAllMatchingDatesFromBaseDateUpToAndIncludingNearestMatchingEndDate( startOfFiscalYearOfFirstDeposit, endDateOfLastPeriod); for (LocalDate matchingDate : allMatchingDates) { LocalDate firstDayofInterval = interestCalculationEvent .findFirstDateOfPeriodForMatchingDate(matchingDate); CalendarPeriod interval = new CalendarPeriod(firstDayofInterval, matchingDate); if (interval.contains(firstActivityDate)) { if (matchingDate.isAfter(endDateOfLastPeriod)) { interval = new CalendarPeriod(firstActivityDate, endDateOfLastPeriod); } else { interval = new CalendarPeriod(firstActivityDate, matchingDate); } validIntervals.add(interval); } else if (matchingDate.isAfter(firstActivityDate) && matchingDate.isBefore(endDateOfLastPeriod) || matchingDate.isEqual(endDateOfLastPeriod)) { validIntervals.add(interval); } else if (matchingDate.isAfter(endDateOfLastPeriod) && (firstDayofInterval.isBefore(endDateOfLastPeriod) || firstDayofInterval.isEqual(endDateOfLastPeriod))) { interval = new CalendarPeriod(firstDayofInterval, endDateOfLastPeriod); validIntervals.add(interval); } } return validIntervals; }
From source file:org.mifos.accounts.savings.interest.schedule.internal.DailyInterestScheduledEvent.java
License:Open Source License
@Override public List<LocalDate> findAllMatchingDatesFromBaseDateUpToAndIncludingNearestMatchingEndDate( LocalDate baseDate, LocalDate cutOffDate) { List<LocalDate> allMatchingDates = new ArrayList<LocalDate>(); LocalDate previousMatchingDate = baseDate.minusDays(1); LocalDate matchingDate = nextMatchingDateFromAlreadyMatchingDate(previousMatchingDate); while (matchingDate.isEqual(cutOffDate) || matchingDate.isBefore(cutOffDate)) { allMatchingDates.add(matchingDate); matchingDate = nextMatchingDateFromAlreadyMatchingDate(matchingDate); }//from w ww . j av a 2 s . c om if (!allMatchingDates.contains(matchingDate)) { allMatchingDates.add(matchingDate); } return allMatchingDates; }
From source file:org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent.java
License:Open Source License
@Override public List<LocalDate> findAllMatchingDatesFromBaseDateUpToAndIncludingNearestMatchingEndDate( LocalDate baseDate, LocalDate cutOffDate) { List<LocalDate> allMatchingDates = new ArrayList<LocalDate>(); LocalDate previousMatchingDate = baseDate.minusDays(1); LocalDate matchingDate = nextMatchingDateFromAlreadyMatchingDate(previousMatchingDate); while (matchingDate.isEqual(cutOffDate) || matchingDate.isBefore(cutOffDate)) { allMatchingDates.add(matchingDate); matchingDate = nextMatchingDateFromAlreadyMatchingDate(matchingDate); }//from ww w .ja v a 2 s .com if (!allMatchingDates.contains(matchingDate)) { allMatchingDates.add(matchingDate); } return allMatchingDates; }
From source file:org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent.java
License:Open Source License
private LocalDate findNextMatchingDateFromList(LocalDate after, List<LocalDate> allMatchingDates) { LocalDate nextMatchingDate = after; for (LocalDate matchingDate : allMatchingDates) { if (matchingDate.isAfter(after) || matchingDate.isEqual(after)) { nextMatchingDate = matchingDate; break; }//from ww w . ja v a 2s . co m } return nextMatchingDate; }
From source file:org.mifos.application.holiday.business.HolidayBO.java
License:Open Source License
@Override public boolean encloses(final Date date) { LocalDate dateToCheck = new LocalDate(date); LocalDate fromDate = new LocalDate(getHolidayFromDate()); LocalDate thruDate = new LocalDate(getHolidayThruDate()); return ((dateToCheck.isEqual(fromDate) || dateToCheck.isAfter(fromDate)) && (dateToCheck.isBefore(thruDate) || dateToCheck.isEqual(thruDate))); }
From source file:org.mifos.application.meeting.business.MeetingBO.java
License:Open Source License
public boolean queryDateIsInMeetingIntervalForFixedDate(LocalDate queryDate, LocalDate fixedDate) { LocalDate startOfMeetingInterval = startDateForMeetingInterval(fixedDate); LocalDate endOfMeetingInterval; if (isWeekly()) { endOfMeetingInterval = startOfMeetingInterval.plusWeeks(getRecurAfter()); } else if (isMonthly()) { endOfMeetingInterval = startOfMeetingInterval.plusMonths(getRecurAfter()); } else {//from w w w.ja v a 2s. c o m // we don't handle meeting intervals in days return false; } return (queryDate.isEqual(startOfMeetingInterval) || queryDate.isAfter(startOfMeetingInterval)) && queryDate.isBefore(endOfMeetingInterval); }
From source file:org.mifos.clientportfolio.loan.ui.CashFlowSummaryFormBean.java
License:Open Source License
private void validatePaymentsAndAmounts(MessageContext messageContext, List<DateTime> actualPaymentDates, List<Number> actualPaymentAmounts) { int index = 0; LocalDate lastPaymentDate = null; BigDecimal totalPayment = BigDecimal.ZERO; for (Number actualPayment : actualPaymentAmounts) { String installment = Integer.valueOf(index + 1).toString(); LocalDate paymentDate = new LocalDate(actualPaymentDates.get(index)); if (paymentDate.isBefore(new LocalDate(this.disbursementDate))) { String defaultMessage = "The payment date cannot be before disbursement date"; ErrorEntry fieldError = new ErrorEntry("paymentDate.before.disbursementDate.invalid", "disbursementDate", defaultMessage); fieldError.setArgs(Arrays.asList(installment)); addErrorMessageToContext(messageContext, fieldError); }//w w w . ja v a 2s.c om if (paymentDate.isAfter(new LocalDate()) && actualPayment.doubleValue() > 0) { String defaultMessage = "The payment date cannot be in the future."; ErrorEntry fieldError = new ErrorEntry("paymentDate.is.future.date.invalid", "disbursementDate", defaultMessage); fieldError.setArgs(Arrays.asList(installment)); addErrorMessageToContext(messageContext, fieldError); } if (lastPaymentDate != null) { if (!paymentDate.isEqual(lastPaymentDate) && !paymentDate.isAfter(lastPaymentDate)) { String defaultMessage = "The payment date cannot be before the previous payment date"; ErrorEntry fieldError = new ErrorEntry("paymentDate.before.lastPaymentDate.invalid", "disbursementDate", defaultMessage); fieldError.setArgs(Arrays.asList(installment)); addErrorMessageToContext(messageContext, fieldError); } } BigDecimal payment = BigDecimal.valueOf(actualPayment.doubleValue()); if (payment.doubleValue() > BigDecimal.ZERO.doubleValue()) { totalPayment = totalPayment.add(payment); } index++; lastPaymentDate = paymentDate; } BigDecimal totalAllowedPayments = this.loanPrincipal.add(this.totalLoanFees).add(this.totalLoanInterest); if (totalPayment.doubleValue() > totalAllowedPayments.doubleValue()) { String defaultMessage = "Exceeds total payments allowed for loan."; ErrorEntry fieldError = new ErrorEntry("totalPayments.exceeded.invalid", "disbursementDate", defaultMessage); addErrorMessageToContext(messageContext, fieldError); } }
From source file:org.mifos.clientportfolio.newloan.domain.LoanDisbursementCoupledToCustomerMeetingScheduleStrategyImpl.java
License:Open Source License
@Override public boolean isDisbursementDateValidInRelationToSchedule(LocalDate disbursementDate) { boolean result = false; if (disbursementDate.isEqual(this.nextValidCustomerMeetingDate)) { result = true;/*from ww w.j a v a2 s. c o m*/ } else if (disbursementDate.isAfter(this.nextValidCustomerMeetingDate)) { LocalDate matchingDate = this.nextValidCustomerMeetingDate; matchingDate = new LocalDate( scheduledEvent.nextEventDateAfter(matchingDate.toDateMidnight().toDateTime())); while (matchingDate.isBefore(disbursementDate)) { matchingDate = new LocalDate( scheduledEvent.nextEventDateAfter(matchingDate.toDateMidnight().toDateTime())); } if (matchingDate.isEqual(disbursementDate)) { result = true; } } return result; }
From source file:org.mifos.customers.business.service.CustomerServiceImpl.java
License:Open Source License
@Override public final void updateClientPersonalInfo(UserContext userContext, ClientPersonalInfoUpdate personalInfo) throws CustomerException { ClientBO client = (ClientBO) this.customerDao.findCustomerById(personalInfo.getCustomerId()); client.validateVersion(personalInfo.getOriginalClientVersionNumber()); client.updateDetails(userContext);/*from w ww .java 2 s. c om*/ LocalDate currentDOB = new LocalDate(client.getDateOfBirth()); LocalDate newDOB = currentDOB; try { // updating Date of birth // doesn''t sound normal but it can be required in certain cases // see http://mifosforge.jira.com/browse/MIFOS-4368 newDOB = new LocalDate(DateUtils.getDateAsSentFromBrowser(personalInfo.getDateOfBirth())); } catch (InvalidDateException e) { throw new MifosRuntimeException(e); } if (!currentDOB.isEqual(newDOB)) { customerDao.validateClientForDuplicateNameOrGovtId(personalInfo.getClientDisplayName(), newDOB.toDateMidnight().toDate(), personalInfo.getGovernmentId()); } try { hibernateTransactionHelper.startTransaction(); hibernateTransactionHelper.beginAuditLoggingFor(client); client.updatePersonalInfo(personalInfo); clientPhotoService.update(personalInfo.getCustomerId().longValue(), personalInfo.getPicture()); customerDao.save(client); hibernateTransactionHelper.commitTransaction(); } catch (ApplicationException e) { hibernateTransactionHelper.rollbackTransaction(); throw new CustomerException(e.getKey(), e); } catch (Exception e) { hibernateTransactionHelper.rollbackTransaction(); throw new MifosRuntimeException(e); } finally { hibernateTransactionHelper.commitTransaction(); } }