On 19/07/23 00:12, Eric Altendorf wrote:
> I seem to not understand how tolerances are used. I have this beancount:
>
> 1 2018-01-01 open Assets:Alpha:ABC ABC
> 2 2018-01-01 open Assets:Beta:ABC ABC
> 3
> 4 2018-01-02 * "synthesize a position with zero cost basis"
> 5 Assets:Alpha:ABC 1.0 ABC {0.00 USD}
This is not a valid transaction. All transactions needs to have at least
two postings. It is a fundamental requirement of double entry accounting.
> 6
> 7 2018-01-03 balance Assets:Alpha:ABC 1.0 ABC ;; Assertion passes
> 8
> 9 2018-01-04 * "Transfer from alpha to beta"
> 10 Assets:Alpha:ABC -0.1 ABC
> 11 Assets:Beta:ABC 0.1 ABC
> 12
> 13 2018-01-05 balance Assets:Alpha:ABC 1.0 ABC ;; Does not fail!
> 14
> 15 2018-01-06 * "Transfer from alpha to beta"
> 16 Assets:Alpha:ABC -0.5 ABC
> 17 Assets:Beta:ABC 0.5 ABC
> 18
> 19 2018-01-07 balance Assets:Alpha:ABC 1.0 ABC ;; Does fail.
>
> I can't get the balance assertion on line 13 to fail.
This is because the inferred tolerance on the ABC commodity is 0.1. If
you want the tolerance inference algorithm to infer a lower tolerance,
you need to write your numbers with more decimal digits. If you write
them with two decimal digits, the balance assertion correctly fails.
> I've tried both
> the "inferred_tolerance_default" option and the "Explicit Tolerances on
> Balance Assertions" (e.g., "~ 0.00001 ABC").
How did you test this? Specifying an explicitly tolerance correctly
triggers the balance assertion for me. "inferred_tolerance_default" is
not relevant here because the ledger contains enough data to derive a
tolerance (although it is not the one you expect).
Cheers,
Dan