project QadFinancials > class BCMask > method ValidateComponentPreCMask

Description

Implement extra validations for the Closing mask


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCMask.ValidateComponentPre


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.

/* ============================================================================================ *
 * Remove empty lines with Daybook or Daybook Group                                             *
 * "Empty" lines have to be removed both from t_s table (comming from UI), but also in t_o      *
 * table (instance data). To avoid confusion between t_o and t_s, there is not used tTable      *
 * ============================================================================================ */
for each t_sCMaskJournal where
         t_sCMaskJournal.tc_ParentRowid = t_sCMask.tc_Rowid and
         t_sCMaskJournal.tc_Status     <> "D":U             and
         (t_sCMaskJournal.tcJournalCode = ? or
          t_sCMaskJournal.tcJournalCode = "":U):
          
    if t_sCMaskJournal.tc_Status = "N":U
    then do:
        find t_oCMaskJournal where
             t_oCMaskJournal.tc_Rowid = t_sCMaskJournal.tc_Rowid
             no-error.
        if available t_oCMaskJournal
        then delete t_oCMaskJournal.
        
        delete t_sCMaskJournal.
    end.          
    else assign t_sCMaskJournal.tc_Status = "D":U.
end.         

for each t_sCMaskJrnlGroup where
         t_sCMaskJrnlGroup.tc_ParentRowid = t_sCMask.tc_Rowid and
         t_sCMaskJrnlGroup.tc_Status     <> "D":U             and
         (t_sCMaskJrnlGroup.tcJournalGroupCode = ? or
          t_sCMaskJrnlGroup.tcJournalGroupCode = "":U):
          
    if t_sCMaskJrnlGroup.tc_Status = "N":U
    then do:
        find t_oCMaskJrnlGroup where
             t_oCMaskJrnlGroup.tc_Rowid = t_sCMaskJrnlGroup.tc_Rowid
             no-error.
        if available t_oCMaskJrnlGroup
        then delete t_oCMaskJrnlGroup.
        
        delete t_sCMaskJrnlGroup.
    end.          
    else assign t_sCMaskJrnlGroup.tc_Status = "D":U.
end.         

/* ============================================================================================ *
 * Calculate closing mask type                                                                  *
 * ============================================================================================ */
assign vlIsCMaskWithJournal      = can-find(first t_sCMaskJournal where
                                                  t_sCMaskJournal.tc_ParentRowid = t_sCMask.tc_Rowid and
                                                  t_sCMaskJournal.tc_Status     <> "D":U)
       vlIsCMaskWithJournalGroup = can-find(first t_sCMaskJrnlGroup where
                                                  t_sCMaskJrnlGroup.tc_ParentRowid = t_sCMask.tc_Rowid and
                                                  t_sCMaskJrnlGroup.tc_Status     <> "D":U).

if vlIsCMaskWithJournal and
   vlIsCMaskWithJournalGroup
then assign vcNewCMaskType = {&CMASKTYPE-COMBINED}.
else if vlIsCMaskWithJournal
then assign vcNewCMaskType = {&CMASKTYPE-JOURNAL}.
else if vlIsCMaskWithJournalGroup
then assign vcNewCMaskType = {&CMASKTYPE-JOURNALGROUP}.
else vcNewCMaskType = {&CMASKTYPE-BLANK}.

if t_sCMask.CMaskType <> vcNewCMaskType
then assign t_sCMask.CMaskType = vcNewCMaskType
            t_sCMask.tc_Status = (if t_sCMask.tc_Status = '':U
                                  then "C":U
                                  else t_sCMask.tc_Status).