project QadFinancials > class BCashReport > method RecalculateGLActualAmounts


Parameters


itCashReportActualsDateinputdate
iiCashReportCurrency_IDinputinteger
ilCashReportGLIsAccountinputlogical
icCashReportGLRowidinputcharacter
icCashReportGLCurrencyViewinputcharacter
iiCashReportGLCurrency_IDinputinteger
iiGLByCodeGL_IDinputinteger
iiGLDivisionIDinputinteger
itPeriodEndDateinputdate
iiLastActualsSeqinputinteger
ilGLIsBalanceAccountinputlogical
bdActualsLCinput-outputdecimal
bdActualsTCinput-outputdecimal
bdActualsCCinput-outputdecimal
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCashReport.Recalculate


program code (program4/bcashreport.p)

oiReturnStatus = -98.

<Q-11 run PostingLineByPostingDateGL
   (Start) in BPosting >


if (itCashReportActualsDate <> ? and ilCashReportGLIsAccount = true)
then do:

   <Q-13 run PostingLineByPostingDateGL (all) (Read) (NoCache)
      (input viCompanyId, (CompanyId)
       input itPeriodEndDate + 1, (FromPostingDate)
       input iiGLByCodeGL_ID, (GLID)
       input itCashReportActualsDate, (ToPostingDate)
       input iiGLDivisionID, (DivisionID)
       input ?, (GLCodeStart)
       input ?, (GLCodeEnd)
       input ?, (JournalID)
       input ?, (GLIsBalanceAccount)
       input ?, (LayerCando)
       input ?, (JournalCando)
       input ?, (DivisionCando)
       input ?, (CostCentreCando)
       input ?, (ProjectCando)
       input ?, (Currency)
       input ?, (FromICBusinessRelation)
       input ?, (ToICBusinessRelation)
       input ?, (GLCategory)
       input ?, (ExcludeJournalTypeCode)
       input ?, (CanCCID)
       output dataset tqPostingLineByPostingDateGL) in BPosting>

    for each tqPostingLineByPostingDateGL where
             tqPostingLineByPostingDateGL.ttPostingDate >= itPeriodEndDate + 1                and
             tqPostingLineByPostingDateGL.ttPostingDate <= itCashReportActualsDate            and
             tqPostingLineByPostingDateGL.tiGL_ID       =  iiGLByCodeGL_ID       :
        
        if tCashReportGL.CashReportGLCurrencyView      = {&CURRENCYTYPE-TC} and 
           tqPostingLineByPostingDateGL.tiCurrency_ID <> iiCashReportGLCurrency_ID
        then next.         
        
        assign vdMovementLC = tqPostingLineByPostingDateGL.tdPostingLineDebitLC - 
                            tqPostingLineByPostingDateGL.tdPostingLineCreditLC
               bdActualsLC  = bdActualsLC + vdMovementLC
               vdMovementTC = tqPostingLineByPostingDateGL.tdPostingLineDebitTC - 
                                tqPostingLineByPostingDateGL.tdPostingLineCreditTC
               bdActualsTC  = bdActualsTC + vdMovementTC
               vdMovementCC = tqPostingLineByPostingDateGL.tdPostingLineDebitCC - 
                                tqPostingLineByPostingDateGL.tdPostingLineCreditCC
               bdActualsCC  = bdActualsCC + vdMovementCC.
        
        if tqPostingLineByPostingDateGL.tcGLTypeCode = {&GLTYPECODE-DEBT} or 
           tqPostingLineByPostingDateGL.tcGLTypeCode = {&GLTYPECODE-CRED}
        then next.
                                
        /* Add the amount to the period that contains the PostingDate.                      */
        /* No need to update if the period is not one of the "Actuals Periods" since        */
        /* the data will be overwritten further on anyway.                                  */
        for each tCashReportGLLine where
                 tCashReportGLLine.tc_Status                <> 'D':U                                      and
                 tCashReportGLLine.tc_ParentRowid            = icCashReportGLRowid                        and
                 tCashReportGLLine.CashReportGLLineSeq      <= iiLastActualsSeq                           and
                 tCashReportGLLine.CashReportGLLineDate     >= tqPostingLineByPostingDateGL.ttPostingDate and
                 tCashReportGLLine.CashReportGLLineCurrView =  icCashReportGLCurrencyView
                 by tCashReportGLLine.CashReportGLLineSeq:

            if tCashReportGL.CashReportGLCurrencyView  = {&CURRENCYTYPE-TC} and 
               tCashReportGLLine.Currency_ID          <> iiCashReportGLCurrency_ID
            then next.                         
                  
               
            /* For Balance accounts, the Balance (DB/CR) reflects the effect on the Bank Account        */
            /* For P&L accounts, reverse the balance : Profit(CR) -> positive ; Loss(DB) -> negatieve   */
            if ilGLIsBalanceAccount
            then assign tCashReportGLLine.CashReportGLLineLC = 
                                   tCashReportGLLine.CashReportGLLineLC + vdMovementLC
                         tCashReportGLLine.CashReportGLLineTC = 
                                   tCashReportGLLine.CashReportGLLineTC + vdMovementTC
                         tCashReportGLLine.CashReportGLLineCC = 
                                   tCashReportGLLine.CashReportGLLineCC + vdMovementCC.
            else assign tCashReportGLLine.CashReportGLLineLC = 
                                tCashReportGLLine.CashReportGLLineLC + (vdMovementLC * -1)
                         tCashReportGLLine.CashReportGLLineTC = 
                                    tCashReportGLLine.CashReportGLLineTC + (vdMovementTC * -1)
                         tCashReportGLLine.CashReportGLLineCC = 
                                    tCashReportGLLine.CashReportGLLineCC + (vdMovementCC * -1).
            
             leave.
        end. /*  for each tCashReportGLLine where */

   end. /* for each tqPostingLineByPostingDateGL where */

end. /* if (tCashReport.CashReportActualsDate <> ?) */

<Q-12 run PostingLineByPostingDateGL
   (Stop) in BPosting >

if oiReturnStatus = -98
then oiReturnStatus = 0.