Emacs: Building Ledger Reports

I have started my financial journaling a few months back, and I am happy with the simplicity and freedom that I can have with the use of Emacs, ledger-mode, and Ledger. I have written about it before, you can check that here. Today we will talk about report generation.

So, for this post, we will be using this mock data for generating balance and monthly expense reports. Create a new file with the name ledger.dat and paste the data in it given below.

2021/02/14 * Dinner-Party
    Expenses:Food:Party                            1500
    Assets:Bank:Checking

2021/02/21 * Lunch-Party
    Expenses:Food:Party                           1600
    Assets:Bank:Checking

2021/02/22 * Home
    Expenses:Home                                   3000
    Assets:Bank:Checking                       3000
    Assets:Investment:Stocks                 180000
    Assets:Bank:Checking

2021/02/25 * Amazon Shopping
    Expenses:Self                                60000
    Assets:Bank:Checking

So let's start with the balance report, open the Emacs with the ledger.dat file, then press C-c C-o C-r. The buffer will ask the report name type in bal and hit enter, you will get the report.

Report: bal
Command: ledger -f /home/ledger.dat bal

              -66100  Assets
             -246100    Bank:Checking
              180000    Investment:Stocks
	       66100  Expenses
		3100    Food:Party
		3000    Home
	       60000    Self
--------------------
                   0

There is another way which I use mainly is from the terminal itself.

>>>  ledger balance -f ledger.dat
              -66100  Assets
             -246100    Bank:Checking
              180000    Investment:Stocks
               66100  Expenses
                3100    Food:Party
                3000    Home
               60000    Self
--------------------
                   0

If you only want to see a particular type of expense, you can easily do so by

# here we are only seeing the expenses
>>> ledger balance -f ledger.dat Expenses
               66100  Expenses
                3100    Food:Party
                3000    Home
               60000    Self
--------------------
               66100

# here we are seeing the Checking account
>>>ledger balance -f dummy.dat Checking
             -246100  Assets:Bank:Checking

We can also see month-wise expense, for that, I have changed the date in the file ledger.dat.

>>> ledger -M --period-sort "(amount)" reg ^expenses -f ledger.dat
21-Jan-01 - 21-Jan-31                             Expenses:Food:Party                                              1600                    1600
21-Feb-01 - 21-Feb-28                             Expenses:Food:Party                                              1500                    3100
                                                  Expenses:Self                                                   60000                   63100
21-Mar-01 - 21-Mar-31                             Expenses:Home                                                    3000                   66100

Reports help to see your money flow, calculate the expenses and savings.

Cheers!

#100DaysToOffLoad #Emacs #LedgerMode #Ledger