How to automatically close all descendants of an account?

Visto 72 veces
Saltar al primer mensaje no leído

cantas...@gmail.com

no leída,
21 ago 2022, 15:59:0521/8/22
a Beancount
Hello,
Sorry if this question has already been asked in the past. I was not able to find any references.

Is there a way to automatically close all an account and all its descendants? It'd be useful for investment accounts with lots of commodities. Maybe there's already a plugin that I am not aware of.

Thank you,
Stefano

Martin Blais

no leída,
21 ago 2022, 17:28:1821/8/22
a Beancount
That's a good idea. I would certainly use it.
The answer is there isn't at the moment.

--
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/4ae041c8-9586-4987-bf01-03e3ce29c325n%40googlegroups.com.

Red S

no leída,
22 ago 2022, 4:57:4122/8/22
a Beancount
I've wanted one too. Just wrote it up. See here.

In short:

pip3 install git+https://github.com/redstreet/beancount_reds_plugins

And add this to your sources:

plugin "beancount_reds_plugins.autoclose_tree.autoclose_tree" "{}"

Stefano Mihai Canta

no leída,
22 ago 2022, 9:18:5922/8/22
a bean...@googlegroups.com
Hey,
Thank you! I was going to write my first plugin, but you beat me to it :)
I'll use this as a template for the future.

I appreciate it,
Stefano

You received this message because you are subscribed to a topic in the Google Groups "Beancount" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beancount/mTDZ3sQjH9U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/25689f47-27c2-4cc2-958c-397a468846d1n%40googlegroups.com.

Stefano Mihai Canta

no leída,
22 ago 2022, 9:27:2222/8/22
a bean...@googlegroups.com
There might be a problem with the account name matching.
This directive:
2018-11-10 close Liabilities:Credit-Cards:Wife:Citi
also seems to match an account named Liabilities:Credit-Cards:Wife:Citi-CustomCash, which should remain open. Instead, the directive should match Liabilities:Credit-Cards:Wife:Citi and Liabilities:Credit-Cards:Wife:Citi:*, but not Liabilities:Credit-Cards:Wife:Citi*.

Stefano

Red S

no leída,
22 ago 2022, 15:22:4822/8/22
a Beancount
There might be a problem with the account name matching.
This directive:
2018-11-10 close Liabilities:Credit-Cards:Wife:Citi
also seems to match an account named Liabilities:Credit-Cards:Wife:Citi-CustomCash, which should remain open. Instead, the directive should match Liabilities:Credit-Cards:Wife:Citi and Liabilities:Credit-Cards:Wife:Citi:*, but not Liabilities:Credit-Cards:Wife:Citi*.

Indeed, fixed now.


Thank you! I was going to write my first plugin, but you beat me to it :)
I'll use this as a template for the future.

Welcome! But oops, didn't mean to take away that opportunity. The more plugin writers we have, the better :). Glad it helps as a template at least.

 

Red S

no leída,
22 ago 2022, 15:25:3522/8/22
a Beancount
Feel free to let me know of other bugs, or better yet, send pull requests on github if you're up for it.

Daniele Nicolodi

no leída,
22 ago 2022, 15:29:0422/8/22
a bean...@googlegroups.com
On 22/08/2022 10:57, Red S wrote:
> I've wanted one too. Just wrote it up. See here
> <https://github.com/redstreet/beancount_reds_plugins/tree/main/beancount_reds_plugins/autoclose_tree#readme>.
>
> In short:
>
> pip3 install git+https://github.com/redstreet/beancount_reds_plugins
>
> And add this to your sources:
>
> plugin "beancount_reds_plugins.autoclose_tree.autoclose_tree" "{}"

Is there a reason why you pass an "empty" configuration string to a
plugin that does not need any configuration?

Cheers,
Dan

Red S

no leída,
22 ago 2022, 15:48:3022/8/22
a Beancount
> plugin "beancount_reds_plugins.autoclose_tree.autoclose_tree" "{}"

Is there a reason why you pass an "empty" configuration string to a
plugin that does not need any configuration?

It's a holdover from when I originally had a config option that I simplified out, but wasn't committed to removing fully yet. Now removed

