project QadFinancials > class BQCrossCyPosting > method ApiProcessQCrossCyPostingForCI

Description

create a movement record for the given creditor invoice


Parameters


icPostingRowIdinputcharacterPosting Row ID
idDebitTCinputdecimal
idCreditTCinputdecimal
idDebitLCinputdecimal
idCreditLCinputdecimal
idDebitCCinputdecimal
idCreditCCinputdecimal
idTCLCExchangeRateinputdecimal
idTCLCExchangeScaleinputdecimal
idTCCCExchangeRateinputdecimal
idTCCCExchangeScaleinputdecimal
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BQCrossCyPosting.ApiProcessQCrossCyPosting


program code (program6/bqcrosscyposting.p)

/* Note: the tQCrossCyPosting record is available here as this method is running in the same segment as the calling method */
    
    /* ===================================================================== */
    /* Empty temp-table that is used as input to the call in class BCInvoice */
    /* ===================================================================== */
    empty temp-table tQCrossCyCDocInvoiceXrefStage.
    
    /* ======================================= */
    /* start and/or open the cinvoice instance */
    /* ======================================= */
    if viBCInvoiceQCrossCyPostID = 0 or viBCInvoiceQCrossCyPostID = ?
    then do:
        <I-1 {bFcStartAndOpenInstance
            &ADD-TO-TRANSACTION = "true"
            &CLASS              = "BCInvoice"}>
    end.
    else do:
        <I-2 {bFcOpenInstance
            &CLASS           = "BCInvoice"}>
    end.
    
    /* start block */
    BlockTransaction:
    do:
        /* =============================== */
        /* create a movement record for it */
        /* =============================== */
        create tQCrossyCyPostingCIMovement.
        assign tQCrossyCyPostingCIMovement.tiCInvoiceId              = tQCrossCyPosting.CInvoice_ID
               tQCrossyCyPostingCIMovement.tcGLAccountDivisionCode   = "":U
               tQCrossyCyPostingCIMovement.tdAmountDebitTC           = idDebitTC 
               tQCrossyCyPostingCIMovement.tdAmountCreditTC          = idCreditTC
               tQCrossyCyPostingCIMovement.tdAmountDebitLC           = idDebitLC
               tQCrossyCyPostingCIMovement.tdAmountCreditLC          = idCreditLC
               tQCrossyCyPostingCIMovement.tdAmountDebitCC           = idDebitCC
               tQCrossyCyPostingCIMovement.tdAmountCreditCC          = idCreditCC
               tQCrossyCyPostingCIMovement.tdRateTCLC                = idTCLCExchangeRate
               tQCrossyCyPostingCIMovement.tdScaleTCLC               = idTCLCExchangeScale
               tQCrossyCyPostingCIMovement.tdRateTCCC                = idTCCCExchangeRate
               tQCrossyCyPostingCIMovement.tdScaleTCCC               = idTCCCExchangeScale
               tQCrossyCyPostingCIMovement.tcPostingRowId            = icPostingRowId
               tQCrossyCyPostingCIMovement.tdMovementDiscountTC      = 0
               tQCrossyCyPostingCIMovement.tdCInvoiceHoldAmountTC    = ? /* Set to unknown-value to make sure this field in the invoice is not updated */
               tQCrossyCyPostingCIMovement.tlMovementisForDraft      = false
               tQCrossyCyPostingCIMovement.tlIsUndoPayment           = false
               tQCrossyCyPostingCIMovement.tlMovementIsAboutWHT      = if tQCrossCyPosting.QCrossCyPostingIsWHT = true then true else false
               tQCrossyCyPostingCIMovement.ttPaymentDate             = tQCrossCyPosting.QCrossCyPostingPaymentDate.
               
        /* ========================== */
        /* Update also staged records */
        /* ========================== */
        if tQCrossCyPosting.CDocumentInvoiceXref_ID <> ?  and
           tQCrossCyPosting.CDocumentInvoiceXref_ID <> 0 
        then do:
            <Q-22 run CDocInvoiceXrefStageById (all) (Read) (NoCache)
               (input tQCrossCyPosting.CDocumentInvoiceXref_ID, (CDocumentInvoiceXrefID)
                input ?, (CDocInvoiceXrefStageId)
                output dataset tqCDocInvoiceXrefStageById) in BCDocument>
            for each tqCDocInvoiceXrefStageById:
                create tQCrossCyCDocInvoiceXrefStage.
                assign tQCrossCyCDocInvoiceXrefStage.CDocInvoiceXrefStage_ID    = tqCDocInvoiceXrefStageById.tiCDocInvoiceXrefStage_ID
                       tQCrossCyCDocInvoiceXrefStage.CDocInvoiceXrefStageAlloTC = tqCDocInvoiceXrefStageById.tdCDocInvoiceXrefStageAlloTC
                       tQCrossCyCDocInvoiceXrefStage.CDocInvoiceXrefStageDiscTC = tqCDocInvoiceXrefStageById.tdCDocInvoiceXrefStageDiscTC
                       tQCrossCyCDocInvoiceXrefStage.CDocumentInvoiceXref_ID    = tqCDocInvoiceXrefStageById.tiCDocumentInvoiceXref_ID
                       tQCrossCyCDocInvoiceXrefStage.CInvoiceStage_ID           = tqCDocInvoiceXrefStageById.tiCInvoiceStage_ID
                       tQCrossCyCDocInvoiceXrefStage.tiCInvoice_ID              = tQCrossyCyPostingCIMovement.tiCInvoiceId 
                       tQCrossCyCDocInvoiceXrefStage.tc_Status                  = "N":U
                       tQCrossCyCDocInvoiceXrefStage.tc_Rowid                   = string(tqCDocInvoiceXrefStageById.tiCDocInvoiceXrefStage_ID).
            end.
        end.
        <I-70 {bFcOpenInstance
             &CLASS           = "Session"}>
        if index(tQCrossCyPosting.QCrossCyPostingInfo, '#SIPAYSELUC#':U) <> 0
        then do:
            <M-23 run SetLogicalValue
                (input  'PaySelUnconfirm':U (icName), 
                 input  true (ilValue), 
                 output viFcReturnSuper (oiReturnStatus)) in Session>
            <M-89 run SetLogicalValue
                (input  'DaemonLogicByPass':U (icName), 
                 input  false (ilValue), 
                 output viFcReturnSuper (oiReturnStatus)) in Session>
            assign tQCrossyCyPostingCIMovement.tlIsUndoPayment = true.
        end. /* if index(tQCrossCyPosting.QCrossCyPostingInfo, '#SIPAYSELUC#':U) <> 0 */
        else do:
            <M-74 run SetLogicalValue
                (input  'PaySelUnconfirm':U (icName), 
                 input  false (ilValue), 
                 output viFcReturnSuper (oiReturnStatus)) in Session>
            <M-49 run SetLogicalValue
              (input  'DaemonLogicByPass':U (icName), 
               input  true (ilValue), 
               output viFcReturnSuper (oiReturnStatus)) in Session>
        end. /* Not if index(tQCrossCyPosting.QCrossCyPostingInfo, '#SIPAYSELUC#':U) <> 0 */

        if index(tQCrossCyPosting.QCrossCyPostingInfo, '#SIBOUNCED#':U) <> 0
        then do:
            assign tQCrossyCyPostingCIMovement.tlIsUndoPayment = true.
        end. /* if index(tQCrossCyPosting.QCrossCyPostingInfo, '#SIBOUNCED#':U) <> 0 */

        if index(tQCrossCyPosting.QCrossCyPostingInfo, '#SIADJ#':U) <> 0
        then do:
            assign tQCrossyCyPostingCIMovement.tlIsDelTaxAtPartialPayment = false.
        end. /* if index(tQCrossCyPosting.QCrossCyPostingInfo, '#SIADJ#':U) <> 0 */

        <I-45 {bFcCloseInstance
             &CLASS           = "Session"}>
       
        /* ===================================================================== */
        /* Call BCI to create the movement record and the associated PostingLine */
        /* ===================================================================== */
        <M-6 run CreateCInvoiceMovements
           (input-output tQCrossyCyPostingCIMovement (tMovement), 
            input  tQCrossCyCDocInvoiceXrefStage (tCInvoiceStageUpdates), 
            input-output viBJournalEntryQCrossCyPostID (biBJournalEntryId), 
            input  no (ilClearData), 
            input  ? (itPaymentTaxPointDate), 
            input  true (ilIsCallFromBankingEntryOrOIAdj), 
            output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
        then assign oiReturnStatus = viFcReturnSuper.
        if viFcReturnSuper < 0 then leave BlockTransaction.
    
        /* ================================== */
        /* Validations and additional updates */
        /* ================================== */
        <M-3 run ValidateBCAndAdditionalUpdates (output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        if viFcReturnSuper < 0
        then do:
            assign vcMsgCrossCy   = trim(substitute(#T-7'Error &1 occurred when validating the supplier invoice.':150(3459)T-7#, string(viFcReturnSuper)))
                   oiReturnStatus = viFcReturnSuper. 
            <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-1108':U (icFcMsgNumber),
                             input  '' (icFcExplanation),
                             input  '' (icFcIdentification),
                             input  '' (icFcContext),
                             output viFcReturnSuper (oiReturnStatus)) in BQCrossCyPosting>
        end.
    end.  /* stop block */

    /* ======================= */
    /* close cinvoice instance */
    /* ======================= */
    <I-5 {bFcCloseInstance
            &CLASS           = "BCInvoice"}>