Description
This method takes the source data which contains no cross company postings and adds in the cross company posting records for each entity. This method can be overridden in NI Customization, by setting the vlIsCustomizedBuildPostings to true.
Parameters
icRowId | input | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program9/bjournalentrymulticy.p)
/* ================================================================ */
/* This method adds the cross company postings to the input */
/* Journal Entries. */
/* A cross company posting line is added to each tPostingMultiCy */
/* record. The posting for the source entity is sum of the */
/* non-source postings related to that posting */
/* The default cross company gl code is retrieved from the domain */
/* and used in the cross company posting line */
/* */
/* This method can be overwritten by NI Customization */
/* If the customization code sets the variable */
/* vlIsCustomizedBuildPostings is set to true, then this method */
/* code will not be run */
/* ================================================================ */
if vlIsCustomizedBuildPostings = true
then return.
assign viCurrentRowID = 1.
<M-35 run GetIntercompanyJEGLAccount
(input vcCompanyCode (icCompanyCode),
output vcCurrentCoGLCode (ocGLCode),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
if viFcReturnSuper <> 0
then do:
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
end. /* viFcReturnSuper <> 0 */
if oiReturnStatus < 0
then return.
/* ============================================================ */
/* Only process records that have not previously been processed */
/* ============================================================ */
find first tPostingHeaderMultiCy where
tPostingHeaderMultiCy.tc_Rowid = icRowid and
tPostingHeaderMultiCy.tlPostingHeaderIsPosted = false
no-error.
if available tPostingHeaderMultiCy
then do:
assign vcParentPostingtcRowId = "".
/* save off the parent tPostingMultiCy row id */
find first tPostingMultiCy where
tPostingHeaderMultiCy.tc_Rowid = tPostingMultiCy.tc_ParentRowid and
tPostingMultiCy.tcCompanyCode = vcCompanyCode
no-error.
if available tPostingMultiCy
then do:
assign vcParentPostingtcRowId = tPostingMultiCy.tc_Rowid
viSourceSequenceNo = 0.
/* calculate the next posting line sequence number */
for each btPostingLineMultiCy where
btPostingLineMultiCy.tc_ParentRowid = tPostingMultiCy.tc_Rowid
on error undo, throw:
if btPostingLineMultiCy.PostingLineSequence > viSourceSequenceNo
then assign viSourceSequenceNo = btPostingLineMultiCy.PostingLineSequence.
end. /* for each btPostingLineMultiCy */
end. /* if available */
/* ================================================================== */
/* Iterate through the cross-company posting in the non-source entity */
/* ================================================================== */
for each tPostingMultiCy where
tPostingMultiCy.tc_ParentRowid = tPostingHeaderMultiCy.tc_Rowid and
tPostingMultiCy.tcCompanyCode <> vcCompanyCode
on error undo, throw:
assign
vdDebitLC = 0
vdDebitTC = 0
vdDebitCC = 0
vdDebitPC = 0
vdCreditLC = 0
vdCreditTC = 0
vdCreditCC = 0
vdCreditPC = 0
vdCCRate = 0
vdCCScale = 0
vdExchangeRate = 0
vdRateScale = 0.
viCCySequenceNo = 0.
vcPostingCrossExternalRef = guid.
<M-83 run GetIntercompanyJEGLAccount
(input tPostingMultiCy.tcCompanyCode (icCompanyCode),
output vcInterCoGLCode (ocGLCode),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
if viFcReturnSuper <> 0
then do:
if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
then assign oiReturnStatus = viFcReturnSuper.
end. /* if viFcReturnSuper <> 0 */
if oiReturnStatus < 0
then return.
for each btPostingLineMultiCy where
btPostingLineMultiCy.tc_ParentRowid = tPostingMultiCy.tc_Rowid
on error undo, throw:
assign
vdDebitLC = vdDebitLC + btPostingLineMultiCy.PostingLineDebitLC
vdDebitTC = vdDebitTC + btPostingLineMultiCy.PostingLineDebitTC
vdDebitCC = vdDebitCC + btPostingLineMultiCy.PostingLineDebitCC
vdDebitPC = vdDebitPC + btPostingLineMultiCy.PostingLineDebitPC
vdCreditLC = vdCreditLC + btPostingLineMultiCy.PostingLineCreditLC
vdCreditTC = vdCreditTC + btPostingLineMultiCy.PostingLineCreditTC
vdCreditCC = vdCreditCC + btPostingLineMultiCy.PostingLineCreditCC
vdCreditPC = vdCreditPC + btPostingLineMultiCy.PostingLineCreditPC
vdCCRate = btPostingLineMultiCy.PostingLineCCRate
vdCCScale = btPostingLineMultiCy.PostingLineCCScale
vdExchangeRate = btPostingLineMultiCy.PostingLineExchangeRate
vdRateScale = btPostingLineMultiCy.PostingLineRateScale.
if btPostingLineMultiCy.PostingLineSequence > viCCySequenceNo
then assign viCCySequenceNo = btPostingLineMultiCy.PostingLineSequence.
end. /* for each tPostingLineMultiCy */
assign vdDebitBalanceLC = 0
vdCreditBalanceLC = 0
vdDebitBalanceCC = 0
vdCreditBalanceCC = 0
vdDebitBalanceTC = 0
vdCreditBalanceTC = 0
vdDebitBalancePC = 0
vdCreditBalancePC = 0.
if vdDebitTC - vdCreditTC > 0
then assign vdDebitBalanceTC = vdDebitTC - vdCreditTC.
if vdDebitTC - vdCreditTC < 0
then assign vdCreditBalanceTC = vdCreditTC - vdDebitTC.
if vdDebitLC - vdCreditLC > 0
then assign vdDebitBalanceLC = vdDebitLC - vdCreditLC.
if vdDebitLC - vdCreditLC < 0
then assign vdCreditBalanceLC = vdCreditLC - vdDebitLC.
if vdDebitCC - vdCreditCC > 0
then assign vdDebitBalanceCC = vdDebitCC - vdCreditCC.
if vdDebitCC - vdCreditCC < 0
then assign vdCreditBalanceCC = vdCreditCC - vdDebitCC.
if vdDebitPC - vdCreditPC > 0
then assign vdDebitBalancePC = vdDebitPC - vdCreditPC.
if vdDebitPC - vdCreditPC < 0
then assign vdCreditBalancePC = vdCreditPC - vdDebitPC.
/* get the cross company account */
find first btPostingLineMultiCy where
btPostingLineMultiCy.tc_ParentRowid = tPostingMultiCy.tc_Rowid and
tPostingMultiCy.tcCompanyCode <> vcCompanyCode
no-error.
if available btPostingLineMultiCy
then do:
/* =================================================================== */
/* Create the source cross company posting line for non-source entity */
/* =================================================================== */
create tPostingLineMultiCy.
buffer-copy btPostingLineMultiCy
except btPostingLineMultiCy.Posting_ID
btPostingLineMultiCy.tc_Rowid
btPostingLineMultiCy.tcProjectDescription
btPostingLineMultiCy.tcGLCode
btPostingLineMultiCy.tcGLDescription
btPostingLineMultiCy.tcGLTypeCode
btPostingLineMultiCy.tcDivisionCode
btPostingLineMultiCy.tcCostCentreCode
btPostingLineMultiCy.tcProjectCode
btPostingLineMultiCy.PostingLineCrossExternRef
btPostingLineMultiCy.Company_ID
btPostingLineMultiCy.tcIntercoBusinessRelationCode
to tPostingLineMultiCy
assign
tPostingLineMultiCy.tc_Rowid = string(guid)
tPostingLineMultiCy.Company_ID = tPostingMultiCy.Company_ID
tPostingLineMultiCy.PostingLineDebitLC = vdCreditBalanceLC
tPostingLineMultiCy.PostingLineDebitTC = vdCreditBalanceTC
tPostingLineMultiCy.PostingLineDebitCC = vdCreditBalanceCC
tPostingLineMultiCy.PostingLineDebitPC = vdCreditBalancePC
tPostingLineMultiCy.PostingLineCreditLC = vdDebitBalanceLC
tPostingLineMultiCy.PostingLineCreditTC = vdDebitBalanceTC
tPostingLineMultiCy.PostingLineCreditCC = vdDebitBalanceCC
tPostingLineMultiCy.PostingLineCreditPC = vdDebitBalancePC
tPostingLineMultiCy.PostingLineCCRate = vdCCRate
tPostingLineMultiCy.PostingLineCCScale = vdCCScale
tPostingLineMultiCy.PostingLineExchangeRate = vdExchangeRate
tPostingLineMultiCy.PostingLineRateScale = vdRateScale
tPostingLineMultiCy.tcGLCode = vcInterCoGLCode
tPostingLineMultiCy.tcGLTypeCode = {&GLTYPECODE-CROSS}
tPostingLineMultiCy.PostingLineSequence = viCCySequenceNo + 1
tPostingLineMultiCy.PostingLineCrossExternRef = vcPostingCrossExternalRef
tPostingLineMultiCy.tcCrossCompanyCode = vcCompanyCode.
/* =========================================================== */
/* Create the source cross company account for source entity */
/* =========================================================== */
create tPostingLineMultiCy.
buffer-copy btPostingLineMultiCy
except btPostingLineMultiCy.Posting_ID
btPostingLineMultiCy.tc_Rowid
btPostingLineMultiCy.tc_ParentRowid
btPostingLineMultiCy.tcProjectDescription
btPostingLineMultiCy.tcGLCode
btPostingLineMultiCy.tcGLDescription
btPostingLineMultiCy.tcGLTypeCode
btPostingLineMultiCy.tcDivisionCode
btPostingLineMultiCy.tcCostCentreCode
btPostingLineMultiCy.tcProjectCode
btPostingLineMultiCy.PostingLineCrossExternRef
btPostingLineMultiCy.tcIntercoBusinessRelationCode
to tPostingLineMultiCy.
assign
tPostingLineMultiCy.tc_ParentRowid = vcParentPostingtcRowId
tPostingLineMulticy.tc_Rowid = string(guid)
tPostingLineMultiCy.Company_ID = viCompanyId
tPostingLineMultiCy.PostingLineDebitLC = vdDebitBalanceLC
tPostingLineMultiCy.PostingLineDebitTC = vdDebitBalanceTC
tPostingLineMultiCy.PostingLineDebitCC = vdDebitBalanceCC
tPostingLineMultiCy.PostingLineDebitPC = vdDebitBalancePC
tPostingLineMultiCy.PostingLineCreditLC = vdCreditBalanceLC
tPostingLineMultiCy.PostingLineCreditTC = vdCreditBalanceTC
tPostingLineMultiCy.PostingLineCreditCC = vdCreditBalanceCC
tPostingLineMultiCy.PostingLineCreditPC = vdCreditBalancePC
tPostingLineMultiCy.PostingLineCCRate = vdCCRate
tPostingLineMultiCy.PostingLineCCScale = vdCCScale
tPostingLineMultiCy.PostingLineExchangeRate = vdExchangeRate
tPostingLineMultiCy.PostingLineRateScale = vdRateScale
tPostingLineMultiCy.tcGLCode = vcCurrentCoGLCode
tPostingLineMultiCy.tcGLTypeCode = {&GLTYPECODE-CROSS}
tPostingLineMultiCy.PostingLineSequence = viSourceSequenceNo + 1
viSourceSequenceNo = viSourceSequenceNo + 1
tPostingLineMultiCy.PostingLineCrossExternRef = vcPostingCrossExternalRef
tPostingLineMultiCy.tcCrossCompanyCode = tPostingMultiCy.tcCompanyCode.
end. /* if available btPostingLineMultiCy */
end. /* for each tPostingMultiCy */
end. /* for each tPostingHeaderMultiCy */