Skip to content

Instantly share code, notes, and snippets.

@bradyt
Forked from simonmichael/README.md
Created July 22, 2017 06:56
Show Gist options
  • Save bradyt/4e8e144a1afc61c27b01bec2497238a6 to your computer and use it in GitHub Desktop.
Save bradyt/4e8e144a1afc61c27b01bec2497238a6 to your computer and use it in GitHub Desktop.
envelope budgetting experiments
; Journal syntax compatible with: hledger, ledger
; Examples tested with: hledger 0.23.98 (should be easily adaptable)
; "Asset subaccounts, balanced virtual transactions"
; "Envelopes" (funds allocated for a certain purpose) are represented
; by virtual subaccounts under an asset account, eg checking:
2014/10/01 * opening balances
equity:opening balances
assets:bank:checking $1000
assets:cash:wallet $100
2014/10/01 * save for food this month
[assets:bank:checking] $-100
[assets:bank:checking:reserve:food]
; The total balance of checking is still correct, but we can see some of it
; has been allocated:
; $ hledger bal assets
; $1000 assets:bank:checking
; $100 reserve:food
; --------------------
; $1000
; $ hledger bal assets --flat
; $900 assets:bank:checking
; $100 assets:bank:checking:reserve:food
; --------------------
; $1000
; To hide the envelopes and see only real-world accounts, add -R (or real:1).
; (we could use depth:3, but -R will be more thorough eg in register reports):
; $ hledger bal assets --flat -R
; $1000 assets:bank:checking
; --------------------
; $1000
; Withdrawing from the reserve is done as a distinct step, keeping
; virtual and real transfers separate and balanced so that reports
; remain correct with or without -R.
2014/10/04 * buy food, using food reserve
; virtual transaction, withdrawing from reserve
[assets:bank:checking:reserve:food] $-50
[assets:bank:checking] $50
; real transaction, paying for food
assets:bank:checking $-50
expenses:food:groceries $50
; Envelopes live in a specific asset account, but what if you spend
; from a different asset account ? We make a corresponding withdrawal
; from the envelope to its parent account, just as above. The result
; is some additional unallocated funds in checking. (So, the non-reserve
; checking balance is no longer exactly the total unallocated balance -
; to get that we'd have to consider the cash balance as well).
2014/10/09 * buy food with cash, and update reserve
expenses:food:groceries $20
assets:cash:wallet $-20
; reduce food reserve accordingly
[assets:bank:checking:reserve:food] $-20
[assets:bank:checking] $20
; The status now:
; $ hledger bal assets --flat
; $920 assets:bank:checking
; $30 assets:bank:checking:reserve:food
; $80 assets:cash:wallet
; --------------------
; $1030
; Real-world transactions:
; $ hledger reg assets real:1
; 2014/10/01 opening balances assets:bank:checking $1000 $1000
; assets:cash:wallet $100 $1100
; 2014/10/04 buy food, using f.. assets:bank:checking $-50 $1050
; 2014/10/09 buy food with cas.. assets:cash:wallet $-20 $1030
; Virtual transactions for budgetting:
; $ hledger reg assets real:0
; 2014/10/01 save for food thi.. [as:bank:checking] $-100 $-100
; [as:ba:ch:re:food] $100 0
; 2014/10/04 buy food, using f.. [as:ba:ch:re:food] $-50 $-50
; [as:bank:checking] $50 0
; 2014/10/09 buy food with cas.. [as:ba:ch:re:food] $-20 $-20
; [as:bank:checking] $20 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment