Search in sources :

Example 1 with RecurringIterator

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;
}
Also used : PendingReminder(jgnash.engine.recurring.PendingReminder) PendingReminder(jgnash.engine.recurring.PendingReminder) MonthlyReminder(jgnash.engine.recurring.MonthlyReminder) Reminder(jgnash.engine.recurring.Reminder) RecurringIterator(jgnash.engine.recurring.RecurringIterator) ArrayList(java.util.ArrayList) LocalDate(java.time.LocalDate)

Aggregations

LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1 MonthlyReminder (jgnash.engine.recurring.MonthlyReminder)1 PendingReminder (jgnash.engine.recurring.PendingReminder)1 RecurringIterator (jgnash.engine.recurring.RecurringIterator)1 Reminder (jgnash.engine.recurring.Reminder)1