project QadFinancials > class BVAT > 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/bvat.p)

/* some initial validations - return-status is checked after the ancestor-code to bundle errors */
    <M-1 run ValidateComponentPreAncestor  (output viPreValidateReturnStatus (oiReturnStatus)) in BVAT>
    

<ANCESTOR-CODE>
    
    
    /* check return status and the return-status of ValidateComponentPreValidate after the ancestor-code to bundle errors */
    if oiReturnStatus < 0
    then return.
    if viPreValidateReturnStatus <> 0
    then assign oiReturnStatus = viPreValidateReturnStatus.
    if viPreValidateReturnStatus < 0 
    then return.
    
    /* Check the VatGroups */
    <M-6 run ValidateComponentCheckVatGroups
       (output viFcReturnSuper (oiReturnStatus)) in BVAT>
    if viFcReturnSuper <> 0
    then assign oiReturnStatus = viFcReturnSuper.
    if viFcReturnSuper < 0 
    then return.
    
    /* if input, then only purchase, import and acquisition allowed and the retained flag cannot be on */
    /* if output, then only sales, export and supply allowed  and the absorbed flag cannot be on*/
    /* the list on transaction type is gone,otherwise you have runtime problems on UI */
    assign vcVATTRANSACTIONTYPESIN   = {&VATTRANSACTIONTYPESIN}
           vcVATTRANSACTIONTYPESOUT  = {&VATTRANSACTIONTYPESOUT}
           viVATTRANSACTIONTYPESIN#  = num-entries(vcVATTRANSACTIONTYPESIN,chr(2))
           viVATTRANSACTIONTYPESOUT# = num-entries(vcVATTRANSACTIONTYPESOUT,chr(2)).


    for each t_sVat where
             t_sVat.tc_Status = "N":U or
             t_sVat.tc_Status = "C":U :
        
        if t_sVat.VatInOut      = {&VATINOUT-OUTPUT} and 
           t_sVat.VatIsRetained = true
        then do :
            assign vcMessage      = trim(substitute(#T-8'You cannot select the retained tax flag for an outgoing tax code. Tax code &1':255(65184)t-8#,t_sVat.VatCode))
                   oiReturnStatus = -1.
            <M-7 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tVat.VatIsRetained':U (icFieldName), 
                input  t_sVat.VatIsRetained (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sVat.tc_Rowid (icRowid), 
                input  'QadFin-6656':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BVAT>
            next.
        end. /* if t_sVat.VatInOut      = {&VATINOUT-INPUT} and */
        
        if t_sVat.VatInOut      = {&VATINOUT-INPUT} and 
           t_sVat.VatIsAbsorbed = true
        then do :
            assign vcMessage      = trim(substitute(#T-10'You cannot select the absorbed tax flag for an incoming tax code. Tax code &1':255(65185)t-10#,t_sVat.VatCode))
                   oiReturnStatus = -1.
            <M-11 run SetMessage
               (input  vcMessage (icMessage), 
                input  '':U (icArguments), 
                input  'tVat.VatIsAbsorbed':U (icFieldName), 
                input  t_sVat.VatIsAbsorbed (icFieldValue), 
                input  'E':U (icType), 
                input  3 (iiSeverity), 
                input  t_sVat.tc_Rowid (icRowid), 
                input  'QadFin-6674':U (icFcMsgNumber), 
                input  '' (icFcExplanation), 
                input  '' (icFcIdentification), 
                input  '' (icFcContext), 
                output viFcReturnSuper (oiReturnStatus)) in BVAT>
            next.
        end. /* if t_sVat.VatInOut      = {&VATINOUT-INPUT} and */
        if t_sVat.VatInOut = {&VATINOUT-INPUT}
        then do:
            assign vlFound = false.
            do viCounter = viVATTRANSACTIONTYPESIN# to 2 by -1 :
                 if t_sVat.VatTransactionType = entry(viCounter,vcVATTRANSACTIONTYPESIN,chr(2)) 
                 then do:
                     assign vlFound = true.
                     leave.
                 end.
            end.
            if not vlFound
            then do:
                assign vcMessage      = trim(substitute(#T-4'The transaction type must be &1, &2 or &3.':150(3841)t-4#,{&VATTRANSACTIONTYPE-PURCHASE-TR},{&VATTRANSACTIONTYPE-IMPORT-TR},{&VATTRANSACTIONTYPE-ACQUISITION-TR}))
                       oiReturnStatus = -1.
                <M-2 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  'tVat.VatTransactionType':U (icFieldName), 
                    input  t_sVat.VatTransactionType (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sVat.tc_Rowid (icRowid), 
                    input  'QADFIN-1250':U (icFcMsgNumber), 
                    input  '' (icFcExplanation), 
                    input  '' (icFcIdentification), 
                    input  '' (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BVAT>
                next.
            end.
        end. /* if t_sVat.VatInOut = {&VATINOUT-INPUT} */
        
        if t_sVat.VatInOut = {&VATINOUT-OUTPUT}
        then do:
            assign vlFound = false.
            do viCounter = viVATTRANSACTIONTYPESOUT# to 2 by -1 :
                 if t_sVat.VatTransactionType = entry(viCounter,vcVATTRANSACTIONTYPESOUT,chr(2)) 
                 then do:
                     assign vlFound = true.
                     leave.
                 end.
            end.
            if not vlFound
            then do:
                assign vcMessage      = trim(substitute(#T-5'The transaction type must be &1, &2 or &3.':150(3841)t-5#,{&VATTRANSACTIONTYPE-SALES-TR},{&VATTRANSACTIONTYPE-EXPORT-TR},{&VATTRANSACTIONTYPE-SUPPLY-TR}))
                       oiReturnStatus = -1.
                <M-3 run SetMessage
                   (input  vcMessage (icMessage), 
                    input  '':U (icArguments), 
                    input  'tVat.VatTransactionType':U (icFieldName), 
                    input  t_sVat.VatTransactionType (icFieldValue), 
                    input  'E':U (icType), 
                    input  3 (iiSeverity), 
                    input  t_sVat.tc_Rowid (icRowid), 
                    input  'QADFIN-1251':U (icFcMsgNumber), 
                    input  '' (icFcExplanation), 
                    input  '' (icFcIdentification), 
                    input  '' (icFcContext), 
                    output viFcReturnSuper (oiReturnStatus)) in BVAT>
                next.
            end.
        end. /* if t_sVat.VatInOut = {&VATINOUT-OUTPUT} */
        
    end. /* for each t_sVat where */
    
    
    if oiReturnStatus < 0 then return.