This trick saved me from a serious mistake this morning, so thought I
would mention it in case anyone else hadn't seen it!

The idea is to use automated transactions to check for common data entry
errors. For example, this check will make sure I don't accidentally
subtract from expenses:

; It's usually a typo to substract from Expenses, unless it's a refund.
= expr "amount < 0 and account =~ /^Expenses:/"
    assert has_tag('refund')

Now you have to tag a transaction as a refund or you get an error, this
saved me a few times!

2024/08/01 * Store
    Expenses:Groceries      -$10    ; :refund:
    Liabilities:Creditcard

Here are a few more I use to check for suspicious dates:

; If a transaction is still not cleared, that is odd.
= expr "pending and date < [30 days ago]"
    assert cleared

; Check for suspicious future dates. This will break --now, so handle that.
= expr "date > [tomorrow] and !options.now"
    assert pending

I also like all dividend payments to have the associated commodity
tagged, this way I can group them by commodity:

    $ ledger bal --no-total --price --group-by "tag('dividend')" %dividend
    FOO
              $12.34  Assets:Brokerage
    BAR
              $56.78  Assets:Brokerage
    BAZ
              $90.12  Assets:Brokerage

That only works if I don't forget, so I make sure like this:

account Income:Dividend
    assert all(amount < 0 or (has_tag('dividend') or !actual))

Now I have to do this, so ledger knows what commodity paid a dividend:

2024/01/01 Broker
    Assets:Brokerage    $123 ; dividend: FOO
    Income:Dividend

I use a bunch more to check for consistency and sanity, but just some
quick examples :)

Tavis.

-- 
 _o)            $ lynx lock.cmpxchg8b.com
 /\\  _o)  _o)  $ finger [email protected]
_\_V _( ) _( )  @taviso

-- 

--- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/va51gl%24f0r%241%40ciao.gmane.io.

Reply via email to