assertions look too much like assignments

6 views
Skip to first unread message

Marco van Hulten

unread,
Jul 23, 2023, 11:27:05 AM7/23/23
to hle...@googlegroups.com
Hi all,

The syntax of a balance assertion is the same as of an assignment (if
one limits hirself to a single line instead of the full transaction).
As a consequence, sometimes I modify an assertion's balance by one
cent, just to assert myself that I actually did a balance assertion
instead of an assignment.

Consider this example:


2023-01-01 * Equity
Assets 100 €
Equity:Opening balance

2023-01-02 * Assertion after income
Assets 10 € = 110 €
Income

2023-01-03 * Assignment (lost a bill)
Assets = 105 €
Adjustment

2023-01-04 * Assertion after income, written differently
Assets = 130 €
Income -25 €


By changing the last assert to 131 €, the assertion fails. When
changing an assignment, I would not get an error so I know it is an
assignment (which I never want to use).

Nonetheless, even this awkward check can go wrong. When I change the
panultimate assignment from 105 € to 120 €, I get an error as well.
This time, of course not from this transaction but from the last
transaction, but I might not notice and incorrectly conclude that the
panultimate "transaction" contains a balance assertion.

I propose to introduce

:= for single-commodity assignment
:== for multi-commodity assignment
:=* and :==* are invalid

and disallow =, ==, =* and ==* for assignments.

If this is not possible (because of ambiguous syntax parsing or
breaking with ledger), another approach is to include an option to
disallow assignments, e.g. one of the following

--disallow-assignments
check noassignments

What do you think?

Marco

Simon Michael

unread,
Jul 24, 2023, 12:30:23 PM7/24/23
to hledger
Hi Marco, thanks for the input.

In my terminology, it's a balance assertion if there's an amount left of the equals, a balance assignment if not.

I think adding a `noassignments` check is low impact and a fine idea, I'd support that (and probably use it myself).

Reply all
Reply to author
Forward
0 new messages