project QadFinancials > class BJournalEntryMultiCy > method ApiCreateCrossCyPostingsApplyCCyValidations
Description
Apply the validations for cross company journal entries. Only validations that don't already exist in Journal Entry will be added here.
Parameters
icRowId | input | character | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
program code (program9/bjournalentrymulticy.p)
/* ================================================================ */
/* This method performs validations on the incoming dataset */
/* All tables are validated before returning - even if an error */
/* is found. */
/* ================================================================ */
find first tPostingHeaderMultiCy where
tPostingHeaderMultiCy.tc_Rowid = icRowid and
tPostingHeaderMultiCy.tlPostingHeaderIsPosted = false
no-lock no-error.
if available tPostingHeaderMultiCy
then do:
/* ================ */
/* Reset Totals etc */
/* ================ */
assign
vcCurrentDaybookLayerType = ""
vdSourceDebitTC = 0
vdSourceCreditTC = 0
vdNonSourceDebitTC = 0
vdNonSourceCreditTC = 0.
/* =============================================================================== */
/* There should be only one and only one tPostingMultiCy record for current entity */
/* question */
/* =============================================================================== */
find first tPostingMultiCy where
tPostingMultiCy.tc_ParentRowid = tPostingHeaderMultiCy.tc_Rowid and
tPostingMultiCy.Company_ID = viCompanyId no-error.
if not available tPostingMultiCy
then do:
assign
vcMessageText = #T-86'There must be one source entity posting per cross company posting':255(875877681)T-86#
vcMsgExplanation = trim(#T-65'This error relates to the following posting:':255(99973123)T-65#) + chr(10) +
trim(substitute(#T-97'Default Posting Year/Period: &1, Date: &2':200(111192207)T-97#, string(tPostingHeaderMultiCy.tiPostingHeaderYear) + '/' + string(tPostingHeaderMultiCy.tiPostingHeaderGLPeriod), string(tPostingHeaderMultiCy.ttPostingHeaderPostingDate))) + chr(10) +
trim(substitute(#T-20'Default Daybook: &1':255(905122758)T-20#,string(tPostingHeaderMultiCy.tcPostingHeaderJournalCode))) + chr(10) +
trim(substitute(#T-3'Default Description: &1':40(144252575)T-3#,string(tPostingHeaderMultiCy.tcPostingHeaderDescription)))
oiReturnStatus = -1.
<M-35 run SetMessage
(input vcMessageText (icMessage),
input ' ' (icArguments),
input vcCompanyCode (icFieldName),
input ' ' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tPostingHeaderMultiCy.tc_Rowid (icRowid),
input 'qadfin-951778':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input ' ' (icFcIdentification),
input ' ' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
end. /* find first tPostingMultiCy */
find next tPostingMultiCy where
tPostingMultiCy.tc_ParentRowid = tPostingHeaderMultiCy.tc_Rowid and
tPostingMultiCy.Company_ID = viCompanyId no-error.
if available tPostingMultiCy
then do:
assign
vcMsgExplanation = <M-37 GetErrorExplanation
(input tPostingMultiCy.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
vcMessageText = #T-60'There can only be one source entity posting per cross company posting':255(142137137)T-60#
oiReturnStatus = -1.
<M-36 run SetMessage
(input vcMessageText (icMessage),
input ' ' (icArguments),
input vcCompanyCode (icFieldName),
input ' ' (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tPostingHeaderMultiCy.tc_Rowid (icRowid),
input 'qadfin-72232':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input ' ' (icFcIdentification),
input ' ' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
end. /* if available tPostingMultiCy */
find first tPostingMultiCy where
tPostingMultiCy.tc_ParentRowid = tPostingHeaderMultiCy.tc_Rowid and
tPostingMultiCy.PostingIsAutoReversal = true no-error.
if available tPostingMultiCy
then do:
assign
vcMessageText = trim(#T-94'The Automatic Reversal functionality is not supported.':255(638710903)T-94#)
oiReturnStatus = -1.
<M-19 run SetMessage
(input vcMessageText (icMessage),
input ' ' (icArguments),
input 'tPostingMultiCy.PostingIsAutoReversal':U (icFieldName),
input tPostingMultiCy.PostingIsAutoReversal (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tPostingHeaderMultiCy.tc_Rowid (icRowid),
input 'qadfin-556563':U (icFcMsgNumber),
input ' ' (icFcExplanation),
input ' ' (icFcIdentification),
input ' ' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
end. /* if available tPostingMultiCy */
/* =================================================================================== */
/* Go through all postings of the input */
/* =================================================================================== */
for each tPostingMultiCy where
tPostingMultiCy.tc_parentRowid = tPostingHeaderMultiCy.tc_rowid
on error undo, throw:
/* =================================================================================================== */
/* Although the period and period-mark of the postings is validated later on by class BPosting itself, */
/* we here already make sure that the combination of CompanyCode and Period or PeriodMark exist. */
/* The reason for checking this already here is that we can give a more clear message - including the */
/* CompanyCode - to the user */
/* =================================================================================================== */
if tPostingMultiCy.Company_ID <> 0 and
tPostingMultiCy.Company_ID <> ?
then do :
if tPostingMultiCy.PostingYear = 0 or
tPostingMultiCy.PostingYear = ? or
tPostingMultiCy.PostingPeriod = 0 or
tPostingMultiCy.PostingPeriod = ?
then do :
assign vcMessageText = trim(substitute(#T-56'You must enter the year and period of the posting on entity &1.':255(23237964)T-56#,tPostingMultiCy.tcCompanyCode))
vcMsgExplanation = <M-16 GetErrorExplanation
(input tPostingMultiCy.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
oiReturnStatus = -1.
<M-79 run SetMessage
(input vcMessageText (icMessage),
input '':U (icArguments),
input 'tPostingMultiCy.PostingPeriod':U (icFieldName),
input tPostingMultiCy.PostingPeriod (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tPostingMultiCy.tc_rowid (icRowid),
input 'qadfin-853838':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
end. /* if tPostingMultiCy.PostingYear = 0 or */
else do :
<Q-29 run PeriodPrim (all) (Read) (NoCache)
(input tPostingMultiCy.Company_ID, (CompanyId)
input ?, (PeriodId)
input tPostingMultiCy.PostingYear, (PeriodYear)
input tPostingMultiCy.PostingPeriod, (PeriodPeriod)
output dataset tqPeriodPrim) in BPeriod >
Find first tqPeriodPrim where
tqPeriodPrim.tiCompany_ID = tPostingMultiCy.Company_ID and
tqPeriodPrim.tiPeriodYear = tPostingMultiCy.PostingYear and
tqPeriodPrim.tiPeriodPeriod = tPostingMultiCy.PostingPeriod
no-error.
if not available tqPeriodPrim
then do :
assign vcMessageText = trim(substitute(#T-40'This period (&1/&2) is not defined for Entity &3.':255(351538488)T-40#,tPostingMultiCy.PostingYear,tPostingMultiCy.PostingPeriod,tPostingMultiCy.tcCompanyCode))
vcMsgExplanation = <M-70 GetErrorExplanation
(input tPostingMultiCy.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
oiReturnStatus = -1.
<M-2 run SetMessage
(input vcMessageText (icMessage),
input '':U (icArguments),
input 'tPostingMultiCy.PostingPeriod':U (icFieldName),
input tPostingMultiCy.PostingPeriod (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input tPostingMultiCy.tc_rowid (icRowid),
input 'qadfin-362001':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
end. /* if not available tqPeriodPrim */
end. /* else if tPostingMultiCy.PostingYear = 0 or */
end. /* if tPostingMultiCy.Company_ID <> 0 and */
/* =================================================================================== */
/* Go through all lines of the posting */
/* =================================================================================== */
for each tPostingLineMultiCy where
tPostingLineMultiCy.tc_parentrowid = tPostingMultiCy.tc_rowid on error undo, throw:
/* =================================================================== */
/* Ensure that the sum of the source entity postings and non-source */
/* entity postings do not equal 0 */
/* =================================================================== */
if tPostingMultiCy.Company_ID = viCompanyID
then assign vdSourceDebitTC = vdSourceDebitTC + tPostingLineMultiCy.PostingLineDebitTC
vdSourceCreditTC = vdSourceCreditTC + tPostingLineMultiCy.PostingLineCreditTC.
else assign vdNonSourceDebitTC = vdNonSourceDebitTC + tPostingLineMultiCy.PostingLineDebitTC
vdNonSourceCreditTC = vdNonSourceCreditTC + tPostingLineMultiCy.PostingLineCreditTC.
end. /* for each tPostingLinMultiCy */
end. /* for each tPostingMultiCy */
/* =============================================================================== */
/* All daybooks should have the same layer type */
/* =============================================================================== */
find first tPostingMultiCy no-error.
assign vcCurrentDaybookLayerType = tPostingMultiCy.tcLayerTypeCode.
find first tPostingMultiCy where tPostingMultiCy.tcLayerTypeCode <> vcCurrentDaybookLayerType no-error.
if available tPostingMultiCy
then do:
assign
vcMsgExplanation = <M-87 GetErrorExplanation
(input tPostingMultiCy.tc_Rowid (icPostingRowId),
input ? (icPostingLineRowId),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
vcMessageText = trim(substitute(#T-21'All daybook layer types have to be the same for cross company postings':255(535401510)T-21#,tPostingMultiCy.tcJournalCode, {&LAYERTYPECODE-TRANSIENT-TR}, tPostingMultiCy.PostingText))
oiReturnStatus = -1.
<M-15 run SetMessage
(input vcMessageText (icMessage),
input '' (icArguments),
input 'tPostingMultiCy.tcJournalCode':U (icFieldName),
input tPostingMultiCy.tcJournalCode (icFieldValue),
input 'E' (icType),
input 3 (iiSeverity),
input tPostingMultiCy.tc_Rowid (icRowid),
input 'qadfin-541369':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '' (icFcIdentification),
input '' (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
end. /* if available tPostingMultiCy */
/* =================================================================================== */
/* Sum of source entity posting lines must equal sum of all other entity posting lines */
/* =================================================================================== */
if (vdSourceDebitTC - vdSourceCreditTC) = 0 and
(vdNonSourceDebitTC - vdNonSourceCreditTC ) = 0 and
(vdSourceDebitTC + vdSourceCreditTC ) <> (vdNonSourceDebitTC + vdNonSourceCreditTC)
then do:
assign vcMessageText = trim(substitute(#T-10'Sum of source entity posting lines must equal sum of all other entity posting lines (Entity &1).':255(66790363)T-10#,vcCompanyCode))
vcMsgExplanation = trim(#T-48'This error relates to the following posting:':255(99973123)T-48#) + chr(10) +
trim(substitute(#T-22'Default Posting Year/Period: &1, Date: &2':200(111192207)T-22#, string(tPostingHeaderMultiCy.tiPostingHeaderYear) + '/' + string(tPostingHeaderMultiCy.tiPostingHeaderGLPeriod), string(tPostingHeaderMultiCy.ttPostingHeaderPostingDate))) + chr(10) +
trim(substitute(#T-8'Default Daybook: &1':255(905122758)T-8#,string(tPostingHeaderMultiCy.tcPostingHeaderJournalCode))) + chr(10) +
trim(substitute(#T-76'Default Description: &1':40(144252575)T-76#,string(tPostingHeaderMultiCy.tcPostingHeaderDescription)))
oiReturnStatus = -1.
<M-91 run SetMessage
(input vcMessageText (icMessage),
input '':U (icArguments),
input '':U (icFieldName),
input '':U (icFieldValue),
input 'E':U (icType),
input 3 (iiSeverity),
input '':U (icRowid),
input 'qadfin-280776':U (icFcMsgNumber),
input vcMsgExplanation (icFcExplanation),
input '':U (icFcIdentification),
input '':U (icFcContext),
output viFcReturnSuper (oiReturnStatus)) in BJournalEntryMultiCy>
assign oiReturnStatus = -1.
end. /* if */
end. /* for each tPostingHeaderMultiCy */