project QadFinancials > class BCMask > method ValidateComponentPostCMask

Description

Implement extra validations for the Closing mask


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCMask.ValidateComponentPost


program code (program1/bcmask.p)

/* ============================================================================================ *
 * Perform validation for CMask record                                                          *
 * ============================================================================================ */

/* Precondition */
if not available t_sCMask
then do:
    assign vcMessage = #T-86'There is missing t_sCMask record.':255(767034268)T-86#.
    <M-22 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-631480':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCMask>
    assign oiReturnStatus = -1.
    return.
end.

/* Get original CMask record */
if t_sCMask.tc_Status <> "N":U
then do:
    find t_iCMask where
         t_iCMask.tc_Rowid = t_sCMask.tc_Rowid
         no-error.
    if not available t_iCMask
    then do:
        assign vcMessage = #T-21'There is missing t_iCMask record.':255(501224094)T-21#.
        <M-41 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-753802':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BCMask>
        assign oiReturnStatus = -1.
        return.
    end.
end. /* if t_sCMask.tc_Status <> "N":U */
                       

/* ============================================================================================ *
 * Closing mask has to have defined at least one Daybook or Daybook group                       *
 * ============================================================================================ */
if t_sCMask.CMaskIsActive = true                                                  and
   t_sCMask.tc_Status <> 'D':U                                                    and
   not can-find(first t_sCMaskJournal where
                      t_sCMaskJournal.tc_ParentRowid   = t_sCMask.tc_Rowid and
                      t_sCMaskJournal.tc_Status       <> 'D':U)                   and
   not can-find(first t_sCMaskJrnlGroup where
                      t_sCMaskJrnlGroup.tc_ParentRowid = t_sCMask.tc_Rowid and
                      t_sCMaskJrnlGroup.tc_Status     <> 'D':U)
then do:
    assign vcMessage = #T-51'You must select at least one daybook group or daybook.':255(537621684)T-51#.
    <M-59 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  'tCMask.CMaskCode':U (icFieldName), 
        input  t_sCMask.CMaskCode (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  t_sCMask.tc_Rowid (icRowid), 
        input  'qadfin-89481':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BCMask>
    assign oiReturnStatus = -1.
end.                      


/* ============================================================================================ *
 * Validate Daybooks of the closing Mask                                                        *
 * ============================================================================================ */
for each t_sCMaskJournal where
         t_sCMaskJournal.tc_ParentRowid = t_sCMask.tc_Rowid and
         t_sCMaskJournal.tc_Status     <> "D":U:
          
    /* Validate CMaskJournal when is changed or when Active status of Mask was changed to True */
    if t_sCMask.CMaskIsActive = false
    then next.
    
    if t_sCMask.tc_Status = "N":U                                    or
       t_sCMask.tc_Status = "C":U and t_iCMask.CMaskIsActive = false or
       t_sCMaskJournal.tc_Status <> "":U
    then do:
        <M-71 run ValidateComponentPostCMaskJournal  (output viFcReturnSuper (oiReturnStatus)) in BCMask>
        if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.        
    end.
end. /* for each t_sCMaskJournal where */


/* ============================================================================================ *
 * Validate Daybook Groups of the closing Mask                                                  *
 * ============================================================================================ */
for each t_sCMaskJrnlGroup where
         t_sCMaskJrnlGroup.tc_ParentRowid = t_sCMask.tc_Rowid and
         t_sCMaskJrnlGroup.tc_Status     <> "D":U:
          
    /* Validate CMaskJournal when is changed or when Active status of Mask was changed to True */
    if t_sCMask.CMaskIsActive = false
    then next.
    
    if t_sCMask.tc_Status = "N":U                                    or
       t_sCMask.tc_Status = "C":U and t_iCMask.CMaskIsActive = false or
       t_sCMaskJrnlGroup.tc_Status <> "":U
    then do:
        <M-54 run ValidateComponentPostCMaskJournalGroup  (output viFcReturnSuper (oiReturnStatus)) in BCMask>
        if viFcReturnSuper < 0 or viFcReturnSuper > 0 and oiReturnStatus = 0 then assign oiReturnStatus = viFcReturnSuper.        
    end.
end. /* for each t_sCMaskJournal where */