Open jcornaz opened 2 years ago
This is something that was really confusing to me too. I would expect Fava to do one of the following:
But instead, it does:
It would be really helpful to have support for methods 1 or 2 above, since I think that's what most users would expect/need when filtering reports.
@yagebu, why the docs
label?
We are asking for a change of behavior here. To me the current behavior is so surprising that I would qualify this issue as "Bug", though I can understand if it is qualified as an "enhancement" in case that behavior was intentional.
I too think the current behavior is a bug. I want to see the accounts I selected. That would be my "this is logical" expectation.
The current behaviour is intentional. Only allowing transactions that balance is one of the core invariants of Beancount. So filtering on complete transactions is the only way to obtain a subset of all entries that behaves consistently in all reports. In the Beancount query language, these two levels of filtering are represented by FROM (complete entries, which works like the filters in Fava) and WHERE (postings) (see also https://beancount.github.io/docs/beancount_query_language.html#transactions-and-postings). So when writing a custom BQL query, you can apply both levels of filters as you wish, but some of the shortcuts like balances
or journal
only support FROM expressions. (@rnd256 described a further filter level above - a filter over the generated report: 1.; the others correspond as follows: FROM: 3. WHERE: 2.)
Both levels of filtering can be useful but only the whole transaction filtering can work well across all reports. In particular for reports with a somewhat well-defined meaning like a balance sheet, IMHO core invariants like the balance sheet equation should not be violated and for that reason the "global" filters should behave like FROM.
I've personally found the FROM-like filters to be very useful, as it easily allows me to answer questions like "how much did I spend on food with which card" (filtering to Expenses:Food). So I've often found the "extra" accounts that are still there after the filtering to be exactly the information I want and was never really bothered by them.
We could add WHERE-like filters to Fava, but I believe these should not apply to the balance sheet and income statement and maybe be new separate reports. For the case of filtering to a single account (which seems to be the example given here) this already exists: The account report for that account.
Thanks for your response, @yagebu. After spending more time on this, I think report filtering is really what we're after here. ie. Generate an entire balance sheet with no filtering, then filter the results based on account. That would effectively give people a view similar to Fava's account report view, but they'd be able to include any number of accounts in the view.
That's useful for cases where the aggregation levels/combinations you're interested in can't be perfectly reflected in your account hierarchy. Eg. If your hierarchy goes AssetClass:Person:Account
, where AssetClass
can be "Investments" or "Cash", Person
can be "rnd256" or "wife". I want to be able to see reports for all "Investments" and reports for all "rnd256".
FYI for folks wanting to accomplish this, I've been using the command line: bean-query main.beancount "SELECT date, narration, position, balance WHERE account = 'Assets:MyAccount'" | less
Given the following beancount file:
When filtering by the account
Assets:A:B
, fava also shows the accountAssets:A:E
that should be filtered out as it is not a sub-account ofAssets:A:B
.Fava version:
1.21