{"action":"created","issue":{"url":"https://api.github.com/repos/aumayr/fava/issues/165","repository_url":"https://api.github.com/repos/aumayr/fava","labels_url":"https://api.github.com/repos/aumayr/fava/issues/165/labels{/name}","comments_url":"https://api.github.com/repos/aumayr/fava/issues/165/comments","events_url":"https://api.github.com/repos/aumayr/fava/issues/165/events","html_url":"https://github.com/aumayr/fava/issues/165","id":136498081,"number":165,"title":"Display budgets","user":{"login":"aumayr","id":5135450,"avatar_url":"https://avatars.githubusercontent.com/u/5135450?v=3","gravatar_id":"","url":"https://api.github.com/users/aumayr","html_url":"https://github.com/aumayr","followers_url":"https://api.github.com/users/aumayr/followers","following_url":"https://api.github.com/users/aumayr/following{/other_user}","gists_url":"https://api.github.com/users/aumayr/gists{/gist_id}","starred_url":"https://api.github.com/users/aumayr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aumayr/subscriptions","organizations_url":"https://api.github.com/users/aumayr/orgs","repos_url":"https://api.github.com/users/aumayr/repos","events_url":"https://api.github.com/users/aumayr/events{/privacy}","received_events_url":"https://api.github.com/users/aumayr/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aumayr/fava/labels/feature","name":"feature","color":"0052cc"},{"url":"https://api.github.com/repos/aumayr/fava/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/aumayr/fava/milestones/1","html_url":"https://github.com/aumayr/fava/milestones/v0.3.0","labels_url":"https://api.github.com/repos/aumayr/fava/milestones/1/labels","id":1580985,"number":1,"title":"v0.3.0","description":"","creator":{"login":"aumayr","id":5135450,"avatar_url":"https://avatars.githubusercontent.com/u/5135450?v=3","gravatar_id":"","url":"https://api.github.com/users/aumayr","html_url":"https://github.com/aumayr","followers_url":"https://api.github.com/users/aumayr/followers","following_url":"https://api.github.com/users/aumayr/following{/other_user}","gists_url":"https://api.github.com/users/aumayr/gists{/gist_id}","starred_url":"https://api.github.com/users/aumayr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aumayr/subscriptions","organizations_url":"https://api.github.com/users/aumayr/orgs","repos_url":"https://api.github.com/users/aumayr/repos","events_url":"https://api.github.com/users/aumayr/events{/privacy}","received_events_url":"https://api.github.com/users/aumayr/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":17,"state":"open","created_at":"2016-02-13T10:17:40Z","updated_at":"2016-03-18T07:15:15Z","due_on":null,"closed_at":null},"comments":24,"created_at":"2016-02-25T20:15:13Z","updated_at":"2016-04-09T17:35:27Z","closed_at":null,"body":"Beancount itself is a double-book accounting tool, and does not know of the concept of \"budgets\". \r\n\r\nBut the more I use fava I wish there would be a way to display information if a certain account is over budget. I do practice setting budgets for various \"accounts\" myself to enforce certain spending behavior, and it would be nice to integrate this into the system. \r\n\r\nIn the \"[budgeting](https://github.com/aumayr/fava/tree/budgeting)\"-branch I drafted a first version of how this might work and look:\r\n\r\n- There is a new file which contains the budget-rules. It is a simple plain-text-file and has content like this:\r\n\r\n  ```\r\n  Expenses:Food:Groceries\r\n      2013-W52       100.00 USD\r\n      2016-W01       120.00 USD\r\n      2016-W02       110.00 USD\r\n      2016-W06       150.00 USD\r\n  \r\n  Expenses:Food:Alcohol\r\n      2016-W01        20.00 USD\r\n      2016-W02        10.00 USD\r\n      2016-W06         5.00 USD\r\n  \r\n  ...\r\n  ```\r\n\r\n  The format is very simple: First, the account name (`Expenses:Food:Groceries`). Then, lines with the week of the year where this budget applies to (and starts) (`2016-W01`), and finally the amount and currency (`20.00 USD`). I will call these lines \"Budget entries\".\r\n\r\n- These budget entries represent the budget for the specified week of the year, and all weeks thereafter, until a new rule is set for a week after that. So you can set a budget of `10.00 USD` at the very first week of 2015 (`2015-W01`), and this budget applies to all weeks until a new entry starting in week 5 of that same year (`2015-W05`) appears and sets the new budget to `20.00 USD`. \r\n\r\n- A budget for a specific account, currency, start-date and end-date is then calculated by stepping through each day in that period, and adding the budget for the week of that day (divided by 7) to the total sum, until the end-date is reached. \r\n\r\nI included a test-file in `fava/util/test-budget.budget`, which contains the rules above for Groceries and Alcohol (accounts in the file generated by `bean-example`). \r\n\r\nYou can test it by starting fava with a `bean-example`-generated file, and navigating to http://localhost:5000/account/Expenses:Food/monthly_changes/ (for example). It should look like this:\r\n\r\n![screenshot](https://cloud.githubusercontent.com/assets/5135450/13332840/376008d4-dc04-11e5-9ae6-a756cb5d58af.png)\r\n\r\nThings to do:\r\n- Discussing if this is a good idea or not\r\n- Discussing if it is to be included in fava or not\r\n- Discussing if the core functionality of this should be factored out into it's own package or should stay within fava\r\n- Writing tests for the \"custom language parser\"\r\n- The budget is currently \"generated\" and displayed in the `account.html`-template, but should ultimately be either part of the API or in a second API (`BudgetAPI`?).\r\n\r\nWhat do you think @yagebu @corani @redstreet @jbms @xentac @blais "},"comment":{"url":"https://api.github.com/repos/aumayr/fava/issues/comments/207820487","html_url":"https://github.com/aumayr/fava/issues/165#issuecomment-207820487","issue_url":"https://api.github.com/repos/aumayr/fava/issues/165","id":207820487,"user":{"login":"blais","id":336019,"avatar_url":"https://avatars.githubusercontent.com/u/336019?v=3","gravatar_id":"","url":"https://api.github.com/users/blais","html_url":"https://github.com/blais","followers_url":"https://api.github.com/users/blais/followers","following_url":"https://api.github.com/users/blais/following{/other_user}","gists_url":"https://api.github.com/users/blais/gists{/gist_id}","starred_url":"https://api.github.com/users/blais/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blais/subscriptions","organizations_url":"https://api.github.com/users/blais/orgs","repos_url":"https://api.github.com/users/blais/repos","events_url":"https://api.github.com/users/blais/events{/privacy}","received_events_url":"https://api.github.com/users/blais/received_events","type":"User","site_admin":false},"created_at":"2016-04-09T17:35:27Z","updated_at":"2016-04-09T17:35:27Z","body":"On Fri, Apr 8, 2016 at 11:35 PM, Chris Grindstaff <notifications@github.com>\nwrote:\n>\n> The new custom directives do not really look good to me, because you would\n> have to specify the account for which this budget would be valid as a\n> string, which looks ugly:\n>\n> Agreed - encoding values in strings diminishes one of beancount's\n> strongest features, which is, \"help me not screw up my data.\" Maybe it\n> makes sense for the initial merge to only support the external file until\n> you get more feedback and nail down a better integrated format?\n>\nThe only reason I haven't included account names in the sets of directives\nis that they don't parse into their own datatype... they parse into 'str'\nobjects. Therefore, there's no practical way to round-trip them.\n\nShort of creating a new custom datatype for Account names - and BTW I've\nthought about it, and it would be a fair bit of work to ensure that the\ntypes are trickled down through the variious transformations on account\nnames - one thing I could do is to make the \"values\" atttribute a list of\npairs of (value, datatype).\n"}}