iiCompanyID | input | integer | CompanyID: the company wherefor you want to retrieve the exchange-rate - when empty then the current company is used |
iiFromCurrencyID | input | integer | FromCurrencyID: when this is not specified and the associated Code-parameter is not filled either, then an error is raised |
icFromCurrencyCode | input | character | FromCurrencyCode: this is only used and required in case the associated ID-parameter is not filled |
iiToCurrencyID | input | integer | ToCurrency ID: when this is not specified and the associated Code-parameter is not filled either, then the local-/base-currency is used as the ToCurrency |
icToCurrencyCode | input | character | ToCurrencyCode: this is only used in case the associated ID-parameter is not filled |
iiExchangeRateTypeID | input | integer | ExchangeRateType ID: when this is not specified and the associated Code-parameter is not filled either, then the rate-type will be set to Accounting |
icExchangeRateTypeCode | input | character | ExchangeRateType Code: this is only used in case the associated ID-parameter is not filled |
itValidityDate | input | date | ValidityDate: Date you want to know the exchange-rate for. If nothing is passed then the sytem-date is used as validaty-date |
odExchangeRate | output | decimal | Exchange Rate (always Multiply) of the retrieved rate. Sample: When you have 120 EUR and you want to know how many HRK this is then you call this method like this : - From-curr: EUR - To-curr: KRK Then odExchangeRate will be 8 as 1 EUR = 8 HRK (and odExchangeScale will be 1). So the value in HRK of 120 EUR will be: 120 * 8 * 1 (AmountInFromCurr) * odExchangeRate * odExchangeScale |
odExchangeScaleFactor | output | decimal | Exchange Rate Scale Factor of the retrieved rate |
oiReturnStatus | output | integer | Return status of the method. |
/* =================================================================================================== */ /* NOTES: */ /* This method is mostly just a wrapper to Cacher:GetExchangeRate() but it also hides some complexity */ /* and serves a better performance: */ /* - To avoid that class Cacher has to find out some company-dependant data, we simply pass this data */ /* as we have this data available here in the class-data-items anyway (if iiCompany equals the */ /* current-company byt that will be the case in the majority of the calls made to this class */ /* - Technical class Cacher does not has a method SetMessage so when an error occures in Cacher then */ /* it has to make a call to SetMessage in the calling program using the handle of the calling */ /* program (ihCallingProgram). To hide this complexity for callers of GetExchangeRate, we handle */ /* all this in this method */ /* =================================================================================================== */ /* ========================================================== */ /* Replace unknown values in the input to ease further coding */ /* ========================================================== */ if iiFromCurrencyID = ? then assign iiFromCurrencyID = 0. if icFromCurrencyCode = ? then assign icFromCurrencyCode = "":U. if iiToCurrencyID = ? then assign iiToCurrencyID = 0. if icToCurrencyCode = ? then assign icToCurrencyCode = "":U. if iiExchangeRateTypeID = ? then assign iiExchangeRateTypeID = 0. if icExchangeRateTypeCode = ? then assign icExchangeRateTypeCode = "":U. /* ================================================================================================= */ /* When the ID of the Currencies or the RateType is filled then the associated code will be ignored */ /* ================================================================================================= */ if iiFromCurrencyID <> 0 then assign icFromCurrencyCode = "":U. if iiToCurrencyID <> 0 then assign icToCurrencyCode = "":U. if iiExchangeRateTypeID <> 0 then assign icExchangeRateTypeCode = "":U. /* ============================================================================= */ /* Default CompanyID to current-company when not filled */ /* Most of the defaulting etc is contained in Cacher:GetExchangeRate() but the */ /* Company has to be handled here already as we need to know that so we can pass */ /* Company-related data to the Cacher to increase the performance */ /* ============================================================================= */ if iiCompanyID = 0 or iiCompanyID = ? then assign iiCompanyID = viCompanyID. /* ================================================================================================= */ /* State the Company- and Domain dependant-values that we will pass to QadFin.Cacher.GetExchangeRate */ /* If iiCompanyID is the current-company */ /* Then we can just take the values from the corresponding class-data-items */ /* Else we have to get the values by querying the database */ /* The reason that we pass them in to class Cacher is that in there these values are not available */ /* straight away although they can easily be read from a local temp-table after switching to the */ /* correct session */ /* ================================================================================================= */ if iiCompanyID = viCompanyID then do : /* Assign the data-items we can just get from the class-data-items */ assign viERCompanyID = viCompanyID viERCompanyLCID = viCompanyLCID vcERCompanyLC = vcCompanyLC viERCompanyCCID = viCompanyCCID vcERCompanyCC = vcCompanyCC vlERDomainIsStatutory = vlDomainIsStatutory. /* Start chacher to get a shared-set-ID out of it */ <M-1 run StartCacher (output vhFcComponent (ohCacher), output viFcReturnSuper (oiReturnStatus)) in business> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then return. /* Get the exchange-rate-shared-set-ID out of the cacher */ <M-46 run GetIntegerValueFromSession (input viSessionID (iiSessionId), input 'SharedSetFor':U + {&SHAREDSETTYPE-EXCHANGERATE} (icDataItemName), output viERSharedSetIDForExchRates (oiValue), output viFcReturnSuper (oiReturnStatus)) in Cacher> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then return. end. /* if iiCompanyID = viCompanyID */ else do : /* Call a query that will just return the data we need */ <Q-23 run CompanyPropertyForSharedSetDet (all) (Read) (NoCache) (input iiCompanyID, (CompanyID) input {&SHAREDSETTYPE-EXCHANGERATE}, (SharedSetTypeCode) output dataset tqCompanyPropertyForSharedSetDet) in BCompanyProperty> find tqCompanyPropertyForSharedSetDet where tqCompanyPropertyForSharedSetDet.tiCompany_ID = iiCompanyID no-lock no-error. if not available tqCompanyPropertyForSharedSetDet then do : assign vcMessage = trim(substitute(#T-77'Unable to retrieve an exchange-rate as the entity cannot be found based upon this ID (&1).':250(481664762)T-77#,string(iiCompanyID))) oiReturnStatus = -1. <M-80 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-698099':U (icFcMsgNumber), input '':U (icFcExplanation), input '':U (icFcIdentification), input '':U (icFcContext), output viFcReturnSuper (oiReturnStatus)) in business> Return. end. /* if not available tqCompanyPropertyForSharedSetDet */ /* Assign the data-items using the query-result-set */ assign viERCompanyID = tqCompanyPropertyForSharedSetDet.tiCompany_ID viERCompanyLCID = tqCompanyPropertyForSharedSetDet.tiLCCurrency_ID vcERCompanyLC = tqCompanyPropertyForSharedSetDet.tcLCCurrencyCode viERCompanyCCID = tqCompanyPropertyForSharedSetDet.tiCCCurrency_ID vcERCompanyCC = tqCompanyPropertyForSharedSetDet.tcCCCurrencyCode vlERDomainIsStatutory = tqCompanyPropertyForSharedSetDet.tlDomainPropertyIsStatutory viERSharedSetIDForExchRates = tqCompanyPropertyForSharedSetDet.tiSharedSet_ID. end. /* if Not iiCompanyID = viCompanyID */ /* ====================================================================================== */ /* Start the Cacher and then call GetExchangeRate in there by passing in all data we have */ /* ====================================================================================== */ <M-53 run StartCacher (output vhFcComponent (ohCacher), output viFcReturnSuper (oiReturnStatus)) in business> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then return. <M-12 run GetExchangeRate (input {&TARGETPROCEDURE} (ihCallingProgram), input viSessionID (iiSessionID), input viERCompanyID (iiERCompanyID), input iiFromCurrencyID (iiFromCurrencyID), input icFromCurrencyCode (icFromCurrencyCode), input iiToCurrencyID (iiToCurrencyID), input icToCurrencyCode (icToCurrencyCode), input iiExchangeRateTypeID (iiExchangeRateTypeID), input icExchangeRateTypeCode (icExchangeRateTypeCode), input itValidityDate (itValidityDate), input viERCompanyLCID (iiERCompanyLCID), input vcERCompanyLC (icERCompanyLC), input viERCompanyCCID (iiERCompanyCCID), input vcERCompanyCC (icERCompanyCC), input vlERDomainIsStatutory (ilERDomainIsStatutory), input viERSharedSetIDForExchRates (iiERSharedSetIDForExchRates), output odExchangeRate (odExchangeRate), output odExchangeScaleFactor (odExchangeScaleFactor), output viFcReturnSuper (oiReturnStatus)) in Cacher> if viFcReturnSuper <> 0 then assign oiReturnStatus = viFcReturnSuper. if viFcReturnSuper < 0 then return.