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. :)

On Tue, Aug 13, 2024 at 8:22 PM Eric Altendorf <[email protected]>
wrote:

> On Tue, Aug 13, 2024 at 7:53 PM Martin Blais <[email protected]> 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
>
>
>>
>> On Tue, Aug 13, 2024 at 10:26 PM Eric Altendorf <[email protected]>
>> wrote:
>>
>>> 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.
>>>
>>> --
>>> 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 [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/beancount/CAFXPr0vPC%3DS86jFMAa9o5dJ2cnNfH1uqExJS9u1_yOkAUUPCSA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/beancount/CAFXPr0vPC%3DS86jFMAa9o5dJ2cnNfH1uqExJS9u1_yOkAUUPCSA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/beancount/CAK21%2BhMS-egFgyKG6UmvD%2BeHp4nY-TvU0MZ1feJzt3pQiaNDEg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/beancount/CAK21%2BhMS-egFgyKG6UmvD%2BeHp4nY-TvU0MZ1feJzt3pQiaNDEg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/CAFXPr0sXV5KksZgPOPv0L6LyRBPgmv1O%3DNQ9ZTpORcsD5nZNxg%40mail.gmail.com.

Reply via email to