Confused about failure to balance

55 views
Skip to first unread message

Eric Altendorf

unread,
Aug 13, 2024, 10:26:16 PM8/13/24
to bean...@googlegroups.com
I'm getting a failure to balance validation error, and I can't quite figure out why.  Here is (a sanitized version of) what I'm getting from beandoctor:

** Unbooked Transaction --------------------------------

2020-01-01 * "Trade 412.47 BAR for 200 FOO"
  Assets:FOO       200 FOO {19.62 USD}
  Assets:BAR   -412.47 BAR {} @ 10.41 USD
  Income:CapGains

** Transaction --------------------------------

2020-01-01 * "Trade 412.47 BAR for 200 FOO"
  Assets:FOO       200 FOO {19.62 USD, 2019-01-01}              ;  ...
  Assets:BAR   -412.47 BAR {10.41 USD, 2019-01-01} @ 10.41 USD  ;  ...


How can this not balance?  I have a price for the acquired asset and a cost for the disposed asset and a capgains account to catch the difference.

Note: I am working with my locally tweaked version of the booking code.  I don't see how my changes would affect this case, but if y'all agree the above should book, then I'll go debug my diffs more closely.

Martin Blais

unread,
Aug 13, 2024, 10:53:46 PM8/13/24
to bean...@googlegroups.com
What's the booking type of account Assets:BAR?
What's the content of the inventory or Assets:BAR just before this gets applied?

--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/CAFXPr0vPC%3DS86jFMAa9o5dJ2cnNfH1uqExJS9u1_yOkAUUPCSA%40mail.gmail.com.

Eric Altendorf

unread,
Aug 13, 2024, 11:23:05 PM8/13/24
to bean...@googlegroups.com
On Tue, Aug 13, 2024 at 7:53 PM Martin Blais <bl...@furius.ca> wrote:
What's the booking type of account Assets:BAR?

FIFO, LIFO, and HIFO seem to produce a similar set of errors like that, although not always on exactly the same transactions.  STRICT produces a ton of errors, which I guess is expected (IIRC that's for manually specifying cost lots).

What's the content of the inventory or Assets:BAR just before this gets applied?

Something like this:

  Assets:BAR     0.936 BAR {10.06 USD, 2018-01-01}
  Assets:BAR  2259.481 BAR {10.41 USD, 2019-01-01}
  Assets:BAR    150.01 BAR {10.09 USD, 2019-01-01}

(Numbers and symbols sanitized, but roughly representative of the relative values.  If exact numbers are more helpful I could send those to you directly.)

thanks!
eric
 

Eric Altendorf

unread,
Aug 14, 2024, 12:31:02 PM8/14/24
to bean...@googlegroups.com
Duh.  I figured out the immediate problem (but not the solution).

It's related to the div-by-zero error in reds capgains plugin which I reported on the other thread.  I'd hacked the plugin to skip the allocation of residual unaccounted-for gains/losses to short/long, in the case that the total gains/losses were zero, to avoid the divide-by-zero.  If I remove that hack, then instead of my failure to balance, I get the old div-by-zero crash again.

So, if I may redirect everyone's attention to the the other thread asking why the capgains plugin ever sees a discrepancy between the original cap-gains posting and the split short/long postings, and what's the right way to deal with that (div by zero doesn't seem to be), maybe we can solve the upstream problem. :)
Reply all
Reply to author
Forward
0 new messages