UFN_PLANNEDGIFTADDITIONREVENUE_GETCURRENCYIDFROMCODE
Returns the the planned gift addition revenue's currency ID if it exists, otherwise returns the planned gift addition's currency ID.
Return
| Return Type |
|---|
| uniqueidentifier |
Parameters
| Parameter | Parameter Type | Mode | Description |
|---|---|---|---|
| @PLANNEDGIFTADDITIONID | uniqueidentifier | IN | |
| @CURRENCYCODE | int | IN | |
| @DEFAULTCURRENCYID | uniqueidentifier | IN |
Definition
Copy
create function dbo.UFN_PLANNEDGIFTADDITIONREVENUE_GETCURRENCYIDFROMCODE
(
@PLANNEDGIFTADDITIONID uniqueidentifier,
@CURRENCYCODE int = 2,
@DEFAULTCURRENCYID uniqueidentifier = null
)
returns uniqueidentifier
with execute as caller
as begin
declare @DISPLAYCURRENCYID uniqueidentifier;
select @DISPLAYCURRENCYID =
case @CURRENCYCODE
when 2 then coalesce(REVENUE.TRANSACTIONCURRENCYID, PGA.TRANSACTIONCURRENCYID)
when 0 then coalesce(REVENUE.BASECURRENCYID, PGA.BASECURRENCYID)
else @DEFAULTCURRENCYID
end
from dbo.PLANNEDGIFTADDITION PGA
left join dbo.PLANNEDGIFTADDITIONREVENUE PGAR on PGA.ID = PGAR.ID
left join dbo.REVENUE on PGAR.REVENUEID = REVENUE.ID
where PGA.ID = @PLANNEDGIFTADDITIONID
return @DISPLAYCURRENCYID
end