financing in emacs
So I wanted to set up my emacs to, well, do my budgeting for me.
I realised that I've been overspending as a college student, and I think it's not a bad idea to set up accountability for oneself in terms of financing. And needless to mention, emacs was my go to for this. I've heard of org-ledger, but I really wanted to have a native solution with org-tables and calc and stuff.
Anyways, here's a native emacs solution to budgeting using a couple of lisp functions
and TBLFM
.
Setting up the system
I first create a file called Finances.org
.
I have 3 headers in the file:
\* Income \* Expenses \* Planned
Setting up the income tables
Income is followed by a table that tracks the various sources of money I have (and how I'm receiving them). I'll probably be adding my bank account info as well later on.
Date | Source | Account | Amount |
Setting up the expenses
#+NAME: expenses | Date | Month | Category | Description | Amount | Week | |------------+---------+--------------+--------------------------+--------+------| | 2025-05-06 | 2025-05 | | | 30 | 19 | | 2025-05-06 | 2025-05 | | | 40 | 19 | | 2025-05-06 | 2025-05 | | | 30 | 19 | #+TBLFM: $2='(substring $1 0 7) #+TBLFM: $6='(format "%02d" (car (calendar-iso-from-absolute (org-time-string-to-absolute $1))))
The formulas autofill the columns for month and week.
Checking up the monthly and weekly expenditure
| Month | Total | |---------+-------| | 2025-05 | | #+TBLFM: $2='(monthly $1)
Here monthly is a function defined as
(defun monthly (month) "Sum Amount from data-table where Month equals MONTH." (let* ((table (org-babel-ref-resolve "expenses")) (sum 0)) (dolist (row table sum) (when (and (listp row) (string= (nth 1 row) month) (nth 4 row)) (setq sum (+ sum (nth 4 row)))))))
And that's it! I agree that the lisp function isn't the best or the most efficient one but it works :) There's a very similar setup for week as well, which needs some tweaks in the lisp function. I leave it up to you to do that.
This extremely simple system is good enough for my needs. Let's see what else I'd add to it!