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

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

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

2021/02/25 * Amazon Shopping
    Expenses:Self                                60000

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

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

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

# 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.


#100DaysToOffLoad #Emacs #LedgerMode #Ledger

Journaling is a great way to keep track of your progress and emotional state, using the same journaling principle in managing your finance can be of great help to see how money flow in & out of your life :).

So, here we will explore how to journal in Emacs or any editor of your choice with the help of the tool ledger.

Before starting, let's get familiar with the basic terminologies.

  • Assets – It's the money that you have.
  • Liabilities – It's the money that you own, or you can say Debt.

Ledger is the double-entry accounting software, which means that you have to mention the flow in of the money[where from it comes like Saving account, Credit Card] and flows out of the money[expenditure, Investment, shopping] and all these entries should balance out each other and result should be zero if it's not the case there is an issue in your entries. The best part of the ledger software is that it allows you to manage your data in a simple text file and don't alter your data, and you have all your data with you.

So, Ledger read the simple text file and generate all kinds of the report that you need. Emacs comes in the picture to manage these text file and give a solid way to manage these file with org-mode also, that we will discuss some other time.

Now get ready to set up the journal system.

Installing the Tools

  • Download the Ledger on your system based on your OS from here — for the lazy ones on Ubuntu OS, you can follow the steps given below.
$ sudo add-apt-repository ppa:mbudde/ledger
$ sudo apt-get update
$ sudo apt-get install ledger
  • Open your Emacs editor and then follow these steps.

    • Press Alt-X package-install [Enter Key]
    • Type ledger-mode [Enter Key], this will install the ledger-mode package
    • Open your Emacs config file and paste this snippet. We are telling the ledger-mode to activate for the file extension of .dat file.

      (use-package ledger-mode
           :ensure t
           (setq ledger-clear-whole-transactions 1)
           :mode "\\.dat\\'")

Ledger Mode in Action

  • Create a file with the extension .dat and open it in Emacs.
  • Press Ctrl-C Ctrl-A to enter an entry in the file.
    • This will ask for the date for the entry, afterward press enter.
    • Give a nice heading to your Ledger entry and add your expense.

Ledger entry example – It's up to you how you want to maintain your journal, Some entries example to sort out your expenses.

Ledger entry example – You can also plan your budget in the ledger and can automate the transaction, if you are geeky enough you can write a code to read the spreadsheet shared by your bank to populate the ledger. – Ctrl-C Ctrl-O Ctrl-R for report generation, you can find more about reports here

#100DaysToOffload #financial-freedom #emacs