scheme to retrieve the customer associated with a transaction

Derek Atkins warlord at MIT.EDU
Thu Mar 3 09:49:33 EST 2016


Hi,

Macho Philipovich <macho at resist.ca> writes:

> On 2016-03-02 08:20 PM, Derek Atkins wrote:
>
>     Hi,
>     
>     On Wed, March 2, 2016 8:11 pm, Macho Philipovich wrote:
>     
>            Does anyone know offhand how Scheme code would find the customer and
>            job objects that are associated with a given transaction "split", if
>            any?
>         
>         Take a look at the aging.scm report.  You'll see:
>         
>             (let* ((transaction (xaccSplitGetParent split))
>                    (temp-owner (gncOwnerNew))
>                    (owner (gnc:owner-from-split split temp-owner)))
>         
>               (if (not (null? owner))
>         ...
>
> Hi again,
>
> (As an aside while I'm thinking of it: is there something I can do so that my
> posts to this list aren't always a whitespace disaster? I'm using Thunderbird
> and I've tried delivery formats of "auto" as well as "plain-text only", but
> neither seem to make a difference. I haven't had problems with any other
> list.)

I'm not sure what you mean by "whitespace disaster".  Your post looks
fine to me.

> I was able to get the customer name by using the code you posted above along
> with "gncOwnerGetName owner", which I am thrilled about!
>
> But I can't for the life of me access the associated job. Running
> (gncOwnerGetJob owner) gives only (). I thought accessing it through the
> invoice might be better, so I also tried (gncInvoiceGetInvoiceFromTxn
> (xaccSplitGetParent split)), but that resulted in () as well.

Are you sure it IS a job?  It might not be.

You can also look at the "owner-report.scm" which shows how to detect if
it's a payment or invoice.  You might need to go through the Lot, which
requires having access to the Split from the A/R and/or A/P account and
not necessarily the transaction itself.

> If I could access the invoice, I suspect I could also resolve my final
> remaining problem, which is that for expenses this approach returns the
> vendor, while what I am after is the chargeback customer.

Hmm... THAT might be a bit harder.

> Thanks again!
>
> Macho

-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