Cannot find text or value inside a split

Derek Atkins warlord at MIT.EDU
Fri Feb 15 14:27:34 EST 2013


Colin Law <clanlaw at googlemail.com> writes:

> On 15 February 2013 00:51, John Ralls <jralls at ceridwen.us> wrote:
>>
>> On Feb 14, 2013, at 1:55 PM, Colin Law <clanlaw at googlemail.com> wrote:
>>> ...
>>> I must be missing something, Derek's query includes split.Account ==
>>> ThisAccount, but we want to find matches where split.Account !=
>>> ThisAccount, don't we want instead something like
>>> Split.ParentTransaction.AnySplit.Account == ThisAccount AND
>>> Split.Memo == "memo"
>>>
>>
>> You're getting tied up in pseudocode.
>>
>> What Derek is trying to convey is "For each split whose account matches the current account, retrieve from that split's parent transaction every split and return all of those splits whose memo matches 'memo'".
>>
>> Split.ParentTransaction.AnySplit.Account == ThisAccount is functionally the same as Split.Account == ThisAccount. That's what Gnucash does now.
>
> OK, got it.  Isn't AnySplit just a join between the transactions and
> splits tables?

Again, you're getting caught up in the pseudocode, and I appologize for
that.  So let me back up a moment and clear something up, and this a key
concept:

An account register does not display Transactions.  It displays Splits.

Pause for a moment and re-read that sentence.

* hums for a few minutes to let you re-read that a third and fourth time *

Okay, now that you've grokked that, let's talk about what it means.  A
transaction is made up of multiple splits.  Each transaction must have
at least two (a debit and a credit).  Each split has an account, and the
transaction binds them all together.  However, when you are looking at
an account register you're really looking at the list of SPLITS that are
tied to that account.  This works out to a query of:

  Split.Account == ThisAccount

When you use the "find" from an account register it's effectively a
"refine search", which means you take the existing query and apply more
restrictions to it, based on the functionality of the QofQuery
Predicates.  So when you refine the search for "Split.Memo == ThisMemo"
then you get the first query in pseudocode I listed before -- which
isn't what you want.

The problem is that there is no "Split.Transaction.AnySplit" Predicate,
and implementing that would be hard because the query framework has no
concept of Splits or Transactions.  Unfortunately this is what you are
asking for, being able to say that you want to find a transaction where
one split is in "this account", and then the memo of ANY split in that
split's transaction matches "ThisMemo".  That functionality does not
exist, and would be challenging to implement in the current QofQuery
framework.

So basically this is a long winded way of saying: "I understand what
you're asking, but it doesn't work that way now.  Morever, it wont work
like that for a while until we can rework the innards of QofQuery in a
way that provides better knowledge of underlying object typing, and I
don't expect that to happen any time soon".

> Colin

> Please remember to CC this list on all your replies.
> You can do this by using Reply-To-List or Reply-All.

-derek

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-user mailing list