project QadFinancials > class BCInvoice > method CreateCInvoiceMovementsRoundDiff

Description

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


Parameters


idDiffDebitinputdecimal
idDiffCreditinputdecimal
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-97 run GLByGLSystemType (all) (Read) (NoCache)
       (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-78 run SetMessage
           (input  trim(#T-49'The system account for rounding differences has not been defined.':255(733756123)T-49#) (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'qadfin-462689':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BCInvoice>            
        assign oiReturnStatus = -1.
        return.
    end.
       
    /* ============================== */
    /* Post the LC balance difference */
    /* ============================== */
    assign vdRoundDebitLC  = if idDiffDebit  > 0 then idDiffDebit else if idDiffCredit < 0 then abs(idDiffCredit) else 0
           vdRoundCreditLC = if idDiffCredit > 0 then idDiffCredit else if idDiffDebit < 0 then abs(idDiffDebit)  else 0.
    <M-10 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  vcCompanyLC (icCurrencyCode), 
        input  0 (idDebitTC), 
        input  vdRoundDebitLC (idDebitLC), 
        input  0 (idDebitCC), 
        input  0 (idDebitPC), 
        input  0 (idCreditTC), 
        input  vdRoundCreditLC (idCreditLC), 
        input  0 (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.