GNOME Bugzilla – Bug 591117
Cash Flow Report's "Depth: All" Option is Broken
Last modified: 2018-06-29 22:26:13 UTC
The Cash Flow report option dialog contains an "Account Display Depth" picklist which can be used to select a numeric value from 1 to 6, or the value "All". I can find no documentation for this option, but it appears intended to let the user truncate the report's account listing to only those accounts whose depth in the account tree is <= the chosen display depth. Due to a bug in the report implementation, the setting does not work as intended if no top-level account has been selected. Consider the scenario depicted in the screenshot which I will post. Two accounts are selected, one at depth 2 and one at depth 3 (where the top level accounts are level 1). The "Account Display Depth" is set to "All". The expected behavior is that the two selected accounts should be displayed under the "Selected Accounts" label in the generated report. However, no accounts are displayed. If the Account Display Depth is changed from "All" to "3", however, both accounts are displayed, as expected. The problem occurs in cash-flow.scm. The handling of the "All" setting for Account Display Depth involves setting the depth threshold to the maximum depth of all selected accounts, at line 215. But the function used to make the calculation, accounts-get-children-depth, actually computes the maximum of the depths of the subtrees rooted at each account in the accounts argument. In the test case, because neither of the two accounts has children, this maximum depth is 1.
Created attachment 140172 [details] screenshot of problem scenario
Here's a patch. By the way, in my previous comment, what I should have said is that the handling of the "All" setting for Account Display Depth involves setting the depth threshold to the maximum depth of all selected accounts *and their children*, at line 215.
Created attachment 140176 [details] [review] patch to fix handling of Account Display Depth 'All' option
Comment on attachment 140176 [details] [review] patch to fix handling of Account Display Depth 'All' option Patch looks good, please apply.
Comment on attachment 140176 [details] [review] patch to fix handling of Account Display Depth 'All' option r18316
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=591117. Please update any external references or bookmarks.