Hello!
I made a PR with an implementation of this feature on GitHub [1] but was
asked to propose it here as well. This means you can actually already try
it out if this interests you. Here is what my proposed change does:
Right now (as of ledger 3.2.1), the `--depth` option in register reports
'cuts off' postings with a deeper level than the specified one. This
means any postings to subaccounts will not be accounted for in the
'amount' column. They will however still be added into the 'total'
column.
In my opinion, this isn't really a useful feature as it stands and the
report is quite unintuitive (adding all amounts does not yield the total).
So instead, my PR changes the behavior as follows:
`--depth` now 'collapses' all subaccounts up to the given depth. This
means any postings to subaccounts will be summed and added to the account
of the given depth. The outcome is that 'amount' and 'total' columns are
in agreement again (adding all 'amount's yields the final 'total') and no
postings are unaccounted for in the 'amount' column.
To visualize this, here is an example. The following register report:
$ ledger reg ^Expenses
20-May-13 Test Expenses:AA:BB 3.00 EUR 3.00 EUR
Expenses:AA 3.00 EUR 6.00 EUR
20-May-14 Test Expenses:AA:BB:CC 2.00 EUR 8.00 EUR
Expenses:DD 4.00 EUR 12.00 EUR
could, with this change implemented, be collapsed to the second level like
this:
$ ledger reg ^Expenses --depth 2
20-May-13 Test Expenses:AA 6.00 EUR 6.00 EUR
20-May-14 Test Expenses:AA 2.00 EUR 8.00 EUR
Expenses:DD 4.00 EUR 12.00 EUR
Note how the total is always the previous total + the amount. Without
this change, you'd get a report like this:
$ ledger reg ^Expenses --depth 2 # The old behavior
20-May-13 Test Expenses:AA 3.00 EUR 6.00 EUR
20-May-14 Test Expenses:DD 4.00 EUR 12.00 EUR
As you can see, in the first line, the total is suddenly 6 even though the
amount is only 3. And in the second line, the total again jumps by more
than what the amount would suggest.
In addition to fixing this inconsistency, this would also bring the
behavior of `--depth` in register reports more in line with what `--depth`
does for balance reports. There, it also doesn't cut off subaccounts but
accumulates their balances in the account of the given depth.
(Sidenote: The existing `-n`/`--collapse` option does what would now be
equivalent to `--depth 0`)
I'd be happy to get some feedback on this!
[1]: https://github.com/ledger/ledger/pull/1901
--
Rahix
--
---
You received this message because you are subscribed to the Google Groups
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ledger-cli/1c6ac861fe533a6bb47663a49dae2cfa2be1a0c1.camel%40rahix.de.