project QadFinancials > class BJournalEntry > method GetPostingAmountAndCurrency

Description

This method will check the inctance table record for a single posting and return the summed amounts of all his posting lines and indicate if a single curreny was used or not


Parameters


iiPostingIDinputintegerPosting ID; mandtaory; identification of the posting
If empty or there is no such posting then all output will be zero and no error will be raised
ocCurrencyCodeoutputcharacterCurrency code of the posting. This parameter is filled in only when all posting lines where a TC-amount is filled have the same currencly. Otherwise it is blank.
odTCLCExchangeRateoutputdecimalTCLCExchangeRate: filled if all postinglines have the same currency and all lines have the same Rate/Scale between TC and LC.
If this is not the case then the output will be zero.
odTCLCExchangeScaleoutputdecimalTCLCExchangeScale: filled if all postinglines have the same currency and all lines have the same Rate/Scale between TC and LC.
If this is not the case then the output will be zero.
odTCCCExchangeRateoutputdecimalTCCCExchangeRate: filled if all postinglines have the same currency and all lines have the same Rate/Scale between TC and CC.
If this is not the case then the output will be zero.
odTCCCExchangeScaleoutputdecimalTCCCExchangeScale: filled if all postinglines have the same currency and all lines have the same Rate/Scale between TC and CC.
If this is not the case then the output will be zero.
odPostingAmountDebitTCoutputdecimalPostingAmountDebitTC
odPostingAmountCreditTCoutputdecimalPosting Amount in CreditTC
odPostingAmountDebitLCoutputdecimalPostingAmountDebitLC
odPostingAmountCreditLCoutputdecimalPosting Amount in CreditLC;
odPostingAmountDebitCCoutputdecimalPostingAmountDebitCC
odPostingAmountCreditCCoutputdecimalPosting Amount in CreditCC
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BOpenItemAdjustment.OIAdjCommitSubCheckPostingBalanceLCCC


program code (program7/bjournalentry.p)

    
    
    /* ========================= */
    /* Exception handling        */
    /* ========================= */
    assign oiReturnStatus = -98
           viLocalReturn  = 0.
           
    /* ========================================================================== */
    /* Default output parameters                                                  */
    /* Set all to unknown as an indication that it has not yet been assigned once */
    /* ========================================================================== */
    assign ocCurrencyCode      = ? 
           odTCCCExchangeRate  = ?
           odTCCCExchangeScale = ?
           odTCLCExchangeRate  = ?
           odTCLCExchangeScale = ?.

    /* ========================= */
    /* Start processing block    */
    /* ========================= */
    PLCALCULATIONBLOCK: do on error undo, leave:
    
        /* =============== */
        /* get the posting */
        /* =============== */
        find first tPosting where
                   tPosting.Posting_ID = iiPostingId
                   no-error.
        if not available tPosting or
           tPosting.tc_Status = "D":U
        then return.
    
        /* ============================================= */
        /* Go through all undeleted lines of the posting */
        /* ============================================= */
        for each tPostingLine where
                 tPostingLine.tc_ParentRowid  = tPosting.tc_Rowid and
                 tPostingLine.tc_Status      <> "D":U :
            
            /* ====================================================================================================== */
            /* Set ocCurrencyCode: it has to be a single currency in case all posting-lines contain the same currency */
            /* If multiple currencies are used then ocCurrency will be set to blank                                   */
            /* Only take posting-lines into account where TC-amoutns are filled                                       */
            /* Same applies for filling the output params on the rate/scale                                           */
            /* ====================================================================================================== */
            if (tPostingLine.PostingLineCreditTC <> 0 and 
                tPostingLine.PostingLineCreditTC <> ?) or 
               (tPostingLine.PostingLineDebitTC  <> 0 and 
                tPostingLine.PostingLineDebitTC  <> ?)
            then do :
                if ocCurrencyCode = ? /* this means this is the first posting-line */
                then assign ocCurrencyCode = tPostingLine.tcCurrencyCode.
                if ocCurrencyCode <> "":U and /* blank means we already detected multiple currencies and we want to keep that indication */ 
                   ocCurrencyCode <> tPostingLine.tcCurrencyCode 
                then assign ocCurrencyCode = "":U.
                if odTCLCExchangeRate  = ? and 
                   odTCLCExchangeScale = ? /* this means this is the first posting-line */
                then assign odTCLCExchangeRate  = (if tPostingLine.PostingLineExchangeRate = ? then 0 else tPostingLine.PostingLineExchangeRate)
                            odTCLCExchangeScale = (if tPostingLine.PostingLineRateScale = ? then 0 else tPostingLine.PostingLineRateScale).
                if odTCLCExchangeRate  <> 0 and /* zero means we already detected multiple rates/scales and we want to keep that indication */ 
                   odTCLCExchangeScale <> 0 and 
                   (odTCLCExchangeRate  <> tPostingLine.PostingLineExchangeRate or
                    odTCLCExchangeScale <> tPostingLine.PostingLineRateScale)
                then assign odTCLCExchangeRate  = 0
                            odTCLCExchangeScale = 0.
                if odTCCCExchangeRate  = ? and 
                   odTCCCExchangeScale = ? /* this means this is the first posting-line */
                then assign odTCCCExchangeRate  = (if tPostingLine.PostingLineCCRate = ? then 0 else tPostingLine.PostingLineCCRate)
                            odTCCCExchangeScale = (if tPostingLine.PostingLineCCScale = ? then 0 else tPostingLine.PostingLineCCScale).
                if odTCCCExchangeRate  <> 0 and /* zero means we already detected multiple rates/scales and we want to keep that indication */ 
                   odTCCCExchangeScale <> 0 and 
                   (odTCCCExchangeRate  <> tPostingLine.PostingLineCCRate or
                    odTCCCExchangeScale <> tPostingLine.PostingLineCCScale)
                then assign odTCCCExchangeRate  = 0
                            odTCCCExchangeScale = 0.
            end. /* if (tPostingLine.PostingLineCreditTC <> 0 and */
                            
            /* ======================== */
            /* Cumulate posting amounts */
            /* ======================== */
            accumulate tPostingLine.PostingLineDebitTC(TOTAL).
            accumulate tPostingLine.PostingLineCreditTC(TOTAL).
            accumulate tPostingLine.PostingLineDebitLC(TOTAL).
            accumulate tPostingLine.PostingLineCreditLC(TOTAL).
            accumulate tPostingLine.PostingLineDebitCC(TOTAL).
            accumulate tPostingLine.PostingLineCreditCC(TOTAL).
            
        end. /* for each tPostingLine where */
      
        /* ============================= */
        /* Output parameters assignment  */
        /* ============================= */
        assign odPostingAmountDebitTC  = accum total tPostingLine.PostingLineDebitTC
               odPostingAmountCreditTC = accum total tPostingLine.PostingLineCreditTC
               odPostingAmountDebitLC  = accum total tPostingLine.PostingLineDebitLC
               odPostingAmountCreditLC = accum total tPostingLine.PostingLineCreditLC
               odPostingAmountDebitCC  = accum total tPostingLine.PostingLineDebitCC
               odPostingAmountCreditCC = accum total tPostingLine.PostingLineCreditCC.
        
    END. /* of PLCALCULATIONBLOCK */
    
    /* ================== */
    /* Exception handling */
    /* ================== */
    assign oiReturnStatus = viLocalReturn.