Okay, this plugin is now usable. All problems above have been fixed, tests updated.
If you use it, I'd be interested in feedback, especially on how the configuration specification works (or not) for your account hierarchy. README <https://github.com/redstreet/beancount_reds_plugins/tree/master/beancount_reds_plugins/capital_gains_classifier#readme> . <https://github.com/redstreet/beancount_reds_plugins/tree/master/beancount_reds_plugins/capital_gains_classifier#readme> On Tuesday, April 26, 2022 at 12:42:49 PM UTC-7 Red S wrote: > Thought this > <https://groups.google.com/g/beancount/c/GCuGaVpe-x0/m/_dZ_ugKMAQAJ> > deserved a thread of its own. Here is a new plugin > <https://github.com/redstreet/beancount_reds_plugins/tree/master/beancount_reds_plugins/capital_gains_classifier> > > that classifies sales into short term or long term capital gains based on > how long they have been held, like so: Converts: > ``` > plugin "long_short" "{ > 'generic_account_pat': ':Capital-Gains', > 'short_account_rep': ':Capital-Gains:Short', > 'long_account_rep': ':Capital-Gains:Long', > }" > > 2014-01-01 open Assets:Brokerage > 2014-01-01 open Assets:Bank > 2014-01-01 open Income:Capital-Gains > > 2014-02-01 * "Buy" > Assets:Brokerage 100 ORNG {1 USD} > Assets:Bank -100 USD > > 2016-02-01 * "Buy" > Assets:Brokerage 100 ORNG {2 USD} > Assets:Bank -200 USD > > 2016-03-01 * "Sell" > Assets:Brokerage -100 ORNG {1 USD} @ 2.50 USD > Assets:Brokerage -100 ORNG {2 USD} @ 2.50 USD > Assets:Bank 500 USD > Income:Capital-Gains > ``` > > to: > ``` > 2014-01-01 open Assets:Brokerage > 2014-01-01 open Assets:Bank > 2014-01-01 open Income:Capital-Gains:Short > 2014-01-01 open Income:Capital-Gains:Long > > 2014-02-01 * "Buy" > Assets:Brokerage 100 ORNG {1 USD} > Assets:Bank -100 USD > > 2016-02-01 * "Buy" > Assets:Brokerage 100 ORNG {2 USD} > Assets:Bank -200 USD > > 2016-03-01 * "Sell" > Assets:Brokerage -100 ORNG {1 USD} @ 2.50 USD > Assets:Brokerage -100 ORNG {2 USD} @ 2.50 USD > Assets:Bank 500 USD > Income:Capital-Gains:Short -50 USD > Income:Capital-Gains:Long -150 USD > ``` > > WARNINGS: > - still under development > - doesn't work for leap years yet > - doesn't distinguish between reductions and short purchases (doesn't > understand the > latter) > - there are probably cases outside the current unit tests that this fails > for > > See beancount-reds-plugins > <https://github.com/redstreet/beancount_reds_plugins/tree/master/beancount_reds_plugins/capital_gains_classifier> > > for how to install and configure: > pip3 install git+https://github.com/redstreet/beancount_reds_plugins > > Added to Martin's contribs doc > <https://docs.google.com/document/d/1Z37bQ45wDtjTPaMQ_x-f33p1trH9fNosEAUgbQXwp30/edit>. > > > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/2362e9e5-fc3f-4ece-949e-df010d41bee7n%40googlegroups.com.