project QadFinancials > class BConsolid > method GetExchangeRatesUserDefined
Description
Get Exchange Rate based on the Exchange Rate Type the user linked to the GL account
Parameters
icCurrencyCode | input | character | Currency Code |
itExchangeRateDate | input | date | Exchange Rate Date |
icUsrDefExchangeRateType | input | character | User Defined Exchange Rate Type Code |
odExchangeRate | output | decimal | Exchange Rate |
odExchangeRateScale | output | decimal | Exchange Rate Scale |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
QadFinancials
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 = icUsrDefExchangeRateType and
tExchangeRateCache.ttValidityDate = itExchangeRateDate
no-error.
if available tExchangeRateCache
then assign odExchangeRate = tExchangeRateCache.tdMultiplyExchangeRate
odExchangeRateScale = tExchangeRateCache.tdExchangeRateScaleFactor.
else do:
<M-93 run GetExchangeRate
(input ? (iiCompanyID),
input ? (iiFromCurrencyID),
input icCurrencyCode (icFromCurrencyCode),
input viCompanyLCId (iiToCurrencyID),
input ? (icToCurrencyCode),
input ? (iiExchangeRateTypeID),
input icUsrDefExchangeRateType (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-53'Cannot find an accounting exchange rate for currency &1 and exchange rate type &2 on &3.':254(600206190)T-53#,
trim(icCurrencyCode),
trim(icUsrDefExchangeRateType),
trim(string(itExchangeRateDate)) )).
if viLocalReturnStatus >= 0
then assign viLocalReturnStatus = viFcReturnSuper.
<M-40 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-810193':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 = icUsrDefExchangeRateType
tExchangeRateCache.ttValidityDate = itExchangeRateDate
tExchangeRateCache.tdMultiplyExchangeRate = odExchangeRate
tExchangeRateCache.tdExchangeRateScaleFactor = odExchangeRateScale.
end. /* else do: */
/* ==================== */
/* Set Output parameter */
/* ==================== */
assign oiReturnStatus = viLocalReturnStatus.