scottohara / loot

An implementation of some of the core MS Money features in Ruby on Rails
MIT License
4 stars 3 forks source link

Auto-enter overdue schedules only does the oldest overdue occurrence #60

Closed scottohara closed 10 years ago

scottohara commented 10 years ago

If an auto-enter schedule has more than one overdue occurrence, currently only the earliest is entered.

Example

Frequency: Monthly Next Due: 1 Mar 2014 Current date: 20 May 2014

The above example implies that there are 3 x occurrences overdue (1 Mar, 1 Apr & 1 May).

Currently, the Schedule.auto_enter_overdue method selects the set of schedules where auto_enter => true and next_due_date < now; and enters each.

This would only enter the 1 Mar occurrence.

To ensure that all overdue occurrences are entered, either the Schedule.auto_enter_overdue method needs to internally loop until the next_due_date of each overdue schedule is in the future; or the LoginsController#create action needs to repeatedly call Schedule.auto_enter_overdue until there are no more overdue schedules.