redstreet / beancount_reds_plugins

Miscellaneous plugins for Beancount double entry accounting
GNU General Public License v3.0
96 stars 18 forks source link

Parent account open/close error with autoclose_tree #19

Closed scanta2 closed 2 years ago

scanta2 commented 2 years ago

Here's an example of a project that shows an error in fava about the parent account getting closed before the opening date. I think the parent account does not get opened properly, or possibly it is assigned an opening date that is not earlier than the children's date.

option "operating_currency" "USD"
option "conversion_currency" "USD"

plugin "beancount.plugins.auto_accounts"
plugin "beancount_reds_plugins.autoclose_tree.autoclose_tree" 

2021-06-17 close Expenses:Non-Retirement:Auto:Fit

2019-01-01 * "Transaction"
  Expenses:Non-Retirement:Auto:Fit:Insurance      10 USD
  Expenses:Non-Retirement:Auto:Fit:Gas            20 USD
  Assets:Transfer
redstreet commented 2 years ago

Ah, 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.

~The solution here might be to get auto_accounts to not add opens for close directives.~

Fixed by special casing this.

blais commented 2 years ago

On vacation, so not getting the full context of this, only on my phone, but closing an account without opening one will trigger an error. If the error is that open and close happen on the same date maybe adjusting the generation of open date makes more sense.

On Thu, Aug 25, 2022, 01:08 Red S @.***> wrote:

Ah, 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.

The solution here might be to get auto_accounts to not add opens for close directives. Let me ask @blais https://github.com/blais for his thoughts.

— Reply to this email directly, view it on GitHub https://github.com/redstreet/beancount_reds_plugins/issues/19#issuecomment-1226583110, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACSBE3U3OSRVZMRL2GXOVTV22TP7ANCNFSM57PS6SRQ . You are receiving this because you were mentioned.Message ID: @.***>

redstreet commented 2 years ago

@blais, please ignore this thread, it's been resolved. If you're curious, here's context. The source below:

plugin beancount.plugins.auto_accounts
2020-01-01 close Assets:Bank

looks like this after the auto_accounts plugin runs:


2020-01-01 open Assets:Bank
2020-01-01 close Assets:Bank

This is fine normally, but the new autoclose_tree plugin I wrote overloads the close syntax to close children of parent accounts that were never opened. Except, when used in conjunction with auto-accounts, that parent account inadvertently gets opened (on the same date as the close). See OP's example on the top of this thread.

I originally tagged you because a "clean" solution is to get auto_accounts to not generate opens for accounts which appear solely in a close directive. Instead, I decided to solve it by detecting this case in autoclose_tree.

Enjoy your vaction!

scanta2 commented 2 years ago

Thanks! Works well now