use of jgnash.engine.recurring.RecurringIterator in project jgnash by ccavanaugh.
the class Engine method getPendingReminders.
public List<PendingReminder> getPendingReminders() {
final ArrayList<PendingReminder> pendingList = new ArrayList<>();
final List<Reminder> list = getReminders();
// today's date
final LocalDate now = LocalDate.now();
for (final Reminder r : list) {
if (r.isEnabled()) {
final RecurringIterator ri = r.getIterator();
LocalDate next = ri.next();
while (next != null) {
LocalDate date = next;
if (r.isAutoCreate()) {
date = date.minusDays(r.getDaysAdvance());
}
if (DateUtils.before(date, now)) {
// need to fire this reminder
pendingList.add(new PendingReminder(r, next));
next = ri.next();
} else {
next = null;
}
}
}
}
return pendingList;
}
Aggregations