project QadFinancials > class BCashReport > method ConvertMovementsToBalance


Parameters


icParentRowidinputcharacter
iiNumberOfPeriodsinputinteger
idStartBalanceLCinputdecimal
idStartBalanceTCinputdecimal
idStartBalanceCCinputdecimal
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCashReport.Recalculate
method BCashReport.RecalculateGLTypeCodeCreditorAmounts
method BCashReport.RecalculateGLTypeCodeDebtorAmounts


program code (program4/bcashreport.p)

/********************************************************************************************/  
/* This method converts Movement Amounts of a G/L's CashReportGLLines to Balance Amounts.   */
/* This comes down to adding a period's Movement Amount to all the periods that follow it.  */
/* The starting Balance Amount is also added for every period.                              */
/* Ensure we are working in the same currency view and currency code as tCashReportGL.      */
/********************************************************************************************/  

for each tCashReportGLLine where
         tCashReportGLLine.tc_Status                <> 'D':U                and
         tCashReportGLLine.tc_ParentRowid           =  icParentRowid        and
         tCashReportGLLine.CashReportGLLineSeq      >  1                    and
         tCashReportGLLine.CashReportGLLineSeq      <= iiNumberOfPeriods   
         by tCashReportGLLine.CashReportGLLineSeq:
    
    find btCashReportGLLine where
         btCashReportGLLine.tc_Status                <> 'D':U                and
         btCashReportGLLine.tc_ParentRowid           =  icParentRowid        and
         btCashReportGLLine.CashReportGLLineSeq      =  tCashReportGLLine.CashReportGLLineSeq - 1  and
         btCashReportGLLine.CashReportGLLineCurrView =  tCashReportGLLine.CashReportGLLineCurrView and
         btCashReportGLLine.Currency_ID              =  tCashReportGLLine.Currency_ID
         no-lock.


    case tCashReportGLLine.CashReportGLLineCurrView:
        when  {&CURRENCYTYPE-LC} 
        then 
           assign tCashReportGLLine.CashReportGLLineLC = tCashReportGLLine.CashReportGLLineLC 
                                                       + btCashReportGLLine.CashReportGLLineLC.

        when {&CURRENCYTYPE-TC} 
        then
           assign tCashReportGLLine.CashReportGLLineTC = tCashReportGLLine.CashReportGLLineTC 
                                                       + btCashReportGLLine.CashReportGLLineTC.

        when {&CURRENCYTYPE-CC} 
        then 
           assign tCashReportGLLine.CashReportGLLineCC = tCashReportGLLine.CashReportGLLineCC 
                                                       + btCashReportGLLine.CashReportGLLineCC.
    end.

    if (tCashReportGLLine.CashReportGLLineSeq = iiNumberOfPeriods)
    then do:
       
       case tCashReportGLLine.CashReportGLLineCurrView:
           when {&CURRENCYTYPE-LC} 
           then
              assign tCashReportGLLine.CashReportGLLineLC = tCashReportGLLine.CashReportGLLineLC 
                                                          + idStartBalanceLC.
           when {&CURRENCYTYPE-TC} 
           then
              assign tCashReportGLLine.CashReportGLLineTC = tCashReportGLLine.CashReportGLLineTC 
                                                          + idStartBalanceTC.

           when {&CURRENCYTYPE-CC} 
           then 
              assign tCashReportGLLine.CashReportGLLineCC = tCashReportGLLine.CashReportGLLineCC 
                                                          + idStartBalanceCC.
       end.

    end.

    case tCashReportGLLine.CashReportGLLineCurrView:
        when {&CURRENCYTYPE-LC} 
        then    
           assign btCashReportGLLine.CashReportGLLineLC = btCashReportGLLine.CashReportGLLineLC 
                                                        + idStartBalanceLC.

        when {&CURRENCYTYPE-TC} 
        then
           assign btCashReportGLLine.CashReportGLLineTC = btCashReportGLLine.CashReportGLLineTC 
                                                        + idStartBalanceTC.
    
        when {&CURRENCYTYPE-CC} 
        then 
           assign btCashReportGLLine.CashReportGLLineCC = btCashReportGLLine.CashReportGLLineCC 
                                                        + idStartBalanceCC.
    end.
end.