project QadFinancials > class BDInvoice > method DefaultValuesOwnVatNumber

Description

default the own vat number


Parameters


ilShipFromCountryIsEUCountryinputlogicalIs the country an EU country for ship from
icShipFromAddressTaxIdStateinputcharacterTax Id State for the ship from address
icShipFromCountryCodeinputcharactercountry code of the ship from address
ocOwnVatNumberoutputcharacterOwn Vat Number
ocOwnVatCountryCodeoutputcharacterOwn Vat Country Code
ocOwnVatCurrencyCodeoutputcharacterOwn Vat Currency Code
icCurrencyCodeinputcharacter
odOwnVatExchangeRateoutputdecimal
odOwnVatExchangeRateScaleoutputdecimal
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


unused


program code (program3/bdinvoice.p)

assign ocOwnVatCountryCode = icShipFromCountryCode.

if ilShipFromCountryIsEUCountry = yes
then do:
    assign ocOwnVatNumber = icShipFromAddressTaxIdState.
    
    /* CEE VAT Currency ================ */
    /* Default Vat declaration currency  */
    /* ================================= */
    if icShipFromCountryCode <> ? and icShipFromCountryCode <> "":U
    then do:
        <Q-1 run CountryByCountry (all) (Read) (NoCache)
           (input ?, (CountryId)
            input icShipFromCountryCode, (CountryCode)
            output dataset tqCountryByCountry) in BCountry >
        find first tqCountryByCountry where
                   tqCountryByCountry.tcCountryCode = icShipFromCountryCode
                   no-error.
        if available tqCountryByCountry
        then do:
            assign ocOwnVatCurrencyCode = tqCountryByCountry.tcCurrencyCode.

            <Q-3 run CurrencyPrim (all) (Read) (NoCache)
               (input icCurrencyCode, (CurrencyCode)
                input ?, (Currency_ID)
                output dataset tqCurrencyPrim) in BCurrency >
            find first tqCurrencyPrim where
                       tqCurrencyPrim.tcCurrencyCode = icCurrencyCode
                       no-error.
            if available tqCurrencyPrim 
            then do:
                if tqCountryByCountry.tiCurrency_ID = tqCurrencyPrim.tiCurrency_ID 
                then assign odOwnVatExchangeRate      = 1
                            odOwnVatExchangeRateScale = 1. 
                else do: 
                    <Q-2 run ExchangeRateByCurrencies (all) (Read) (NoCache)
                       (input viCompanyId, (CompanyId)
                        input tqCountryByCountry.tiCurrency_ID, (FromCurrency_ID)
                        input tqCurrencyPrim.tiCurrency_ID, (ToCurrency_ID)
                        output dataset tqExchangeRateByCurrencies) in BExchangeRate >
                        
                     find first tqExchangeRateByCurrencies where
                                tqExchangeRateByCurrencies.tiFromCurrency_ID = tqCountryByCountry.tiCurrency_ID and
                                tqExchangeRateByCurrencies.tiToCurrency_ID   = tqCurrencyPrim.tiCurrency_ID
                                no-error.
                     if available tqExchangeRateByCurrencies 
                     then assign odOwnVatExchangeRate      = tqExchangeRateByCurrencies.tdExchangeRate
                                 odOwnVatExchangeRateScale = tqExchangeRateByCurrencies.tdExchangeRateScale.
                end. /* end else tqCountryByCountry.tiCurrency_ID = ... */                        
            end. /* if available tqCurrencyPrim */
        end. /* end if available tqCountryByCoutnry */
    end. /* if icShipFromCountryCode <> ?... */  
end. /* if ilShipFromCountryIsEUCountry = yes */