Open binshengliu opened 2 years ago
Unfortunately, this is an incompatibility between ledger and beancount. Assertions / balance checks work in a different way.
This is covered in the manual:
First, beancount evaluates balance assertions at the beginning of the day whereas ledger evaluates them at the end of the day (up to ledger 3.1.1) or at the end of the transaction (newer versions of ledger). Therefore, we schedule the balance assertion for the day after the original transaction. This assumes that there are no other transactions on the same day that change the balance again for this account.
see "Balance assertions and assignments" in guide.md
Having said that, I'll check if ledger2beancount can avoid creating two balance checks for the same account on the same day, maybe with a conversion note about this issue.
Thanks. I had read the doc you mentioned and understood why this happened. In my case, I have thousands of errors after conversion, so I have to delete all the balance checks to make the file usable. It would be nice if the tool can deal with it.
It would be nice if the tool can deal with it.
What would you suggest? Skipping the balance checks and generating a warning?
Ideally, I would hope the checks being merged and produce one balance check for one day, so the original data are preserved as much as possible.
Implementation-wise, since ledger requires the transactions to be in the correct order, would it make sense to only keep the last assertion of a day?
Unfortunately, the current code doesn't make it easy to implement this but I'll take a look.
I'm on vacation at the moment but I'll try to look soon.
I haven't had time to look into this more, although I've solidified my impression that this would require big changes.
In the meantime, I suggest you use a workaround like:
./bin/ledger2beancount foo.ledger | grep -v "^[0-9]...-..-.. balance "
Thanks. Yeah I've removed the balance checks as a workaround.
Sorry, I won't have time to work on this in the near future.
+1
I also ran into this issue.
Sorry that I still haven't fixed this issue. I remember exactly where I was on vacation when it was filed. Long time.
I actually thought about this issue a week or two ago and I think I know how to solve it. I'd like to fix it this year but I have urgent work so this seems unlikely. I'll try to get it done soon, though.
@girishso you can use the workaround for now:
./bin/ledger2beancount foo.ledger | grep -v "^[0-9]...-..-.. balance "
Hi, I have a ledger file where most transactions have a balance assertion. After conversion, there may be multiple assertions for the same day which causes some trouble.
The following is an example:
After conversion, I get
bean-check reports:
version:
ledger2beancount 2.6