One of the most useful directories on my laptop

One of the most useful directories on my laptop is called finances.

Almost every single time I touch it, I'm reminded of its usefulness. Every single year when we have to file our tax returns, I'm again reminded of how useful it is. What does it contain, one might ask? It contains a log of all my financial transactions across different bank accounts (both active and inactive), in a plain-text format, dating all the way back to the beginning of 2016. At the time of this writing, this is 8 years of financial activity, in one directory (and it's even version controlled!).


Before I talk about the cool stuff, let me quickly talk about Beancount.

Beancount is one of the most useful programs (at least to me) in existence. It's an implementation of the double-entry bookkeeping system in Python. It lets you represent financial transactions - money moving from one account to another - in an easy-to-read plain text file. The file is easy to read for both humans and computers. Here's an example snippet:

2024-04-01 * "Thank you for your purchase."
    Assets:MyBank              -10.00 EUR
    Expenses:Supermarket        10.00 EUR

These three lines make up a transaction that conveys that an amount of €10 moved from your bank account to your local supermarket's account, perhaps when you went grocery shopping.

Beancount files are a collection of lots and lots of such transactions. The way everything works is that you download an export of your financial activity from your bank (usually a CSV export), run a Python program that converts the CSV to the .beancount format, and then append everything to your own .beancount file.

Over time, this file starts accumulating more and more of your financial activity and starts to grow into a documentation of essentially how your money has been moving between different accounts. This makes answering questions about your financial activity almost trivial. For instance, if you want to know how much money your side-hustle (let's call it Apple) made back in 2018, all you have to do is filter for transactions that deposit money into the Income:Hustles:Apple account (made-up name) and limit the timeframe to 2018.

The concept is quite simple but it unlocks so many cool use cases. I'll describe one here.

Efficiently preparing tax returns

At the end of the year you normally have to file tax returns. At least in the country where I live, this involves collecting lots and lots of receipts and invoices that you can send to the tax authorities as proof that your business incurred some expenses, so you can claim some of that taxed money back.

In my pre-Beancount days, this was the part I never liked. I never knew where to put receipts. How was I supposed to find and collect them? I had a Documents folder on my machine. Maybe that's where the receipts should go? Should this folder be organized by year, or by purpose, or by something else entirely? Also, what if I decide one organizational scheme one day but then after a few months I find out that that was completely stupid and I should be using a different organizational scheme? Does this mean I have to rearrange everything?

Beancount lets me solve this problem very elegantly. You see, Beancount lets me attach documents to transactions. Again, this is such a simple concept, but it is so powerful.

Let's illustrate using the following transaction.

2024-04-01 * "Thank you for your purchase."
    Assets:MyBank              -12.99 EUR
    Expenses:Netflix            12.99 EUR

Assume that this transaction lives inside finances/example.beancount. If you have a receipt from Netflix for this payment (and for whatever funky reason you want to show this as a business expense), you can create a finances/documents/ directory and place the receipt at finances/documents/Expenses/Netflix/2024-04-01.pdf, and that's it! The Expenses/Netflix/ directory tree represents the name of the account and the file name is the same as the date of the transaction. These two things make sure that that document is linked to this specific transaction.

Repeat this process with all the receipts and invoices you have and suddenly you have a system of organizing (most of) your financial documents next to your financial data. And it's even version-controlled!

So when your tax advisor asks you for all those documents to file your tax returns, it'll take you less than 5 minutes to collect everything. Because all you would have to do is go to the Fava web interface, set the time period to last year, and you'll have a list of all the relevant transactions with their documents attached. Download everything and zip it off to your tax advisor. They'll be so proud. 🫢🏻

That's it! That was the entire post, me nerding out about something I find cool.

If you found this post interesting and also like to nerd out about keeping track of personal finances and about organizing things, I wrote an entire book on this topic that you might find interesting.

The book assumes that you are comfortable with reading and writing Python code, and teaches you how you can build your own system to keep track of your personal finances in a developer-friendly manner using only open-source software. Readers have given it good feedback so far, so if you're into such nerdy topics, I think you would like it too! πŸ™ƒ