project QadFinancials > class Business Component > method GetExchangeRate

Description

GetExchangeRate: this method will provide you the correct exchange-rate based upon the input parameters you provide.


Parameters


iiCompanyIDinputintegerCompanyID: the company wherefor you want to retrieve the exchange-rate - when empty then the current company is used
iiFromCurrencyIDinputintegerFromCurrencyID: when this is not specified and the associated Code-parameter is not filled either, then an error is raised
icFromCurrencyCodeinputcharacterFromCurrencyCode: this is only used and required in case the associated ID-parameter is not filled
iiToCurrencyIDinputintegerToCurrency 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
icToCurrencyCodeinputcharacterToCurrencyCode: this is only used in case the associated ID-parameter is not filled
iiExchangeRateTypeIDinputintegerExchangeRateType ID: when this is not specified and the associated Code-parameter is not filled either, then the rate-type will be set to Accounting
icExchangeRateTypeCodeinputcharacterExchangeRateType Code: this is only used in case the associated ID-parameter is not filled
itValidityDateinputdateValidityDate: Date you want to know the exchange-rate for. If nothing is passed then the sytem-date is used as validaty-date
odExchangeRateoutputdecimalExchange 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
odExchangeScaleFactoroutputdecimalExchange Rate Scale Factor of the retrieved rate
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method BAllocationBatch.ExecuteAllocationBatch
method BAllocationBatch.GetProposedAllocations
method BAPMatching.CalculatePost
method BAPMatching.DefaultValuesInvoice
method BAPMatching.GetPendingVouchersAssignCostMethodsCCRate
method BAPMatching.ValidateComponentPreAPM
method BBankEntry.AddBankEntryAllocateDocument
method BBankEntry.AdditionalUpdatesInv
method BBankEntry.AdditionalUpdatesInvCIMovements
method BBankEntry.AdditionalUpdatesInvCurrDiff
method BBankEntry.AdditionalUpdatesInvDeductions
method BBankEntry.AdditionalUpdatesInvDiscountCurrDiff
method BBankEntry.AdditionalUpdatesInvPrePayments
method BBankEntry.ApiStdMaintainTTSub
method BBankEntry.CalculateAll
method BBankEntry.CalculateBankState
method BBankEntry.CreateDeduction
method BBankEntry.CreatePrepayment
method BBankEntry.DefaultBankStateAllocBank
method BBankEntry.GetJournalEntryBalance
method BBankEntry.GetPossibleAllocations
method BBankEntry.GetPossibleAllocationsCInvoiceCrossCy
method BBankEntry.GetPossibleAllocationsDInvoiceCrossCy
method BBankEntry.GetPossibleCollAllocations
method BBankEntry.ValidateComponentPre
method BBankEntry.ValidateComponentPreUpdateBankStateAlloc
method BBLWIReport.CreateBWLIReportFromCInvoiceMovement
method BBLWIReport.CreateBWLIReportFromCInvoices
method BBLWIReport.CreateBWLIReportFromDInvoiceMovement
method BBLWIReport.CreateBWLIReportFromDInvoices
method BBudget.ApiCheckBudget
method BBudgetReporting.BudgetDetail
method BBudgetReporting.BudgetOverview
method BCashBox.GetCashGLInfo
method BCDocument.AdditionalUpdatesCCollection
method BCDocument.AdditionalUpdatesPostingCrossCy
method BCDocument.AdditionalUpdatesPostingDocCtrl3
method BCDocument.AdditionalUpdatesPostingDocExchRatePaid
method BCDocument.AdditionalUpdatesPostingPrePayment
method BCDocument.AdditionalUpdatesPostingXrefGetRates
method BCDocument.AdditionalUpdatesPostingXrefGetWHTRates
method BCDocument.ValidateComponentPreCInvoice
method BCDocument.ValidateComponentPreInvXrefCI
method BCDocument.ValidateComponentPreInvXrefDI
method BCDocument.ValidateComponentPreInvXrefPrep
method BCInvoice.CreateCInvoiceMovementsCrossCy
method BCInvoice.DefaultWHTDataBasedOnCInvoice
method BCInvoice.GetExRateByEntityInvoiceFlag
method BCInvoice.GetVatExchangeRate
method BCInvoice.UpdateCInvoiceVatDelay
method BCInvoiceAPMatching.CreateCInvoice
method BCInvoiceJournalEntry.GetExRateByEntityInvoiceFlag
method BConsolid.AdditionalUpdatesConsolidationBlock
method BConsolid.GetExchangeRatesCurrent
method BConsolid.GetExchangeRatesSimpleAverage
method BConsolid.GetExchangeRatesUserDefined
method BConsolidDump.DefaultValuesCurrencyCode
method BCreditor.CalculateBalanceOI
method BCreditor.CalculateBOIforCompanies
method BCreditor.GetBalanceLCAmount
method BCreditor.GetBalanceLCAmountForComp
method BOpenBalance.ApiCalculateLCTCForOpenBalances
method BOpenBalance.GetInvoiceAmountTCChanges
method BCreditorReport.CreditorWHTCertificate
method BCreditorReport.CreditorWithholdingTax
method BCreditorReport.CreditorWithholdingTaxDue
method BDCollection.RetrievePaySelInitial
method BDDocument.AdditionalUpdatesDCollection
method BDDocument.AdditionalUpdatesPostingDeduction
method BDDocument.AdditionalUpdatesPostingDocCtrl3
method BDDocument.AdditionalUpdatesPostingPrePayment
method BDDocument.AllocateInvoices
method BDDocument.ValidateComponentPreInvXrefDI
method BDDocument.ValidateComponentPreInvXrefPrep
method BDebtor.ApiCheckCreditLimit
method BDebtor.ApiExtractHighCreditInfo
method BDebtor.ApiGetCustomerInvoicePastDueTotal
method BDebtor.CalcOpenOrderTotal
method BDebtor.CalculateBalanceDrafts
method BDebtor.CalculateBalanceOpenItems
method BDebtor.CalculateBalanceSalesOrders
method BDebtor.CalculateBOIforCompanies
method BDebtor.CalculateBSOForCompany
method BDebtor.CalculateCreditOnTurnover
method BDebtor.GetCurrencyAmount
method BDebtorBalance.UpdateDBalanceAndDHistDebtorHighCredit
method BDebtorFinanceCharge.FCDInvoiceCommit
method BDebtorReport.CustomerCreditOverview
method BDebtorReport.GetExchangeRateForEntity
method BDeductionCat.GetDeductionStatus
method BDInvoice.AdditionalUpdatesAllDebtorUpdates
method BDInvoice.ApiStdMaintainTTCalcAmounts
method BDInvoice.CreateDInvoiceMovementsCrossCy
method BDInvoice.CreateDInvoicesValidate
method BDInvoice.DefaultValuesExchangeRateOriginal
method BDInvoice.GetExRateByEntityInvoiceFlag
method BDInvoice.GetVatExchangeRate
method BDInvoice.ValidateComponentPreValidateVat
method BDInvoiceJournalEntry.ApiStdMaintainTTFillCCLC
method BDInvoiceJournalEntry.GetExRateByEntityInvoiceFlag
method BDPaymentSelection.GetDDocumentInfo
method BDPaymentSelection.GetPaymentCurrencyAmounts
method BDPaymentSelection.GetToPayObjects
method BDPaymentSelection.GetToPayObjectsInitialLoad
method BExchangeRate.APIGetExchangeRate
method BExpenseNote.Calculate
method BFixedAssetAsset.CapitalizeAsset
method BFixedAssetDepreciation.DepreciationMain
method BFixedAssetDepreciation.DepreciationMainSub
method BFixedAssetDisposal.DisposalCreateDet
method BFixedAssetDisposal.DisposalProposals
method BFixedAssetRevaluation.RevaluationCreate
method BGLOpenItemProcessor.GLOpenItemInitializationPosting
method BGLReport.AuditLogReport
method BGLReport.BalanceSheetReport
method BGLReport.BalanceSheetReport2
method BGLReport.ChangeBudgetFromTCtoReqCurr
method BGLReport.ChineseBalanceSheet
method BGLReport.ChineseIncomeStatement
method BGLReport.GLHistory
method BGLReport.GLTransactionsOperational
method BGLReport.IncomeStatement
method BGLReport.JournalEntryReport
method BGLReport.MultiColBalanceSheet
method BGLReport.MultiColIncomeStatement
method BGLReport.Transactions_DIV
method BGLReport.Transactions_GL
method BGLReport.Transactions_IC
method BGLReport.Transactions_JRNL
method BGLReport.TrialBalance
method BPosting.AddControlPosting
method BPosting.AddPostingLineTaxForSuspDel
method BPosting.AddStandardPosting
method BPosting.AddTaxPostingGetExchRates
method BPosting.CalculateCCAmount
method BPosting.ValidateComponentPre
method BPosting.ValidateComponentPreAssignPostingLine
method BPosting.ValidateComponentPreAssignPostingVat
method BJournalEntry.GetExchangeRates
method BJournalEntry.LoadTemplate
method BJournalEntry.LoadVatTemplate
method BJournalEntry.PostingLineGLUpdate
method BJournalEntry.UpdatePostingLine
method BOpenItemAdjustment.ApiGetDeductionAmountByDInvIDStatus
method BOpenItemAdjustment.GetExchangeRateAndScale
method BPaymentSelection.AdditionalUpdatesRegisterPrePayment
method BPaymentSelection.ApiGetPaySelInfo
method BPaymentSelection.ApiGetToPayObjectsV01
method BPaymentSelection.ApiGetToPayObjectsV02
method BPaymentSelection.ApiGetToPayObjectsV03
method BPaymentSelection.ApiGetToPayObjectsV04
method BPaymentSelection.GetToPayObjectsInitialLoad
method BPaymentSelection.PaySelLineCalcValues
method BPaymentSelection.ValidateComponentPost
method BQBudgetActual.AdditonalUpdatesDeleteSub
method BQBudgetCommitment.AdditionalUpdatesDeleteSub
method BQCInvoiceMovement.ApiCreateQCInvoiceMovement
method BQCrossCyPosting.ApiProcessQCrossCyPostingCalcAmount
method BQCrossCyPosting.ApiProcessQCrossCyPostingCalcAmountCI
method BQDInvoiceMovement.ApiCreateQDInvoiceMovement
method BSelfBill.ApiCreateInvPrepayPaymentSub
method BVATExportListing.GetReportExchangeRate
method BVATReport.GetAPTaxRegisterPostings
method BVATReport.GetReportExchangeRate
method BVATReport.ITARVATReg
method BVATReport.ITVATRegSusp

QadFitnesse
method BBankEntry.AddBankEntryAllocationV02


program code (program1/business.p)

/* =================================================================================================== */
/* 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.