project QadFinancials > class BSystemProperty > 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/bsystemproperty.p)

<ANCESTOR-CODE>

/* =============================================== */
/* Go through all records                          */
/* =============================================== */
for each t_sSysProperty no-lock :

    /* ================================================================================================= */    
    /* Backwards compatibility issue: SysPropertyIsSpecCIApprVal has been added as a mandatory boolean   */
    /* but we can still have callers that do not pass any value for this field. This gets solved by      */
    /* making sure that in case the value is unknown, we set it here to its default                      */ 
    /* ================================================================================================= */    
    if t_sSysProperty.SysPropertyIsSpecCIApprVal = ? and 
       (t_sSysProperty.tc_Status = "N":U or 
        t_sSysProperty.tc_Status = "C":U)
    then assign t_sSysProperty.SysPropertyIsSpecCIApprVal = false.
    
    /* =============================================== */
    /* Give warning in case the record will be deleted */
    /* =============================================== */
    if t_sSysProperty.tc_Status = "D":U
    then do :
        assign vcMessage = trim(#T-10'Are you sure you want to remove the global QAD system properties?':255(3776)T-10#) + chr(10) + 
                           trim(#T-11'Warning. This action may corrupt the whole Financials application.':255(3777)t-11#).
        <M-1 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'W':U (icType), 
            input  4 (iiSeverity), 
            input  t_sSysProperty.tc_Rowid (icRowid), 
            input  'QADFIN-29':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BSystemProperty>
        if oiReturnStatus >= 0
        then assign oiReturnStatus = 1.
    end. /* if t_sSysProperty.tc_Status = "D":U */
    
    /* =============================================== */
    /* Make sure there is only 1 record in the db      */
    /* =============================================== */
    if t_sSysProperty.tc_Status = "N":U 
    then do :
        <Q-3 assign vlFcQueryRecordsAvailable = SystemPropertyByAll (NoCache)  () in BSystemProperty >
        if vlFcQueryRecordsAvailable <> false
        then do :
            assign vcMessage      = trim(#T-12'Only one record with the system settings is allowed in Financials.':255(3778)T-12#)
                   oiReturnStatus = -1.
            <M-4 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  '':U (icFieldName), 
                input  '':U (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sSysProperty.tc_Rowid (icRowid), 
                input  'QADFIN-30':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BSystemProperty>
            leave.
        end. /* if vlFcQueryRecordsAvailable <> false */
    end. /* if t_sSysProperty.tc_Status = "N":U */
        
    /* ================================================================ */
    /* Consolidation Currency can not be changed, once a posting exists */
    /* ================================================================ */
    if t_sSysProperty.tc_Status = 'C':U and
       available t_iSysProperty       and
       t_sSysProperty.Currency_ID <> t_iSysProperty.Currency_ID
    then do:        
        <Q-21 assign vlFcQueryRecordsAvailable = PostingPrim (NoCache)
           (input 0, (CompanyId)
            input '':U, (JournalCode)
            input 0, (PeriodYear)
            input 0, (PostingVoucher)
            input 0, (PostingID)) in BPosting >
        if vlFcQueryRecordsAvailable <> false
        then do:
            assign vcMessage      = trim(#T-22'The Statutory currency cannot be changed once transactions are created.':200(48099)t-22#) + chr(10) +
                                    trim(substitute(#T-23'The original currency code was &1.':100(48100)t-23#, trim(t_iSysProperty.tcCurrencyCode) ))
                   oiReturnStatus = -1.
            <M-24 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tSysProperty.tcCurrencyCode':U (icFieldName), 
                input  t_sSysProperty.tcCurrencyCode (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sSysProperty.tc_Rowid (icRowid), 
                input  'QadFin-5147':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BSystemProperty>                                                              
        end. /* if vlFcQueryRecordsAvailable <> false */                                                     
    end. /* if t_sSysProperty = 'C':U ... */
    
    /* ============================================================================================ */
    /* Make sure the directory / location of the OpenSSL is really a valid directory on the server  */
    /* This is not needed on UNIX as OpenSSL is just part of UNIX and can be called from anywhere   */
    /* ============================================================================================ */
    if t_sSysProperty.SysPropertyInvCertOpenSSLDir <> "":U     and
       OPSYS                                     <> "UNIX:U" and 
       (t_sSysProperty.tc_Status = "N" or
        (t_sSysProperty.tc_Status = "C" and
         can-find (first t_iSysProperty where 
                         t_iSysProperty.SysPropertyInvCertOpenSSLDir <> t_sSysProperty.SysPropertyInvCertOpenSSLDir)))
    then do :
        /* Get the file-info of the OpenSSLDir */
        assign file-info:file-name = t_sSysProperty.SysPropertyInvCertOpenSSLDir.
               vcFileType          = file-info:file-type.
        if vcFileType = ? 
        then assign vcFileType = "":U.
        /* Check if it really is a directory */
        if index(vcFileType, "D":U) = 0
        then do:
            assign vcMessage      = trim(substitute(#T-82'The OpenSSL-directory you entered does not exist on the server (&1). Please enter a valid directory.':255(257658920)T-82#,t_sSysProperty.SysPropertyInvCertOpenSSLDir))
                   oiReturnStatus = -1.
            <M-88 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tSysProperty.SysPropertyInvCertOpenSSLDir':U (icFieldName), 
                input  t_sSysProperty.SysPropertyInvCertOpenSSLDir (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sSysProperty.tc_Rowid (icRowid), 
                input  'qadfin-851120':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BSystemProperty>
        end. /* if index(vcFileType, "D":U) = 0 */
        else 
            /* Check if you can read in the directory */
            if index(vcFileType, "R":U) = 0
            then do:
                assign vcMessage      = trim(substitute(#T-53'The OpenSSL-directory you entered does not support reading (&1). Please enter a valid directory.':255(196036239)T-53#,t_sSysProperty.SysPropertyInvCertOpenSSLDir))
                       oiReturnStatus = -1.
                <M-25 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  'tSysProperty.SysPropertyInvCertOpenSSLDir':U (icFieldName), 
                    input  t_sSysProperty.SysPropertyInvCertOpenSSLDir (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sSysProperty.tc_Rowid (icRowid), 
                    input  'qadfin-267301':U (icFcMsgNumber), 
                    input  '':U (icFcExplanation), 
                    input  '':U (icFcIdentification), 
                    input  '':U (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BSystemProperty>
            end. /* if index(vcFileType, "R":U) = 0 */
    end. /* if t_sSysProperty.SysPropertyInvCertOpenSSLDir <> "":U and */
    
    /* ============================================================================================ */
    /* Make sure the Invoice-certification-version is an integer (when filled)                      */
    /* This field is in fact a character but needs to be an integer so we just add a valition on it */
    /* ============================================================================================ */
    if t_sSysProperty.SysPropertyInvCertVersion <> "":U     and
       t_sSysProperty.SysPropertyInvCertVersion <> ?        and
       (t_sSysProperty.tc_Status = "N" or
        (t_sSysProperty.tc_Status = "C" and
         can-find (first t_iSysProperty where 
                         t_iSysProperty.SysPropertyInvCertVersion <> t_sSysProperty.SysPropertyInvCertVersion)))
    then do :
        assign viIntegerTest = integer(t_sSysProperty.SysPropertyInvCertVersion) no-error.
        if error-status:error
        then do :
            assign vcMessage      = trim(substitute(#T-48'The version (&1) of the invoice-certification should be an integer.':255(781765325)T-48#,t_sSysProperty.SysPropertyInvCertVersion))
                   oiReturnStatus = -1.
            <M-6 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tSysProperty.SysPropertyInvCertVersion':U (icFieldName), 
                input  t_sSysProperty.SysPropertyInvCertVersion (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sSysProperty.tc_Rowid (icRowid), 
                input  'qadfin-548515':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BSystemProperty>
        end. /* if index(vcFileType, "D":U) = 0 */
    end. /* if t_sSysProperty.SysPropertyInvCertVersion <> "":U     and */
    /* ============================================================================================ */
    /* Bank File Batch Size Cannot be greater than 200.                                             */
    /* And also cannot be less than zero.                                                           */
    /* ============================================================================================ */    
    if t_sSysProperty.SysPropertyBankFileBatchSize < 0 or t_sSysProperty.SysPropertyBankFileBatchSize > 200 then
    do:
        assign vcMessage = trim(#T-17'The bank file batch size must be between 0 and 200.':255(50902383)T-17#)
               oiReturnStatus = -1.
        <M-73 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tSysProperty.SysPropertyBankFileBatchSize':U (icFieldName), 
                input  t_sSysProperty.SysPropertyBankFileBatchSize (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sSysProperty.tc_Rowid (icRowid), 
                input  'qadfin-816879':U (icFcMsgNumber), 
                input  '':U (icFcExplanation), 
                input  '':U (icFcIdentification), 
                input  '':U (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BSystemProperty>
    end.
    /* ============================================================================================ */
    /* Maximum Batch Size Cannot be negative or zero.                                               */
    /* ============================================================================================ */    
    if t_sSysProperty.SysPropertyPaySelMaxBatchSize < 0 or t_sSysProperty.SysPropertyPaySelMaxBatchSize > 2000
    then do:
        assign vcMessage = trim(#T-84'Maximum batch size for confirm should be in the range 1-2000.':255(405218543)T-84#)
               oiReturnStatus = -1.
        <M-57 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'tSysProperty.SysPropertyPaySelMaxBatchSize':U (icFieldName), 
            input  t_sSysProperty.SysPropertyPaySelMaxBatchSize (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sSysProperty.tc_Rowid (icRowid), 
            input  'qadfin-445548':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BSystemProperty>
    end.
    /* ============================================================================================ */
    /* Minumum Batch Size Cannot be negative.                                                       */
    /* ============================================================================================ */    
    /*
    if t_sSysProperty.SysPropertyPaySelMinBatchSize < 0 
    then do:
        assign vcMessage = trim(#T-16'Minimum batch size cannot be negative.':255(627584981)T-16#)
               oiReturnStatus = -1.
        <M-34 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'tSysProperty.SysPropertyPaySelMinBatchSize':U (icFieldName), 
            input  t_sSysProperty.SysPropertyPaySelMinBatchSize (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sSysProperty.tc_Rowid (icRowid), 
            input  'qadfin-213636':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BSystemProperty>  
    end.
    */

    /* ============================================================================================ */
    /* Maximum Batch Size cannot be less than Minumum Batch Size.                                   */
    /* ============================================================================================ */    
    /*
    if t_sSysProperty.SysPropertyPaySelMaxBatchSize < t_sSysProperty.SysPropertyPaySelMinBatchSize 
    then do:
        assign vcMessage = trim(#T-39'Maximum batch size cannot be less than minimum batch size.':255(986228030)T-39#)
               oiReturnStatus = -1.
        <M-59 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'tSysProperty.SysPropertyPaySelMaxBatchSize':U (icFieldName), 
            input  t_sSysProperty.SysPropertyPaySelMaxBatchSize (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sSysProperty.tc_Rowid (icRowid), 
            input  'qadfin-823718':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BSystemProperty>
    end.
    */
end. /* for each t_sSysProperty */