project QadFinancials > class BConsolid > method GetExchangeRatesWeightedAverage

Description

Get Exchange Rate for exchange method WEIGHTEDAVERAGE


Parameters


icCurrencyCodeinputcharacterCurrency Code
itPeriodStartDateinputdatePeriod Start Date
itPeriodEndDateinputdatePeriod End 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 */
/* ===================== */
assign vhFcComponent = ?.
<M-4 run ApiGetAverageExchangeRate
   (input  0 (iiFromCurrencyId), 
    input  icCurrencyCode (icFromCurrencyCode), 
    input  viCompanyLCId (iiToCurrencyId), 
    input  '':U (icToCurrencyCode), 
    input  0 (iiExchangeRateTypeId), 
    input  {&EXCHANGERATETYPE-ACCOUNTING} (icExchangeRateTypeCode), 
    input  itPeriodStartDate (itFromValidityDate), 
    input  itPeriodEndDate (itToValidityDate), 
    output odExchangeRate (odAverageMultiplyExchangeRate), 
    output odExchangeRateScale (odAverageExchangeRateScaleFactor), 
    output viFcReturnSuper (oiReturnStatus)) in BExchangeRate>
if viFcReturnSuper <> 0
then do:
    assign vcMessage = trim(#T-3'Errors were found when calculating the weighted average exchange rate.':200(61748)t-3#).
    if viLocalReturnStatus >= 0
    then assign viLocalReturnStatus = viFcReturnSuper.
    <M-2 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-6331':U (icFcMsgNumber),
             input  '' (icFcExplanation),
             input  '' (icFcIdentification),
             input  '' (icFcContext),
             output viFcReturnSuper (oiReturnStatus)) in BConsolid>
end. /* if viFcReturnSuper <> 0 */

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