UFN_PLANNEDGIFTDESIGNATION_GETNETPRESENTVALUE_SINGLE_TRANSACTION
Gets the net present value for single designation in transaction currency
Return
Return Type |
---|
money |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@PLANNEDGIFTID | uniqueidentifier | IN | |
@ID | uniqueidentifier | IN |
Definition
Copy
create function dbo.UFN_PLANNEDGIFTDESIGNATION_GETNETPRESENTVALUE_SINGLE_TRANSACTION
(
@PLANNEDGIFTID uniqueidentifier,
@ID uniqueidentifier
)
returns money
with execute as caller
as
begin
declare @xmlvar as xml
declare @giftAmount as money
declare @netPresentValue as money
declare @npv as money
declare @return table
(
ID uniqueidentifier,
NETPRESENTVALUE money
)
select @giftAmount=PG.TRANSACTIONEXPECTEDGIFTAMOUNT,@netPresentValue=PG.TRANSACTIONNETPRESENTVALUE
from PLANNEDGIFT PG
WHERE PG.ID = @PLANNEDGIFTID
set @xmlvar = (
select
PGD.ID ID,PGD.TRANSACTIONAMOUNT AMOUNT
from
PLANNEDGIFT PG
INNER JOIN PLANNEDGIFTDESIGNATION PGD ON PG.ID = PGD.PLANNEDGIFTID
where PG.ID = @PLANNEDGIFTID
for xml path('ITEM'), root('DESIGNATION')
)
select @npv=tb.NETPRESENTVALUE
from UFN_PLANNEDGIFTDESIGNATION_GETNETPRESENTVALUE_MULTIPLE(@xmlvar,@giftAmount,@netPresentValue) tb
where tb.ID = @ID
return @npv
end