project QadFinancials > class BExchangeRate > method InitialValues

Description

Add code here to initialize the calculated fields of a 'new' record (= a record that must be created in the application database) in a class temp-table.


Parameters


icTableNameinputcharacterName of the database table of which a record is created in the class temp-table.
oiReturnStatusoutputinteger


Internal usage


unused


program code (program/bexchangerate.p)

<ANCESTOR-CODE>

if oiReturnStatus < 0
then return.

case icTableName:
    when "ExchangeRate":U
    then do:
        <Q-1 run ExchangeRateTypePrim (all) (Read) (NoCache)
          (input 0, (ExchangeRateTypeId)
           input {&EXCHANGERATETYPE-ACCOUNTING}, (ExchangeRateTypeCode)
           output dataset tqExchangeRateTypePrim) in BExchangeRateType >
        find first tqExchangeRateTypePrim no-lock no-error.
        if available tqExchangeRateTypePrim
        then assign tExchangeRate.ExchangeRateType_ID  = tqExchangeRateTypePrim.tiExchangeRateType_ID
                    tExchangeRate.tcExchangeRateTypeCode = tqExchangeRateTypePrim.tcExchangeRateTypeCode.
        else assign tExchangeRate.ExchangeRateType_ID  = 0
                    tExchangeRate.tcExchangeRateTypeCode = "":U.
        
        assign tExchangeRate.ExchangeRateValidDateFrom = today
               tExchangeRate.ExchangeRateScale         = 1.
        
        /* set the shared set id that is linked to the currency company */
        <Q-2 run LookupSharedSetForCompany (all) (Read) (NoCache)
          (input viCompanyId, (CompanyId)
           input 'EXCHANGERATE':U, (SharedSetType)
           output dataset tqSharedSetForCompany) in BCompany >
        find first tqSharedSetForCompany no-lock no-error.
        if available tqSharedSetForCompany
        then assign tExchangeRate.SharedSet_ID = tqSharedSetForCompany.tiSharedSet_ID.
    end.
end case.