Stefano Mihai Canta

no leída,
22 ago 2022, 16:09:0122/8/22
a bean...@googlegroups.com
Does the order of the directives matter?

Here's what I have (simplified)

plugin "beancount_reds_plugins.autoclose_tree.autoclose_tree"
plugin "beancount.plugins.auto_accounts"
2017-08-10 open Assets:Investments:Non-Retirement:Ciara:Robinhood
2017-11-13 close Assets:Investments:Non-Retirement:Ciara:Robinhood
[... a bunch of transactions into subaccounts, :SIRI, :Cash, etc]

I don't see a close directive for Assets:Investments:Non-Retirement:Ciara:Robinhood:SIRI in Fava.

--
You received this message because you are subscribed to a topic in the Google Groups "Beancount" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beancount/mTDZ3sQjH9U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/e4e7c5e2-edee-4a9e-b75b-6564bbf90279n%40googlegroups.com.

Red S

no leída,
22 ago 2022, 16:17:0622/8/22
a Beancount
I don't know -- I don't use the auto_accounts plugin. I assume it inserts open directives, meaning autoclose_tree should likely come after it. Could you please try and confirm, and I'll update the doc.

Stefano Mihai Canta

no leída,
22 ago 2022, 16:35:4422/8/22
a bean...@googlegroups.com
That was it. Swapping the order of the two plugins fixed the error. In addition, auto_accounts opens the leaves automatically, but it does not add a directive to open an ancestor account if that's missing. I had another set of transactions with a different broker, and all the leaf accounts had an open statement, but not the parent one (...:WiseBanyan was never open, but ...:WiseBanyan:Cash, ...:WiseBanyan:APPL, etc were).


--
You received this message because you are subscribed to a topic in the Google Groups "Beancount" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beancount/mTDZ3sQjH9U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beancount+...@googlegroups.com.

Red S

no leída,
22 ago 2022, 18:33:2322/8/22
a Beancount
That was it. Swapping the order of the two plugins fixed the error. In addition, auto_accounts opens the leaves automatically, but it does not add a directive to open an ancestor account if that's missing. I had another set of transactions with a different broker, and all the leaf accounts had an open statement, but not the parent one (...:WiseBanyan was never open, but ...:WiseBanyan:Cash, ...:WiseBanyan:APPL, etc were).

Yeah, I ran into that case as well. autoclose_tree now handles it.

You can close unopened parents:

2017-11-10 open Assets:Brokerage:AAPL
2017-11-10 open Assets:Brokerage:ORNG
2018-11-10 close Assets:Brokerage ; this account was never opened, and this would
                                  ; normally be an invalid directive

becomes:

2017-11-10 open Assets:Brokerage:AAPL
2017-11-10 open Assets:Brokerage:ORNG
2018-11-10 close Assets:Brokerage:AAPL
2018-11-10 close Assets:Brokerage:ORNG


 

Red S

no leída,
22 ago 2022, 20:39:3222/8/22
a Beancount
On Monday, August 22, 2022 at 3:33:23 PM UTC-7 Red S wrote:
That was it. Swapping the order of the two plugins fixed the error.

Documented in README.md

Stefano Mihai Canta

no leída,
22 ago 2022, 21:30:5122/8/22
a bean...@googlegroups.com
Hi,
I still get this error message in fava with your latest change if I get rid of the open directive, and rely on the auto_accounts plugin.
image.png
Thanks,


--
You received this message because you are subscribed to a topic in the Google Groups "Beancount" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beancount/mTDZ3sQjH9U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beancount+...@googlegroups.com.

Red S

no leída,
23 ago 2022, 0:03:4723/8/22
a Beancount
Would you mind filing a bug in github with a minimal reproducible example? If you feel up to it, a fix with a unit test is also appreciated.

Red S

no leída,
24 ago 2022, 19:36:3724/8/22
a Beancount
Thanks for filing.

beancount.plugins.auto_accounts inserts an open for Expenses:Non-Retirement:Auto:Fit because it sees the close directive for it. The open and Close occur on the same date, leading to this error. Fixed by special casing this scenario.



Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos