You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I received the below error when trying to access "Asset Allocation Classes" in Fava Investor.
I was able to get around it by casting meta_value to a Decimal on line 122 and 123.
Exception on /generic-users-finances/extension/Investor/ [GET]
Traceback (most recent call last):
File "/Users/generic-user/.virtualenvs/beans/lib/python3.9/site-packages/flask/app.py", line 2525, in wsgi_app
response = self.full_dispatch_request()
File "/Users/generic-user/.virtualenvs/beans/lib/python3.9/site-packages/flask/app.py", line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/generic-user/.virtualenvs/beans/lib/python3.9/site-packages/flask/app.py", line 1820, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/generic-user/.virtualenvs/beans/lib/python3.9/site-packages/flask/app.py", line 1796, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "/Users/generic-user/.virtualenvs/beans/lib/python3.9/site-packages/fava/application.py", line 360, in extension_report
content = Markup(render_template_string(template, extension=extension))
File "/Users/generic-user/.virtualenvs/beans/lib/python3.9/site-packages/flask/templating.py", line 159, in render_template_string
return _render(app, template, context)
File "/Users/generic-user/.virtualenvs/beans/lib/python3.9/site-packages/flask/templating.py", line 130, in _render
rv = template.render(context)
File "/Users/generic-user/.virtualenvs/beans/lib/python3.9/site-packages/jinja2/environment.py", line 1301, in render
self.environment.handle_exception()
File "/Users/generic-user/.virtualenvs/beans/lib/python3.9/site-packages/jinja2/environment.py", line 936, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 239, in top-level template code
File "/Users/generic-user/.virtualenvs/beans/lib/python3.9/site-packages/fava_investor/__init__.py", line 22, in build_assetalloc_by_class
return libassetalloc.assetalloc(accapi, self.config.get('asset_alloc_by_class', {}))
File "/Users/generic-user/.virtualenvs/beans/lib/python3.9/site-packages/fava_investor/modules/assetalloc_class/libassetalloc.py", line 203, in assetalloc
asset_buckets = bucketize(vbalance, accapi)
File "/Users/genric-user/.virtualenvs/beans/lib/python3.9/site-packages/fava_investor/modules/assetalloc_class/libassetalloc.py", line 122, in bucketize
asset_buckets[bucket] += amount.number * (meta_value / 100)
TypeError: unsupported operand type(s) for /: 'str' and 'int'
I recently moved to using OFX and the corresponding reds importer for OFX files and it introduced some Assets:Zero-Sum-Accounts:Transfers that I believe created some "unknown" asset_alloc_by_class. I added this to my fava_config to get unknown to zero but even after doing that it looks like I need to cast meta_value to decimal to get Asset Allocation Classes to load
The text was updated successfully, but these errors were encountered:
This casting should not be required. Casting is likely hiding your true problem. And hmm, postings to Assets:Zero-Sum-Accounts:Transfers may not be related at all. The unknown warning occurs when your commodity metatadata is not fully filled out, or non-existent for a certain commodity. See here.
The only requirement is that the metadata field name begins with the prefix asset_allocation_, and has a number for its value that is a percentage, corresponding to the percentage of the commodity belonging to that asset class. The set of all asset classes for a commodity should add up to a 100. When they do not, the reporter will pad the remaining with the 'unknown' class.
Yep all solved. Thanks for pointing me in the right direction.
TypeError: unsupported operand type(s) for /: 'str' and 'int'
I actually had some asset_allocation defined in my commodities file as str accidentally (e.g. asset_allocation_x "100" instead of asset_allocation_x 100).
Great! Thanks for sharing the issue too. Heh, while it's awesome that Beancount allows arbitrary metadata types, I've tripped up these a few times myself. The code should probably catch this exception and provide a helpful warning to the user (eg: "Your metadata turned out to be a string, while an integer was expected" rather than just a stack trace. Will do at some point.
I received the below error when trying to access "Asset Allocation Classes" in Fava Investor.
I was able to get around it by casting meta_value to a Decimal on line 122 and 123.
I recently moved to using OFX and the corresponding reds importer for OFX files and it introduced some Assets:Zero-Sum-Accounts:Transfers that I believe created some "unknown" asset_alloc_by_class. I added this to my fava_config to get unknown to zero but even after doing that it looks like I need to cast meta_value to decimal to get Asset Allocation Classes to load
The text was updated successfully, but these errors were encountered: