Random Geekery

Logging Money In Org Mode

Added by to Tools on (Updated )

Tags · emacs · org ·

Backing The Flask Mega Tutorial Kickstarter Emacs Writegood Mode
Logging Money In Org Mode
Logging Money In Org Mode
(see full size in new window)

I am setting up Emacs org mode to track how I use my money. This is a healthy habit, which I applied in the past with a little paper notebook. This needs to be as easy as that little notebook, or I will never use it.

I only want to see how I use my money. This can eventually become part of a budget, but all I want today is the ability to make quick money notes.

  • My friend paid me back some money they borrowed
  • One of the housemates chipped in for groceries
  • I treated myself to coffee.

Stuff like that. Let’s see what I come up with.

The Setup

I already use journaling features of Emacs org mode to record tasks that I accomplish through the day. That journal could also record income and expenses. I need a new org capture template and menu item for money, though.

Adding a menu entry and template

org-capture-templates holds templates for creating new org entries. I manually edit mine, although the recommended approach to managing those is through the Emacs Customize interface. Old habits die hard.

;; Probably easier for most folks to manage this with Customize (C-c c C),
;; but setting this stuff directly helps me understand the structure better.

(setq org-capture-templates
       (("p" "Personal")
        ; ... other entries removed for clarity
        ("pm" "Money entry" entry
         (file+datetree "~/Sync/org/agendas/journal.org")
         "** %U - %^{Amount} %^{Summary} :money:%^g"))))

I start with fields needed for the template selection menu in org-capture. I also tell org mode to save money entries will in the journal.org file under a date tree, which presents a year / month / date heirarchy for entries. Finally, I describe the capture template.

A capture template can be a string or file containing text and template directives. A short string describes money entries. The table below explains the template expansion rules I used.

Code What it does
%U Creates an inactive timestamp, which will not appear in my regular agenda
%^{Amount} Prompts me for the dollar amount of this transaction
%^{Summary} Prompts me for a summary of this transaction
%^g Prompts me for additional tags for this transaction

This template does not validate input. I don’t know how to do that yet. I must remember to use money values for “Amount” and to tag every transaction as :income or :expense:. Later I can learn how to enforce these rules with code.

Triggering a Capture

C-c c is a global binding which starts org-capture from whatever I’m doing.

Entering org capture menu
C-c c to enter org capture menu
Choosing personal money entry
p then m for a Personal Money entry

I get prompted for Amount, Summary, and tags. Once I answer those prompts, I am shown the Capture buffer. I don’t need to change anything, so I finalize the entry with C-c C-c.

capture buffer for a money entry
C-c C-c to finalize

After I finalize the entry, Emacs closes the Capture buffer and returns me to whatever I was doing before. I can complete the whole process in about five seconds, which makes it even more convenient for me than the old paper notebook.

Filtering my agenda

Even though Org knows journal.org is an agenda file, inactive timestamps aren’t shown in the default agenda view. I’m okay with this for now. Things can get a little cluttered if I start showing every logged item.

Show me all the :money: entries

C-c a opens the menu of Agenda commands. m lets me search for tag matches. Let’s start with all :money: entries.

Filtering on the money tag
C-c a m money

Show me income

I already have the agenda match view open, so I use C-u r to refresh with a new search string, “income”.

Filtering on the income tag
C-u r income

Show me expenses

Again, I use C-u r to refresh, this time looking for entries that match “expense”.

Filtering on the expense tag
C-u r expense


Oh I want to get fancy so bad. Honestly though, I need to set the basic habit of logging all the little things I do with my money. Besides, this gives me something to learn and write future blog posts about!