Home

Sharing expenses with ledger

Written on 2021-12-06

If you live with someone whom you share expenses with (a spouse, romantic partner, roomate, etc.), you might want to split those evenly. However, depending on how low their tolerance threshold to accounting is, it might be a hard sell to track all expenses properly. I've found a setup that works quite well for me using ledger.

The gist of it is: have an account representing the other person, annotate transactions that should be split as "shared" and let ledger do the rest. Here is an example:

2021-12-01 Carouf
    Expenses:Food:Groceries                12.00 EUR  ; shared
    Assets:Bank:Checking

2021-12-02 Le clerc
    Expenses:Food:Groceries                22.00 EUR  ; shared
    Assets:Reimbursements:John
What this means is that I've paid for the groceries on December 1st and John has paid for them the next day. When asking ledger for the balance after those transactions (including the bit of magic that I'll introduce later), it returns:
          -17.72 EUR  Assets
          -13.65 EUR    Bank:Checking
           -4.07 EUR    Reimbursements:John
           17.72 EUR  Expenses:Food:Groceries
--------------------
                   0
Note: This is pretty much exactly what I want. Notice that I've put John in Assets:Reimbursements. Depending on whether I expect to owe him money or be owed money, it might make more or less sense to have him in my Liabilities. Arguably, you might want to put other people outside of the standard scheme and just have their name as a top-level account. It doesn't change anything and I find having people in Assets is easiest to reason about and makes the most sense for the queries I tend to make.

The bit of magic that makes this possible and so trivial is the following:

= expr note =~ / *shared */
    $account                   -0.5
    Assets:Reimbursements:John  0.5
This leverages ledger's automated transactions. What this means is, for any account in a transaction that is marked "shared" (possibly with leading/trailing white space), add a new transaction that cancels half of it and yet another one that forwards half of it to John. Let's spell it out with our earlier example:
2021-12-01 Carouf
    Expenses:Food:Groceries                12.00 EUR
    Expenses:Food:Groceries                -6.00 EUR
    Assets:Reimbursements:John              6.00 EUR
    Assets:Bank:Checking                  -12.00 EUR

2021-12-02 Le clerc
    Expenses:Food:Groceries                22.00 EUR
    Expenses:Food:Groceries               -11.00 EUR
    Assets:Reimbursements:John             11.00 EUR
    Assets:Reimbursements:John            -22.00 EUR
After factoring out the cancellations:
2021-12-01 Carouf
    Expenses:Food:Groceries                 6.00 EUR
    Assets:Reimbursements:John              6.00 EUR
    Assets:Bank:Checking                  -12.00 EUR

2021-12-02 Le clerc
    Expenses:Food:Groceries                11.00 EUR
    Assets:Reimbursements:John            -11.00 EUR
As you can see once you wrap your head around it, this automated transaction elegantly does what you want by cancelling out unwanted parts of transactions and forwarding the right kind of debt (either positive or negative) to John's account.

In practice

What this lets me do is stop worrying about splitting every single bill. Any of John and I can pay any shared bill and ledger will keep track of who is ahead/behind. If I ledger balance John, I'll see how much John owe's me, or how much I owe him if the result is negative. We can then let the one behind pay the next few bills to balance it out naturally or make a bank transfer if the gap gets too wide.

The biggest challenge is making sure to get the right summary of the bills that John paid, since he isn't an accounting nut and sometimes forgets to get bills for the things he pays for (or just to give them to me).

One strategy that can work is to sit down together monthly to reconcile his bank statement with my ledger, but this is quite annoying and he'd rather avoid that or might downright refuse it.

What I've done instead is write a small ad-hoc Matrix bot that outputs ledger transactions. This way, he can simply send "12 groceries" to the bot and I get a properly formatted transaction to put in my ledger on the other end. This is easy enough for John not to complain about it, I get a detailed record of my accounting without a black hole in the middle where the shared stuff is and we never have to worry about shared expenses anymore.