how to collapse sub-accounts?

524 views
Skip to first unread message

Myles English

unread,
Aug 6, 2013, 7:07:40 AM8/6/13
to ledger-cli

Hello,

In a monthly report, I would like to conceal how much money I really
spend on gum by included it in the food budget.

This does most of what I want:

$ ledger -M --period-sort "(amount)" reg ^expenses:Food -X £

2013-06-01 - 2013-06-30 Expenses:Food:Gum £5.90 £2,965.84
Expenses:Food £127.17 £3,093.01
2013-07-01 - 2013-07-31 Expenses:Food £18.00 £3,111.01

but how can I remove the Gum line and add it to the Food?, thus:

2013-06-01 - 2013-06-30 Expenses:Food £133.07 £3,093.01
2013-07-01 - 2013-07-31 Expenses:Food £18.00 £3,111.01

Thanks for any help,

Myles

John Wiegley

unread,
Aug 6, 2013, 2:46:08 PM8/6/13
to ledge...@googlegroups.com
>>>>> Myles English <mylese...@gmail.com> writes:

> but how can I remove the Gum line and add it to the Food?, thus:

For a balance report that would be --depth=2, but I'm not sure if it works
that way in the register or not. Certainly worth a feature request, if it
doesn't.

John

Martin Blais

unread,
Aug 6, 2013, 9:05:06 PM8/6/13
to ledge...@googlegroups.com
Hmmm interesting idea, collapsing by level, that is.

Have you ever thought that Payees often end up functioning like an extra subaccount?
I've come to realize that for Payees that only ever touch a single account, the line is really fuzzy there.
I've been entertaining the idea of automatically creating subaccounts for payees like that.
Any thoughts?

John Wiegley

unread,
Aug 7, 2013, 1:02:48 AM8/7/13
to ledge...@googlegroups.com
>>>>> Martin Blais <goo...@furius.ca> writes:

> Have you ever thought that Payees often end up functioning like an extra
> subaccount? I've come to realize that for Payees that only ever touch a
> single account, the line is really fuzzy there. I've been entertaining the
> idea of automatically creating subaccounts for payees like that. Any
> thoughts?

Ledger 3 does support --account=payee, would that be close to what you mean?

John

Martin Blais

unread,
Aug 7, 2013, 1:16:13 AM8/7/13
to ledge...@googlegroups.com
I don't know. What does it do? I just spent 10 minutes leafing through the PDF doc for v3, I can't find it. There's an "--account NAME" option that says it prepends a string to all accounts (not what I meant).

What I mean is that the last/leaf (not the first/root) component of an account could sometimes be automatically refined by one level, by appending the payee name as a subaccount.

An example is illustrative; the following input

Transactions with payees "TMobile", "AT&T" and "Verizon"
where one posting is always on "Expenses:Phone"

could be automatically converted into postings with accounts:

Expenses:Phone:TMobile
Expenses:Phone:ATT
Expenses:Phone:Verizon

I'm not entirely sure yet what conditions would unambiguously qualify a payee's transactions to materialize into auto-generated sub-accounts, but it's worth considering. In my own bookkeeping, sometimes I use payee names, and sometimes I use subaccounts. The lines are blurred.

(Otherwise, the payees are only rendered, and used to generate "views" of all transactions where the payee appears.)

John Wiegley

unread,
Aug 7, 2013, 4:45:15 AM8/7/13
to ledge...@googlegroups.com
>>>>> Martin Blais <goo...@furius.ca> writes:

>> Ledger 3 does support --account=payee, would that be close to what you
>> mean?

> I don't know. What does it do? I just spent 10 minutes leafing through the
> PDF doc for v3, I can't find it. There's an "--account NAME" option that
> says it prepends a string to all accounts (not what I meant).

Sorry, I didn't realize it wasn't well documented yet.

--account=EXPR means that whatever string EXPR resolves to for each posting
will be used as the account name, instead of the standard --account=account.
So, --account=payee makes the payee into the account. And --payee=account
does the opposite.

John

Myles English

unread,
Aug 7, 2013, 7:19:41 AM8/7/13
to ledge...@googlegroups.com
Thanks John here is my feature request, what shall I do with it?

Feature request: collapse and accumulate sub accounts to hide unwanted
detail

Use case: For certain reports, I would like to:
- hide the name of a sub account, and
- add it to the parent account

For example: Suppose I would like to conceal the amount I spend on gum
and add the value of the transaction to the Food account:

$ cat ~/tmp/gum_test.bat
2013-08-06 The Shop
Expenses:Food £10.10
Expenses:Food:Gum £1.10
Assets:Cash

2013-08-07 The Shop
Expenses:Food £0.02
Expenses:Food:Gum £0.01 ;; following a collapse in gum prices
Assets:Cash

The basic register report:

$ ledger reg -f ~/tmp/gum_test.bat
2013-08-06 The Shop Expenses:Food £10.10 £10.10
Expenses:Food:Gum £1.10 £11.20
Assets:Cash £-11.20 0
2013-08-07 The Shop Expenses:Food £0.02 £0.02
Expenses:Food:Gum £0.01 £0.03
Assets:Cash £-0.03 0

This almost does it but doesn't accumulate the Gum entries into the Food
entries:

$ ledger reg -f ~/tmp/gum_test.bat --depth=2
2013-08-06 The Shop Expenses:Food £10.10 £10.10
Assets:Cash £-11.20 0
2013-08-07 The Shop Expenses:Food £0.02 £0.02
Assets:Cash £-0.03 0

The basic balance report can get the right totals:

$ ledger bal -f ~/tmp/gum_test.bat --depth=2
£-11.23 Assets:Cash
£11.23 Expenses:Food
--------------------
0

It would be nice if the new feature could get results like this:

$ ledger reg -f ~/tmp/gum_test.bat --depth=2
2013-08-06 The Shop Expenses:Food £11.20 £11.20
Assets:Cash £-11.20 0
2013-08-07 The Shop Expenses:Food £0.03 £0.03
Assets:Cash £-0.03 0

Further considerations, what happens if the level (or depth) of the
required cut-off varies, i.e.

Expenses:Food
Expenses:Food:Gum
Expenses:Food:Nuts

and I want Nuts to be reported but want Gum to be hidden in Food. Then
perhaps an option similar to --depth could apply a default for all
transactions unless an account has a depth configured by some other
method.

Thanks,
Myles

John Wiegley

unread,
Aug 7, 2013, 7:18:14 PM8/7/13
to ledge...@googlegroups.com
>>>>> Myles English <mylese...@gmail.com> writes:

> Thanks John here is my feature request, what shall I do with it?

Make an issue at http://bugs.ledger-cli.org, and paste it in!

Many thanks,
John
Reply all
Reply to author
Forward
0 new messages