Conquering personal finances the Opensource way - Introduction

April 08, 2020  ○   4 min read  ○   783 words

Now more then ever, the importance of having personal finances conquered is showing to be of immeasurable utility. Understanding inflows and outflows of allows you to make better informed decisions when deciding how to act as a consumer.

While one way to do it is to take out a fresh notebook and start writing down each transaction with pencil, it might not be the most useful ever. That is why there are number of applications online for tracking finances. There is however a better alternative, that doesn't limit you and doesn't ask for your credit card information. And best of all, it is opensource. I am talking about plain text accounting tools. Most famous tools include:

Ledger and Hledger are two of the most popular choices, and they are available for all major platforms (Linux, MacOS and Windows). I use Ledger, mainly because I am used to it, and here I will present Ledger syntax. While syntax is generally the same, I propose that you look at the documentation, if you choose to use Hledger instead.

Let's Get started

I will demonstrate power of ledger here, later I will show you how to set up permanent configuration for your finances. I use linux, but reader should be able to follow the instruction on other platforms as well.

Before starting, make sure you have installed Ledger

First, let's create our ledger file:

#UNIX
touch finances.ledger

Ledger files are basic text files, so you can edit them with text editor of your choice. If you use VIM, I propose that you get the vim-ledger plugin. If you are on the Emacs side of the editor wars you could get ledger-mode. Ledger plugin can be installed on the Atom editor too.

In plain text accounting everything is entered as a transaction. Every transaction has to have balance of zero - meaning, everything has to come from somewhere and go somewhere. Keeping this in mind,, we can start with first transaction:

# finances.ledger

2020/01/01 * Opening Balance
  Assets:Checking                       EUR  1000.00
  Assets:Savings                        EUR 10000.00
  Liabilities:Credit Card               EUR  -250.00
  Equity:Opening Balances

In every transaction one account can be written without value, ledger will automatically assign the right value to it, in order to balance out the transaction.

Now let's run first report:

# ledger -f <filename.ledger> <type of report> <account/s>
ledger -f finances.ledger bal ^Assets ^Liabilities ^Equity
# You should get the following result
        EUR 11000.00  Assets
         EUR 1000.00    Checking
        EUR 10000.00    Savings
       EUR -10750.00  Equity:Opening Balances
         EUR -250.00  Liabilities:Credit Card
--------------------
                   0

At highest level ledger provides five different accounts:

  1. Expenses — where you spend your money
  2. Assets — worth of your assets
  3. Income — where you earn your money
  4. Liabilities — money you owe
  5. Equity — your net worth when starting ledger file

The beauty of ledger, is that it allows us to create any number of accounts in any way we want. So we can detail our finances at the precision we choose.

Let's add few more transactions:

#finances.ledger 
2020/01/02 * New Year groceries
  Expenses:Groceries           EUR  69.69
  Expenses:Clothing            EUR 123.45
  Assets:Checking

2020/01/03 * Bought Bitcoin
  Assets:Crypto:Bitcoin        XBT   0.01 @ EUR 7,200
  Assets:Checking

Ledger let's you track any type of asset you like. If you bought other asset than your main currency, you want to specify at which price you have bought the asset.

Let's see the report after we have added new transaction to the 'finances.ledger' file:

ledger -f finances.ledger bal ^Assets ^Liabilities
        EUR 10734.86
            XBT 0.01  Assets
          EUR 734.86    Checking
            XBT 0.01    Crypto:Bitcoin
        EUR 10000.00    Savings
         EUR -250.00  Liabilities:Credit Card
--------------------
        EUR 10484.86
            XBT 0.01

If you want to get the report in a specific currency run the following command:

ledger -f finances.ledger bal ^Assets ^Liabilities -X EUR
        EUR 10806.86  Assets
          EUR 734.86    Checking
           EUR 72.00    Crypto:Bitcoin
        EUR 10000.00    Savings
         EUR -250.00  Liabilities:Credit Card
--------------------
        EUR 10556.86

There is a way to track change in value of specific asset, but we will get to that later.

There are some other reports you can run on your ledger file:

20-Jan-01 Opening Balance    Assets:Checking           EUR 1000.00   EUR 1000.00
                             Assets:Savings           EUR 10000.00  EUR 11000.00
                             Liabilities:Credit Card   EUR -250.00  EUR 10750.00
20-Jan-02 New Year groceries Expenses:Groceries          EUR 69.69  EUR 10819.69
                             Expenses:Clothing          EUR 123.45  EUR 10943.14
                             Assets:Checking           EUR -193.14  EUR 10750.00
20-Jan-03 Bought Bitcoin     Assets:Crypto:Bitcoin       EUR 72.00  EUR 10822.00
                             Assets:Checking            EUR -72.00  EUR 10750.00

This was only demonstration of the Ledger tool, in next few posts I will show you how to configure permanent setup for tracking finances.

Simon Sekavcnik