Hacker News new | ask | show | jobs
by akerl_ 2348 days ago
(Sorry in advance, this got way longer than I expected)

Yup. Other than the actual journal files, my full set of scripts is on GitHub. The documentation isn’t necessarily stellar, and there’s some sprawl due to the organic nature of the scripts, but I’ll try to call out the interesting pieces:

For starters, I have a relatively lightweight Ruby library for interacting with Ledger journal entries: http://github.com/akerl/libledger . Definitely doesn’t support the full ledger entry spec, I’ve basically expanded it as-necessary to be used by the following 2 tools.

Ballista ( https://github.com/akerl/ballista ) handles future projections. It consumes a YAML description of recurring expenses (shown in the readme) and can project them as ledger transactions. My projection YAML has recurring bills.

Burglar ( https://github.com/akerl/burglar ) handles posted transactions on my bank accounts. The docs are slightly out of date but correct-in-spirit; it now supports a “Plaid” module instead of the older Ally/Amex modules, and given that Plaid has support for all my banks, I use that module for 100% of the transaction parsing, with this config file: https://gist.github.com/akerl/ce93d9584f6cf2fd2948eed6fe93cb... . The creds get stored separately. Burglar, based on that config, fetches all transactions for my credit/checking/savings accounts.

Both those tools can technically work alone, but they’re limited by not knowing how somebody’s particular ledger journals are set up. I store mine as one-file-per-month, one-directory-per-year, and I’ve written a little script that uses Ballista and Burglar and applies them to my journals ( https://github.com/akerl/ledgerhelpers/blob/master/ldgprojec... ). It basically takes all the already-posted content in the journals, the posted content burglar returns, and the projected content ballista generates, and sorts them out into the appropriate files.

My rough process for using this is pretty straightforward. I run ldgproject and check the git diff to see what it’s changed. Burglar uses Ledger’s built-in “xact” function to try to guess the correct expense category for transactions (for example, it knows that Starbucks for me is Expenses:Food:fastsolo and Hilton is Expenses:Travel:hotel), but I generally scroll through and correct a couple it’s gotten wrong. I also have to manually merge transactions that touch multiple accounts. For example, when I pay a credit card, the credit card payment appears on my checking and credit accounts. I have to merge the transaction_id fields onto a single transaction. I’ve considered making it smarter about IDing these kinds of transfer transactions, but it hasn’t yet bothered me enough to cause me to dig in and do it. There are also some specific transactions that I fix to be more specific than the Burglar estimation (mostly, this is my paychecks, which I break out to account for tax withholding and other pre-tax bits).

From there, I’ve got a couple helper aliases in bash that amount to “the questions I usually ask about my money”: https://github.com/akerl/dotfiles/blob/0f4e9521cbb1f087b7495...

`prj` gives me “what’s all my credit card usage mapped against my personal checking account”, which basically amounts to “not including bills and my automatic savings, am I overspending on other stuff”.

`bills` gives me “how’s the account where all my bills get auto-paid from looking”

`freg` is a generic helper for forward-projection of “what does this account look like, now and in the past/future”

`bal` shows a balance report for $right_now

`aj` is a helper to open the active journal (this month’s)

I also have a tab completion written for zsh for ledger, that will autocomplete based on account names in your journals: https://github.com/akerl/dotfiles/blob/0f4e9521cbb1f087b7495...

Beyond that, if you’re new to the ledger CLI, I highly recommend https://devhints.io/ledger as a great quick-reference. The actual upstream docs at https://www.ledger-cli.org/3.0/doc/ledger3.html are comprehensive, but if you need to find something, take a moment to skim the introduction to make sure you understand how ledger uses various terms like account/transaction/payee/etc, since it will make searching the page much saner.

If you’re still not bored, I also have a slightly outdated blog post on using the ledger files to calculate US tax liability, by taking advantage of the aforementioned splitting of paycheck transactions into net income / tax withholding / etc: https://blog.akerl.org/2016/04/27/code-and-taxes-totally-exc...

1 comments

Thanks for sharing this info!