project QadFinancials > class BBudget > method BudgetVersionRollUpAmounts

Description

This method will calculate the amounts of all nodes that have childs based on the amounts entered on the child-nodes.


Parameters


icBudgetTcRowidinputcharacterBudgetTcRowid
icBudgetVersionTcRowidinputcharacterBudgetVersionTcRowid; Rowid of the source BudgetVersion
tNewBudgetVersionFigureinput-outputtemp-tableinput-output table containing the updated BudgetVerisonFigure records
tNewBudgetVersionGLFiginput-outputtemp-tableinput-output table containing the updated BudgetVerisonGLFig records
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program6/bbudget.p)

/* =========================================================================================== */
    /* Replace unknown values // Check existance of the tBudget record and the tBudgetVersion rec  */
    /* =========================================================================================== */
    if icBudgetVersionTcRowid = ?
    then assign icBudgetVersionTcRowid = "":U.
    if icBudgetTcRowid = "":U or icBudgetTcRowid = ?
    then do :
        assign oiReturnStatus = -3
               vcMessage      = trim(#T-9'You must enter the budget identification (row ID) for the creation of budget topics.':255(535)T-9#).
        <M-1 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'S':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-864':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        Return.
    end. /* if icBudgetTcRowid  = ? or */
    else do :
        find tBudget where 
             tBudget.tc_Rowid   = icBudgetTcRowid and 
             tBudget.tc_Status <> "D":U 
             no-lock no-error.
        if not available tBudget
        then do :
            assign oiReturnStatus = -3
                   vcMessage      = trim(substitute(#T-10'Cannot find the budget based on its row ID (&1).':255(448)t-10#,string(icBudgetTcRowid))).
            <M-2 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'S':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-865':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
            Return.
        end. /* if not available tBudget */
    end. /* not if iiBudgetID = 0 or */
    find tBudgetVersion where 
         tBudgetVersion.tc_Rowid   = icBudgetVersionTcRowid and 
         tBudgetVersion.tc_Status <> "D":U
         no-lock no-error.
    if not available tBudgetVersion
    then do :
        assign oiReturnStatus = -3
               vcMessage      = trim(substitute(#T-11'Cannot find the budget version based on its row ID (&1).':255(536)t-11#,string(icBudgetVersionTcRowid))).
        <M-3 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'S':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-866':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        Return.
    end. /* if not available tBudgetVersion */
    
    /* ================================================================= */
    /* Only 1 of the 2 input 6tables shoudl contain error.               */
    /* Simply return in case none of the tabels contains data (no error) */
    /* ================================================================= */
    if not can-find (first tNewBudgetVersionFigure) and 
       not can-find (first tNewBudgetVersionGLFig)
    then return.
    if can-find (first tNewBudgetVersionFigure) and 
       can-find (first tNewBudgetVersionGLFig)
    then do :
        assign oiReturnStatus = -3
               vcMessage      = trim(#T-12'Internal error: figures of the budget version should be stored in one single table.':255(537)T-12#) + chr(10) + 
                                trim(substitute(#T-13'Budget version row ID: &1.':255(538)T-13#,string(icBudgetVersionTcRowid))).
        <M-5 run SetMessage (input  vcMessage (icMessage),
                     input  '':U (icArguments),
                     input  '':U (icFieldName),
                     input  '':U (icFieldValue),
                     input  'S':U (icType),
                     input  3 (iiSeverity),
                     input  '':U (icRowid),
                     input  'QADFIN-867':U (icFcMsgNumber),
                     input  '' (icFcExplanation),
                     input  '' (icFcIdentification),
                     input  '' (icFcContext),
                     output viFcReturnSuper (oiReturnStatus)) in BBudget>
        Return.
    end. /* if can-find (first tNewBudgetVersionFigure) and  */
    
    /* ======================================================================================== */
    /* Go through all Figures that are located on the bottom-nodes (they have no childs)        */
    /* and add the amount of these nodes to all parent-nodes of the bottom-node.                */
    /* The assignments for both tables are split because otherwise this method became to large. */
    /* ======================================================================================== */
    if can-find (first tNewBudgetVersionFigure) 
    then do :
        <M-7 run BudgetVersionRollUpAmountsFig (input  icBudgetVersionTcRowid (icBudgetVersionTcRowid), 
                                        input-output tNewBudgetVersionFigure (tNewBudgetVersionFigure), 
                                        output viFcReturnSuper (oiReturnStatus)) in BBudget>
        if viFcReturnSuper <> 0 
        then assign oiReturnStatus = viFcReturnSuper.
        if oiReturnStatus < 0                                            
        then Return.
    end. /* if can-find (first tNewBudgetVersionFigure)  */
    if can-find (first tNewBudgetVersionGLFig)
    then do :
        <M-8 run BudgetVersionRollUpAmountsGLFig (input  icBudgetVersionTcRowid (icBudgetVersionTcRowid), 
                                          input-output tNewBudgetVersionGLFig (tNewBudgetVersionGLFig), 
                                          output viFcReturnSuper (oiReturnStatus)) in BBudget>
        if viFcReturnSuper <> 0 
        then assign oiReturnStatus = viFcReturnSuper.
        if oiReturnStatus < 0                                            
        then Return.
    end. /* if can-find (first tNewBudgetVersionGLFig) */