project QadFinancials > class BBusinessRelation > method ValidateComponentPostAddressTax

Description

This method validates the tax IDs that have been entered against an address: This method can validate federal, state and misc IDs.


Parameters


oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BBusinessRelation.ValidateComponentPostAddress


program code (program1/bbusinessrelation.p)

/* ====================================================================================== *
 * Method       : ValidateComponentPostAddressTax                                         *
 * Description  : This method validates wheather the entered taxes comply with format     *
 *                definition                                                              *
 * -------------------------------------------------------------------------------------- *
 * Caution:       Method has to be in the same segment as ValidateComponent method        *
 * -------------------------------------------------------------------------------------- *
 * Parameters   :                                                                         *
 * ====================================================================================== */
 
assign oiReturnStatus = -98
       viLocalReturn  = 0.

MAIN_BLOCK:
do on error undo, return:
    /* Pre-validation block */
    if not available t_sAddress
    then do:
        assign vcMessage = #T-2'Internal record is missing.':255(33090436)T-2#.
        <M-62 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-685122':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  'available t_sAddress=false':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BBusinessRelation>
        assign viLocalReturn = -1.
        leave MAIN_BLOCK.
    end.


    /* Validate tax ids */
    if t_sAddress.AddressIsTaxable
    then do:
        /* Start BFormatSet component for validation */
        if viBFormatSetID = ? or 
           viBFormatSetID = 0
        then do:
            <I-17 {bFcStartAndOpenInstance
                 &ADD-TO-TRANSACTION   = "no"
                 &CLASS                = "BFormatSet"}>
        end.
        else if not valid-handle(vhBFormatSetInst)
        then do:
            <I-32 {bFcOpenInstance
                 &CLASS           = "BFormatSet"}>
        end.
        
        /* Federal tax validations - validation executed even it is blank */
        <M-46 run ValidateFormat
           (input  {&FORMATSETTYPE-TAXID} (icFormatType), 
            input  t_sAddress.AddressTaxIDFederal (icValueToValidate), 
            input  'Address':U (icTableName), 
            input  'AddressTaxIDFederal':U (icFieldName), 
            input  t_sAddress.tcCountryCode (icCountryCode), 
            input  t_sAddress.tcStateCode (icStateCode), 
            input  t_sAddress.tcAddressTypeCode (icAddressType), 
            input  'E':U (icErrorType), 
            output viFcReturnSuper (oiReturnStatus)) in BFormatSet>
        if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
        
        /* State tax validations - validation executed even it is blank */
        <M-10 run ValidateFormat
           (input  {&FORMATSETTYPE-TAXID} (icFormatType), 
            input  t_sAddress.AddressTaxIDState (icValueToValidate), 
            input  'Address':U (icTableName), 
            input  'AddressTaxIDState':U (icFieldName), 
            input  t_sAddress.tcCountryCode (icCountryCode), 
            input  t_sAddress.tcStateCode (icStateCode), 
            input  t_sAddress.tcAddressTypeCode (icAddressType), 
            input  'E':U (icErrorType), 
            output viFcReturnSuper (oiReturnStatus)) in BFormatSet>
        if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
        
        /* Miscelenous tax 1 - validation only when not blank */
        if t_sAddress.AddressTaxIDMisc1 <> ? and
           t_sAddress.AddressTaxIDMisc1 <> "":U
        then do:
            <M-26 run ValidateFormat
               (input  {&FORMATSETTYPE-TAXID} (icFormatType), 
                input  t_sAddress.AddressTaxIDMisc1 (icValueToValidate), 
                input  'Address':U (icTableName), 
                input  'AddressTaxIDMisc1':U (icFieldName), 
                input  t_sAddress.tcCountryCode (icCountryCode), 
                input  t_sAddress.tcStateCode (icStateCode), 
                input  t_sAddress.tcAddressTypeCode (icAddressType), 
                input  'E':U (icErrorType), 
                output viFcReturnSuper (oiReturnStatus)) in BFormatSet>
            if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
        end.
           
        /* Miscelenous tax 2 - validation only when not blank */
        if t_sAddress.AddressTaxIDMisc2 <> ? and
           t_sAddress.AddressTaxIDMisc2 <> "":U
        then do:
            <M-45 run ValidateFormat
               (input  {&FORMATSETTYPE-TAXID} (icFormatType), 
                input  t_sAddress.AddressTaxIDMisc2 (icValueToValidate), 
                input  'Address':U (icTableName), 
                input  'AddressTaxIDMisc2':U (icFieldName), 
                input  t_sAddress.tcCountryCode (icCountryCode), 
                input  t_sAddress.tcStateCode (icStateCode), 
                input  t_sAddress.tcAddressTypeCode (icAddressType), 
                input  'E':U (icErrorType), 
                output viFcReturnSuper (oiReturnStatus)) in BFormatSet>
            if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
        end.
        
        /* Miscelenous tax 3 - validation only when not blank */
        if t_sAddress.AddressTaxIDMisc3 <> ? and
           t_sAddress.AddressTaxIDMisc3 <> "":U
        then do:
            <M-55 run ValidateFormat
               (input  {&FORMATSETTYPE-TAXID} (icFormatType), 
                input  t_sAddress.AddressTaxIDMisc3 (icValueToValidate), 
                input  'Address':U (icTableName), 
                input  'AddressTaxIDMisc3':U (icFieldName), 
                input  t_sAddress.tcCountryCode (icCountryCode), 
                input  t_sAddress.tcStateCode (icStateCode), 
                input  t_sAddress.tcAddressTypeCode (icAddressType), 
                input  'E':U (icErrorType), 
                output viFcReturnSuper (oiReturnStatus)) in BFormatSet>
            if viFcReturnSuper < 0 or viFcReturnSuper > 0 and viLocalReturn = 0 then assign viLocalReturn = viFcReturnSuper.
        end.
    end.
end. /* MAIN_BLOCK */

assign oiReturnStatus = viLocalReturn.