project QadFinancials > class BVATExportListing > method GetReportExchangeRate

Description

This method is used to get exchange rate and exchange rate scale by input currencies.


Parameters


icConvertToCurrencyinputcharacterConvert To Currency.
iiExportCurrency_IDinputintegerExport Currency ID.
odExchangeRateoutputdecimalExchange Rate.
odExchangeRateScaleoutputdecimalExchange Rate Scale.
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BVATExportListing.ApiExportQuarterSum
method BVATExportListing.ApiExportYearlyVatBE


program code (program9/bvatexportlisting.p)

assign vdExchangeRateScale = 1.

find first tExchangeRateVEL 
            where tExchangeRateVEL.tiFromCurrencyId = viCompanyLCId and
                  tExchangeRateVEL.tiToCurrencyId = iiExportCurrency_ID no-error.
if not available tExchangeRateVEL
then do:
    <M-68 run GetExchangeRate
       (input  ? (iiCompanyID), 
        input  viCompanyLCId (iiFromCurrencyID), 
        input  ? (icFromCurrencyCode), 
        input  iiExportCurrency_ID (iiToCurrencyID), 
        input  ? (icToCurrencyCode), 
        input  ? (iiExchangeRateTypeID), 
        input  {&EXCHANGERATETYPE-VAT} (icExchangeRateTypeCode), 
        input  today (itValidityDate), 
        output vdExchangeRateValue (odExchangeRate), 
        output vdExchangeRateScale (odExchangeScaleFactor), 
        output viFcReturnSuper (oiReturnStatus)) in BVATExportListing>
    if viFcReturnSuper <> 0 or
       vdExchangeRateValue = ?   or
       vdExchangeRateValue = 0
    then do:
        <M-58 run GetExchangeRate
           (input  ? (iiCompanyID), 
            input  viCompanyLCId (iiFromCurrencyID), 
            input  ? (icFromCurrencyCode), 
            input  iiExportCurrency_ID (iiToCurrencyID), 
            input  ? (icToCurrencyCode), 
            input  ? (iiExchangeRateTypeID), 
            input  {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode), 
            input  today (itValidityDate), 
            output vdExchangeRateValue (odExchangeRate), 
            output vdExchangeRateScale (odExchangeScaleFactor), 
            output viFcReturnSuper (oiReturnStatus)) in BVATExportListing>
        if viFcReturnSuper <> 0 or
           vdExchangeRateValue = ?   or
           vdExchangeRateValue = 0
        then do:

            <M-3 run SetMessage
          (input  #T-4'No exchange rate was defined for the selected currency ($1).':100(3850)T-4# (icMessage), 
           input  icConvertToCurrency (icArguments), 
           input  '':U (icFieldName), 
           input  '':U (icFieldValue), 
           input  'E':U (icType), 
           input  3 (iiSeverity), 
           input  '':U (icRowid), 
           input  'QADFIN-1894':U (icFcMsgNumber), 
           input  '' (icFcExplanation), 
           input  '' (icFcIdentification), 
           input  '' (icFcContext), 
           output viFcReturnSuper (oiReturnStatus)) in BVATExportListing>

            
            assign oiReturnStatus = -1.
            return.
        end.
    end.
    create tExchangeRateVEL.
    assign tExchangeRateVEL.tiFromCurrencyId    = viCompanyLCId
           tExchangeRateVEL.tiToCurrencyId      = iiExportCurrency_ID
           tExchangeRateVEL.tdExchangeRateValue = vdExchangeRateValue
           tExchangeRateVEL.tdExchangeRateScale = (if vdExchangeRateScale <= 0 then 1 else vdExchangeRateScale).
end.
assign odExchangeRate        = tExchangeRateVEL.tdExchangeRateValue
       odExchangeRateScale   = tExchangeRateVEL.tdExchangeRateScale.