Getting started with budgets in ledger and org-mode

1,328 views
Skip to first unread message

Will Monroe

unread,
Jul 19, 2014, 6:35:18 PM7/19/14
to ledge...@googlegroups.com
Hello,

I'm a first-time poster on the ledger listserv although I've spent a
couple of months lurking. There's been some great correspondence here
and everyone seems willing to help. Community was an important factor
in my choosing to use ledger to organize my finances. The simplicity of
storing financial information in a readable text file that can be
manipulated and exported was another. I'm also enjoying learning some
of the basic accounting concepts!

I'm looking for troubleshooting advice as I attempt to get started using
use budgets with ledger. I've been happily using ledger in org-mode as
described in the worg tutorial http:bit.ly/1wIGq98 I've had no trouble
using Babel to generate simple reports. However, I am having trouble
getting the results I expect when it comes to using the budget function
described in the ledger-cli manual here http://bit.ly/UhV1fh

***
To start keeping a budget, put some periodic transactions (see Periodic
Transactions) at the top of your ledger file. A periodic transaction is
almost identical to a regular transaction, except that it begins with a
tilde and has a period expression in place of a payee.

~ Monthly
Expenses:Rent $500.00
Expenses:Food $450.00
Expenses:Auto:Gas $120.00
Expenses:Insurance $150.00
Expenses:Phone $125.00
Expenses:Utilities $100.00
Expenses:Movies $50.00
Expenses $200.00 ; all other expenses
Assets

~ Yearly
Expenses:Auto:Repair $500.00
Assets
***

These instructions and an example I found elsewhere (although I can't
locate the source now) has led me to believe that I should be able to
generate a comparison between income, expenses, and the budget with code
and a journal that looks like this:

***
#+name: balance and budget
#+begin_src ledger :cmdline --budget register ^expenses :noweb yes
~ Monthly
expenses:rent $500.00
2010/07/22 * Got paid
assets:bank:checking $1000.00
income:salary
2010/07/23 Rent
expenses:rent $500.00
assets:bank:checking
#+end_src
***

When I run the code by typing C-c C-c on the "begin_src" line, I do not
get any results in the org file as I do with all my other commands
(e.g., when I run "bal" I get a balance). I also see this result in
Emacs Messages:

***
Evaluate this ledger code block (balance) on your system? (y or n) y
executing Ledger code block (balance)...
executing Ledger source code block
ledger -f /tmp/babel-23672nm/ledger-2367yuD --budget register ^expenses
While balancing entry:
~ Monthly
Unbalanced remainder is:
$500.00
Error: "/tmp/babel-23672nm/ledger-2367yuD", line 2: Entry does not balance
Code block evaluation complete.
***

So it seems that the code is being evaluated successfully even though,
in this case, it doesn't balance. But the output only appears in the
Emacs Messages output and not just beneath the source block as happens
when I evaluate all other code. I suppose I could use ledger-cli to
output to a file. But I'd prefer to output directly to the org file itself.

So my questions here are two-fold:

1. (Specific) Can anyone advise me on how to begin troubleshooting the
lack of output to the org file as described above?
2. (General) I'm aware that there seem to be other methods to generate
budgets using ledger and org-mode such as the excellent description
provided in Worg here http://bit.ly/1wIGq98 and Sacha Chua's example
http://bit.ly/1p4d1EU with an example file here http://bit.ly/UhV2zW
However, both are a bit beyond me at the moment. Would it be advisable
to use one of these approaches instead? I'd like to avoid spending a
lot of time learning how to create a budget only to find that there is a
simpler method.

Thanks for creating such a elegant piece of software and maintaining a
community of support around it!

All the best,

Will

Erik Hetzner

unread,
Jul 19, 2014, 8:56:39 PM7/19/14
to ledge...@googlegroups.com, Will Monroe
Hi Will,

At Sat, 19 Jul 2014 11:06:33 -0500,
Will Monroe wrote:
>
> Hello,
>
> […]
> ***
> #+name: balance and budget
> #+begin_src ledger :cmdline --budget register ^expenses :noweb yes
> ~ Monthly
> expenses:rent $500.00
> 2010/07/22 * Got paid
> assets:bank:checking $1000.00
> income:salary
> 2010/07/23 Rent
> expenses:rent $500.00
> assets:bank:checking
> #+end_src
> ***

You need another side for your Monthly budget, e.g.

~ Monthly
expenses:rent $500.00
assets

> […]
>
> So it seems that the code is being evaluated successfully even though,
> in this case, it doesn't balance. But the output only appears in the
> Emacs Messages output and not just beneath the source block as happens
> when I evaluate all other code. I suppose I could use ledger-cli to
> output to a file. But I'd prefer to output directly to the org file itself.

It’s not outputting anything because your budget transaction doesn’t
balance.

