Page 1 of 1

Navigating from CR_BatchPayLine to CR_BatchTranLine

PostPosted: Wed Aug 01, 2018 1:13 pm
by neil.interactit
Hi guys,

I'm stuck on this. From the "Creditor Cheque/EFT Payment" form, in need to access the "Creditor Purchase" LINE ITEM associated with a specific payment LINE ITEM.

In the database, it looks like there's a line by line association between CR_BatchPayLines and CR_Trans, but only an overall batch association between CR_Trans and CR_BatchTranLines, making it impossible to traverse from a payment CR_BatchPayLinesID back to it's originating purchase ReceiptLineID.

Please refer to the attached spreadsheet for an illustration.

Alternatively, in code, I am working with a
Code: Select all
foreach (clsPayLineInvoice paymentLine in creditor.InvoicePaymentLines)
loop, but haven't been able to spot how to navigate from the clsPayLineInvoice to the associated purchase line item.

Can you tell me what I'm missing, or advise?

Cheers,
Neil.

Re: Navigating from CR_BatchPayLine to CR_BatchTranLine  Topic is solved

PostPosted: Wed Aug 01, 2018 1:48 pm
by Scott.Pearce
You are correct, there is *not* a very solid linkage between the 2 lines you are interested in, and the business logic objects are a bit old and decrepit.

Here's the best I reckon you can do:

Starting with the clsPayLineInvoices line, I would use it's CRTransID property to do a read from CR_Trans - I would read in InvRemitNo, DiscountedAmount, and SourceID from the CR_Trans table.

Using the SourceID, I would instantiate a JiwaCRBatchTX.CreditorBatchTrans object and read the batch using the SourceID. Now I have the batch.

I would now iterate through the lines on the JiwaCRBatchTX.CreditorBatchTrans object, looking for a match on CRBatchTranLine.RemitNo = InvRemitNo and CRBatchTranLine.HomeTransAmount = DiscountedAmount. When a match is found you have your payment line.

Re: Navigating from CR_BatchPayLine to CR_BatchTranLine

PostPosted: Wed Aug 01, 2018 2:45 pm
by neil.interactit
Thanks Scott.

Yep, that pretty much what I've been doing - I was doing this in SQL, but same idea. The client recently put through a batch of 50 line items all "July Rent" often with common rent amounts and my query failed to distinguish. They seem to be OK with making invoice number unique, so I might add a plugin to enforce this.

Cheers,
Neil