Description
Prepare instance for dump of summarized postings
Parameters
| iiCompanyId | input | integer | |
| icDumpDirectory | input | character | |
| icConsolCompany | input | character | |
| iiFromYear | input | integer | |
| iiFromPeriod | input | integer | |
| iiToYear | input | integer | |
| iiToPeriod | input | integer | |
| ilIsOpeningBal | input | logical | |
| iiOpeningYear | input | integer | |
| iiOpeningPeriod | input | integer | |
| idCCExchangeRate | input | decimal | |
| idCCExchangeRateScale | input | decimal | |
| icCCCurrencyCode | input | character | |
| bcGLIDList | input-output | character | |
| bcJournalIDList | input-output | character | |
| bcBusinessRelationIDList | input-output | character | |
| bcDivisionIDList | input-output | character | |
| bcCostCentreIDList | input-output | character | |
| bcProjectIDList | input-output | character | |
| bcSafStructureIDList | input-output | character | |
| bcSafIDList | input-output | character | |
| bcSafStructureLinkIDList | input-output | character | |
| oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program1/bjournalentry.p)
If oiReturnStatus = 0
Then Assign oiReturnStatus = -98.
/* ========================================================================= */
/* Normalize input paramters */
/* ========================================================================= */
if iiCompanyId = 0 then assign iiCompanyId = viCompanyId.
if iiCompanyId = ? then assign iiCompanyId = viCompanyId.
Assign bcGLIDList = Replace(bcGLIDList, Chr(4),',':U).
Assign bcJournalIDList = Replace(bcJournalIDList, Chr(4),',':U).
Assign bcBusinessRelationIDList = Replace(bcBusinessRelationIDList,Chr(4),',':U).
Assign bcDivisionIDList = Replace(bcDivisionIDList, Chr(4),',':U).
Assign bcCostCentreIDList = Replace(bcCostCentreIDList, Chr(4),',':U).
Assign bcProjectIDList = Replace(bcProjectIDList, Chr(4),',':U).
Assign bcSafStructureIDList = Replace(bcSafStructureIDList, Chr(4),',':U).
Assign bcSafIDList = Replace(bcSafIDList, Chr(4),',':U).
Assign bcSafStructureLinkIDList = Replace(bcSafStructureLinkIDList,Chr(4),',':U).
<Q-4 run PostingByPeriodRange (all) (Read) (NoCache)
(input iiCompanyId, (CompanyId)
input ((iiFromYear * 100) + iiFromPeriod), (FromYearPeriod)
input ((iiToYear * 100) + iiToPeriod), (ToYearPeriod)
output dataset tqPostingByPeriodRange) in BPosting >
/* Start queries */
<Q-5 run PostingSafByIDs (Start) in BPosting >
<Q-6 run SafStructureLinkByAllIDs (Start) in BSafStructureLink >
<Q-23 run PeriodByYearPeriod (Start) in BPeriod >
For Each tqPostingByPeriodRange:
<Q-12 run PostingSafByIDs (all) (Read) (NoCache)
(input ?, (PostingSafId)
input tqPostingByPeriodRange.tiPostingLine_ID, (PostingLineId)
input ?, (SafId)
input ?, (SafStructureId)
output dataset tqPostingSafByIDs) in BPosting >
Assign viPostingSafCount = 0.
For Each tqPostingSafByIDs:
Assign viPostingSafCount = viPostingSafCount + 1.
End.
Assign vlPostingMatchFound = False.
Assign vlPostingFound = False.
For Each tPosting Where
tPosting.Company_ID = iiCompanyId And
(tPosting.PostingYearPeriod = tqPostingByPeriodRange.tiPostingYearPeriod Or ilIsOpeningBal) And
tPosting.Journal_ID = tqPostingByPeriodRange.tiJournal_ID:
Assign vlPostingFound = True.
For Each tPostingLine Where
tPostingLine.tc_ParentRowid = tPosting.tc_Rowid And
tPostingLine.GL_ID = tqPostingByPeriodRange.tiGL_ID And
tPostingLine.Division_ID = tqPostingByPeriodRange.tiDivision_ID And
tPostingLine.IntercoBusinessRelation_ID = tqPostingByPeriodRange.tiIntercoBusinessRelation_ID And
tPostingLine.CostCentre_ID = tqPostingByPeriodRange.tiCostCentre_ID And
tPostingLine.Project_ID = tqPostingByPeriodRange.tiProject_ID:
If viPostingSafCount = 0 And
Not Can-Find(First tPostingSaf Where
tPostingSaf.tc_ParentRowid = tPostingLine.tc_Rowid)
Then Assign vlPostingMatchFound = True.
Else If viPostingSafCount > 0
Then Do:
Assign vlPostingMatchFound = True.
For Each tqPostingSafByIDs:
If Not Can-Find(tPostingSaf Where
tPostingSaf.tc_ParentRowid = tPostingLine.tc_Rowid And
tPostingSaf.PostingSafInputSequence = tqPostingSafByIDs.tiPostingSafInputSequence And
tPostingSaf.PostingSafParentType = tqPostingSafByIDs.tcPostingSafParentType And
tPostingSaf.SafStructure_ID = tqPostingSafByIDs.tiSafStructure_ID And
tPostingSaf.Saf_ID = tqPostingSafByIDs.tiSaf_ID)
Then Assign vlPostingMatchFound = False.
End. /*For Each tqPostingSafByIDs:*/
End. /*If viPostingSafCount > 0*/
If vlPostingMatchFound
Then Do:
Assign vdTotalAmount = tPostingLine.PostingLineDebitLC
- tPostingLine.PostingLineCreditLC
+ tqPostingByPeriodRange.tdPostingLineDebitLC
- tqPostingByPeriodRange.tdPostingLineCreditLC.
If vdTotalAmount >= 0
Then Assign
tPostingLine.PostingLineDebitLC = vdTotalAmount
tPostingLine.PostingLineCreditLC = 0.
Else Assign
tPostingLine.PostingLineCreditLC = - vdTotalAmount
tPostingLine.PostingLineDebitLC = 0.
Assign
tPostingLine.PostingLineDebitTC = tPostingLine.PostingLineDebitLC
tPostingLine.PostingLineCreditTC = tPostingLine.PostingLineCreditLC
tPostingLine.PostingLineQTY = tqPostingByPeriodRange.tdPostingLineQTY.
End. /*If vlPostingMatchFound*/
If vlPostingMatchFound
Then Leave.
End. /* For Each tPostingLine Of tPosting Where */
If vlPostingMatchFound
Then Leave.
End. /* For Each tPosting Where */
If vlPostingMatchFound
Then Next.
If Not vlPostingFound
Then Do:
/* add new posting */
<M-18 run AddDetailLine (input 'Posting':U (icTable),
input '':U (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
If ilIsOpeningBal
Then Do:
<Q-26 run PeriodByYearPeriod (all) (Read) (NoCache)
(input iiCompanyId, (CompanyId)
input iiOpeningYear, (PeriodYear)
input iiOpeningPeriod, (PeriodPeriod)
input ?, (PeriodId)
output dataset tqPeriodByYearPeriod) in BPeriod >
End.
Else Do:
<Q-22 run PeriodByYearPeriod (all) (Read) (NoCache)
(input iiCompanyId, (CompanyId)
input iiFromYear, (PeriodYear)
input iiFromPeriod, (PeriodPeriod)
input ?, (PeriodId)
output dataset tqPeriodByYearPeriod) in BPeriod >
End.
Find First tqPeriodByYearPeriod No-error.
Assign
tPosting.Company_ID = tqPostingByPeriodRange.tiCompany_ID
tPosting.Journal_ID = tqPostingByPeriodRange.tiJournal_ID
tPosting.PeriodMark_ID = tqPostingByPeriodRange.tiPeriodMark_ID
tPosting.Period_ID = tqPostingByPeriodRange.tiPeriod_ID
tPosting.PostingDate = tqPeriodByYearPeriod.ttPeriodStartDate
tPosting.PostingPeriod = tqPostingByPeriodRange.tiPostingPeriod
tPosting.PostingSystemDate = tqPeriodByYearPeriod.ttPeriodStartDate
tPosting.PostingText = #T-19'Summary':100(17038)T-19#
tPosting.PostingVoucher = 0
tPosting.PostingYear = tqPostingByPeriodRange.tiPostingYear
tPosting.PostingYearPeriod = tqPostingByPeriodRange.tiPostingYearPeriod
tPosting.Posting_ID = tqPostingByPeriodRange.tiPosting_ID
tPosting.tcJournalCode = tqPostingByPeriodRange.tcJournalCode
tPosting.tcLayerTypeCode = tqPostingByPeriodRange.tcLayerTypeCode
tPosting.tcPeriodTypeCode = tqPeriodByYearPeriod.tcPeriodTypeCode
.
If ilIsOpeningBal
Then Assign
tPosting.PostingPeriod = iiOpeningPeriod
tPosting.PostingYear = iiOpeningYear
tPosting.PostingYearPeriod = (iiOpeningYear * 100) + iiOpeningPeriod
tPosting.Period_ID = 0.
End.
Find First tPosting Where
tPosting.Company_ID = iiCompanyId And
(tPosting.PostingYearPeriod = tqPostingByPeriodRange.tiPostingYearPeriod Or ilIsOpeningBal) And
tPosting.Journal_ID = tqPostingByPeriodRange.tiJournal_ID No-error.
If Not Available tPosting Then Next.
/* add new postingline with safs */
<M-20 run AddDetailLine (input 'PostingLine':U (icTable),
input tPosting.tc_rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
Assign
tPostingLine.Company_ID = tqPostingByPeriodRange.tiPostingLineCompanyId
tPostingLine.CostCentre_ID = tqPostingByPeriodRange.tiCostCentre_ID
tPostingLine.Currency_ID = tqPostingByPeriodRange.tiCurrency_ID
tPostingLine.Division_ID = tqPostingByPeriodRange.tiDivision_ID
tPostingLine.GL_ID = tqPostingByPeriodRange.tiGL_ID
tPostingLine.IntercoBusinessRelation_ID = tqPostingByPeriodRange.tiIntercoBusinessRelation_ID
tPostingLine.Period_ID = tqPostingByPeriodRange.tiPostingLinePeriodId
tPostingLine.PostingLineCreditLC = tqPostingByPeriodRange.tdPostingLineCreditLC
tPostingLine.PostingLineCreditTC = tqPostingByPeriodRange.tdPostingLineCreditLC
tPostingLine.PostingLineDebitLC = tqPostingByPeriodRange.tdPostingLineDebitLC
tPostingLine.PostingLineDebitTC = tqPostingByPeriodRange.tdPostingLineDebitLC
tPostingLine.PostingLineExchangeRate = 1
tPostingLine.PostingLineIsProjPosting = tqPostingByPeriodRange.tlPostingLineIsProjPosting
tPostingLine.PostingLineQTY = tqPostingByPeriodRange.tdPostingLineQTY
tPostingLine.PostingLineRateScale = 1
tPostingLine.PostingLine_ID = tqPostingByPeriodRange.tiPostingLine_ID
tPostingLine.PostingYearPeriod = tqPostingByPeriodRange.tiPostingLineYearPeriod
tPostingLine.Posting_ID = tqPostingByPeriodRange.tiPostingLinePostingId
tPostingLine.Project_ID = tqPostingByPeriodRange.tiProject_ID
tPostingLine.tcCostCentreCode = tqPostingByPeriodRange.tcCostCentreCode
tPostingLine.tcProjectCode = tqPostingByPeriodRange.tcProjectCode
tPostingLine.tcProjectDescription = tqPostingByPeriodRange.tcProjectDescription
tPostingLine.tcGLCode = tqPostingByPeriodRange.tcGLCode
tPostingLine.tcGLDescription = tqPostingByPeriodRange.tcGLDescription
tPostingLine.tcGLTypeCode = tqPostingByPeriodRange.tcGLTypeCode
tPostingLine.tlGLIsAutomaticAccount = tqPostingByPeriodRange.tlGLIsAutomaticAccount
tPostingLine.tlGLIsDebitAccount = tqPostingByPeriodRange.tlGLIsDebitAccount
tPostingLine.tcIntercoBusinessRelationCode = tqPostingByPeriodRange.tcBusinessRelationICCode
tPostingLine.tcCurrencyCode = vcCompanyLC
tPostingLine.tcDivisionCode = tqPostingByPeriodRange.tcDivisionCode
tPostingLine.tlLinkedCrCyDaemonReqExists = false
.
If ilIsOpeningBal
Then Assign
tPostingLine.PostingYearPeriod = (iiOpeningYear * 100) + iiOpeningPeriod
tPostingLine.Period_ID = 0
.
/* add safs to postingline */
For Each tqPostingSafByIDs:
<M-21 run AddDetailLine (input 'PostingSaf':U (icTable),
input tPostingLine.tc_rowid (icParentRowid),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
Assign
tPostingSaf.PostingLine_ID = tqPostingSafByIDs.tiPostingLine_ID
tPostingSaf.PostingSafInputSequence = tqPostingSafByIDs.tiPostingSafInputSequence
tPostingSaf.PostingSafParentType = tqPostingSafByIDs.tcPostingSafParentType
tPostingSaf.PostingSaf_ID = tqPostingSafByIDs.tiPostingSaf_ID
tPostingSaf.SafStructure_ID = tqPostingSafByIDs.tiSafStructure_ID
tPostingSaf.Saf_ID = tqPostingSafByIDs.tiSaf_ID
tPostingSaf.tcSafCode = tqPostingSafByIDs.tcSafCode
tPostingSaf.tcSafConceptCode = tqPostingSafByIDs.tcSafConceptCode
tPostingSaf.tcSafStructureCode = tqPostingSafByIDs.tcSafStructureCode
.
End.
If Not Can-do(bcGLIDList + ",0":U, String(tqPostingByPeriodRange.tiGL_ID))
Then Assign bcGLIDList = bcGLIDList + ',':U + String(tqPostingByPeriodRange.tiGL_ID).
If Not Can-do(bcJournalIDList + ",0":U, String(tqPostingByPeriodRange.tiJournal_ID))
Then Assign bcJournalIDList = bcJournalIDList + ',':U + String(tqPostingByPeriodRange.tiJournal_ID).
If Not Can-do(bcBusinessRelationIDList + ",0":U, String(tqPostingByPeriodRange.tiIntercoBusinessRelation_ID))
Then Assign bcBusinessRelationIDList = bcBusinessRelationIDList + ',':U + String(tqPostingByPeriodRange.tiIntercoBusinessRelation_ID).
If Not Can-do(bcDivisionIDList + ",0":U, String(tqPostingByPeriodRange.tiDivision_ID))
Then Assign bcDivisionIDList = bcDivisionIDList + ',':U + String(tqPostingByPeriodRange.tiDivision_ID).
If Not Can-do(bcCostCentreIDList + ",0":U, String(tqPostingByPeriodRange.tiCostCentre_ID))
Then Assign bcCostCentreIDList = bcCostCentreIDList + ',':U + String(tqPostingByPeriodRange.tiCostCentre_ID).
If Not Can-do(bcProjectIDList + ",0":U, String(tqPostingByPeriodRange.tiProject_ID))
Then Assign bcProjectIDList = bcProjectIDList + ',':U + String(tqPostingByPeriodRange.tiProject_ID).
For Each tqPostingSafByIDs:
If Not Can-do(bcSafStructureIDList + ",0":U, String(tqPostingSafByIDs.tiSafStructure_ID))
Then Assign bcSafStructureIDList = bcSafStructureIDList + ',':U + String(tqPostingSafByIDs.tiSafStructure_ID).
If Not Can-do(bcSafIDList + ",0":U, String(tqPostingSafByIDs.tiSaf_ID))
Then Assign bcSafIDList = bcSafIDList + ',':U + String(tqPostingSafByIDs.tiSaf_ID).
If tqPostingSafByIDs.tiSaf_ID <> 0 And
tqPostingSafByIDs.tiSaf_ID <> ?
Then Do:
If tqPostingSafByIDs.tcPostingSafParentType = {&POSTINGSAFPARENTTYPE-GL}
Then Do:
<Q-14 run SafStructureLinkByAllIDs (all) (Read) (NoCache)
(input ?, (SafStructureLinkID)
input tqPostingSafByIDs.tiSafStructure_ID, (SafStructureID)
input tqPostingByPeriodRange.tiGL_ID, (GLID)
input ?, (ProjectID)
input ?, (CostCentreID)
output dataset tqSafStructureLinkByAllIDs) in BSafStructureLink >
Find First tqSafStructureLinkByAllIDs No-lock No-error.
If Available tqSafStructureLinkByAllIDs
Then Do:
If Not Can-do(bcSafStructureLinkIDList + ",0":U, String(tqSafStructureLinkByAllIDs.tiSafStructureLink_ID))
Then Assign bcSafStructureLinkIDList = bcSafStructureLinkIDList + ',':U + String(tqSafStructureLinkByAllIDs.tiSafStructureLink_ID).
End.
End.
If tqPostingSafByIDs.tcPostingSafParentType = {&POSTINGSAFPARENTTYPE-COSTCENTRE}
Then Do:
<Q-27 run CostCentrePrim (all) (Read) (NoCache)
(input iiCompanyId, (CompanyId)
input tqPostingByPeriodRange.tiCostCentre_ID, (CostCentreID)
input ?, (CostCentreCode)
output dataset tqCostCentrePrim) in BCostCentre >
For First tqCostCentrePrim:
If tqCostCentrePrim.tlCostCentreIsStructFromGL = true then do:
<Q-28 run SafStructureLinkByAllIDs (all) (Read) (NoCache)
(input ?, (SafStructureLinkID)
input tqPostingSafByIDs.tiSafStructure_ID, (SafStructureID)
input tqPostingByPeriodRange.tiGL_ID, (GLID)
input ?, (ProjectID)
input ?, (CostCentreID)
output dataset tqSafStructureLinkByAllIDs) in BSafStructureLink >
End.
Else do:
<Q-15 run SafStructureLinkByAllIDs (all) (Read) (NoCache)
(input ?, (SafStructureLinkID)
input tqPostingSafByIDs.tiSafStructure_ID, (SafStructureID)
input ?, (GLID)
input ?, (ProjectID)
input tqPostingByPeriodRange.tiCostCentre_ID, (CostCentreID)
output dataset tqSafStructureLinkByAllIDs) in BSafStructureLink >
End.
Find First tqSafStructureLinkByAllIDs No-lock No-error.
If Available tqSafStructureLinkByAllIDs
Then Do:
If Not Can-do(bcSafStructureLinkIDList + ",0":U, String(tqSafStructureLinkByAllIDs.tiSafStructureLink_ID))
Then Assign bcSafStructureLinkIDList = bcSafStructureLinkIDList + ',':U + String(tqSafStructureLinkByAllIDs.tiSafStructureLink_ID).
End.
End. /* for first tqCostCentrePrim */
End.
If tqPostingSafByIDs.tcPostingSafParentType = {&POSTINGSAFPARENTTYPE-PROJECT}
Then Do:
<Q-29 run ProjectPrim (all) (Read) (NoCache)
(input tqPostingByPeriodRange.tiCompany_ID, (CompanyId)
input tqPostingByPeriodRange.tiProject_ID, (ProjectID)
input ?, (ProjectCode)
output dataset tqProjectPrim) in BProject >
For First tqProjectPrim:
If tqProjectPrim.tlProjectIsStructFromGL = true then do:
<Q-30 run SafStructureLinkByAllIDs (all) (Read) (NoCache)
(input ?, (SafStructureLinkID)
input tqPostingSafByIDs.tiSafStructure_ID, (SafStructureID)
input tqPostingByPeriodRange.tiGL_ID, (GLID)
input ?, (ProjectID)
input ?, (CostCentreID)
output dataset tqSafStructureLinkByAllIDs) in BSafStructureLink >
End.
Else do:
<Q-16 run SafStructureLinkByAllIDs (all) (Read) (NoCache)
(input ?, (SafStructureLinkID)
input tqPostingSafByIDs.tiSafStructure_ID, (SafStructureID)
input ?, (GLID)
input tqPostingByPeriodRange.tiProject_ID, (ProjectID)
input ?, (CostCentreID)
output dataset tqSafStructureLinkByAllIDs) in BSafStructureLink >
End.
Find First tqSafStructureLinkByAllIDs No-lock No-error.
If Available tqSafStructureLinkByAllIDs
Then Do:
If Not Can-do(bcSafStructureLinkIDList + ",0":U, String(tqSafStructureLinkByAllIDs.tiSafStructureLink_ID))
Then Assign bcSafStructureLinkIDList = bcSafStructureLinkIDList + ',':U + String(tqSafStructureLinkByAllIDs.tiSafStructureLink_ID).
End.
End. /* For First tqProjectPrim */
End.
End.
End. /* For Each tqPostingSafByIDs: */
End. /* For Each tqPostingByPeriodRange: */
/* Stop queries */
<Q-11 run PostingSafByIDs (Stop) in BPosting >
<Q-9 run SafStructureLinkByAllIDs (Stop) in BSafStructureLink >
<Q-24 run PeriodByYearPeriod (Stop) in BPeriod >
Assign bcGLIDList = Replace(Trim(bcGLIDList, ',':U),',':U,Chr(4)).
Assign bcJournalIDList = Replace(Trim(bcJournalIDList, ',':U),',':U,Chr(4)).
Assign bcBusinessRelationIDList = Replace(Trim(bcBusinessRelationIDList,',':U),',':U,Chr(4)).
Assign bcDivisionIDList = Replace(Trim(bcDivisionIDList, ',':U),',':U,Chr(4)).
Assign bcCostCentreIDList = Replace(Trim(bcCostCentreIDList, ',':U),',':U,Chr(4)).
Assign bcProjectIDList = Replace(Trim(bcProjectIDList, ',':U),',':U,Chr(4)).
Assign bcSafStructureIDList = Replace(Trim(bcSafStructureIDList, ',':U),',':U,Chr(4)).
Assign bcSafIDList = Replace(Trim(bcSafIDList, ',':U),',':U,Chr(4)).
Assign bcSafStructureLinkIDList = Replace(Trim(bcSafStructureLinkIDList,',':U),',':U,Chr(4)).
Assign vcDumpFile = icDumpDirectory + "Posting.xml":U.
<M-17 run DumpJEForConsolid (input vcDumpFile (icDumpFile),
input icConsolCompany (icConsolCompany),
input idCCExchangeRate (idCCExchangeRate),
input idCCExchangeRateScale (idCCExchangeRateScale),
input icCCCurrencyCode (icCCCurrencyCode),
input-output bcGLIDList (bcGLIDList),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return.
If oiReturnStatus = -98
Then Assign oiReturnStatus = 0.