UFN_PLEDGE_GETAMOUNTPAIDINCURRENCY
Returns the amount paid off (excluding write-offs) for a given pledge in a given currency.
Return
Return Type |
---|
money |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@PLEDGEID | uniqueidentifier | IN | |
@CURRENCYID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_PLEDGE_GETAMOUNTPAIDINCURRENCY
(
@PLEDGEID uniqueidentifier,
@CURRENCYID uniqueidentifier
)
returns money
as
begin
declare @AMOUNT money;
declare @PLEDGECURRENCYID uniqueidentifier;
set @AMOUNT = dbo.UFN_PLEDGE_GETAMOUNTPAID(@PLEDGEID);
select @PLEDGECURRENCYID = REVENUE.TRANSACTIONCURRENCYID
from dbo.REVENUE
where ID = @PLEDGEID;
if @CURRENCYID = @PLEDGECURRENCYID
return @AMOUNT
else
begin
declare @CURRENCYEXCHANGERATEID uniqueidentifier = dbo.UFN_CURRENCYEXCHANGERATE_GETLATESTINCLUDEEXPIRED(@PLEDGECURRENCYID, @CURRENCYID, GETDATE(), 1, null);
set @AMOUNT = dbo.UFN_CURRENCY_CONVERT(@AMOUNT, @CURRENCYEXCHANGERATEID);
end
return @AMOUNT
end