project QadFinancials > class BCInvoice > method CreateCInvoiceMovementsRoundDiffCC

Description

Extended method of CreateCInvoiceMovements.
This method will post the CC balance difference when TC is completely balanced.


Parameters


idDiffDebitCCinputdecimal
idDiffCreditCCinputdecimal
icCBusinessRelationInterCodeinputcharacter
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program7/bcinvoice.p)

    /* NOTE: Make sure this method is in the same segment as the calling method */
    
    /* ============================= */
    /* Retrieve the rounding account */
    /* ============================= */            
    <Q-94 run GLByGLSystemType (all) (Read) (Cache)
       (input viCompanyId, (CompanyId)
        input {&GLSYSTEMTYPE-ROUND}, (GLSystemTypeCode)
        input {&GLTYPECODE-SYST}, (GlTypeCode)
        input ?, (GlIsDivisionAccount)
        output dataset tqGLByGLSystemType) in BGL >
    find first tqGLByGLSystemType where
                   tqGLByGLSystemType.tcGLSystemTypeCode = {&GLSYSTEMTYPE-ROUND} and
                   tqGLByGLSystemType.tcGLTypeCode       = {&GLTYPECODE-SYST}
                   no-error.
    if not available tqGLByGLSystemType
    then do:
        <M-4 run SetMessage
           (input  trim(#T-2'The system account for rounding differences has not been defined.':250(16626)T-2#) (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'qadfin-368370':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        
        assign oiReturnStatus = -1.
        return.
    end.
   
    /* ============================== */
    /* Post the CC balance difference */
    /* ============================== */
    assign vdRoundDebitCC  = if idDiffDebitCC  > 0 then idDiffDebitCC else if idDiffCreditCC < 0 then abs(idDiffCreditCC) else 0
           vdRoundCreditCC = if idDiffCreditCC > 0 then idDiffCreditCC else if idDiffDebitCC < 0 then abs(idDiffDebitCC)  else 0.
    <M-25 run AddStandardPosting
       (input  tMovement.tcPostingRowId (icPostingtcRowid), 
        input  tqGLByGLSystemType.tcGLCode (icGLCode), 
        input  ? (icDivisionCode), 
        input  tCInvoice.tcCostCentreCode (icCostCentreCode), 
        input  ? (icCostCentreText), 
        input  tCInvoice.tcProjectCode (icProjectCode), 
        input  ? (icProjectText), 
        input  icCBusinessRelationInterCode (icIntercoBusinessRelationCode), 
        input  vcCompanyCC (icCurrencyCode), 
        input  0 (idDebitTC), 
        input  0 (idDebitLC), 
        input  vdRoundDebitCC (idDebitCC), 
        input  0 (idDebitPC), 
        input  0 (idCreditTC), 
        input  0 (idCreditLC), 
        input  vdRoundCreditCC (idCreditCC), 
        input  0 (idCreditPC), 
        input  0 (idQty), 
        input  ? (icLineText), 
        input  ? (icSafText), 
        input  tDefaultSafsCI (tDefaultSafs), 
        input  {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateType), 
        input  1 (idExchangeRate), 
        input  1 (idExchangeRateScale), 
        input  1 (idPostingLineCCRate), 
        input  1 (idPostingLineCCScale), 
        output viDummy (oiPostingLineId), 
        input  ? (iiSafStructureId), 
        input  ? (icSafStructureCode), 
        input  ? (icAllocationKey), 
        input  false (ilLinkedCrCyDaemonReqExists), 
        output viFcReturnSuper (oiReturnStatus)) in BJournalEntry>
    if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = 0)
    then assign oiReturnStatus = viFcReturnSuper.
    if viFcReturnSuper < 0
    then Return.