Skip to main content

Finance under Control with Ledger (2) - The Emacs ledger mode

Doing your finances on the commandline. Or more comfortably in Emacs with ledger mode.

In the last part I wrote about how bookings in Ledger work and how they are written. Because they are just simple text files, you don't need more than a plain text editor. Choosing Emacs, the work becomes a little bit easier.

Well, admittedly, easy is not the right word when it comes to mathematics, but having your finances under control, and being not overwhelmed every January from the wave of "unexpected" bookings is a good feeling. And Emacs helps you with Ledger Mode at simply writing flawless booking records.

Automatic accountname completion

A major source of problems is that the account names (which are usually within categories) may become very long. Expenses:Living:Additional costs:Electricity is a quite ordinary account name. When you load your ledger file The Ledger Mode reads all your account names and after that you can add the parts of those account names by tab completion. In addition to the time saved on typing, this decreases the chance of typos.

Speaking of typos in account names: Ledger offers the opportunity to create unknown accounts in a booking on the fly if the don't exist. As seductive as this option is, you should stay away from it and choose the exact other way to be your way of working.

With that configuration Ledger refuses to work as soon as an account you want to book to, was not explicitly set up beforehand. This refusal may seem annoying at first, but then Ledger at least gives you a good hint which account was misspelled. Without this hint you are faced with the challenge of just having wrong values ​​in this accounts and trying to find the cause in hundreds of bookings.

Aided reality checks.

Another help to ensure that your bookkeeping does not deviate from reality, is a regular reconciliation of accounts. I do that for my current account & the credit card based on the bank statements and for my purse by simply putting the contents of it on the table.

In any case, I get the account balance that my bookkeeping should also show. The Reconcile function of the ledger mode asks me for this value when called, and then gives me a listing of all bookings that I have not yet matched with reality. Now I can sit down with my bank statement in my hand and mark all the bookings that I also see in Ledger. During this process I always see the difference of my confirmed bookings against the reality. As soon as this difference is 0, the adjustment is done, and the temporary markings become final. I never have to worry about these finalized bookings again.

Automatic report updates

Reality matching is sometimes difficult, especially with cash, because it presupposes that every cent you may have spend somewhere for some candy bar somehow gets into the accounts. For this reason, I recommend to minimize cash payments at the beginning and pay a lot with plastic. The money you get from the ATM could then be booked with an general cash account, or split, or split according to your feelings. Only those who are willing to keep disciplined notes of their cash spendings will have fun with tracking their cash expenses.

I use a USB voice recorder anyway for small notes and so the cash accounting works very well. In those cases where it becomes a bit more work to understand my expenses, it is helpful that Emacs shows me the register of my expenses in a second window. Its good to see spendings and income (when I was at the ATM) in my wallet and update immediately when I add bookings.

Suppose I think that two weeks ago I bought food for 15 Euros at the chinese food store. When I type that into my ledger I see immediately something can't be right, because the final sum of my cash accounts correspond to what I have in my wallet (and thus the 15 euros were actually spent) but the time of this spending cannot be correct because otherwise my wallet must have been temporarily in the negative numbers, which is simply not possible with cash.

So obviously it was not two, but one week ago, after I was at the ATM in between. I can make my booking shift through time and see immediately in the report whether one Booking may have been possible or not.

Automatic cleanup

Even if this function is actually nothing stunning, it is tremendously practical if you don't have to pay attention to where in the file you write your bookings, or whether you also place all decimal points below the other. The ledger mode has both functions, legible formatting and time sorting of booking. I have it even made more simple for me and call this "make pretty" by a hook every time I save my ledger file. So all data is always Formatted for easy reading

2020-02-21