beancount / ledger2beancount

Ledger to Beancount text-based converter
GNU General Public License v3.0
79 stars 15 forks source link

errors with assertions in subaccounts #243

Closed mefromthepast closed 3 years ago

mefromthepast commented 3 years ago

Apparently, beancount uses cummulative amounts for assertions, while hledger does not add amounts from its subaccounts to the main accounts. This leads to error in fava / bean-check when using ledger2beancount.

Sample hledger file

2021-01-04 test
    expenses:subaccount:subsubaccount              -1 EUR = -1 EUR
    expenses:subaccount                             1 EUR =  1 EUR

ledger2beancount ledger.journal > out.journal fava out.journal

assertions

bean-check out.journal 
out.journal:19:      Balance failed for 'Expenses:Subaccount': expected 1 EUR != accumulated 0 EUR (1 too little)

   2021-01-05 balance Expenses:Subaccount                             1 EUR
tbm commented 3 years ago

Thanks, that's an interesting scenario. So it seems that beancount's balance checks works the same way as hledger's =* syntax.

I don't think there's anything ledger2beancount can do about this. I can improve the docs, though, to highlight potential issues.

Do you have any suggestions on how to improve the current behviour/status?

tbm commented 3 years ago

@mefromthepast I looked into this issue when you reported it but then got distracted with other things.

As it turns out, we can look for sub-accounts of the account specified in the assertion and print a warning. Your example will now lead to:

;   - Assertion for Expenses:Subaccount may fail due to sub-accounts

I've also updated the docs to describe this problem.

hledger's =* syntax is handled correctly and won't print the warning.

Thanks for making me aware of this issue!