project QadFinancials > class BDebtor > method ValFederalTax

validation procedure

Description

This method validates Federal Tax IDs. This validation includes:
Validating that the head office address exists.
Validates that the federal tax ID is correct.

This method does not include specific validation for EU countries.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BDebtor.PostValidateComponent


program code (program1/bdebtor.p)

if oiReturnStatus = 0
then oiReturnStatus = -98.

/* Validate format of the Tax ID */
if t_sDebtor.DebtorIsTaxable          and
   t_sDebtor.BusinessRelation_ID <> ? and
   t_sDebtor.BusinessRelation_ID <> 0
then do:
    /* Start BFormatSet component for validation */
    if viBFormatSetBDebID = ? or 
       viBFormatSetBDebID = 0
    then do:
        <I-53 {bFcStartAndOpenInstance
             &ADD-TO-TRANSACTION   = "no"
             &CLASS                = "BFormatSet"}>
    end.
    else if not valid-handle(vhBFormatSetBDebInst)
    then do:
        <I-80 {bFcOpenInstance
             &CLASS           = "BFormatSet"}>
    end.
    
    <Q-94 run AddressByAddressBusRelType (all) (Read) (Cache)
       (input ?, (AddressTypeId)
        input {&ADDRESSTYPECODESYSTEM-HEADOFFICE}, (AddressTypeCode)
        input t_sDebtor.BusinessRelation_ID, (BusinessRelationId)
        input ?, (BusinessRelationCode)
        input ?, (AddressId)
        output dataset tqAddressByAddressBusRelType) in BBusinessRelation >
    find first tqAddressByAddressBusRelType where
               tqAddressByAddressBusRelType.tiBusinessRelation_ID = t_sDebtor.BusinessRelation_ID and
               tqAddressByAddressBusRelType.tcAddressTypeCode     = {&ADDRESSTYPECODESYSTEM-HEADOFFICE}
               no-error.
               
    if not available tqAddressByAddressBusRelType
    then do:
        assign vcMessage = #T-16'Cannot read Customer head office address definition (Customer = &1).':255(473136780)T-16#
               vcMessage = substitute(vcMessage, t_sDebtor.DebtorCode).
        <M-89 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  t_sDebtor.tc_Rowid (icRowid), 
            input  'qadfin-689938':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BDebtor>
        assign oiReturnStatus = -1.
    end.
    else do:
        /* Federal tax validations - validation executed even it is blank */
        <M-83 run ValidateFormat
           (input  {&FORMATSETTYPE-TAXID} (icFormatType), 
            input  t_sDebtor.DebtorTaxIDFederal (icValueToValidate), 
            input  'Debtor':U (icTableName), 
            input  'DebtorTaxIDFederal':U (icFieldName), 
            input  tqAddressByAddressBusRelType.tcCountryCode (icCountryCode), 
            input  tqAddressByAddressBusRelType.tcStateCode (icStateCode), 
            input  tqAddressByAddressBusRelType.tcAddressTypeCode (icAddressType), 
            input  'E':U (icErrorType), 
            output viFcReturnSuper (oiReturnStatus)) in BFormatSet>
        if viFcReturnSuper < 0 or 
           viFcReturnSuper > 0 and (oiReturnStatus = 0 or oiReturnStatus = -98)
        then assign oiReturnStatus = viFcReturnSuper.  
    end.
end. /* if t_sDebtor.DebtorIsTaxable */

if oiReturnStatus = -98
then oiReturnStatus = 0.