Autogenerate assertions?

I think it is not possible. hledger provides commands to close/open accounts. But, it does not provide a comand to autogerenate assertions.

For example, lets suppose I concilied accounts and I want to ensure the accounts won't change in the future due to a mistake. There could be one command to generate the transaction that could assert the current state of accounts. Something like hledger assert assets: liabilities: which could print:

2025-01-01 assertion
    assets:cash  0.00 EUR = 100.00 EUR
    assets:bank  0.00 EUR = 1232.34 EUR 
    liabilities:mortage  0.00 EUR = -123000.00 EUR

This could be used to a form of closing books or avoid mistakes in the future. Just to ensure the previous transactions are not modified.

I think I could script this in bash or python.

Do you think is useful?

(this idea is related to discussion at Must we close accounts? …and why? - #7 by zako)

Yes, and it exists: hledger close --assert [OPTS] [ACCTS]

1 Like

In accounting, closing the books is an assertion that all data before the closing date is immutable, and any reports as of the closing date will never change. A balance assertion will catch many changes, but not all.
I'm thinking perhaps the best way would be to insert an assertion after the closing point based on hashing preceding characters in journal file.