use of jgnash.engine.recurring.Reminder 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;
}
use of jgnash.engine.recurring.Reminder in project jgnash by ccavanaugh.
the class EngineTest method testReminders.
@Test
public void testReminders() throws IOException {
assertEquals(0, e.getReminders().size());
assertEquals(0, e.getPendingReminders().size());
Reminder r = new DailyReminder();
r.setIncrement(1);
r.setEndDate(null);
assertTrue(e.addReminder(r));
assertEquals(1, e.getReminders().size());
assertEquals(1, e.getPendingReminders().size());
// close and reopen to force check for persistence
closeEngine();
e = EngineFactory.bootLocalEngine(testFile, EngineFactory.DEFAULT, EngineFactory.EMPTY_PASSWORD);
assertEquals(e.getReminders().size(), 1);
// remove a reminder
e.removeReminder(e.getReminders().get(0));
assertEquals(0, e.getReminders().size());
assertEquals(0, e.getPendingReminders().size());
// close and reopen to force check for persistence
closeEngine();
e = EngineFactory.bootLocalEngine(testFile, EngineFactory.DEFAULT, EngineFactory.EMPTY_PASSWORD);
assertEquals(0, e.getReminders().size());
assertEquals(0, e.getPendingReminders().size());
}
use of jgnash.engine.recurring.Reminder in project jgnash by ccavanaugh.
the class RegisterTableController method handleCreateNewReminder.
private void handleCreateNewReminder() {
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
final Reminder reminder = engine.createDefaultReminder(selectedTransaction.get(), account.get());
final Optional<Reminder> optional = RecurringEntryDialog.showAndWait(reminder);
optional.ifPresent(engine::addReminder);
}
use of jgnash.engine.recurring.Reminder in project jgnash by ccavanaugh.
the class RecurringEntryDialog method generateReminder.
private Reminder generateReminder() {
RecurringTab tab = (RecurringTab) freqTab.getSelectedComponent();
Reminder r = tab.getReminder();
r.setDescription(descriptionField.getText());
r.setEnabled(enabledCheckBox.isSelected());
r.setStartDate(startDateField.getLocalDate());
r.setNotes(notesArea.getText());
r.setAutoCreate(autoEnterCheckBox.isSelected());
r.setDaysAdvance(daysBeforeField.intValue());
r.setAccount(accountCombo.getSelectedAccount());
r.setTransaction(transaction);
return r;
}
use of jgnash.engine.recurring.Reminder in project jgnash by ccavanaugh.
the class AbstractRegisterPanel method handleCreateNewReminder.
private void handleCreateNewReminder() {
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
Reminder reminder = engine.createDefaultReminder(getSelectedTransaction(), getAccount());
reminder = RecurringEntryDialog.showDialog(reminder);
if (reminder != null) {
engine.addReminder(reminder);
}
}
Aggregations