project QadFinancials > class BQCrossCyPosting > method ApiProcessQCrossCyPostingForAPM

Description

ApiProcessQCrossCyPostingForAPM:
create a posting-line based on the APMatching information in the daemon-request


Parameters


icPostingRowIdinputcharacterPosting Row ID
idDebitTCinputdecimal
idDebitLCinputdecimal
idDebitCCinputdecimal
idCreditTCinputdecimal
idCreditLCinputdecimal
idCreditCCinputdecimal
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BQCrossCyPosting.ApiProcessQCrossCyPosting


program code (program6/bqcrosscyposting.p)

/* Note: the tQCrossCyPosting record and the tqCurrencyPrim record are available here as this method is running in the same segment as the calling method */
    
    /* ================================================================================================== */
    /* Find the GLCode, DivisionCode, ProjectCode and CostCentreCode based on the corresponding ID-fields */
    /* ================================================================================================== */
    if tQCrossCyPosting.APMatchingGL_ID <> ? and 
       tQCrossCyPosting.APMatchingGL_ID <> 0 
    then do :
        <Q-3 run GLPrim (all) (Read) (NoCache)
            (input ?, (CompanyId)
             input ?, (GLCode)
             input tQCrossCyPosting.APMatchingGL_ID, (GLId)
             output dataset tqGLPrim) in BGL >
        find tqGLPrim no-lock no-error.
        if not available  tqGLPrim
        then do :
            assign vcMsgCrossCy   = trim(substitute(#T-5'The system was unable to convert the cross-company GL ID (&1) for the receiver matching into the corresponding code.':255(59390)T-5#,tQCrossCyPosting.APMatchingGL_ID))
                   oiReturnStatus = -1.
            <M-4 run SetMessage
               (input  vcMsgCrossCy (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  '':U (icRowid), 
                input  'QadFin-5979':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BQCrossCyPosting>
            Return.
        end. /* if not available  tqGLPrim */
    end. /* if tQCrossCyPosting.APMatchingGL_ID <> ? and  */
    if tQCrossCyPosting.APMatchingDivision_ID <> ? and 
       tQCrossCyPosting.APMatchingDivision_ID <> 0 
    then do :
        <Q-9 run DivisionPrim (all) (Read) (NoCache)
           (input ?, (CompanyId)
            input tQCrossCyPosting.APMatchingDivision_ID, (DivisionID)
            input ?, (DivisionCode)
            output dataset tqDivisionPrim) in BDivision >
        find tqDivisionPrim no-lock no-error.
        if not available  tqDivisionPrim
        then do :
            assign vcMsgCrossCy   = trim(substitute(#T-8'The system was unable to convert the cross-company sub-account ID (&1) for the receiver matching into the corresponding code.':255(59391)T-8#,tQCrossCyPosting.APMatchingDivision_ID))
                   oiReturnStatus = -1.
            <M-7 run SetMessage
               (input  vcMsgCrossCy (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  '':U (icRowid), 
                input  'QadFin-5980':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BQCrossCyPosting>
            Return.
        end. /* if not available  tqDivisionPrim */
    end. /* if tQCrossCyPosting.APMatchingDivision_ID <> ? and  */
    if tQCrossCyPosting.APMatchingProject_ID <> ? and 
       tQCrossCyPosting.APMatchingProject_ID <> 0 
    then do :
        <Q-13 run ProjectPrim (all) (Read) (NoCache)
           (input ?, (CompanyId)
            input tQCrossCyPosting.APMatchingProject_ID, (ProjectID)
            input ?, (ProjectCode)
            output dataset tqProjectPrim) in BProject >
        find tqProjectPrim no-lock no-error.
        if not available  tqProjectPrim
        then do :
            assign vcMsgCrossCy   = trim(substitute(#T-12'Internal error: cannot convert the cross-company Project ID &1 for the receiver matching into the corresponding code.':255(59392)T-12#,tQCrossCyPosting.APMatchingProject_ID))
                   oiReturnStatus = -1.
            <M-11 run SetMessage
               (input  vcMsgCrossCy (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  '':U (icRowid), 
                input  'QadFin-5981':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BQCrossCyPosting>
            Return.
        end. /* if not available  tqProjectPrim */
    end. /* if tQCrossCyPosting.APMatchingProject_ID <> ? and  */
    if tQCrossCyPosting.APMatchingCostCentre_ID <> ? and 
       tQCrossCyPosting.APMatchingCostCentre_ID <> 0 
    then do :
        <Q-20 run CostCentrePrim (all) (Read) (NoCache)
           (input ?, (CompanyId)
            input tQCrossCyPosting.APMatchingCostCentre_ID, (CostCentreID)
            input ?, (CostCentreCode)
            output dataset tqCostCentrePrim) in BCostCentre >
        find tqCostCentrePrim no-lock no-error.
        if not available tqCostCentrePrim
        then do :
            assign vcMsgCrossCy   = trim(substitute(#T-19'Internal error: cannot convert the cross-company with the Cost Center ID &1 for the receiver matching into the corresponding code.':255(59394)T-19#,tQCrossCyPosting.APMatchingProject_ID))
                   oiReturnStatus = -1.
            <M-18 run SetMessage
               (input  vcMsgCrossCy (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  '':U (icRowid), 
                input  'QadFin-5991':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BQCrossCyPosting>
            Return.
        end. /* if not available  tqCostCentrePrim */
    end. /* if tQCrossCyPosting.APMatchingCostCentre_ID <> ? and  */
    
    /* ========================================================================= */
    /* Create the PostingLine that will compensate the posting-line on the IC-GL */
    /* ========================================================================= */
    <M-21 run AddStandardPosting
       (input  icPostingRowId (icPostingtcRowid), 
        input  (if available tqGLPrim then tqGLPrim.tcGLCode else '':U) (icGLCode), 
        input  (if available tqDivisionPrim then tqDivisionPrim.tcDivisionCode else '':U) (icDivisionCode), 
        input  (if available tqCostCentrePrim then tqCostCentrePrim.tcCostCentreCode else '':U) (icCostCentreCode), 
        input  ? (icCostCentreText), 
        input  (if available tqProjectPrim then tqProjectPrim.tcProjectCode else '':U) (icProjectCode), 
        input  ? (icProjectText), 
        input  '':U (icIntercoBusinessRelationCode), 
        input  tqCurrencyPrim.tcCurrencyCode (icCurrencyCode), 
        input  if tQCrossCyPosting.CrossCompanyGLIsCredit = true  then tQCrossCyPosting.QCrossCyPostingAmountTC else 0 (idDebitTC), 
        input  idDebitLC (idDebitLC), 
        input  idDebitCC (idDebitCC), 
        input  ? (idDebitPC), 
        input  if tQCrossCyPosting.CrossCompanyGLIsCredit = false  then tQCrossCyPosting.QCrossCyPostingAmountTC else 0 (idCreditTC), 
        input  idCreditLC (idCreditLC), 
        input  idCreditCC (idCreditCC), 
        input  ? (idCreditPC), 
        input  tQCrossCyPosting.QCrossCyPostingQTY (idQty), 
        input  #T-20'Compensate Receiver Matching':40(59489)T-20# (icLineText), 
        input  '':U (icSafText), 
        input  tQCrossCyDefaultSafs (tDefaultSafs), 
        input  {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateType), 
        input  ? (idExchangeRate), 
        input  ? (idExchangeRateScale), 
        input  ? (idPostingLineCCRate), 
        input  ? (idPostingLineCCScale), 
        output viPostingLineId (oiPostingLineId), 
        input  ? (iiSafStructureId), 
        input  ? (icSafStructureCode), 
        input  ? (icAllocationKey), 
        input  true (ilLinkedCrCyDaemonReqExists), 
        input  ? (itExchangeRateDate), 
        output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
    if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
    then assign oiReturnStatus = viFcReturnSuper.
    if viFcReturnSuper < 0 then Return.
    
    /* I19 requirement for Brazil ================================================================== *
     * When the original posting line in the first company contains filled in legal document number, *
     * then this number has to be also propagated to the counterpart posting                         *
     * ============================================================================================= */
    if vcLegalDocumentNumber <> ?
    then do:
        <M-28 run SetPostingLineLegalDocNumber
           (input  ? (icPostingLineTcRowID), 
            input  viPostingLineId (iiPostingLineID), 
            input  vcLegalDocumentNumber (icLegalDocumentNumber), 
            output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
        then assign oiReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0 then Return.
    end. /* if vcLegalDocumentNumber <> ? */