List of usage examples for org.joda.time LocalDate isAfter
public boolean isAfter(ReadablePartial partial)
From source file:org.mifos.accounts.savings.business.SavingsBO.java
License:Open Source License
@Override public boolean isTrxnDateValid(Date trxnDate, Date lastMeetingDate, boolean repaymentIndependentOfMeetingEnabled) { LocalDate transactionLocalDate = new LocalDate(trxnDate); LocalDate today = new LocalDate(); if (AccountingRules.isBackDatedTxnAllowed()) { if (repaymentIndependentOfMeetingEnabled) { Date activationDate = this.getActivationDate(); return trxnDate.compareTo(DateUtils.getDateWithoutTimeStamp(activationDate)) >= 0; }//from w w w .jav a 2s. com InterestScheduledEvent postingEvent = new SavingsInterestScheduledEventFactory() .createScheduledEventFrom(this.getInterestPostingMeeting()); LocalDate nextPostingDate = new LocalDate(this.nextIntPostDate); LocalDate currentPostingPeriodStartDate = postingEvent .findFirstDateOfPeriodForMatchingDate(nextPostingDate); if (getInterestPostingMeeting().isDaily()) { if (lastIntPostDate == null) { currentPostingPeriodStartDate = new LocalDate(activationDate); } else { currentPostingPeriodStartDate = new LocalDate(lastIntPostDate).plusDays(1); } } // FIXME throw an exception with the correct reason instead of returning false if (transactionLocalDate.isBefore(currentPostingPeriodStartDate)) { return false; } LocalDate activationDate = new LocalDate(this.activationDate); if (lastMeetingDate != null) { LocalDate meetingDate = new LocalDate(lastMeetingDate); return (transactionLocalDate.isAfter(meetingDate) || transactionLocalDate.isEqual(meetingDate)) && (transactionLocalDate.isAfter(activationDate) || transactionLocalDate.isEqual(activationDate)); } return (transactionLocalDate.isAfter(activationDate) || transactionLocalDate.isEqual(activationDate)) && (transactionLocalDate.isBefore(today) || transactionLocalDate.isEqual(today)); } return transactionLocalDate.isEqual(today); }
From source file:org.mifos.accounts.savings.interest.CalendarPeriod.java
License:Open Source License
public CalendarPeriod(LocalDate startDate, LocalDate endDate) { this.startDate = startDate; this.endDate = endDate; if (startDate.isAfter(endDate)) { throw new IllegalArgumentException( "startDate cannot be after endDate of period. startDate:" + startDate + " endDate:" + endDate); }//from w w w. j a v a 2 s. c o m }
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. *//*from w w w . ja v 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. *//* w ww .ja v a 2 s.c om*/ 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
private LocalDate findNextMatchingDateFromList(LocalDate after, List<LocalDate> allMatchingDates) { LocalDate nextMatchingDate = after; for (LocalDate matchingDate : allMatchingDates) { if (matchingDate.isAfter(after)) { nextMatchingDate = matchingDate; break; }/*from w w w .j av a2 s . c om*/ } return nextMatchingDate; }
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. j a v a 2 s . c o m*/ } return nextMatchingDate; }
From source file:org.mifos.accounts.savings.struts.actionforms.SavingsApplyAdjustmentActionForm.java
License:Open Source License
private void validateDate(ActionErrors errors) { try {/* w ww . jav a 2 s. c o m*/ if (isTrxnDateEntered()) { LocalDate trxnDate = getTrxnDateLocal(); if (trxnDate.isAfter(new LocalDate())) { addError(errors, SavingsConstants.TRXN_DATE_FIELD, SavingsConstants.FUTURE_DATE, getLocalizedMessage(SavingsConstants.TRXN_DATE)); } } else { addError(errors, SavingsConstants.TRXN_DATE_FIELD, SavingsConstants.MANDATORY, getLocalizedMessage(SavingsConstants.TRXN_DATE)); } } catch (RuntimeException ex) { addError(errors, SavingsConstants.TRXN_DATE_FIELD, SavingsConstants.INVALID_TRXN_DATE, getLocalizedMessage(SavingsConstants.TRXN_DATE)); } }
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.holiday.business.HolidayBO.java
License:Open Source License
private void validateFromDateAgainstCurrentDate(final Date fromDate) { LocalDate currentDate = new LocalDate(); LocalDate fromLocalDate = new LocalDate(fromDate); if (!fromLocalDate.isAfter(currentDate)) { throw new BusinessRuleException(HolidayConstants.INVALIDFROMDATE); }/* w ww .jav a 2 s . c o m*/ }
From source file:org.mifos.application.holiday.business.HolidayBO.java
License:Open Source License
private void validateFromDateAgainstThruDate(final Date fromDate, final Date thruDate) { LocalDate fromLocalDate = new LocalDate(fromDate); LocalDate thruLocalDate = new LocalDate(thruDate); if (fromLocalDate.isAfter(thruLocalDate)) { throw new BusinessRuleException(HolidayConstants.INVALIDTHRUDATE); }//from ww w. j av a2 s .c o m }