Search in sources :

Example 1 with Reminder

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;
}
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)

Example 2 with Reminder

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());
}
Also used : Reminder(jgnash.engine.recurring.Reminder) DailyReminder(jgnash.engine.recurring.DailyReminder) DailyReminder(jgnash.engine.recurring.DailyReminder) Test(org.junit.Test)

Example 3 with Reminder

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);
}
Also used : Reminder(jgnash.engine.recurring.Reminder) Engine(jgnash.engine.Engine)

Example 4 with Reminder

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;
}
Also used : MonthlyReminder(jgnash.engine.recurring.MonthlyReminder) WeeklyReminder(jgnash.engine.recurring.WeeklyReminder) Reminder(jgnash.engine.recurring.Reminder) OneTimeReminder(jgnash.engine.recurring.OneTimeReminder) YearlyReminder(jgnash.engine.recurring.YearlyReminder) DailyReminder(jgnash.engine.recurring.DailyReminder)

Example 5 with Reminder

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);
    }
}
Also used : Reminder(jgnash.engine.recurring.Reminder) Engine(jgnash.engine.Engine)

Aggregations

Reminder (jgnash.engine.recurring.Reminder)14 PendingReminder (jgnash.engine.recurring.PendingReminder)8 Engine (jgnash.engine.Engine)7 MonthlyReminder (jgnash.engine.recurring.MonthlyReminder)4 FXML (javafx.fxml.FXML)3 LocalDate (java.time.LocalDate)2 ArrayList (java.util.ArrayList)2 DailyReminder (jgnash.engine.recurring.DailyReminder)2 BigDecimal (java.math.BigDecimal)1 List (java.util.List)1 ResourceBundle (java.util.ResourceBundle)1 ExecutionException (java.util.concurrent.ExecutionException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 SimpleBooleanProperty (javafx.beans.property.SimpleBooleanProperty)1 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)1 TableCell (javafx.scene.control.TableCell)1 TableColumn (javafx.scene.control.TableColumn)1 CheckBoxTableCell (javafx.scene.control.cell.CheckBoxTableCell)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Account (jgnash.engine.Account)1