project QadFinancials > class BCInvoice > method GetVatExchangeRate

Description

Method to calculate VAT exchange rate. Logic between invoice currency and VAT currency is considered. The method is a part of CEE Vat Currency development.


Parameters


iiCompanyIDinputinteger
icCInvoiceCurrencyCodeinputcharacter
icOwnVatCurrencyCodeinputcharacter
idCInvoiceExchangeRateinputdecimal
idCInvoiceRateScaleinputdecimal
iiCInvoiceCurrencyIdinputinteger
iiOwnVatCurrencyIdinputinteger
itTaxPointDateinputdate
odVatExchangeRateoutputdecimal
odVatRateScaleoutputdecimal
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BCInvoice.CreateCInvoices
method BCInvoice.DefaultValuesVatCurrency


program code (program3/bcinvoice.p)

/* CEE Vat Currency ==================================================== */
/* Set the exchange rate between transactional currency and Vat currency */
/* ===================================================================== */
if iiOwnVatCurrencyId = ?
then assign iiOwnVatCurrencyId = 0.

if iiCInvoiceCurrencyId = ?
then assign iiCInvoiceCurrencyId = 0.

if icOwnVatCurrencyCode = ?
then assign icOwnVatCurrencyCode = "":U.

if icCInvoiceCurrencyCode = ?
then assign icCInvoiceCurrencyCode = "":U.

if (iiOwnVatCurrencyId     <> ?     or
    icOwnVatCurrencyCode   <> "":U) and
   (iiCInvoiceCurrencyId   <> ?     or
    icCInvoiceCurrencyCode <> "":U)
then do:
    /* if Vat currency are the same as local currency, the same exchange rate as on invoice has to be used */
    if iiOwnVatCurrencyID   = viCompanyLCId or
       icOwnVatCurrencyCode = vcCompanyLC
    then assign odVatExchangeRate = idCInvoiceExchangeRate
                odVatRateScale    = idCInvoiceRateScale.

    /* If Vat currency are the same as transactional currency, exchange rate must be 1 */
    else
    if iiOwnVatCurrencyId   = iiCInvoiceCurrencyId or
       icOwnVatCurrencyCode = icCInvoiceCurrencyCode
    then assign odVatExchangeRate = 1
                odVatRateScale    = 1.
  
    /* Find correct exchange rate from Transactional currency to Vat currency */
    else do :
        <M-92 run GetExchangeRate
           (input  iiCompanyID (iiCompanyID), 
            input  iiCInvoiceCurrencyId (iiFromCurrencyID), 
            input  icCInvoiceCurrencyCode (icFromCurrencyCode), 
            input  iiOwnVatCurrencyId (iiToCurrencyID), 
            input  icOwnVatCurrencyCode (icToCurrencyCode), 
            input  ? (iiExchangeRateTypeID), 
            input  {&EXCHANGERATETYPE-VAT} (icExchangeRateTypeCode), 
            input  itTaxPointDate (itValidityDate), 
            output odVatExchangeRate (odExchangeRate), 
            output odVatRateScale (odExchangeScaleFactor), 
            output viFcReturnSuper (oiReturnStatus)) in BCInvoice>
        if viFcReturnSuper < 0 or
           oiReturnStatus  = 0
        then assign oiReturnStatus = viFcReturnSuper.
        if oiReturnStatus < 0
        then return.
    end.
end.