Followon from #1738 and #1742:
bin/hledger-check-fancyassertions.hs, an addon, is little maintained. It adds more powerful assertions to hledger. What should be its future ? Occasional fixes.. more cleanup.. integration into hledger ? Does anyone use it ? I never do myself, partly because the UI seems hard. But I often suggest it to people asking for more powerful checks.
Here's a summary of its added value (AI text):
hledger-check-fancyassertions (an addon script in bin/, by Michael Walker) adds journal-wide, rule-based balance checking that hledger's built-in balance assertions can't express. Where a built-in assertion (account $10 = $20) is written inline in the journal, pins one account to one exact amount, and is checked only at that posting, this script lets you state standing invariants on the command line and verifies them across the whole journal:
- Comparisons, not just equality: assert an account balance is
<, <=, ==, >=, >, or != some amount - e.g. "assets never go negative", not just "assets equal exactly X here".
- Account-to-account comparisons: either side of a comparison can be another account name, so you can assert things like "liabilities never exceed savings".
- Subaccount-inclusive balances:
*assets:checking means the account plus all its subaccounts.
- Logical combinations: assertions compose with
&&, ||, ==> (implies), <==> (iff), !, and parentheses - e.g. (assets:overdraft < £2000) ==> (*assets:checking == £0): "if I've dipped into the overdraft, my checking must be empty".
- Choice of checkpoint: a bare assertion must hold after every transaction;
-D/-W/-M/-Q/-Y check it only at the end of each day/week/month/quarter/year. So a rule can be allowed to be violated mid-period as long as it holds at period end.
- Scoping options: restrict checking to a date range (
-b/-e), to cleared/pending/unmarked or real postings, and rewrite account names with --alias.
It exits nonzero and prints the offending transaction and balances when an assertion fails, so it works as a validation step in scripts or pre-commit checks. One syntax gotcha worth remembering: two or more spaces are required around operators, because account names may contain single spaces.
Followon from #1738 and #1742:
bin/hledger-check-fancyassertions.hs, an addon, is little maintained. It adds more powerful assertions to hledger. What should be its future ? Occasional fixes.. more cleanup.. integration into hledger ? Does anyone use it ? I never do myself, partly because the UI seems hard. But I often suggest it to people asking for more powerful checks.
Here's a summary of its added value (AI text):