project QadFinancials > class BExchangeRateType > 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/bexchangeratetype.p)

<ANCESTOR-CODE>
/* return if there is error in ancestor code */
if oiReturnStatus < 0    
then return.

for each t_sExchangeRateType where t_sExchangeRateType.tc_Status = "C":U or
                                   t_sExchangeRateType.tc_Status = "N":U:
    /* does not allow fall back for Accounting or VAT type */
    if t_sExchangeRateType.ExchangeRateTypeIsFallBack = true                           and
       t_sExchangeRateType.ExchangeRateTypeCode       = {&EXCHANGERATETYPE-ACCOUNTING}
    then do:
        assign  vcArgument   = {&EXCHANGERATETYPE-ACCOUNTING-TR}
                vcMessage    = trim(substitute(#T-2'Exchange Rate Type &1 does not allow Fall-back.':150(999890738)T-2#,
                                    vcArgument))
                                                
              oiReturnStatus = -1.
        <M-1 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'tExchangeRateType.ExchangeRateTypeIsFallBack':U (icFieldName), 
            input  t_sExchangeRateType.ExchangeRateTypeIsFallBack (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sExchangeRateType.tc_Rowid (icRowid), 
            input  'QadFin-9199':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BExchangeRateType>
    end. /* end of if t_sExchangeRateType.ExchangeRateTypeCode */

    /* the validity days should be bigger than 0 if the Type was defined with Till Date */
    if t_sExchangeRateType.ExchangeRateTypeIsTillDate = true and
      (t_sExchangeRateType.ExchangeRateTypeValidity   < 1   or
       t_sExchangeRateType.ExchangeRateTypeValidity   >  999)
    then do:
        assign vcMessage      = trim(substitute(#T-4'The Default Validity days (&1) should be between 1 and 999 when the exchange rate type (&2) is defined with Use Validity End Date.':150(999890729)T-4#,
                                                string(t_sExchangeRateType.ExchangeRateTypeValidity),
                                                t_sExchangeRateType.ExchangeRateTypeCode))
               oiReturnStatus = -1.
        <M-3 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'tExchangeRateType.ExchangeRateTypeValidity':U (icFieldName), 
            input  t_sExchangeRateType.ExchangeRateTypeValidity (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sExchangeRateType.tc_Rowid (icRowid), 
            input  'QadFin-9200':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BExchangeRateType>
    end. /* end of if t_sExchangeRateType.ExchangeRateTypeIsTillDate = true and */

    /* the validity days should be zero if the Type was not defined with Till Date */
    if t_sExchangeRateType.ExchangeRateTypeIsTillDate = false and
       t_sExchangeRateType.ExchangeRateTypeValidity   <> 0
    then do:
        assign vcMessage      = trim(substitute(#T-6'The Default Validity days (&1) should be zero when the exchange rate type (&2) is defined without Use Validity End Date.':150(999890736)T-6#,
                                     string(t_sExchangeRateType.ExchangeRateTypeValidity), 
                                     t_sExchangeRateType.ExchangeRateTypeCode))
               oiReturnStatus = -1.
        <M-5 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  'tExchangeRateType.ExchangeRateTypeValidity':U (icFieldName), 
            input  t_sExchangeRateType.ExchangeRateTypeValidity (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sExchangeRateType.tc_Rowid (icRowid), 
            input  'QadFin-9201':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BExchangeRateType>
    end. /* end of if t_sExchangeRateType.ExchangeRateTypeIsTillDate = true and */

    /* can not choose both IsFallback and Is till date*/
    if t_sExchangeRateType.ExchangeRateTypeIsTillDate = true and
       t_sExchangeRateType.ExchangeRateTypeIsFallBack = true 
    then do:
        assign vcMessage      = trim(substitute(#T-8'You can not choose both Fallback to Accounting and Use Validity End Date for exchange rate type (&1).':150(999890737)T-8#,
                                     t_sExchangeRateType.ExchangeRateTypeCode))
               oiReturnStatus = -1.
        <M-7 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sExchangeRateType.tc_Rowid (icRowid), 
            input  'QadFin-9202':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BExchangeRateType>
    end. /* end of if t_sExchangeRateType.ExchangeRateTypeIsTillDate = true and */
end. /* end of for each */

for each t_sExchangeRateType where t_sExchangeRateType.tc_Status = "D":U and
                                   t_sExchangeRateType.ExchangeRateTypeIsSystem:
    assign vcMessage      = trim(#T-24'System Owned Exchange Rate Type can be deleted by the user.':150(605105985)T-24#)
           oiReturnStatus = -1.
    <M-14 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  3 (iiSeverity), 
        input  t_sExchangeRateType.tc_Rowid (icRowid), 
        input  'QadFin-651951':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BExchangeRateType>
end. /* end of for each */