Database link for creditor purchase JobNo?  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Database link for creditor purchase JobNo?

Postby neil.interactit » Thu Sep 28, 2017 12:48 pm

Hi guys,

I'm stumped - and prepared to be embarrassed when you tell me how obvious this is! - but I can't trace the database linking.

For a given CR_BatchPayLines.CR_BatchPayLinesID, how do I traverse the database to the field(s) displayed in the JobNo column?

Cheers,
Neil.
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Database link for creditor purchase JobNo?

Postby Mike.Sheen » Thu Sep 28, 2017 2:16 pm

CR_BatchPayLines.CR_TransID -> CR_Trans.TransID

then CR_Trans.SourceID links to different tables, depending on the CR_Trans.Source:

For example, when CR_Trans.Source == "Creditor Sourced Purchase"
then CR_Trans.SourceID -> CR_BatchTranLines.ReceiptLineID, CR_BatchTranLines.JB_JobStages_RecID -> JB_JobStages.RecID, JB_JobStages.JB_Stages_RecID -> JB_Stages.RecID and so on.

Make sense?
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Database link for creditor purchase JobNo?

Postby neil.interactit » Thu Sep 28, 2017 4:26 pm

Almost!

I can successfully traverse to CR_BatchTranLines.JB_JobStages_RecID, but from there I can't find the (many-to-one) path to JB_Main?

Cheers,
Neil
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Database link for creditor purchase JobNo?  Topic is solved

Postby Scott.Pearce » Thu Sep 28, 2017 4:39 pm

JB_JobCostCentres is the missing stepping stone.

CR_BatchTranLines.JB_JobStages_RecID -> JB_JobStages.RecID, JB_JobStages.JB_JobCostCentres_RecID ->JB_JobCostCentres.RecID, JB_JobCostCentres.JobID -> JB_Main.JobID
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Database link for creditor purchase JobNo?

Postby neil.interactit » Fri Sep 29, 2017 4:41 pm

Cool! Many thanks.

FWIW, here's my final SQL, traversing from CR_BatchPayLines to JB_Main ...

Code: Select all
SELECT *
,ROW_NUMBER() OVER (PARTITION BY bp.LineNumber ORDER BY bp.LineNumber) AS RowNumber -- remove duplicate LineNumbers
FROM CR_BatchPayLines bp
LEFT JOIN CR_Trans tr ON bp.CR_TransID = tr.TransID
LEFT JOIN CR_BatchTranLines bt ON tr.SourceID = bt.ReceiptID
LEFT JOIN JB_JobStages js ON bt.JB_JobStages_RecID =js.RecID
LEFT JOIN JB_JobCostCentres jcc ON js.JB_JobCostCentres_RecID = jcc.RecID
LEFT JOIN JB_Main jb ON jcc.JobID = jb.JobID
WHERE tr.InvRemitNo = bt.RemitNo
AND tr.CreditorID = bt.AccountID
AND bp.CR_BatchPayID = (SELECT CR_BatchPayID FROM CR_BatchPayment WHERE BatchNo = '006970')
AND tr.Source = 'Creditor Sourced Purchase'

Thanks again,
Neil.
neil.interactit
Kohai
Kohai
 
Posts: 227
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 15 guests