I agree with your analysis. Honestly the easiest way before+if this is
officially supported may be to hack the beancount source and so it rewrites
the lots before booking. Start here:
https://github.com/beancount/beancount/blob/3ec62d4d8e68f352156eec6c7068b8aee8fc65f1/beancount/loader.py#L531
and
add your code right before booking. Simply running the transfer_lots
plugin manually before booking is called may just work without any other
changes.

For hacking a python project `pip install -e` is great. You'll need to make
sure to use the same modified package for fava etc too.

On Sun, Nov 13, 2022 at 1:16 PM Peter <[email protected]> wrote:

> I looked through some threats I could find, but I didn't find any
> (automatic) solution to this problem, actually.
>
> - the plugin posted in my initial posting doesn't work
> - https://github.com/hoostus/beancount-asset-transfer-plugin doesn't work
> (only supports LIFO and has errors)
>
> I guess, I found your emacs plugin solution, but as I don't know or use
> emacs, I can't use it. I guessing it does (semi-automated):
> - check bean-doctor
> - take the lots
> - convert them to postings
> - replace the original txn
>
> While this works, and I tried something like this manually, this has one
> huge disadvantage for me:
> It replaces a "simple"
> 2021-01-10 * "" "Transfer LOT" #transfer
> Assets:Broker:LOT -1.25 LOT {}
> Assets:Storage:LOT
> with a hard coded lot
> 2021-01-10 * "" "Transfer LOT" #transfer
> Assets:Broker:LOT -1.25 LOT {600 USD, 2021-01-08}
> Assets:Storage:LOT 1.25 LOT {600 USD, 2021-01-08}
>
> I'm trying to import dozens to hundreds of transactions from different
> sources. Therefore, I can't/want to replace the reductions with hard coded
> lots, as there might be other lots coming in later that have to be used.
>
> (Just throwing in all txns doesn't really work, too, as they are sorted by
> account, then by date. So, I wouldn't know if I'm skipping a txn. I tried
> to use bean-report print, but it erases txns with errors, which isn't
> helping.)
>
> I'm lost at this point.
>
>
> [email protected] schrieb am Samstag, 12. November 2022 um 17:34:19 UTC+1:
>
>> Yes. This is a flaw of the plugin approach to solving this problem - I
>> recommend you deploy one of the other solutions from prior threads on this
>> list about transferring lots between accounts. I am personally a fan of the
>> bean-doctor integration of the beancount emacs plugin for this task.
>>
>> On Sat, Nov 12, 2022 at 1:06 AM Peter <[email protected]> wrote:
>>
>>> Hi,
>>>
>>> thanks for the answer. So, „there's no hope“ here until v3 (if it
>>> includes pre-booking plugins)?
>>>
>>> [email protected] schrieb am Freitag, 11. November 2022 um 22:14:33 UTC+1:
>>>
>>>> This should probably be a FAQ.
>>>> See recent thread: https://groups.google.com/g/beancount/c/88WjwEhJKUk
>>>> and many before.
>>>>
>>>> In short: Booking runs before plugins
>>>> <https://github.com/beancount/beancount/blob/3ec62d4d8e68f352156eec6c7068b8aee8fc65f1/beancount/loader.py#L531>.
>>>> There's been discussion in the past about having pre-booking plugins, it
>>>> would certainly be helpful in a case like this.
>>>>
>>>>
>>>> On Fri, Nov 11, 2022 at 7:19 AM Peter <[email protected]> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I'm using the transfer_lots plugin to transfer lots between accounts.
>>>>>
>>>>> Sadly, after one transfer the lot seems to be locked. I.e., the
>>>>> `failed to categorize posting` error occurs.
>>>>> See this MWE:
>>>>>
>>>>> option "booking_method" "FIFO"
>>>>> option "operating_currency" "USD"
>>>>> plugin "beancount.plugins.auto_accounts"
>>>>>
>>>>> option "insert_pythonpath" "True"
>>>>> plugin "Plugins.transfer_lots" "transfer"
>>>>> plugin "beancount.plugins.implicit_prices"
>>>>>
>>>>> 2021-01-08 * "" "Buy LOT"
>>>>> Assets:Broker:LOT 1.25 LOT { 600 USD }
>>>>> Equity:Opening-Account
>>>>>
>>>>> 2021-01-10 * "" "Transfer LOT" #transfer
>>>>> Assets:Broker:LOT -1.25 LOT {}
>>>>> Assets:Storage:LOT
>>>>>
>>>>>
>>>>> 2021-03-11 * "Buy more LOT"
>>>>> Assets:Broker:LOT 0.25 LOT { 800 USD }
>>>>> Equity:Opening-Account
>>>>>
>>>>> 2021-03-12 * "Transfer LOT" #transfer ; failed to categorize posting
>>>>> Assets:Storage:LOT -1.25 LOT {}
>>>>> Assets:Storage2:LOT
>>>>>
>>>>> 2021-04-10 * "Transfer LOT" #transfer
>>>>> Assets:Broker:LOT -0.25 LOT {}
>>>>> Assets:Storage2:LOT
>>>>>
>>>>> 2021-04-10 * "Transfer LOT" #transfer ; failed to categorize posting
>>>>> Assets:Storage2:LOT -0.25 LOT {}
>>>>> Assets:Storage:LOT
>>>>>
>>>>> Why is that and what can I do here, to make this work?
>>>>>
>>>>> Editing the last txn to: (inspired by github issue 541)
>>>>> <https://github.com/beancount/beancount/issues/541>
>>>>>
>>>>> 2021-04-10 * "Transfer LOT" #transfer ; failed to categorize posting
>>>>> Assets:Storage2:LOT -0.25 LOT {USD}
>>>>> Assets:Storage:LOT 0
>>>>>
>>>>> Doesn't work, either:
>>>>>
>>>>> ** Balances before transaction --------------------------------
>>>>>
>>>>>   Assets:Storage2:LOT                     0.25 LOT {800 USD,
>>>>> 2021-03-11}
>>>>>
>>>>>   Assets:Storage:LOT                      1.25 LOT {600 USD,
>>>>> 2021-01-08}
>>>>>
>>>>>
>>>>> ** Unbooked Transaction --------------------------------
>>>>>
>>>>> 2021-04-10 * "Transfer LOT" #transfer
>>>>>   Assets:Storage2:LOT                            -0.25 LOT {}     ;
>>>>>
>>>>>   Assets:Storage:LOT   0 <class 'beancount.core.number.MISSING'>  ; 0
>>>>> <class 'beancount.core.number.MISSING'>
>>>>>
>>>>>
>>>>> ** Transaction --------------------------------
>>>>>
>>>>> 2021-04-10 * "Transfer LOT" #transfer
>>>>>   Assets:Storage2:LOT  -0.25 LOT {-0 USD, 2021-04-10}  ;  0 USD
>>>>>   Assets:Storage:LOT    0.25 LOT {-0 USD, 2021-04-10}  ; -0 USD
>>>>>
>>>>>
>>>>> ** Residual and Tolerances --------------------------------
>>>>>
>>>>>
>>>>>
>>>>> ** Balances after transaction --------------------------------
>>>>>
>>>>>   Assets:Storage2:LOT                     0.25 LOT {800 USD,
>>>>> 2021-03-11}
>>>>> * Assets:Storage2:LOT                     -0.25 LOT {-0 USD,
>>>>> 2021-04-10}
>>>>>
>>>>>   Assets:Storage:LOT                      1.25 LOT {600 USD,
>>>>> 2021-01-08}
>>>>> * Assets:Storage:LOT                       0.25 LOT {-0 USD,
>>>>> 2021-04-10}
>>>>>
>>>>> Any help/input is greatly appreciated. How can I "unlock" the lots and
>>>>> transfer them more than once?
>>>>>
>>>>> Regards
>>>>>
>>>>> --
>>>>> 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/5785792c-695a-4c5c-94d2-3adcc090aed7n%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/beancount/5785792c-695a-4c5c-94d2-3adcc090aed7n%40googlegroups.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/f7870d92-daa1-4eca-8bb9-4e6689858dc1n%40googlegroups.com
>>> <https://groups.google.com/d/msgid/beancount/f7870d92-daa1-4eca-8bb9-4e6689858dc1n%40googlegroups.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/31b5878e-14d0-46cd-8c2e-c1a80c0869a3n%40googlegroups.com
> <https://groups.google.com/d/msgid/beancount/31b5878e-14d0-46cd-8c2e-c1a80c0869a3n%40googlegroups.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/CACGEkZuVJoR48U-LHRwKj_K%2BVFDuHy77sZpY8xPEJOiGRCUDmg%40mail.gmail.com.

Reply via email to