project QadFinancials > class BConsolid > method GetExchangeRates

Description

Get Exchange Rates
Based on the Exchange Method (linked to the GL).


Parameters


icCurrencyCodeinputcharacterCurrency Code of the Subsidiary ( = Source) Company.
itExchangeRateDateinputdateDate of the exchange rate.
= The Consolidation date
icGLExchangeMethodinputcharacterExchange Method that is linked to the GL
icUsrDefExchangeRateTypeinputcharacterPossible Exchange Rate Type when the exchange method is USERDEFINED.
itPeriodStartDateinputdatePeriod Start Date
itPeriodEndDateinputdatePeriod End Date
odExchangeRateoutputdecimalExchange Rate
odExchangeRateScaleoutputdecimalExchange Rate Scale
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BConsolid.AdditionalUpdatesConsolidationBlock


program code (program6/bconsolid.p)

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

/* ======================================== */
/* Check if the input parameters are filled */
/* ======================================== */
if icCurrencyCode     = ? or icCurrencyCode     = "":U or
   icGLExchangeMethod = ? or icGLExchangeMethod = "":U or
   itExchangeRateDate = ? or
   itPeriodStartDate  = ? or
   itPeriodEndDate    = ? or
  (icGLExchangeMethod = {&EXCHANGEMETHOD-USERDEFINED} and (icUsrDefExchangeRateType = "":U or icUsrDefExchangeRateType = ?))
then do:
    assign vcMessage     = trim(#T-13'Not all parameters of method GetExchangeRate were entered correctly.':100(61701)t-13#) + chr(10) +
                           trim(substitute(#T-16'Currency Code: &1':30(61703)T-16#, trim(icCurrencyCode) ))                   + chr(10) +
                           trim(substitute(#T-22'Period Start Date: &1':100(61708)T-22#, trim(string(itPeriodStartDate)) ))   + chr(10) +
                           trim(substitute(#T-23'Period End Date: &1':100(61709)T-23#, trim(string(itPeriodEndDate)) ))       + chr(10) +
                           trim(substitute(#T-24'Exchange Rate Date: &1':100(61710)T-24#, trim(string(itExchangeRateDate)) )) + chr(10) +
                           trim(substitute(#T-19'Exchange Method: &1':100(61706)T-19#, trim(icGLExchangeMethod) ))            + chr(10) +
                           trim(substitute(#T-20'User Defined Exchange Rate Type: &1':100(61707)T-20#, trim(icUsrDefExchangeRateType) ))
           oiReturnStatus = -3.
    <M-21 run SetMessage
       (input  vcMessage (icMessage), 
        input  '':U (icArguments), 
        input  '':U (icFieldName), 
        input  '':U (icFieldValue), 
        input  'E':U (icType), 
        input  2 (iiSeverity), 
        input  '':U (icRowid), 
        input  'QadFin-6313':U (icFcMsgNumber), 
        input  '':U (icFcExplanation), 
        input  '':U (icFcIdentification), 
        input  '':U (icFcContext), 
        output viFcReturnSuper (oiReturnStatus)) in BConsolid>
    return.
end. /* Check input parameters */

/* ============================================ */
/* Start Submethod based on the Exchange Method */
/* ============================================ */
case icGLExchangeMethod:
    when {&EXCHANGEMETHOD-CURRENT}
    then do:
        <M-27 run GetExchangeRatesCurrent
           (input  icCurrencyCode (icCurrencyCode), 
            input  itPeriodEndDate (itExchangeRateDate), 
            output odExchangeRate (odExchangeRate), 
            output odExchangeRateScale (odExchangeRateScale), 
            output viFcReturnSuper (oiReturnStatus)) in BConsolid>
        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and viLocalReturnStatus >= 0)
        then assign viLocalReturnStatus = viFcReturnSuper.
    end. /* when {&EXCHANGEMETHOD-CURRENT} */
    
    when {&EXCHANGEMETHOD-WEIGHTEDAVERAGE}
    then do:
        <M-28 run GetExchangeRatesWeightedAverage
           (input  icCurrencyCode (icCurrencyCode), 
            input  itPeriodStartDate (itPeriodStartDate), 
            input  itPeriodEndDate (itPeriodEndDate), 
            output odExchangeRate (odExchangeRate), 
            output odExchangeRateScale (odExchangeRateScale), 
            output viFcReturnSuper (oiReturnStatus)) in BConsolid>
        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and viLocalReturnStatus >= 0)
        then assign viLocalReturnStatus = viFcReturnSuper.
    end. /* when {&EXCHANGEMETHOD-WEIGHTEDAVERAGE} */
    
    when {&EXCHANGEMETHOD-SIMPLEAVERAGE}
    then do:
        <M-29 run GetExchangeRatesSimpleAverage
           (input  icCurrencyCode (icCurrencyCode), 
            input  itPeriodStartDate (itPeriodStartDate), 
            input  itPeriodEndDate (itPeriodEndDate), 
            output odExchangeRate (odExchangeRate), 
            output odExchangeRateScale (odExchangeRateScale), 
            output viFcReturnSuper (oiReturnStatus)) in BConsolid>
        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and viLocalReturnStatus >= 0)
        then assign viLocalReturnStatus = viFcReturnSuper.
    end. /* when {&EXCHANGEMETHOD-SIMPLEAVERAGE} */
    
    when {&EXCHANGEMETHOD-USERDEFINED}
    then do:
        <M-31 run GetExchangeRatesUserDefined
           (input  icCurrencyCode (icCurrencyCode), 
            input  itPeriodEndDate (itExchangeRateDate), 
            input  icUsrDefExchangeRateType (icUsrDefExchangeRateType), 
            output odExchangeRate (odExchangeRate), 
            output odExchangeRateScale (odExchangeRateScale), 
            output viFcReturnSuper (oiReturnStatus)) in BConsolid>
        if viFcReturnSuper < 0 or (viFcReturnSuper > 0 and viLocalReturnStatus >= 0)
        then assign viLocalReturnStatus = viFcReturnSuper.
    end. /* when {&EXCHANGEMETHOD-SIMPLEAVERAGE} */
    
    otherwise do:
        assign vcMessage      = trim(substitute(#T-25'The exchange method &1 was not defined in the consolidation.':100(61714)t-25#, trim(icGLExchangeMethod) ))
               oiReturnStatus = -3.
        <M-26 run SetMessage
           (input  vcMessage (icMessage), 
            input  '':U (icArguments), 
            input  '':U (icFieldName), 
            input  '':U (icFieldValue), 
            input  'E':U (icType), 
            input  2 (iiSeverity), 
            input  '':U (icRowid), 
            input  'QadFin-6315':U (icFcMsgNumber), 
            input  '':U (icFcExplanation), 
            input  '':U (icFcIdentification), 
            input  '':U (icFcContext), 
            output viFcReturnSuper (oiReturnStatus)) in BConsolid>
        return.
    end. /* otherwise do: */
end case. /* case icGLExchangeMethod: */

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