project QadFinancials > class BPosting > method ValidateComponentPostPostingLine3

Description

ValidatePostingLine


Parameters


ilPostingIsYearClosinginputlogical
blQueryStartedGLForPostingLineinput-outputlogical
blQueryStartedGetCostCentreinput-outputlogical
blQueryStartedGetProjectinput-outputlogical
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BPosting.ValidateComponentPost


program code (program4/bposting.p)

/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus      = -98
       viLocalReturnStatus = 0.

POSTINGLINEBLOCK:
do: 
    /* tqGLByPostingValidation should be available in ValidateComponentPostPostingLine2 */
    if not available tqGLByPostingValidation
    then leave POSTINGLINEBLOCK.

    if t_sPosting.tc_Status <> "D":U and
      (t_sPostingLine.tc_Status      = "N":U               or
       t_sPostingLine.tc_Status      = "C":U)
    then do:        
        if ilPostingIsYearClosing = false
        then do:
            COABLOCK:
            do: 
                /* ================================================================================= */
                /* skip coa validations when daybook is of period costing and skipcoavalforPC = true */
                /* ================================================================================= */
                if t_sPosting.tcJournalTypeCode                = {&JOURNALTYPE-PERIODICCOSTING} and
                   t_sPostingLine.tlSkipCOAValForPeriodCosting = true
                then leave COABLOCK.
    
                /* ================= */
                /* Check Cost Centre */
                /* ================= */
                if tqGLByPostingValidation.tlGLIsCostCentreAccount                                        and
                  (not tqGLByPostingValidation.tlGLIsProjectAccount                                       or
                   tqGLByPostingValidation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-BOTHREQUIRED}) 
                then do:
                    /* Retrieve cost center from default profile */
                    if t_sPostingLine.CostCentre_ID = ? or t_sPostingLine.CostCentre_ID = 0
                    then do:
                        if blQueryStartedGLForPostingLine = false
                        then do:
                            <Q-247 run GLForPostingLineCreation  (Start) in BGL >
                            assign blQueryStartedGLForPostingLine = true.
                        end. /* if blQueryStartedGLForPostingLine = false */
    
                        if t_sPostingLine.GL_ID <> 0 and t_sPostingLine.GL_ID <> ?
                        then do:
                            <Q-222 run GLForPostingLineCreation (all) (Read) (Cache)
                               (input ?, (CompanyID)
                                input ?, (GLCode)
                                input t_sPostingLine.GL_ID, (GLId)
                                output dataset tqGLForPostingLineCreation) in BGL>
                        end.
                        else do:
                            <Q-7 run GLForPostingLineCreation (all) (Read) (Cache)
                               (input t_sPostingLine.Company_ID, (CompanyID)
                                input t_sPostingLine.tcGLCode, (GLCode)
                                input ?, (GLId)
                                output dataset tqGLForPostingLineCreation) in BGL>
                        end.
                        
                        find first tqGLForPostingLineCreation no-error.
                        if available tqGLForPostingLineCreation
                        then do:
                            /* ======================================== */
                            /* Set the CostCentre and its optional SAFs */
                            /* ======================================== */
                            if tqGLForPostingLineCreation.tlGLIsCostCentreAccount
                            then do:
                                if (tqGLForPostingLineCreation.tiCostCentreProfile_ID <> 0 and 
                                    tqGLForPostingLineCreation.tiCostCentreProfile_ID <> ?)    and 
                                   (tqGLForPostingLineCreation.tlGLIsProjectAccount = false or
                                    t_sPostingLine.tcProjectCode                                   = "":U  or
                                    t_sPostingLine.tcProjectCode                                   = ?)
                                then do:
                                    if blQueryStartedGetCostCentre = false
                                    then do:
                                        <Q-249 run GetCostCentreFromProfile  (Start) in BProfile >
                                        assign blQueryStartedGetCostCentre = true.
                                    end. /* if blQueryStartedGetCostCentre = false */
    
                                    <Q-223 run GetCostCentreFromProfile (all) (Read) (Cache)
                                       (input viCompanyId, (CompanyId)
                                        input tqGLForPostingLineCreation.tiCostCentreProfile_ID, (CostCentreProfileId)
                                        output dataset tqCostCentreFromProfile) in BProfile >
                                    find first tqCostCentreFromProfile no-error.
                                    if available tqCostCentreFromProfile
                                    then assign t_sPostingLine.CostCentre_ID   = tqCostCentreFromProfile.tiCostCentre_ID
                                               t_sPostingLine.tcCostCentreCode = tqCostCentreFromProfile.tcCostCentreCode.
                                end. /* if (tqGLForPostingLineCreation.tiCostCentreProfile_ID <> 0 and */
                            end. /* if tqGLForPostingLineCreation.tlGLIsCostCentreAccount */
                        end. /* if available tqGLForPostingLineCreation */
                    end. /* End of retreive from ...*/
                    if t_sPostingLine.CostCentre_ID = ? or  t_sPostingLine.CostCentre_ID = 0
                    then do:
                        assign vcMsgExplanation = <M-66 GetErrorExplanation
                                                     (input  t_sPosting.tc_Rowid (icPostingRowId), 
                                                      input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                                                      output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                                  
                        assign vcMessage           = trim(subst(#T-228'The GL account &1 requires a cost center code.':150(3235)T-228#, t_sPostingLine.tcGLCode))
                               viLocalReturnStatus = -1.
                        <M-206 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '':U (icArguments), 
                            input  'tPostingLine.tcCostCentreCode':U (icFieldName), 
                            input  '':U (icFieldValue), 
                            input  'E':U (icType), 
                            input  3 (iiSeverity), 
                            input  t_sPostingLine.tc_Rowid (icRowid), 
                            input  'QadFin-8837':U (icFcMsgNumber), 
                            input  vcMsgExplanation (icFcExplanation), 
                            input  '' (icFcIdentification), 
                            input  '' (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BPosting>
                    end. /* if t_sPostingLine.CostCentre_ID = ? or  t_sPostingLine.CostCentre_ID = 0 */
                end. /* if tqGLByPostingValidation.tlGLIsCostCentreAccount ... */
                
                if not tqGLByPostingValidation.tlGLIsCostCentreAccount 
                then assign t_sPostingLine.CostCentre_ID = 0.
                if not tqGLByPostingValidation.tlGLIsCostCentreAccount and
                   t_sPostingLine.CostCentre_ID <> 0                   and
                   t_sPostingLine.CostCentre_ID <> ?
                then do:
                    assign vcMsgExplanation = <M-70 GetErrorExplanation
                                                 (input  t_sPosting.tc_Rowid (icPostingRowId), 
                                                  input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                                                  output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                                  
                    assign vcMessage           = trim(subst(#T-237'You cannot use a cost center code with GL account &1.':150(65717)T-237#, t_sPostingLine.tcGLCode))
                           viLocalReturnStatus = -1.
                    <M-215 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '':U (icArguments), 
                        input  'tPostingLine.tcCostCentreCode':U (icFieldName), 
                        input  '':U (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  t_sPostingLine.tc_Rowid (icRowid), 
                        input  'QadFin-8846':U (icFcMsgNumber), 
                        input  vcMsgExplanation (icFcExplanation), 
                        input  '' (icFcIdentification), 
                        input  '' (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BPosting>
                end. /* if not tqGLByPostingValidation.tlGLIsCostCentreAccount and */
        
                /* ============= */
                /* Check Project */
                /* ============= */
                if tqGLByPostingValidation.tlGLIsProjectAccount                                           and
                  (not tqGLByPostingValidation.tlGLIsCostCentreAccount                                    or
                   tqGLByPostingValidation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-BOTHREQUIRED}) 
                then do:
                    if t_sPostingLine.Project_ID  = ? or t_sPostingLine.Project_ID  = 0
                    then do:
                        if blQueryStartedGLForPostingLine = false
                        then do:
                            <Q-248 run GLForPostingLineCreation  (Start) in BGL >
                            assign blQueryStartedGLForPostingLine = true.
                        end. /* if blQueryStartedGLForPostingLine = false */
    
                        <Q-224 run GLForPostingLineCreation (all) (Read) (Cache)
                           (input t_sPostingLine.Company_ID, (CompanyID)
                            input t_sPostingLine.tcGLCode, (GLCode)
                            input t_sPostingLine.GL_ID, (GLId)
                            output dataset tqGLForPostingLineCreation) in BGL >
                        find first tqGLForPostingLineCreation no-error.
                        if available tqGLForPostingLineCreation
                        then do:
                            /* ======================================== */
                            /* Set the Projectand its optional SAFs     */
                            /* ======================================== */
                            if tqGLForPostingLineCreation.tlGLIsProjectAccount
                            then do:
                                if (tqGLForPostingLineCreation.tiProjectProfile_ID <> 0 and 
                                    tqGLForPostingLineCreation.tiProjectProfile_ID <> ?)    and 
                                   (tqGLForPostingLineCreation.tlGLIsCostCentreAccount  = false or
                                    t_sPostingLine.tcProjectCode                                   = "":U  or
                                    t_sPostingLine.tcProjectCode                                   = ?)
                                then do:
                                    if blQueryStartedGetProject = false
                                    then do:
                                        <Q-251 run GetProjectFromProfile  (Start) in BProfile >                                    
                                        assign blQueryStartedGetProject = true.
                                    end. /* if blQueryStartedGetCostCentre = false */
    
                                    <Q-225 run GetProjectFromProfile (all) (Read) (Cache)
                                       (input viCompanyId, (CompanyId)
                                        input tqGLForPostingLineCreation.tiProjectProfile_ID, (ProjectProfileID)
                                        output dataset tqProjectFromProfile) in BProfile >
                                    find first tqProjectFromProfile no-error.
                                    if available tqProjectFromProfile
                                    then assign t_sPostingLine.Project_ID    = tqProjectFromProfile.tiProject_ID
                                                t_sPostingLine.tcProjectCode = tqProjectFromProfile.tcProjectCode.
                                end. /* if (tqGLForPostingLineCreation.tiProjectProfile_ID <> 0 and */
                            end. /* if tqGLForPostingLineCreation.tlGLIsProjectAccount */
                        end. /* if available tqGLForPostingLineCreation */
                    end. /* if t_sPostingLine.Project_ID  = ? or t_sPostingLine.Project_ID  = 0 */
                    if t_sPostingLine.Project_ID  = ? or t_sPostingLine.Project_ID  = 0
                    then do:
                        assign vcMsgExplanation = <M-68 GetErrorExplanation
                                                     (input  t_sPosting.tc_Rowid (icPostingRowId), 
                                                      input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                                                      output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                                  
                        assign vcMessage           = trim(subst(#T-232'The GL account &1 requires a project code.':150(3240)T-232#, t_sPostingLine.tcGLCode))
                               viLocalReturnStatus = -1.
                        <M-207 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '':U (icArguments), 
                            input  'tPostingLine.tcProjectCode':U (icFieldName), 
                            input  '':U (icFieldValue), 
                            input  'E':U (icType), 
                            input  3 (iiSeverity), 
                            input  t_sPostingLine.tc_Rowid (icRowid), 
                            input  'QadFin-8838':U (icFcMsgNumber), 
                            input  vcMsgExplanation (icFcExplanation), 
                            input  '' (icFcIdentification), 
                            input  '' (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BPosting>
                    end. /* if t_sPostingLine.Project_ID  = ? or t_sPostingLine.Project_ID  = 0 */
                end. /* if tqGLByPostingValidation.tlGLIsProjectAccount ... */
                
                if not tqGLByPostingValidation.tlGLIsProjectAccount 
                then assign t_sPostingLine.Project_ID = 0.
                if not tqGLByPostingValidation.tlGLIsProjectAccount and
                   t_sPostingLine.Project_ID <> 0                   and
                   t_sPostingLine.Project_ID <> ?
                then do:
                    assign vcMsgExplanation = <M-41 GetErrorExplanation
                                                 (input  t_sPosting.tc_Rowid (icPostingRowId), 
                                                  input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                                                  output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                                  
                    assign vcMessage           = trim(subst(#T-238'You cannot use a project code with GL account &1.':150(65719)T-238#, t_sPostingLine.tcGLCode))
                           viLocalReturnStatus = -1.
                    <M-216 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '':U (icArguments), 
                        input  'tPostingLine.tcProjectCode':U (icFieldName), 
                        input  '':U (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  t_sPostingLine.tc_Rowid (icRowid), 
                        input  'QadFin-8847':U (icFcMsgNumber), 
                        input  vcMsgExplanation (icFcExplanation), 
                        input  '' (icFcIdentification), 
                        input  '' (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BPosting>
                end. /* if not tqGLByPostingValidation.tlGLIsProjectAccount and */
        
                /* ======================================= */                   
                /* Check Project / Cost Centre combination */
                /* ======================================= */
                if (tqGLByPostingValidation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-ATLEASTONE}     or
                    tqGLByPostingValidation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-EXCLEACHOTHER}) and
                   (t_sPostingLine.CostCentre_ID                   = 0                                      or
                    t_sPostingLine.CostCentre_ID                   = ?)                                     and
                   (t_sPostingLine.Project_ID                      = 0                                      or
                    t_sPostingLine.Project_ID                      = ?)
                then do:
                    assign vcMsgExplanation = <M-23 GetErrorExplanation
                                                 (input  t_sPosting.tc_Rowid (icPostingRowId), 
                                                  input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                                                  output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                                  
                    assign vcMessage           = trim(subst(#T-233'The GL account &1 requires a cost center or project code.':150(3244)T-233#, t_sPostingLine.tcGLCode))
                           viLocalReturnStatus = -1.
                    <M-211 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '':U (icArguments), 
                        input  'tPostingLine.tcCostCentreCode':U (icFieldName), 
                        input  '':U (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  t_sPostingLine.tc_Rowid (icRowid), 
                        input  'QadFin-8842':U (icFcMsgNumber), 
                        input  vcMsgExplanation (icFcExplanation), 
                        input  '':U (icFcIdentification), 
                        input  '':U (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BPosting>
                end. /* if (tqGLByPostingValidation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-ATLEASTONE}     or */
        
                if tqGLByPostingValidation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-EXCLEACHOTHER} and
                   t_sPostingLine.CostCentre_ID                  <> 0                                     and
                   t_sPostingLine.CostCentre_ID                  <> ?                                     and
                   t_sPostingLine.Project_ID                     <> 0                                     and
                   t_sPostingLine.Project_ID                     <> ?
                then do:
                    assign vcMsgExplanation = <M-75 GetErrorExplanation
                                                 (input  t_sPosting.tc_Rowid (icPostingRowId), 
                                                  input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                                                  output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                                  
                    assign vcMessage           = trim(subst(#T-234'The GL account &1 requires either cost center or project analysis.':150(3245)T-234#, t_sPostingLine.tcGLCode))
                           viLocalReturnStatus = -1.
                    <M-212 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '':U (icArguments), 
                        input  'tPostingLine.tcCostCentreCode':U (icFieldName), 
                        input  '':U (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  t_sPostingLine.tc_Rowid (icRowid), 
                        input  'QadFin-8843':U (icFcMsgNumber), 
                        input  vcMsgExplanation (icFcExplanation), 
                        input  '':U (icFcIdentification), 
                        input  '':U (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BPosting>
                end. /* if tqGLByPostingValidation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-EXCLEACHOTHER} and */
                
               /* If analysis limitation is ATLEASTCOSTCENTER (aka COSTCENTREREQUIRED) then throw error if no cost center is defined */
               if tqGLByPostingValidation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-ATLEASTCOSTCENTER} and
                  ( t_sPostingLine.CostCentre_ID                  = 0                                        or
                    t_sPostingLine.CostCentre_ID                  = ?         )                               
                then do:
                    assign vcMsgExplanation = <M-62 GetErrorExplanation
                                                 (input  t_sPosting.tc_Rowid (icPostingRowId), 
                                                  input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                                                  output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                                  
                    assign vcMessage           = trim(subst(#T-9'The GL account &1 requires cost center analysis as it is defined with analysis limitation &2':150(599812732)T-9#,
                                                         t_sPostingLine.tcGLCode,
                                                         {&GLANALYSISLIMITATION-ATLEASTCC-TR}))
                           viLocalReturnStatus = -1.
                    <M-21 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '':U (icArguments), 
                        input  'tPostingLine.tcCostCentreCode':U (icFieldName), 
                        input  '':U (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  t_sPostingLine.tc_Rowid (icRowid), 
                        input  'qadfin-160594':U (icFcMsgNumber), 
                        input  vcMsgExplanation (icFcExplanation), 
                        input  '':U (icFcIdentification), 
                        input  '':U (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BPosting>
                end. /* if tqGLByPostingValidation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-ATLEASTCOSTCENTER} and */
                
                 /* If analysis limitation is PROJECTREQUIRED then throw error if no project code  is defined */
               if tqGLByPostingValidation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-PROJECTREQUIRED} and
                  ( t_sPostingLine.Project_ID                  = 0                                        or
                   t_sPostingLine.Project_ID                  = ?     )                                   
                then do:
                    assign vcMsgExplanation = <M-37 GetErrorExplanation
                                                 (input  t_sPosting.tc_Rowid (icPostingRowId), 
                                                  input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                                                  output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                                  
                    assign vcMessage           = trim(subst(#T-4'The GL account &1 requires project analysis as it is defined with analysis limitation &2':150(141078291)T-4#,
                                                         t_sPostingLine.tcGLCode,
                                                         {&GLANALYSISLIMITATION-PROJECTREQUIRED-TR}))
                           viLocalReturnStatus = -1.
                    <M-97 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '':U (icArguments), 
                        input  'tPostingLine.tcProjectCode':U (icFieldName), 
                        input  '':U (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  t_sPostingLine.tc_Rowid (icRowid), 
                        input  'qadfin-286119':U (icFcMsgNumber), 
                        input  vcMsgExplanation (icFcExplanation), 
                        input  '':U (icFcIdentification), 
                        input  '':U (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BPosting>
                end. /* if tqGLByPostingValidation.tcGLAnalysisLimitation = {&GLANALYSISLIMITATION-PROJECTREQUIRED} and */
            end. /* COABLOCK */
            
            /* ========================================================================================================================== */
            /* Check Interco (skip validation for external posting and for cross-cy postings as the IntercoBusinessRelation is not filled */
            /* by the user for these accounts but by the program-code right before the ancestor-code of method ValidateComponent)         */ 
            /* ========================================================================================================================== */
            
            if (t_sPosting.PostingOriginIsExternal = false or
                (t_sPosting.PostingOriginIsExternal = true and
                 (t_sPostingLine.PostingLineCrossExternRef = '':U or t_sPostingLine.PostingLineCrossExternRef = ?)))   and
                tqGLByPostingValidation.tcGLTypeCode         <> {&GLTYPECODE-CROSS}     and 
                tqGLByPostingValidation.tlGLIsIntercoAccount =  true                    and
                (t_sPostingLine.tcIntercoBusinessRelationCode <> "":U and t_sPostingLine.tcIntercoBusinessRelationCode <> ?)
            then do:
                <Q-54 run BusinessRelationByIDCodeIC (all) (Read) (Cache)
                   (input ?, (BusinessRelationID)
                    input ?, (BusinessRelationCode)
                    input t_sPostingLine.tcIntercoBusinessRelationCode, (BusinessRelationIntercoCode)
                    input true, (BusinessRelationIsActive)
                    output dataset tqBusinessRelationByIDCodeIC) in BBusinessRelation>
                                
                find first tqBusinessRelationByIDCodeIC where 
                          (tqBusinessRelationByIDCodeIC.tcBusinessRelationICCode = t_sPostingLine.tcIntercoBusinessRelationCode and
                          (tqBusinessRelationByIDCodeIC.tiDomain_ID = 0 or tqBusinessRelationByIDCodeIC.tiDomain_ID = ?))       or
                          (tqBusinessRelationByIDCodeIC.tcBusinessRelationICCode = t_sPostingLine.tcIntercoBusinessRelationCode and
                           tqBusinessRelationByIDCodeIC.tiDomain_ID = viDomainID                                                and
                           tqBusinessRelationByIDCodeIC.tlBusinessRelationIsDomRestr) no-error.
                                                              
                if not available tqBusinessRelationByIDCodeIC
                then do:

                    find first tqBusinessRelationByIDCodeIC where 
                               tqBusinessRelationByIDCodeIC.tcBusinessRelationICCode = t_sPostingLine.tcIntercoBusinessRelationCode and
                              (tqBusinessRelationByIDCodeIC.tiDomain_ID <> 0 and tqBusinessRelationByIDCodeIC.tiDomain_ID <> ?)     and
                               tqBusinessRelationByIDCodeIC.tiDomain_ID <> viDomainID                                               and
                               tqBusinessRelationByIDCodeIC.tlBusinessRelationIsDomRestr no-error.
                                       
                    if available tqBusinessRelationByIDCodeIC
                    then do:   
                        assign vcMsgExplanation = <M-46 GetErrorExplanation
                                                     (input  t_sPosting.tc_Rowid (icPostingRowId), 
                                                      input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                                                      output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                          
                        assign vcMessage           = trim(subst(#T-33'Inter Company code: &1 does not belong to the current domain':150(849458244)T-33#, t_sPostingLine.tcIntercoBusinessRelationCode))
                    
                        viLocalReturnStatus = -1.
                        
                        <M-98 run SetMessage
                           (input  vcMessage (icMessage), 
                            input  '':U (icArguments), 
                            input  'tPostingLine.tcIntercoBusinessRelationCode':U (icFieldName), 
                            input  '':U (icFieldValue), 
                            input  'E':U (icType), 
                            input  3 (iiSeverity), 
                            input  t_sPostingLine.tc_Rowid (icRowid), 
                            input  'qadfin-124043':U (icFcMsgNumber), 
                            input  vcMsgExplanation (icFcExplanation), 
                            input  '':U (icFcIdentification), 
                            input  '':U (icFcContext), 
                            output viFcReturnSuper (oiReturnStatus)) in BPosting>
                    end.
               
                end.
               
            end.

            if (t_sPosting.PostingOriginIsExternal = false or
                (t_sPosting.PostingOriginIsExternal = true and
                 (t_sPostingLine.PostingLineCrossExternRef = '':U or t_sPostingLine.PostingLineCrossExternRef = ?)))   and
                tqGLByPostingValidation.tcGLTypeCode         <> {&GLTYPECODE-CROSS}     and 
                tqGLByPostingValidation.tlGLIsIntercoAccount =  true                    and
                (t_sPostingLine.IntercoBusinessRelation_ID = 0 or t_sPostingLine.IntercoBusinessRelation_ID = ?)
                
            then do:
                assign vcMsgExplanation = <M-85 GetErrorExplanation
                                             (input  t_sPosting.tc_Rowid (icPostingRowId), 
                                              input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                                              output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                              
                assign vcMessage           = trim(subst(#T-235'The GL account &1 requires an intercompany code.':150(3246)T-235#, t_sPostingLine.tcGLCode))
                       viLocalReturnStatus = -1.
                <M-208 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  'tPostingLine.tcIntercoBusinessRelationCode':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sPostingLine.tc_Rowid (icRowid), 
                    input  'QadFin-8839':U (icFcMsgNumber), 
                    input  vcMsgExplanation (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BPosting>
            end. /* if (t_sPosting.PostingOriginIsExternal = false or */
    
            if not tqGLByPostingValidation.tlGLIsIntercoAccount and
               t_sPostingLine.IntercoBusinessRelation_ID <> 0   and
               t_sPostingLine.IntercoBusinessRelation_ID <> ?
            then do:
                assign vcMsgExplanation = <M-50 GetErrorExplanation
                                             (input  t_sPosting.tc_Rowid (icPostingRowId), 
                                              input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                                              output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                              
                assign vcMessage           = trim(subst(#T-239'You cannot use an intercompany code with GL account &1.':150(65723)T-239#, t_sPostingLine.tcGLCode))
                       viLocalReturnStatus = -1.
                <M-217 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  'tPostingLine.tcIntercoBusinessRelationCode':U (icFieldName), 
                    input  '':U (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sPostingLine.tc_Rowid (icRowid), 
                    input  'QadFin-8848':U (icFcMsgNumber), 
                    input  vcMsgExplanation (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BPosting>
            end. /* if not tqGLByPostingValidation.tlGLIsIntercoAccount and */
    
            if tqGLByPostingValidation.tlGLIsFixedInterco and
               tqGLByPostingValidation.tiBusinessRelation_ID <> t_sPostingLine.IntercoBusinessRelation_ID
            then do:
                assign vcMsgExplanation = <M-27 GetErrorExplanation
                                             (input  t_sPosting.tc_Rowid (icPostingRowId), 
                                              input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                                              output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                              
                assign vcMessage           = trim(subst(#T-229'The GL account &1 has been defined with fixed intercompany analysis.':150(165)T-229#, t_sPostingLine.tcGLCode))
                       viLocalReturnStatus = -1.
                <M-209 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  'tPostingLine.tcIntercoBusinessRelationCode':U (icFieldName), 
                    input  t_sPostingLine.tcIntercoBusinessRelationCode (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sPostingLine.tc_Rowid (icRowid), 
                    input  'QadFin-8840':U (icFcMsgNumber), 
                    input  vcMsgExplanation (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BPosting>
            end. /* if tqGLByPostingValidation.tlGLIsFixedInterco and */
    
            /* ============== */
            /* Check Currency */
            /* ============== */
            if tqGLByPostingValidation.tlGLIsLocalCurrency     and
               t_sPostingLine.Currency_ID <> viCompanyLCId     or
               not tqGLByPostingValidation.tlGLIsLocalCurrency and
               tqGLByPostingValidation.tiCurrency_ID <> 0      and
               tqGLByPostingValidation.tiCurrency_ID <> ?      and
               t_sPostingLine.Currency_ID            <> tqGLByPostingValidation.tiCurrency_ID
            then do:
                /* Allow wrong currency for consolidation company (requested by Alban & Ian 3/12/2008) */
                <Q-246 assign vlFcQueryRecordsAvailable = CompanyPropertyByCyConsolid (NoCache)
                   (input t_sPosting.Company_ID, (CompanyId)
                    input true, (IsConsolid)) in BCompanyProperty >
                if vlFcQueryRecordsAvailable = false
                then do:
                    assign vcMsgExplanation = <M-3 GetErrorExplanation
                                                 (input  t_sPosting.tc_Rowid (icPostingRowId), 
                                                  input  t_sPostingLine.tc_Rowid (icPostingLineRowId), 
                                                  output viFcReturnSuper (oiReturnStatus)) in BPosting>.
                              
                    assign vcMessage      = trim(subst(#T-244'You cannot use currency &1 for the GL account &2.':150(168)T-244#, t_sPostingLine.tcCurrencyCode, t_sPostingLine.tcGLCode))
                           vcMsgContext   = string (tqGLByPostingValidation.tlGLIsLocalCurrency) + ' ':U +
                                            string (t_sPostingLine.Currency_ID)   + ' ':U +
                                            string (viCompanyLCId)                + ' ':U +
                                            string (tqGLByPostingValidation.tiCurrency_ID)       + ' ':U +
                                            t_sPostingLine.tcCurrencyCode                            
                           viLocalReturnStatus = -1.
    
                    <M-210 run SetMessage
                       (input  vcMessage (icMessage), 
                        input  '':U (icArguments), 
                        input  'tPostingLine.tcCurrencyCode':U (icFieldName), 
                        input  t_sPostingLine.tcCurrencyCode (icFieldValue), 
                        input  'E':U (icType), 
                        input  3 (iiSeverity), 
                        input  t_sPostingLine.tc_Rowid (icRowid), 
                        input  'QadFin-8841':U (icFcMsgNumber), 
                        input  vcMsgExplanation (icFcExplanation), 
                        input  '':U (icFcIdentification), 
                        input  vcMsgContext (icFcContext), 
                        output viFcReturnSuper (oiReturnStatus)) in BPosting>
                end. /* if vlFcQueryRecordsAvailable = false */
            end. /* if tqGLByPostingValidation.tlGLIsLocalCurrency     and */
        end. /* JournalTypeCode <> YEARCLOSING */
    end. /* if t_sPosting.tc_Status <> "D":U and */
end. /* POSTINGLINEBLOCK */    

/* ================== */
/* Exception handling */
/* ================== */
assign oiReturnStatus = viLocalReturnStatus.