project QadFinancials > class BExchangeRate > method DefaultValuesValidDateTill
Description
This remoting method will return the default value of the default Valid Date Till, based on the Exchange Rate Type and Valid Date From.
Parameters
icExchangeRateType | input | character | |
itValidDateFrom | input | date | |
icRowid | input | character | |
icFromCurrencyCode | input | character | |
icToCurrencyCode | input | character | |
otValidDateTill | output | date | |
olShowValidDateTill | output | logical | |
oiReturnStatus | output | integer | Return status of the method. |
Internal usage
unused
program code (program9/bexchangerate.p)
/* initial output parameters */
assign olShowValidDateTill = false
otValidDateTill = ?.
/* validate the input paraemters */
if icRowid = "":U or
itValidDateFrom = ? or
icExchangeRateType = "":U or
icExchangeRateType = ? or
icFromCurrencyCode = "":U or
icFromCurrencyCode = ? or
icToCurrencyCode = "":U or
icToCurrencyCode = ?
then return.
/* find the Exchange Rate in instance by row id */
find first tExchangeRate where tExchangeRate.tc_Rowid = icRowid no-error.
if available tExchangeRate
then do:
/* check whether the exchange rate type support Till Date */
<Q-1 run ExchangeRateTypeByCode (all) (Read) (NoCache)
(input icExchangeRateType, (ExchangeRateTypeCode)
output dataset tqExchangeRateTypeByCode) in BExchangeRateType >
find first tqExchangeRateTypeByCode no-error.
/* check whether there is record in database has greater from date */
/* no need to input the company ID because exchange rate is by sharedset and will be handled by query itself */
<Q-2 run ExchangeRateByGreaterFromDate (all) (Read) (NoCache)
(input itValidDateFrom, (ValidDateFrom)
input ?, (FromCurrencyId)
input ?, (ToCurrencyId)
input ?, (ExchangeRateTypeId)
input ?, (CompanyId)
input icFromCurrencyCode, (FromCurrencyCode)
input icToCurrencyCode, (ToCurrencyCode)
input icExchangeRateType, (ExchangeRateTypeCode)
input tExchangeRate.SharedSet_ID, (SharedSetId)
output dataset tqExchangeRateByGreaterFromDate) in BExchangeRate >
find first tqExchangeRateByGreaterFromDate no-error.
/* check the current instance, bExchangerate is for t_s table */
find first bExchangeRate where
bExchangeRate.ExchangeRateValidDateFrom > tExchangeRate.ExchangeRateValidDateFrom and
bExchangeRate.tcFromCurrencyCode = tExchangeRate.tcFromCurrencyCode and
bExchangeRate.tcToCurrencyCode = tExchangeRate.tcToCurrencyCode and
bExchangeRate.tcExchangeRateTypeCode = tExchangeRate.tcExchangeRateTypeCode
no-error.
/* to enable the date till when the type allow and can not find next exchange rate */
if available tqExchangeRateTypeByCode and
tqExchangeRateTypeByCode.tlExchangeRateTypeIsTillDate = true and
not available tqExchangeRateByGreaterFromDate and
not available bExchangeRate
then assign olShowValidDateTill = true.
/* assign the Till Date by different situations */
if available tqExchangeRateByGreaterFromDate
then assign otValidDateTill = tqExchangeRateByGreaterFromDate.ttExchangeRateValidDateFrom - 1.
else if olShowValidDateTill = true
then assign otValidDateTill = itValidDateFrom + tqExchangeRateTypeByCode.tiExchangeRateTypeValidity - 1.
/* else assign otValidDateTill = vtBiggestDate. */
end. /* end of if available tExchangeRate */