redstreet / fava_investor

Comprehensive set of reports, analyses, and tools for investments, for Beancount and Fava (plain text, double entry accounting software). Includes Fava plugins, command line tools, and libraries for each module.
GNU General Public License v3.0
135 stars 19 forks source link

New fava version breaks fava-investor #84

Closed francocalvo closed 10 months ago

francocalvo commented 1 year ago

Hi! Apparently, v1.2.5 breaks fava_dashboards. For example, I've seen that FavaAPIException is not FavaAPIError in helpers.py.

I get this error:

werkzeug.routing.exceptions.BuildError: Could not build url for endpoint 'extension_report' with values ['bfile', 'module', 'report_name']. Did you forget to specify values ['extension_name']?

Reference:

redstreet commented 1 year ago

Good to know, thanks for the references too!

I'll get around to it when I can. Meanwhile, PR welcome from anyone.

francocalvo commented 1 year ago

I'll take a look at it. Most modules work just adding the correct extension_name.

There is a problem where g.ledger.price_map doesn't exist anymore. Now, it's called g.ledger.price, which returns a ~PriceMap called FavaPriceMap. This is the definition: link to beancount/fava.

When fava-investor tries to convert positions to amounts in assetalloc_class here: permalink to fava-investor/assetalloc_class/libassetalloc, it uses the beancount API, which tries to inverse, which breaks the process. Look:


  File "/home/calvo/Nextcloud/Finanzas/Beans/.venv/lib/python3.10/site-packages/fava_investor/modules/assetalloc_class/libassetalloc.py", line 103, in bucketize
    amount = convert.convert_position(pos, base_currency, price_map, date=end_date)
  File "/home/calvo/Nextcloud/Finanzas/Beans/.venv/lib/python3.10/site-packages/beancount/core/convert.py", line 177, in convert_position
    return convert_amount(pos.units, target_currency, price_map,
  File "/home/calvo/Nextcloud/Finanzas/Beans/.venv/lib/python3.10/site-packages/beancount/core/convert.py", line 202, in convert_amount
    _, rate = prices.get_price(price_map, base_quote, date)
  File "/home/calvo/Nextcloud/Finanzas/Beans/.venv/lib/python3.10/site-packages/beancount/core/prices.py", line 356, in get_price
    return get_latest_price(price_map, base_quote)
  File "/home/calvo/Nextcloud/Finanzas/Beans/.venv/lib/python3.10/site-packages/beancount/core/prices.py", line 329, in get_latest_price
    price_list = _lookup_price_and_inverse(price_map, base_quote)
  File "/home/calvo/Nextcloud/Finanzas/Beans/.venv/lib/python3.10/site-packages/beancount/core/prices.py", line 278, in _lookup_price_and_inverse
    return price_map[base_quote]
TypeError: 'FavaPriceMap' object is not subscriptable

There isn't an obvious way to go from FavaPriceMap to PriceMap, so maybe we can get the amount without the convert_amount method?

redstreet commented 10 months ago

See this comment:

With the latest fixes, everything works except for asset allocation by class, with which the display formatting is incorrect, and is missing the graph. I've opened https://github.com/beancount/fava/issues/1721 for it. Help appreciated.

87 tracks that issue. Closing this.