project QadFinancials > class BGLCalendar > 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/bglcalendar.p)

/* Validate that start date are not out of sequence with GLCalendar number */
for each t_sGLCalendar where
    t_sGLCalendar.tc_Status = "N":U or t_sGLCalendar.tc_Status = "C":U:
               
    /* Look if there is not CalendarYear with a start date lower and a period number greated */
    find first bGLCalendar where
               bGLCalendar.GLCalendarYear = t_sGLCalendar.GLCalendarYear and
               bGLCalendar.tc_Status <> "D":U and
               bGLCalendar.GLCalendarStart < t_sGLCalendar.GLCalendarStart and
               bGLCalendar.GLCalendarPeriod > t_sGLCalendar.GLCalendarPeriod no-error.

    if available bGLCalendar
    then do:
        assign vcMessage = trim(substitute(#T-1'Start date of GL period &1 is out of sequence with GL period &2.':100(4248)T-1#, string(t_sGLCalendar.GLCalendarPeriod), string(bGLCalendar.GLCalendarPeriod)))
               oiReturnStatus = -1.

        <M-2 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  '-134':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BGLCalendar>
    end.
end.

for each t_sGLCalendar where 
         t_sGLCalendar.tc_Status = "D":U:

    if not can-find(first t_iGLCalendar where
         t_iGLCalendar.Domain_ID = t_sGLCalendar.Domain_ID and
         t_iGLCalendar.GLCalendarYear = t_sGLCalendar.GLCalendarYear and
         t_iGLCalendar.GLCalendarPeriod = t_sGLCalendar.GLCalendarPeriod)
    then next.

    /* Since we maintain the calendars for the current domain,
    *  we can use vcDomainCode.  Otherwise we have to query the Domain
    *  table for the corresponding domain code for each t_sGLCalendar record.
    */
    <Q-3 assign vlFcQueryRecordsAvailable = TransactionByDateType (NoCache)
       (input vcDomainCode, (Domain)
        input '':U, (Entity)
        input '':U, (Type)
        input t_sGLCalendar.GLCalendarStartDate, (StartDate)
        input t_sGLCalendar.GLCalendarEndDate, (EndDate)) in BMfgUnpostedTransDetail >

    if not vlFcQueryRecordsAvailable = false
    then do:
        assign vcMessage = trim(substitute(#T-4'Cannot delete GL period &1. Unposted transactions exist for this period.':100(2335)T-4#, string(t_sGLCalendar.GLCalendarPeriod)))
               oiReturnStatus = -1.

        <M-5 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  '-135':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BGLCalendar>
    end.
end.

<ANCESTOR-CODE>

/* If the domain_id is not correct, following check should not be done */
if oiReturnStatus < 0
then return.
         
/* GL Calendars can not be entered when the domain is not set as setup complete */
for each t_sGLCalendar where
         t_sGLCalendar.tc_Status = 'N':U:
    /* Check DomainPropertyIsSetupCompl flag */
    <Q-10 run DomainPropertyByDomain (all) (Read) (NoCache)
       (input t_sGLCalendar.Domain_ID, (DomainID)
        output dataset tqDomainPropertyByDomain) in BDomainProperty >
    find tqDomainPropertyByDomain where
         tqDomainPropertyByDomain.tiDomain_ID = t_sGLCalendar.Domain_ID
         no-lock no-error.
    if not available tqDomainPropertyByDomain
    then do:
        assign vhFcComponent  = ?
               oiReturnStatus = -25.                                                        
        <M-11 run CreateCorruption
           (input  'DomainProperty':U (icTableName), 
            input  'DomainProperty.Domain_ID':U (icKey), 
            input  trim(#T-5'The record DomainProperty does not exist for this domain.':200(46826)T-5#) (icDescription), 
            input  ? (ilSkipMessage), 
            output viFcReturnSuper (oiReturnStatus)) in BCorrLog>
        return.                            
    end. /* not available tqDomainPropertyByDomain */                                           
    
    if tqDomainPropertyByDomain.tlDomainPropertyIsSetupCompl = false
    then do:
        assign vcMessage      = trim(#T-12'GL periods cannot be created until the domain setup is complete.':200(46827)T-12#)
               oiReturnStatus = -1.
        <M-13 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sGLCalendar.tc_Rowid (icRowid), 
            input  'QadFin-5103':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BGLCalendar>               
    end.
end. /* for each t_sGLCalendar where ... */