project QadFinancials > class BConsolid > method GetExchangeRatesCurrent

Description

Get Exchange Rate for Exchange Method CURRENT.
Don't call this method. Always use method GetExchangeRate.


Parameters


icCurrencyCodeinputcharacterCurrency Code
itExchangeRateDateinputdateExchange Rate Date
odExchangeRateoutputdecimalExchange Rate
odExchangeRateScaleoutputdecimalExchange Rate Scale
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BConsolid.GetExchangeRates


program code (program6/bconsolid.p)

/* =================================================================================== */
/* The input parameters are already validated in the calling method (GetExchangeRates) */
/* So don't call this method, except from method GetExchangeRates.                     */
/* =================================================================================== */

/* =============================================== */
/* Initialise output parameters and oiReturnStatus */
/* =============================================== */
assign viLocalReturnStatus = oiReturnStatus
       oiReturnStatus      = -98
       odExchangeRate      = 0
       odExchangeRateScale = 0.

/* ===================== */
/* Get the Exchange Rate */
/* ===================== */
find tExchangeRateCache where
     tExchangeRateCache.tcFromCurrencyCode     = icCurrencyCode                 and
     tExchangeRateCache.tiToCurrencyId         = viCompanyLCId                  and
     tExchangeRateCache.tcExchangeRateTypeCode = {&EXCHANGERATETYPE-ACCOUNTING} and
     tExchangeRateCache.ttValidityDate         = itExchangeRateDate
     no-error.
if available tExchangeRateCache
then assign odExchangeRate      = tExchangeRateCache.tdMultiplyExchangeRate
            odExchangeRateScale = tExchangeRateCache.tdExchangeRateScaleFactor.
else do:
    <M-87 run GetExchangeRate
       (input  ? (iiCompanyID), 
        input  ? (iiFromCurrencyID), 
        input  icCurrencyCode (icFromCurrencyCode), 
        input  viCompanyLCId (iiToCurrencyID), 
        input  ? (icToCurrencyCode), 
        input  ? (iiExchangeRateTypeID), 
        input  {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode), 
        input  itExchangeRateDate (itValidityDate), 
        output odExchangeRate (odExchangeRate), 
        output odExchangeRateScale (odExchangeScaleFactor), 
        output viFcReturnSuper (oiReturnStatus)) in BConsolid>
    if viFcReturnSuper <> 0
    then do:
        assign vcMessage = trim(substitute(#T-33'The accounting exchange rate for currency &1 on &2 is not defined in the system.':255(943372468)T-33#, trim(icCurrencyCode), trim(string(itExchangeRateDate)) )).
        if viLocalReturnStatus >= 0
        then assign viLocalReturnStatus = viFcReturnSuper.
        <M-28 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  3 (iiSeverity), 
            input  '':U (icRowid), 
            input  'qadfin-661258':U (icFcMsgNumber), 
            input  '' (icFcExplanation), 
            input  '' (icFcIdentification), 
            input  '' (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BConsolid>
    end. /* if viFcReturnSuper <> 0 */
    create tExchangeRateCache.
    assign tExchangeRateCache.tcFromCurrencyCode        = icCurrencyCode                 
           tExchangeRateCache.tiToCurrencyId            = viCompanyLCId                  
           tExchangeRateCache.tcExchangeRateTypeCode    = {&EXCHANGERATETYPE-ACCOUNTING} 
           tExchangeRateCache.ttValidityDate            = itExchangeRateDate
           tExchangeRateCache.tdMultiplyExchangeRate    = odExchangeRate
           tExchangeRateCache.tdExchangeRateScaleFactor = odExchangeRateScale.
end. /* else do: */

/* ==================== */
/* Set Output parameter */
/* ==================== */
assign oiReturnStatus = viLocalReturnStatus.