scheme to retrieve the customer associated with a transaction

Macho Philipovich macho at resist.ca
Thu Mar 3 00:33:22 EST 2016


   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 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.
   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.
   Thanks again!
   Macho


More information about the gnucash-user mailing list