Budgeting with ledger-cli
Saturday, Aug 08, 2020
In my Personal Finance Philosophy post, I describe the importance of budgeting and acknowledge that it can be time consuming to do properly. Since I’m a software engineer by trade, I looked for software to help me with the job. Initially, that was practicing double-entry accounting for all my personal finances using GnuCash, an open-source accounting tool. It allowed me to understand the workflows, but the integrated expense matcher is terrible and I wanted something better.
I found the
ledger-cli tool which is double-entry accounting software that uses a simple text file as your database. This allows you to use version control (git) to maintain/version it and write simple scripts to update and modify it (in addition to the already powerful CLI).
My new workflow for managing my budget looks like this:
- Every month, download CSV exports of transactions from my credit card and bank accounts.
- Use JCF to match the transactions then convert them to a ledger-cli compatible file.
- Merge each ledger file into the master ledger.
- Check diffs using Git and commit the results if they look correct.
- Import the master expenses CSV into a spreadsheet and use a pivot table to break down the expenses in to budget categories.
Sound interesting? Set it up for yourself.
Download transaction CSVs
Each month, I log in to my bank and credit card accounts and download all the transactions that occurred in the last month. I know that I could automate this even more using something like Plaid, but I’m a bit security paranoid so I still do it myself. If I can’t remember where I left off in any given account, I can invoke ledger to find out:
# "Account Name" here means plain substring matching from account names # in your master ledger. It could be "Assets" to get all assets or "1234" # to get transactions for Assets:Current Assets:Checking 1234 ~/Development/ledger-scripts$ bash register.sh "Account Name"
I download CSVs for all transactions that aren’t already in the register (based off date). If I’m balancing a brand new account I prefer as much history as possible but accept that only 30/60 days is perfectly fine. Then, I match them using JCF.
Match transactions and convert to ledger format
See JCF documentation page for Matching
Merge the new ledgers
See JCF documentation page for Merging
Use git to maintain my databases
See JCF documentation page for Committing an update
Use a spreadsheet with pivot table
See JCF documentation page for Expense Reports