payee limiting question

143 views
Skip to first unread message

Eric Abrahamsen

unread,
Jul 30, 2014, 5:09:53 AM7/30/14
to ledge...@googlegroups.com
For the longest time I haven't been able to use payee limiting in
reports in any convenient way, and I'm finally getting around to
bringing it up here. I am using git ledger, built on archlinux. Here's
the basic problem:

[eric@pellet ~]$ ledger reg assets:receivable --limit 'payee=~/CBI/'
14-May-03 CBI Assets:Receivable 2,000.00 RMB 2,000.00 RMB
14-Jun-18 CBI Assets:Receivable -2,000.00 RMB 0

[eric@pellet ~]$ ledger reg assets:receivable and CBI
[eric@pellet ~]$ ledger reg assets:receivable @CBI
{displays all postings for assets:receivable}

According to the docs and whatnot, one of the shorter forms ought to
work. The longer one is horrible to type!

Am I doing something wrong, or are the docs incorrect, or is this a bug
of some sort?

Thanks!
Eric

Nathan Grigg

unread,
Jul 30, 2014, 6:03:06 AM7/30/14
to ledge...@googlegroups.com

On Jul 30, 2014, at 2:13 AM, Eric Abrahamsen <er...@ericabrahamsen.net> wrote:

[eric@pellet ~]$ ledger reg assets:receivable and CBI
[eric@pellet ~]$ ledger reg assets:receivable @CBI
{displays all postings for assets:receivable}

It should work if you combine these into 

ledger reg assets:receivable and @CBI

Nathan
signature.asc

Jostein Berntsen

unread,
Jul 30, 2014, 7:39:08 AM7/30/14
to ledge...@googlegroups.com
This works for me:

ledger assets:receivable and /CBI/


Jostein




Eric Abrahamsen

unread,
Jul 30, 2014, 10:00:07 AM7/30/14
to ledge...@googlegroups.com
So it does! Thank you very much. I should have experimented a bit more...

Martin Blais

unread,
Jul 30, 2014, 10:13:34 AM7/30/14
to ledger-cli
So then what does this one mean:
ledger reg assets:receivable @CBI

Is it to be "or'ed"?

Martin Blais

unread,
Jul 30, 2014, 10:16:34 AM7/30/14
to ledger-cli
This is perhaps a second question, but I'm confused as to the meaning of Ledger's filter expressions.

When you say:
ledger reg assets:receivable and @CBI

Does it mean:
Select all the POSTINGS with account Assets:Receivable 
AND
select all the TRANSACTIONS with payee "CBI"?

I don't quite understand in Ledger whether you're selecting
- postings,
- transactions, or perhaps
- all the postings of matching transactions.
Can somebody shed some light on this?

 

Nathan Grigg

unread,
Jul 30, 2014, 2:34:39 PM7/30/14
to ledge...@googlegroups.com
> On Jul 30, 2014, at 7:13 AM, Martin Blais <bl...@furius.ca> wrote:
>
> So then what does this one mean:
> ledger reg assets:receivable @CBI
>
> Is it to be "or'ed"?

Yes

Nathan Grigg

unread,
Jul 30, 2014, 2:44:54 PM7/30/14
to ledge...@googlegroups.com
On Jul 30, 2014, at 7:16 AM, Martin Blais <bl...@furius.ca> wrote:

> This is perhaps a second question, but I'm confused as to the meaning of Ledger's filter expressions.
>
> When you say:
> ledger reg assets:receivable and @CBI
>
> Does it mean:
> Select all the POSTINGS with account Assets:Receivable
> AND
> select all the TRANSACTIONS with payee "CBI"?

As I understand it, you are always matching postings, but the payee is propagated to each posting. I think of it as "postings with given account and payee," but you may be more comfortable if you say "postings with a given account and in a transaction with given payee." (Although this might also be less correct because you can override the payee per posting in a transaction.)

Note that it doesn't say "give me postings matching given account AND give me postings matching given payee." Despite our use of "and" there, this would require an OR (i.e. union) operation.

Nathan

Eric Abrahamsen

unread,
Jul 30, 2014, 9:40:06 PM7/30/14
to ledge...@googlegroups.com
Nathan Grigg <nat...@nathangrigg.net> writes:

