This repository is my attempt at keeping a tabs on insurance claims using heldger. To keep things concrete, let's say we're talking about medical bills.
Specifically, I want to abide by the following constraints:
- Add an entry when the insurance claim comes in.
- Add an entry when I pay the insurance company.
And be able to answer the following questions:
- How much deductible and out-of-pocket are remaining?
- How much did the insurance company pay?
- How much did I pay?
For those not familiar with this insurance system, this is how it works.
- I pay all the bills until I paid fully my deductible. In the example, it's 50. When I fully paid 50, go to 2.
- Then, the insurance kicks in and covers part of my bills. Whatever I pay then goes to my out-of-pocket cap. In the example it's 10. So when I fully paid 10, go to 3.
- The insurance covers now everything, I don't need to pay anything. In the example, I will pay at most 60 for the whole year.
The hledger.journal file contains all transactions.
-
2025/01/01: As opening balance for the new yeat, I get a salary of 100.
2025-01-01 Opening balances assets:checking 100 income:salary:meAlso, I add an entry to for
Insurance capssince deductible and out-of-pocket amounts are reset on the new year.2025-01-01 Opening balances cap:insurance:medical:me:deductible:init -50 cap:insurance:medical:me:deductible:rem 50 ; cap:insurance:medical:me:out-of-pocket:init -10 cap:insurance:medical:me:out-of-pocket:rem 10For a given cap, like
cap:insurance:medical:me:deductibleorcap:insurance:medical:me:out-of-pocket, there are 3 sub accounts::initis for the initial cap at the beginning of the year.:remis for what's left in the cap. When I pay the insurance bill, first thedeductible:remaccount will get reduced until 0, then theout-of-pocket:remaccount will get reduced. When both gets to 0, the insurance covers everything.:spentis the counterpart of:rem. Whenever we reduce:rem, we increase:spent.
Only having
:remcould be enough but we need the other two to keep the double accounting rule satisfied. -
2025/01/02: Next day, I get an insurance claim. Already?!
2025-01-02 Insurance claim expenses:medical:me 50 liabilities:payable:insurance:medical:me -50 ; cap:insurance:medical:me:deductible:rem -50 cap:insurance:medical:me:deductible:spent 50I'm not paying the insurance claim right away, so I put it in
liabilities:payable.Also, the deductible gets reduced. To keep things simple, the amount corresponds fully to what was in the
deductiablecap, so now that amount is 0. -
2025/01/03: I pay the insurance company.
This reduces the amount of money in my checking account. Sniff.
2025-01-03 Insurance payment assets:checking -50 liabilities:payable:insurance:medical:me 50 -
2025/01/04: Another insurance claim comes in
2025-01-04 Insurance claim expenses:medical:me 50 liabilities:payable:insurance:medical:me -10 income:insurance:medical:me -40 ; cap:insurance:medical:me:out-of-pocket:rem -10 cap:insurance:medical:me:out-of-pocket:spent 10This time, the expense was also of 50 but since I paid fully my deductible, it covered part of the expense.
The out-of-pocket gets reduced this time. To keep things simple, the amount corresponds fully to what was in the
out-of-pocketcap, so now that amount is 0. -
2025/01/06: One more insurance claim comes in
2025-01-06 Insurance claim expenses:medical:me 50 income:insurance:medical:me -50This time the insurance company covers everything since my deductible and out-of-pocket are fully paid.
hledger -f hledger.journal bal -p "daily" --historical ":rem" --pretty
Ending balances (historical) in 2025-01-01..2025-01-06:
║ 2025-01-01 2025-01-02 2025-01-03 2025-01-04 2025-01-05 2025-01-06
════════════════════════════════════════════╬════════════════════════════════════════════════════════════════════════
cap:insurance:medical:me:deductible:rem ║ 50 0 0 0 0 0
cap:insurance:medical:me:out-of-pocket:rem ║ 10 10 10 0 0 0
────────────────────────────────────────────╫────────────────────────────────────────────────────────────────────────
║ 60 10 10 0 0 0hledger -f hledger.journal bal -p "daily" --historical "income:insurance" --pretty --invert
Ending balances (historical) in 2025-01-01..2025-01-06:
║ 2025-01-01 2025-01-02 2025-01-03 2025-01-04 2025-01-05 2025-01-06
═════════════════════════════╬════════════════════════════════════════════════════════════════════════
income:insurance:medical:me ║ 0 0 0 40 40 90
─────────────────────────────╫────────────────────────────────────────────────────────────────────────
║ 0 0 0 40 40 90$ hledger -f hledger.journal bal -p "daily" --historical ":spent" --pretty
Ending balances (historical) in 2025-01-01..2025-01-06:
║ 2025-01-01 2025-01-02 2025-01-03 2025-01-04 2025-01-05 2025-01-06
══════════════════════════════════════════════╬════════════════════════════════════════════════════════════════════════
cap:insurance:medical:me:deductible:spent ║ 0 50 50 50 50 50
cap:insurance:medical:me:out-of-pocket:spent ║ 0 0 0 10 10 10
──────────────────────────────────────────────╫────────────────────────────────────────────────────────────────────────
║ 0 50 50 60 60 60hledger -f hledger.journal bal -p "daily" --historical "expenses:medical" --pretty
Ending balances (historical) in 2025-01-01..2025-01-06:
║ 2025-01-01 2025-01-02 2025-01-03 2025-01-04 2025-01-05 2025-01-06
═════════════════════╬════════════════════════════════════════════════════════════════════════
expenses:medical:me ║ 0 50 50 100 100 150
─────────────────────╫────────────────────────────────────────────────────────────────────────
║ 0 50 50 100 100 150 hledger -f hledger.journal is -p "daily" --historical --pretty
Income Statement 2025-01-01..2025-01-06 (Historical Ending Balances)
║ 2025-01-01 2025-01-02 2025-01-03 2025-01-04 2025-01-05 2025-01-06
═════════════════════════════╬════════════════════════════════════════════════════════════════════════
Revenues ║
─────────────────────────────╫────────────────────────────────────────────────────────────────────────
income:insurance:medical:me ║ 0 0 0 40 40 90
income:salary:me ║ 100 100 100 100 100 100
─────────────────────────────╫────────────────────────────────────────────────────────────────────────
║ 100 100 100 140 140 190
═════════════════════════════╬════════════════════════════════════════════════════════════════════════
Expenses ║
─────────────────────────────╫────────────────────────────────────────────────────────────────────────
expenses:medical:me ║ 0 50 50 100 100 150
─────────────────────────────╫────────────────────────────────────────────────────────────────────────
║ 0 50 50 100 100 150
═════════════════════════════╬════════════════════════════════════════════════════════════════════════
Net: ║ 100 50 50 40 40 40From the reports above we know I paid 60 in total, so having 40 remaining makes sense.
hledger -f hledger.journal bs -p "daily" --historical --pretty
Balance Sheet 2025-01-01..2025-01-06 (Historical Ending Balances)
║ 2025-01-01 2025-01-02 2025-01-03 2025-01-04 2025-01-05 2025-01-06
══════════════════════════════════════════╬════════════════════════════════════════════════════════════════════════
Assets ║
──────────────────────────────────────────╫────────────────────────────────────────────────────────────────────────
assets:checking ║ 100 100 50 50 40 40
──────────────────────────────────────────╫────────────────────────────────────────────────────────────────────────
║ 100 100 50 50 40 40
══════════════════════════════════════════╬════════════════════════════════════════════════════════════════════════
Liabilities ║
──────────────────────────────────────────╫────────────────────────────────────────────────────────────────────────
liabilities:payable:insurance:medical:me ║ 0 50 0 10 0 0
──────────────────────────────────────────╫────────────────────────────────────────────────────────────────────────
║ 0 50 0 10 0 0
══════════════════════════════════════════╬════════════════════════════════════════════════════════════════════════
Net: ║ 100 50 50 40 40 40 Same here. Since I paid the insurance company, I've got no liabilities at the end but my assets got reduced to 40.
hledger -f hledger.journal reg ":rem" --width 80
2025-01-01 Insurance caps ca:in:me:me:de:rem 50 50
ca:in:me:me:ou:rem 10 60
2025-01-02 Insurance claim ca:in:me:me:de:rem -50 10
2025-01-04 Insurance claim ca:in:me:me:ou:rem -10 0