> So my questions here are two-fold:
>
> 1. (Specific) Can anyone advise me on how to begin troubleshooting the
> lack of output to the org file as described above?
> 2. (General) I'm aware that there seem to be other methods to generate
> budgets using ledger and org-mode such as the excellent description
> provided in Worg here http://bit.ly/1wIGq98 and Sacha Chua's example
> http://bit.ly/1p4d1EU with an example file here http://bit.ly/UhV2zW
> However, both are a bit beyond me at the moment. Would it be advisable
> to use one of these approaches instead? I'd like to avoid spending a
> lot of time learning how to create a budget only to find that there is a
> simpler method.

I didn’t find that ledger’s built in budgeting worked for the kind of
budgeting I wanted to do (“envelope” budgeting), so I wrote:

http://orgmode.org/worg/org-tutorials/weaving-a-budget.html

but your mileage may vary.

best, Erik

--
Sent from my free software system <http://fsf.org/>.

Will Monroe

unread,
Jul 19, 2014, 9:31:41 PM7/19/14
to ledge...@googlegroups.com
Thanks, Erik. I guess the basic concepts of double-entry accounting have
not sunk in very deeply yet ; ) I added "assets" as you suggested and it
balanced just fine.

Also, I appreciate your advice regarding ledger's built in budgeting
features. I too prefer "envelope" budgeting and would like to implement
something like it in my use of org-mode and ledger. I'll try to study
your example and see if I can't make it work.

Thanks again,

Will

Alan Schmitt

unread,
Jul 20, 2014, 2:37:53 AM7/20/14
to ledge...@googlegroups.com
On 2014-07-20 03:31, Will Monroe <wtmo...@gmail.com> writes:

> Thanks, Erik. I guess the basic concepts of double-entry accounting have
> not sunk in very deeply yet ; ) I added "assets" as you suggested and it
> balanced just fine.
>
> Also, I appreciate your advice regarding ledger's built in budgeting
> features. I too prefer "envelope" budgeting and would like to implement
> something like it in my use of org-mode and ledger. I'll try to study
> your example and see if I can't make it work.

I've been using a system very close to the one Erik describes for about
six months now, and it works great. My tweaks are mostly on the org
side, to get a table summarizing what remains in the envelopes, how much
was spent in the current and in the previous month, and average
spending. This is described here:
http://permalink.gmane.org/gmane.comp.finance.ledger.general/5673

Best,

Alan

--
OpenPGP Key ID : 040D0A3B4ED2E5C7

Gmail

unread,
Jul 20, 2014, 10:17:40 AM7/20/14
to ledge...@googlegroups.com
Alan,

Thanks for sharing this. I ran across your example when I was searching the list but it was a bit beyond me since I hadn't a working version of Erik's example at the time. But yours intrigues me. As I read this, it appears that you keep all your ledger data in a separate file, mescomptes.ledger, is that correct? Am I also correct in thinking that all of the code blocks you shared are run from within the same org file?

Will


Alan Schmitt

unread,
Jul 21, 2014, 3:39:36 AM7/21/14
to ledge...@googlegroups.com
On 2014-07-20 16:17, Gmail <wtmo...@gmail.com> writes:

> Alan,
>
> Thanks for sharing this. I ran across your example when I was
> searching the list but it was a bit beyond me since I hadn't a working
> version of Erik's example at the time. But yours intrigues me. As I
> read this, it appears that you keep all your ledger data in a separate
> file, mescomptes.ledger, is that correct?

Yes, I'm entering transactions and reconciling accounts using
ledger-mode only. The org-mode part is for reporting and dealing with
the budget.

> Am I also correct in thinking that all of the code blocks you shared
> are run from within the same org file?

Yes, but the one I only use is the table (the other code blocks are
there to support it). My workflow usually is (I do this once a week):
- enter the transactions by hand (I like doing it that way as it gives
me a good sense of how I spend money, tab completion of accounts
works great for that);
- reconcile with my bank account (the ledger-mode reconcile view is
most useful for this);
- evaluate the formulas in the big table of my org file and look at
how much I have left to spend for each envelope.

At the beginning of each month, I may tweak a little the budget, then
I run the last bit of code that generates a ledger transaction from
Unallocated to the Expense envelopes. I copy and paste this
transaction in my ledger file. (Usually I also copy and paste the
scheduled transactions for the coming month, but this is irrelevant to
the org setup.)

Monroe, Will

unread,
Jul 21, 2014, 4:36:10 PM7/21/14
to ledge...@googlegroups.com
Alan,

Thanks for sharing more detail about how you use ledger, org-mode, and
your code to generate reports. I admire the efficiency you describe
whilst continuing to log your expenses by hand. I like that you've
automated the calculations and reports but not the actual documentation
of your expenses and assets. Seems like the best of both worlds!

Thanks again,

Will
Reply all
Reply to author
Forward
0 new messages