> On Jul 30, 2014, at 7:16 AM, Martin Blais <bl...@furius.ca> wrote:
>
>> This is perhaps a second question, but I'm confused as to the meaning of Ledger's filter expressions.
>>
>> When you say:
>> ledger reg assets:receivable and @CBI
>>
>> Does it mean:
>> Select all the POSTINGS with account Assets:Receivable
>> AND
>> select all the TRANSACTIONS with payee "CBI"?
>
> As I understand it, you are always matching postings, but the payee is
> propagated to each posting. I think of it as "postings with given
> account and payee," but you may be more comfortable if you say
> "postings with a given account and in a transaction with given payee."
> (Although this might also be less correct because you can override the
> payee per posting in a transaction.)

In my case, I was hoping for something exactly equivalent in meaning to
the more verbose --limit statement. So what I understood was: "spit out
all postings that match assets:receivable, but then only show me those
with a payee that matches 'CBI'".

Eric Abrahamsen

unread,
Jul 30, 2014, 9:45:09 PM7/30/14
to ledge...@googlegroups.com
Thanks, that makes a lot more sense. I had assumed that the "@CBI" was
simply being ignored there; now I see it really is an or.

Martin Blais

unread,
Jul 30, 2014, 10:52:33 PM7/30/14
to ledger-cli
That's counterintuitive. A better default is to and IMO.
 

Martin Blais

unread,
Jul 30, 2014, 11:03:43 PM7/30/14
to ledger-cli
On Wed, Jul 30, 2014 at 2:43 PM, Nathan Grigg <nat...@nathangrigg.net> wrote:
On Jul 30, 2014, at 7:16 AM, Martin Blais <bl...@furius.ca> wrote:

> This is perhaps a second question, but I'm confused as to the meaning of Ledger's filter expressions.
>
> When you say:
> ledger reg assets:receivable and @CBI
>
> Does it mean:
> Select all the POSTINGS with account Assets:Receivable
> AND
> select all the TRANSACTIONS with payee "CBI"?

As I understand it, you are always matching postings, but the payee is propagated to each posting. I think of it as "postings with given account and payee," but you may be more comfortable if you say "postings with a given account and in a transaction with given payee." (Although this might also be less correct because you can override the payee per posting in a transaction.)

That seems like an odd choice. If it was constrained to only select subsets of transactions, then you'd have a claim to balance the reports. Any subset of transactions will balance (because each of them individually does). So for instance, my view of what "account = X" should mean is "match all transactions that have at least one posting with account X". You should never be able to isolate postings from their transactions, it breaks the DE system.

Then if you want to restrict what you end up printing out, that's fine, but that's an entirely different operation, one that only filters what gets rendered, and that would depend only on the report type, it would never affect any calculations.

FWIW, this is what I have in mind for my own little filter language thingmajig.

Simon Michael

unread,
Jul 31, 2014, 10:42:33 AM7/31/14
to ledge...@googlegroups.com
On 7/30/14 8:03 PM, Martin Blais wrote:
> As I understand it, you are always matching postings, but the payee
> is propagated to each posting. I think of it as "postings with given
> account and payee," but you may be more comfortable if you say
> "postings with a given account and in a transaction with given
> payee." (Although this might also be less correct because you can
> override the payee per posting in a transaction.)
>
> That seems like an odd choice. If it was constrained to only select
> subsets of transactions, then you'd have a claim to balance the reports.
> Any subset of transactions will balance (because each of them
> individually does). So for instance, my view of what "account = X"
> should mean is "match all transactions that have at least one posting
> with account X". You should never be able to isolate postings from their
> transactions, it breaks the DE system.
>
> Then if you want to restrict what you end up printing out, that's fine,
> but that's an entirely different operation, one that only filters what
> gets rendered, and that would depend only on the report type, it would
> never affect any calculations.

As I see it, the print command prints whole transactions and filters by
transaction, but register prints individual postings and filters by
posting, so there's no expectation of it showing you balanced data.

I haven't needed or wanted more than one kind of filtering (eg --limit
and --display in ledger). Sometimes (not often) I'll do a multi-step
filter by using print to select the transactions I want and pipe the
result into register.


Martin Blais

unread,
Aug 4, 2014, 10:39:55 PM8/4/14
to ledger-cli
It would be really nice if the Ledger manual was updated to reflect its filtering semantics more clearly.
I don't think I've come across this detail.

 

Craig Earls

unread,
Aug 4, 2014, 11:00:58 PM8/4/14
to ledge...@googlegroups.com
That is because I don't think I understood it either. I will put this
on my list of things to add.
> --
>
> ---
> 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 ledger-cli+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Craig, Corona De Tucson, AZ
enderw88.wordpress.com
Reply all
Reply to author
Forward
0 new messages