project QadFinancials > class BCashReport > method ValidateComponent

Description

Write here all tests on database update (new / modify / delete) that cannot be coded with a validation mask.
The type of update can be found in tc_status (N/C/D).
If you find incorrect data, you must write an entry in tFcMessages (using SetMessage) and set the return status of this method to either +1 or -1.
Return status +1 = data will still be accepted.
Return status -1 = data will not be accepted.
This method is run from SetPublicTables, before transferring the received data into the class temp-tables.


Parameters


oiReturnStatusoutputinteger


Internal usage


unused


program code (program/bcashreport.p)

    
    /* =============================================================================== */
    /* Assign CashReportID on CashReportGLLine to improve the performance on           */
    /* dataload by using the OverridePrimary construction for reading the data from db */ 
    /* =============================================================================== */
    for each t_sCashReport where 
             t_sCashReport.tc_Status <> "D":U ,
        each t_sCashReportGL where 
             t_sCashReportGL.tc_ParentRowid = t_sCashReport.tc_Rowid and 
             t_sCashReportGL.tc_Status <> "D":U ,
        each t_sCashReportGLLine where 
             t_sCashReportGLLine.tc_ParentRowid  = t_sCashReportGL.tc_Rowid and  
             t_sCashReportGLLine.CashReport_ID  <> t_sCashReport.CashReport_ID and 
             (t_sCashReportGLLine.tc_Status = "N":U or 
              t_sCashReportGLLine.tc_Status = "C":U) :
        assign t_sCashReportGLLine.CashReport_ID = t_sCashReport.CashReport_ID.
    end. /* for each t_sCashReport */
    
    
<ANCESTOR-CODE>

    
    if oiReturnStatus = 0
    then oiReturnStatus = -98.
    
    for each t_sCashReport where t_sCashReport.tc_Status <> "D":U:
    
        t_sCashReport.CashReportLastSavedDate = today.
    
        <M-18 run ValActualsDate (input  t_sCashReport.CashReportActualsDate (itActualsDate), 
                                  input  t_sCashReport.TillPeriod_ID (iiPeriodID), 
                                  output viFcReturnSuper (oiReturnStatus)) in BCashReport>
        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and oiReturnStatus = -98)
        then assign oiReturnStatus = viFcReturnSuper.
    
    
        for each t_sCashReportGL where 
                 t_sCashReportGL.tc_ParentRowid            =  t_sCashReport.tc_Rowid              and
                 t_sCashReportGL.tc_Status                <> "D":U                                and
                 t_sCashReportGL.CashReportGLCurrencyView  = t_sCashReport.CashReportCurrencyView and
                 t_sCashReportGL.Currency_ID               =  t_sCashReport.Currency_ID:
    
            assign t_sCashReportGL.CashReportGLIsAccount = t_sCashReportGL.tcAccount = {&CASHREPORTACCOUNT-ACC}
                   t_sCashReportGL.CashReportGLIsCumul   = t_sCashReportGL.tcCumul   = {&CASHREPORTCUMUL-CUMUL}.
    
            if (t_sCashReportGL.tcAccount = {&CASHREPORTACCOUNT-ACC} and 
                t_sCashReportGL.tcGLCode  = "":U)
            then do:
                assign vcCashReportMsg = #T-16'A GL account is mandatory when entering an account line.':200(865)t-16#
                       oiReturnStatus = -1.
                <M-11 run SetMessage
              (input  trim(vcCashReportMsg) (icMessage), 
               input  '':U (icArguments), 
               input  '':U (icFieldName), 
               input  '':U (icFieldValue), 
               input  'E':U (icType), 
               input  3 (iiSeverity), 
               input  ? (icRowid), 
               input  'QADFIN-2854':U (icFcMsgNumber), 
               input  '' (icFcExplanation), 
               input  '' (icFcIdentification), 
               input  '' (icFcContext), 
               output viFcReturnSuper (oiReturnStatus)) in BCashReport>
            end.
    
            if (t_sCashReportGL.tcGLCode <> "":U)
            then do: 
                find first btCashReportGL where
                           btCashReportGL.tcGLCode = t_sCashReportGL.tcGLCode and
                           btCashReportGL.tc_Rowid > t_sCashReportGL.tc_Rowid and  /* '>' instead of '<>' to avoid twice the same message */
                           btCashReportGL.CashReportGLCurrencyView  = t_sCashReportGL.CashReportGLCurrencyView and
                           btCashReportGL.Currency_ID               = t_sCashReportGL.Currency_ID
                           no-lock no-error.
                if available(btCashReportGL)
                then do:
                    assign vcCashReportMsg = subst(#T-17'GL account &1 is used more than once in the Cash Flow report.':200(866)t-17#,
                                                   t_sCashReportGL.tcGLCode)
                           oiReturnStatus = -1.
                    <M-12 run SetMessage
              (input  trim(vcCashReportMsg) (icMessage), 
               input  '':U (icArguments), 
               input  '':U (icFieldName), 
               input  '':U (icFieldValue), 
               input  'E':U (icType), 
               input  3 (iiSeverity), 
               input  ? (icRowid), 
               input  'QADFIN-2855':U (icFcMsgNumber), 
               input  '' (icFcExplanation), 
               input  '' (icFcIdentification), 
               input  '' (icFcContext), 
               output viFcReturnSuper (oiReturnStatus)) in BCashReport>
                end.
            end.
            if not t_sCashReportGL.CashReportGLIsAccount then do:
    	 	    if t_sCashReportGL.tlGLIsBalanceAccount
    	 	    then assign t_sCashReportGL.CashReportGLAmountType = {&CASHREPORTGL-AMOUNTTYPE-BALANCE}.
    	 	    else assign t_sCashReportGL.CashReportGLAmountType = {&CASHREPORTGL-AMOUNTTYPE-MOVEMENT}.
    	 	end.
    
        end. /* for each t_sCashReportGL where t_sCashReportGL.tc_Status <> "D":U: */
    end. /* for each t_sCashReport where t_sCashReport.tc_Status <> "D": */
    
    if oiReturnStatus = -98
    then assign oiReturnStatus = 0.