project QadFinancials > class BRecurringEntry > 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/brecurringentry.p)

/* ========================== */
    /* Run Stop External Instance */
    /* ========================== */
    if vlSkipStopExternalInstances = false
    then do :
        <M-9 run StopExternalInstances
           (output viFcReturnSuper (oiReturnStatus)) in BRecurringEntry>
    end. /* if vlSkipStopExternalInstances = false */
    
    /* ====================================== */
    /* Go through all non-deleted rec-entries */
    /* ====================================== */
    for each t_sRecEntry where 
             t_sRecEntry.tc_Status <> "D":U : 
        
        /* ================================================= */
        /* Every header should have at least one detail-line */
        /* ================================================= */
        if not can-find (first t_sRecEntryLine where 
                               t_sRecEntryLine.tc_ParentRowid  = t_sRecEntry.tc_Rowid and 
                               t_sRecEntryLine.tc_Status      <> "D":U)
        then do :
            assign vcMessageRE = trim(substitute(#T-8'A recurring entry (&1) must have at least one detail line.':255(62540)T-8#, t_sRecEntry.RecEntryCode))
                   oiReturnStatus = -1.
            <M-7 run SetMessage
               (input  vcMessageRE (icMessage), 
                input  '':U (icArguments), 
                input  'tRecEntry.RecEntryCode':U (icFieldName), 
                input  t_sRecEntry.RecEntryCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sRecEntry.tc_rowid (icRowid), 
                input  'QadFin-6364':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BRecurringEntry>
        end. /* if not can-find (first t_sRecEntryLine where  */

        if vcActivityCode = "TransientCreate":U                       and
            (t_sRecEntry.tc_Status = "N":U   or 
             (t_sRecEntry.tc_Status = "C":U  and 
              can-find (t_iRecEntry where 
                     t_iRecEntry.tc_Rowid         = t_sRecEntry.tc_Rowid and 
                     t_iRecEntry.tcJournalCode <> t_sRecEntry.tcJournalCode) ))
        then do:
            <Q-12 run JournalPrim (all) (Read) (NoCache)
               (input viCompanyId, (CompanyId)
                input t_sRecEntry.tcJournalCode, (JournalCode)
                input ?, (JournalID)
                output dataset tqJournalPrim) in BJournal >
            find first tqJournalPrim no-error.
            if available tqJournalPrim and
                         tqJournalPrim.tcLayerTypeCode <> {&LAYERTYPECODE-TRANSIENT}
            then do:
                assign oiReturnStatus = -1
                       vcMessageRE    = trim(#T-10'Recurring entries can only be created to transient layers with this function.':200(733738568)T-10#).
                <M-11 run SetMessage
                   (input  vcMessageRE (icMessage), 
                    input  '':U (icArguments), 
                    input  't_sRecEntry.tcJournalCode':U (icFieldName), 
                    input  t_sRecEntry.tcJournalCode (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sRecEntry.tc_rowid (icRowid), 
                    input  'QadFin-9556':U:U (icFcMsgNumber), 
                    input  '' (icFcExplanation), 
                    input  '' (icFcIdentification), 
                    input  '' (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BRecurringEntry>
            end. /* end of if available */
        end. /* end of vcactivitycode */
        
        /* ======================================================================= */
        /* A Recurring Entry Line can not be deleted  if the status is not waiting */
        /* A Recurring Entry Line can not be modified if the status is not waiting */
        /* ======================================================================= */
        for each t_sRecEntryLine where         
                (t_sRecEntryLine.tc_status           = 'D':U or
                 t_sRecEntryLine.tc_status           = 'C':U    ) and
                 can-find(t_iRecEntryLine where
                          t_iRecEntryLine.tc_Rowid = t_sRecEntryLine.tc_Rowid and
                          t_iRecEntryLine.RecEntryLineStatus <> {&RECENTRYLINESTATUS-WAITING})
                 no-lock:
            assign vcMessageRE = trim(substitute(#T-3'Only open recurring entry lines can be &1.':150(3488)t-3#, if t_sRecEntryLine.tc_status = 'D':U then trim(#T-4'deleted':20(3489)t-4#) else trim(#T-5'modified':20(3490)t-5#)))
                   oiReturnStatus = -1.
            <M-1 run SetMessage
               (input  vcMessageRE (icMessage), 
                input  '':U (icArguments), 
                input  'tRecEntryLine.RecEntryLineStatus':U (icFieldName), 
                input  t_sRecEntryLine.RecEntryLineStatus (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sRecEntryLine.tc_rowid (icRowid), 
                input  'QADFIN-979':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BRecurringEntry>
        end. /* for each t_sRecEntryLine where   */
    end. /* for each t_sRecEntry where  */
    
    /* ======================== */
    /* Return in case of errors */
    /* ======================== */
    if oiReturnStatus < 0
    then return.
    
    

<ANCESTOR-CODE>