Here, I finally did implemented a prototype: https://bitbucket.org/blais/beancount/commits/ecf5229f65fd574676cd47a060cfbe22152d12fb I guess it took me two hours.
It's not entirely trivial; there are a few issues that keep this at the level of "prototype": 1. the price annotations get stripped out, which means that if you used the implicit_prices plugin AFTER this one, your prices might disappear. Other plugins, such as sellgains, would also have to run BEFORE this one in order to take effect. Custom scripts also would not see price annotations. This could be fixed by changing the booking code to ignore the price annotation for modified postings (identified via flag of the presence of metadata). In other words, instead of removing the price annotations, keep them but make them "lame" by inserting some metadata and requiring collaboration with the booking code (it's a little bit ugly, but I'd be okay with it). 2. In some cases - a transaction with multiple currency groups, at least one price annotation, and some non-zero residual - a currency trading account posting will be inserted in lieu of a residual posting. This messes with the rounding feature that automatically inserts postings for residuals (maybe it's not that big a deal). I think it could be improved further by conditioning the insertion on multiple required currency account postings. For more about these limitations, see the test file (look for FIXME). I like this plugin. There's no need to change any of your input to use it (it worked on my ledger without modification). Maybe I should finesse it and this could become there by default in a future version. It works on my personal large input file and does adds only an insignificant amount of overhead. This is the most natural way to deal with conversions. See this file for usage instructions: https://bitbucket.org/blais/beancount/src/default/beancount/plugins/currency_accounts.py On Wed, Feb 27, 2019 at 9:17 PM Martin Blais <[email protected]> wrote: > I believe it's absent. > In Beancount, what would be required is basically to sum up the balances > of each currency group and insert new accounts. > It's not difficult, though it's not cheap, some optimizations might be > required. > > > > > > > On Wed, Feb 27, 2019 at 9:14 PM Callum Makkai <[email protected]> wrote: > >> >> On 2/27/19 9:10 PM, Martin Blais wrote: >> >> An elegant way to handle this is to use the Selinger trading accounts >> method. >> It would be easy to write a Beancount plugin to do this automatically. >> >> >> Jumping in here ... Martin, I was reading about the Selinger method the >> other day. Do you know if ledger or hledger implements this method? Or it's >> totally absent from all plain text packages? >> >> Callum >> >> -- >> 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 post to this group, send email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/beancount/73b3eb60-39b3-3d64-37e4-0b82543fe40e%40gmail.com >> <https://groups.google.com/d/msgid/beancount/73b3eb60-39b3-3d64-37e4-0b82543fe40e%40gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- 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 post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/CAK21%2BhOtEonPbvLgDj6%2BDDns7BhkHgggMeaxu9ZWXoGyJb%2B5Zw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
