bean-check error for balance assertion with prefix?

38 views
Skip to first unread message

Aaron Stacy

unread,
Apr 15, 2022, 12:28:28 AM4/15/22
to bean...@googlegroups.com
Hello, I'm getting a balance assertion error when I use an account name with the same prefix as another. Here's a minimal repro:

2022-01-01 open Assets:US:HSA
2022-01-01 open Assets:US:HSA:Receivable
2022-01-01 open Expenses:Health
2022-01-01 open Income:Acme

2022-01-01 * "Paycheck contribution to HSA"
  Assets:US:HSA                               100 USD
  Income:Acme

2022-01-15 * "Disbursement for medical expense"
  Assets:US:HSA                              -100 USD
  Expenses:Health

2022-02-01 * "Paycheck contribution to HSA that's not showing up in account yet"
  Assets:US:HSA:Receivable                     50 USD
  Income:Acme

; This, as expected, does not have an error:
2022-02-02 balance Assets:US:HSA:Receivable    50 USD

; The following has the error:
;
;     Balance failed for 'Assets:US:HSA': expected 0 USD != accumulated 50 USD
;     (50 too much)
;
; Note if I rename the receivable account to not have the Assets:US:HSA prefix,
; i.e. Assets:US:Foo:Receivable, then it is not an error, so it seems related to
; the prefix.
2022-02-02 balance Assets:US:HSA                0 USD

The receivable account is $50 as expected, but it seems like beancount is adding the $50 from the receivable to the HSA account itself. Am I missing something?

Thanks!

Martin Michlmayr

unread,
Apr 15, 2022, 1:08:43 AM4/15/22
to bean...@googlegroups.com
* Aaron Stacy <aaron....@gmail.com> [2022-04-14 22:32]:
> The receivable account is $50 as expected, but it seems like
> beancount is adding the $50 from the receivable to the HSA account
> itself. Am I missing something?

Beancount uses the total of all sub-accounts for the balance checks,
so this is the expected behaviour.

This is different to the behaviour in ledger (in case you're used to
that).

--
Martin Michlmayr
https://www.cyrius.com/
Reply all
Reply to author
Forward
0 new messages