beancount / fava

Fava - web interface for Beancount
https://beancount.github.io/fava/
MIT License
1.93k stars 284 forks source link

Fava is incompatible with beanquery #1824

Open zacchiro opened 3 months ago

zacchiro commented 3 months ago

I'm using Beancount 2.3.5 with Fava 1.25.1 and Beanquery 0.1.dev0 (commit b8c2ddd3105f3e15a8651bd74faa0097fe1e37d3). My queries work fine on the Beanquery CLI and REPL, but many of them fail in various ways when used within the Fava UI. A few examples follow.

This query:

  SELECT sum(position) AS expenses, any_meta('trip') AS trip
  WHERE account ~ '^Expenses'
  AND NOT account ~ 'Cash'
  GROUP BY any_meta('trip')
  ORDER BY any_meta('trip')

fails with:

Traceback (most recent call last):
  File "/usr/lib/python3.11/cmd.py", line 214, in onecmd
    func = getattr(self, 'do_' + cmd)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'QueryShell' object has no attribute 'do_SELECT'

This query:

SELECT account, any_meta('creditor') AS creditor, sum(position) AS amount
WHERE account ~ '^Liabilities:Payables'
AND any_meta('creditor') IS NOT NULL
GROUP BY account, creditor
HAVING NOT empty(sum(position))
ORDER BY creditor, account

fails with:

ERROR: Syntax error near 'is' (at 143)

I understand that, in a general sense, this is due to the Beancount v2/v3 split, but I haven't explored the problem deeper than this. I'd like to understand if there is a plan to fix this incompatibility and how contributors can help.

cc: @dnicolodi (Beanquery maintainer)

yagebu commented 6 days ago

See #1860 for a PR that switches Fava to use beanquery