tbm / test

0 stars 0 forks source link

option "account_rounding" should check for valid account name #67

Closed tbm closed 9 years ago

tbm commented 9 years ago

Original report by Jakob Schnitzer (Bitbucket: yagebu, GitHub: yagebu).


When running balances in the bean-query shell, I get the following Traceback. I have non-standard root accounts set using options in my beancount file and don't get this error with the example generated by bean-example. Not sure if the fact that I'm using non-standard root accounts produces this problem or if it's something else

Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/cmd.py", line 214, in onecmd
    func = getattr(self, 'do_' + cmd)
AttributeError: 'BQLShell' object has no attribute 'do_balances'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/beancount/query/shell.py", line 229, in default
    self.dispatch(statement)
  File "/usr/local/lib/python3.4/site-packages/beancount/query/shell.py", line 219, in dispatch
    return method(statement)
  File "/usr/local/lib/python3.4/site-packages/beancount/query/shell.py", line 408, in on_Balances
    return self.on_Select(balance)
  File "/usr/local/lib/python3.4/site-packages/beancount/query/shell.py", line 362, in on_Select
    self.options_map)
  File "/usr/local/lib/python3.4/site-packages/beancount/query/query_execute.py", line 271, in execute_query
    for c_expr in c_nonaggregate_exprs)
  File "/usr/local/lib/python3.4/site-packages/beancount/query/query_execute.py", line 271, in <genexpr>
    for c_expr in c_nonaggregate_exprs)
  File "/usr/local/lib/python3.4/site-packages/beancount/query/query_env.py", line 183, in __call__
    index, name = account_types.get_account_sort_key(context.account_types, args[0])
  File "/usr/local/lib/python3.4/site-packages/beancount/core/account_types.py", line 45, in get_account_sort_key
    return (account_types.index(get_account_type(account_name)), account_name)
ValueError: tuple.index(x): x not in tuple

Update: thought the shell just ignored the options, but it doesn't, so I'm not sure anymore where the problem comes from

tbm commented 9 years ago

Original comment by Jakob Schnitzer (Bitbucket: yagebu, GitHub: yagebu).


I have removed the account_rounding option and the error has disappeared.

tbm commented 9 years ago

Original comment by Jakob Schnitzer (Bitbucket: yagebu, GitHub: yagebu).


Turns out I simply had set account_rounding to an invalid account name. I mistakenly thought it was also going to be a subaccount of Equity like the other account_* options...

It would be nice if beancount checked the options that set account names and displayed an error if they're invalid, then this won't happen to anyone else.

tbm commented 9 years ago

Original comment by Martin Blais (Bitbucket: blais, GitHub: blais).


Fixed #67: Changed the semantics of the 'account_rounding' option to be consistent with the other ones: a sub-account of Equity.