Feature: Schedules #14

KieranP opened this Issue May 16, 2009 · 3 comments

2 participants



Everyone has payments that need to go out weekly, fortnightly etc. Schedules would work with these payments and in combination with buckets, to ensure they that amounts needed are met on time by indicating via green/orange/red current values for scheduled events, and to automatically create expenses that have occurred since your last login. The reverse where money is expected on a regular basis would in turn add deposits that occurred since your last login. This makes management of bills/automatic payments easier to keep track of. It would also be constructed so that if a expense/deposit is created, you'll get alerts on the dashboard to review the payments made, with the ability to delete that payment, amend etc.

Model Implementation

  • User has many schedules

  • Bucket has many actions, has many schedules through actions

  • Schedule model that belongs to account, has user through account, has many actions, has many buckets through actions. Has the fields:

    • id
    • account_id
    • name
    • scheduled_time
    • recurrence (in # weeks)
    • last_executed
  • Action model that belongs to schedule, belongs to bucket. Has the fields:

    • id
    • schedule_id
    • bucket_id
    • type (expense/deposit/transfer)
    • amount (in $)

Routes Implementation

  • /accounts/1/schedules
  • /accounts/1/schedules/new
  • /accounts/1/schedules/edit/5
  • /accounts/1/schedules/show/5
  • /accounts/1/schedules/destroy/5
  • /buckets/5/schedules

UI Implementation

  • Dashboard, Buckets show, and accounts show would get new widget "Upcoming Schedules" listing name and when. Clicking will take them to schedule show page, listing the actions that schedule has in details (what type, what bucket, how much) and showing how much in in there at present in the buckets it'll be taking action in. Depending on the pages visited, schedules will be constrained to that area (dash = all, account = only in account, bucket = only in bucket).

  • Dashboard would get new widget "Recent Alerts" listing events that took place since the last login, with links to each transaction that took place for review.

    • (you may know of a faster more efficient way to do this, but the idea is here)
    • When you login, schedules are checked against the current time, scheduled time, and the last executed time. Formula for finding schedules via SQL is something like WHERE (Time.now > schedule.scheduled_time AND schedule.scheduled_time > schedule.last_executed ) (essentially, run schedules that have occurred prior to now, but after the last execution).
    • The schedule is then executed (its actions are run, depositing/subtracting money from the baskets it's tied to). and the alerts model is then populated as needed in a before_filter so alerts are available on the next request
    • The schedule is then either deleted if it isn't needed again, or is updated with Time.now for the execution time, and scheduled_time becomes scheduled_time + recurrence.weeks (where recurrence is number weeks after the last scheduled_time that is should run again)
    • A query is run again to ensure no more schedules have taken place (incase user doesn't login for 2/3 weeks. Something like this
      • while Schedule.count(:conditions => "#{Time.now} > schedule.scheduled_time AND schedule.scheduled_time > schedule.last_executed") > 0
  • Any place where buckets are listed (account buckets, dashboard etc) get modified to include amounts of transactions coming within 7 days of today. The label will be colored according to time remaining and money available.

    • In the case that we have funds in that basket are met, the label is green
    • In the case that the funds in that basket are below required levels, and the next schedule is 2 or more days, the label is orange
    • In the case that the funds in that basket are below required levels, and the next schedule is within 2 days, the label is red
  • Schedule show/destroy don't need any specific stuff, however add will need the following:

    • The link to the page will be within an account page, next to 'Buckets in xxxxx' called 'Add Schedule in xxxxx' (along with view schedules in xxxxx)
    • The new schedule form will need the following fields
      • Account selection dropdown (default to current account)
      • Actions section similar to multiple buckets expenses/deposit where you can add extra buckets. Each line has a bucket dropdown for the current account, a type dropdown (expense/deposit/transfer) and an amount). These populate actions association
      • First payment section where it has year, months and day fields. This populates the scheduled time field on creation
      • Recurrence section where you select either "one time payment" (for future payment usage, this would make recurrence fields nil) or you select the occurrence. Weekly, fortnightly, monthly, or a text fields to specify number of weeks. That amount is stored in the schedules recurrence field and used as described in the section on how alerts are created.
  • Schedules should be able to be skipped. On the schedule show page, you should be able to "Skip the next occurrence", which would then make scheduled_time on the model == (scheduled_time + recurrence.weeks), effectively skipping it till next time.


I think think this feature would be quite useful. If you have any questions about its implementation, let me know.


Sounds like you've about got it done. :) It's on my plate to implement, as this is a feature I've wanted, too, but I suspect my solution will be much simpler than what you've described here. If you'd rather implement this to your own specification, let me know and I'll hold off on mine until a patch is ready.


I'd love to help but if I can't get it done sometime tomorrow, I probably won't have time for another week or two :-( If I find some time to implement it, and it's not already done, I'll give a shot and let you know.


Took a crack at implementing this. Code at


Adding, editing, deleting and upcoming schedules are implemented. Still got to implement code to execute the actions along with other things (see commit message).

Feel free to take and continue with it. Sorry for the lack of tests.

That's all the time I'll have till next weekend. Hope this has helped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment