Hi,

The output is correct in all cases.
See explanations below.

On Thu, Sep 4, 2014 at 11:12 PM, Stefano Zacchiroli <[email protected]> wrote:

> Hi all,
>   in a previous thread we have discussed how the notion of "payee" in
> Ledger-CLI seems to be ambiguous in the sense that:
>
> - sometimes it refers to the narrative part of a transaction, i.e. to
>   what appears after the "*" (or equivalent) symbol. I refer to this as
>   the "narrative is payee" interpretation.
>
> - sometimes it refers to the content of the payee special metadata tag
>   (interpretation: "special metadata field is payee")
>
> I've experiment with it a bit more, and I've a question about the
> specific examples reported below:
>
> ------ BEGIN payee.ledger ----------------------------------------------
>
> 2014/08/01 * foo quid
>     Expenses:F                                     1 EUR
>     Assets:Checking
>
> 2014/08/01 * bar
>     ; payee: foo
>     Expenses:B                                     1 EUR
>     Assets:Checking
>
> 2014/08/01 * qux
>     ; payee: baz
>     Expenses:Q                                     1 EUR
>     Assets:Checking
>
> ;
> ------------------------------------------------------------------------------
> ;
> ; $ ledger -f payee.ledger reg -l 'payee =~ /quid/'
> ; 14-Aug-01 foo quid            Expenses:F                    1 EUR
> 1 EUR
> ;                               Assets:Checking              -1 EUR
>     0
> ;
> ; # matches 1st transaction, as expected  (interpretation: "narrative is
> payee")
> ;
> ------------------------------------------------------------------------------
> ; $ ledger -f payee.ledger reg -l 'payee =~ /foo/'
> ; 14-Aug-01 foo quid            Expenses:F                    1 EUR
> 1 EUR
> ;                               Assets:Checking              -1 EUR
>     0
> ; 14-Aug-01 foo                 Expenses:B                    1 EUR
> 1 EUR
> ;           foo                 Assets:Checking              -1 EUR
>     0
> ;
> ; # matches both 1st (interpretation: "narrative is payee") and 2nd
> ; # (interpretation: special metadata field is payee) transactions, quite
> ; # puzzling
>


The metatag is added on the transaction, and overrides the narrative payee
on both postings and thus matches foo.



> ;
> ------------------------------------------------------------------------------
> ;
> ; $ ledger -f payee.ledger reg -l 'payee =~ /qux/'
> ;
> ; # doesn't match 3rd transaction, whereas it should (at least according
> to the
> ; # interpretation "narrative is payee"). Is there any way to match on the
> ; # "narrative" line when payee is defined as a metadata tag?
>

Narrative is payee unless overridden by a metatag on the transaction.
If you moved the payee metatag below the first posting it should match
because in that case the payee "baz" is only set on the first posting,
while the second posting will keep the narrative payee "qux":

$ ledger -f payee.dat reg -l 'payee =~ /qux/'
14-Aug-01 qux                   Assets:Checking              -1 EUR
-1 EUR



> ;
> ------------------------------------------------------------------------------
> ;
> ; $ ledger -f payee.ledger reg -l 'payee =~ /baz/'
> ; 14-Aug-01 baz                 Expenses:Q                    1 EUR
> 1 EUR
> ;           baz                 Assets:Checking              -1 EUR
>     0
> ; $
> ;
> ------------------------------------------------------------------------------
>
>
Again,baz is set for both postings.



> ------ END payee.ledger ----------------------------------------------
>
> It seems that when payee is present as a metadata, it completely
> overrides the narrative line as payee. Whereas when it is not present,
> the narrative subsumes the role of payee. That might be a fine behavior
> to have (or not --- I personally find it quite puzzling), but my
> immediate problem is that I haven't found a way to match over the
> narrative line when the payee tag is present.
>
> Is there a way to do so that I've overlooked?
>

Not that I know of. Payee and narrative are really the same thing.

The best use case for payee metatag is to override the payee on individual
postings within a transaction.


More generally, I find these examples quite convincing about the need of
> separating more clearly narrative and payee information, and allowing
> independent querying over the two fields of a transaction. Is that
> something that Ledger developers would be open to consider refactoring
> in the query interface? If so, I'll be happy to open a Bugzilla entry
> about this.
>
> TIA,
> Cheers.
>
>

Cheers,

Olaf

-- 

--- 
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to