Is there a straightforward generic way to throw an error if two account 
balances don't match?

I know I can use balance assertions, but it seems these must have explicit 
amounts given (i.e. = $1,000) rather than variable amounts (i.e. = 
Assets:Bank).

To give you context, I am using Ledger to implement a YNAB-type envelope 
system, much like @bsilvereagle does in his article Envelope Budgeting with 
Ledger <https://frdmtoplay.com/envelope-budgeting-with-ledger/>.  However, 
instead of partitioning a particular sub-account, as he does in his 
article, I partition my total Assets.  This corresponds to the YNAB rule 
"Give Every Dollar a Job".   

; define accounts for use with 
; ledger bal --explicit --pedantic
commodity $

account Assets

account Assets:Bank
account Assets:Envelopes

account Assets:Bank:Checking
account Assets:Bank:Savings

account Assets:Envelopes:Rent
account Assets:Envelopes:Groceries
account Assets:Envelopes:Gasoline
account Assets:Envelopes:Vacation

account Expenses:Rent
account Expenses:Groceries
account Expenses:Gasoline
account Expenses:Vacation

account Equity:Opening

; bind expense to corresponding envelope
= /Expenses:Groceries/
    [Assets:Envelopes:Groceries]                -1.0
    [Assets]                                     1.0

= /Expenses:Rent/
    [Assets:Envelopes:Rent]                     -1.0
    [Assets]                                     1.0

= /Expenses:Gasoline/
    [Assets:Envelopes:Gasoline]                 -1.0
    [Assets]                                     1.0

= /Expenses:Vacation/
    [Assets:Envelopes:Vacation]                 -1.0
    [Assets]                                     1.0

; Beginning of transactions
2018/01/01  Opening balance
    Assets:Bank:Checking                     $250.00
    Assets:Bank:Savings                     $1000.00
    Equity:Opening

2018/01/01 Transfer to envelopes
    [Assets:Envelopes:Groceries]                $500
    [Assets:Envelopes:Rent]                     $500
    [Assets:Envelopes:Gasoline]                 $100
    [Assets:Envelopes:Vacation]                 $150
    [Assets]

2018-01-02 Buy groceries from checking
    Expenses:Groceries                           $50
    Assets:Bank:Checking

2018-01-02 Pay rent
    Expenses:Rent                                $50
    Assets:Bank:Checking

2018-01-02 But groceries from Savings
    Expenses:Groceries                          $100
    Assets:Bank:Savings

Ideally, *Assets:Envelopes* should always match *Assets:Bank*.  There are 
three possible scenarios:

   1. *Assets:Envelopes* < *Assets:Bank* - There is money to allocate into 
   envelopes.
   2. *Assets:Envelopes* == *Assets:Bank* - Every dollar has a job, all 
   assets have been allocated, and things are good.  
   3. *Assets:Envelopes* > *Assets:Bank* - There is an error somewhere.    

This implementation works great, however, checking for each of the 
scenarios must be done manually by literally looking at the balances and 
performing the subtraction.  It'd be nice to have hard rule that said "The 
*Asset:Envelopes* balance must always equal the *Assets:Bank* balance" or 
"Show the balance difference between *Assets:Bank* and *Assets:Envelopes*".

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to