I'm preparing reports for my accountant and I have found what looks like a limitation of hledger. I'm interested in knowing:
Am I using hledger incorrectly?
If this is a limitation of hledger, is it intentional?
If this feature is desired, how much effort would it be?
I have a tree of Expense accounts and the postings in those accounts are labeled with a significant tag. Now I want to combine the beauty of --pivot on balance amounts per tag value with the beauty of --tree in order to get both the balances per tag value of each subaccount and the rolled-up balance per tag value.
Based on what I've tried so far, if I use --pivot, then --tree appears to have no effect.
I get a balance report per rental_unit value, but only for the root account and not the subaccounts.
Workaround
I know that I can list the subaccounts, then run the --pivot report for each subaccount. I'm wondering whether I'm missing something, and if not whether this is intentional, and if not whether what I'm trying to do is something that hledger could feasibly support.
No, the problem was that there are effectively two trees: one consisting of subaccounts of Expenses:Residential Rental Properties and the other consisting of the values of the tag rental_unit. As far as I can tell, that means a Morton's Fork.
pivot on rental_unit, but then I can't see the subaccount balances per rental unit, but rather only the total in Residential Rental Properties.
tree on Expenses:Residential Rental Properties, but then I can't see the amounts by rental unit, but rather only the total balance in each subaccount for all rental units.
It makes perfect sense that hledger would behave like this, because the resulting report is a forest and not a tree, but I was hoping I had missed some magic somewhere.
An example to make it more concrete:
Expenses
Residential Rental Properties
Management Fees
Ordinary Repairs
Electricity
Could I get a tree-style report showing the balance in each of those three subaccounts as well as the parent accounts also pivoted by rental unit tag value in a single command? I know that I could iterate over either the subaccount names or the rental unit tag values.
I'm finally getting back to this and I appreciate you for giving me a near-perfect solution. The only downside to your command is that it includes the items not tagged with rental_unit. Fortunately, I tried the obvious fix and that worked. I added "tag:rental_unit" in order to select only the transactions with a value for that tag.
Unfortunately, this seems to also match transactions with tags that contain this string. I presume the query is a (partial) regex match and not a full-text match.
For example, I have a tag named trip as well as Stripe-related tags with names like stripe_transaction_id, so when I run this report, it includes transactions with the Stripe-related tags.
@simonmic, is this a defect in the product or the documentation?
I found a way to get the result I want without matching the unrelated transactions. At the very least, I believe this merits special mention in the documentation, because it makes sense, but maybe isn't obvious. Note the use of ^...$ for the tag query.