UFN_CONSTITUENT_GETGIFTTOTALINCURRENCY_RESPECTSITE
Returns the total gift amount (in the given currency) from all the gifts ever made by a constituent, while respecting site security.
Return
Return Type |
---|
money |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@CONSTITUENTID | uniqueidentifier | IN | |
@CURRENTAPPUSERID | uniqueidentifier | IN | |
@CURRENCYID | uniqueidentifier | IN |
Definition
Copy
create function dbo.UFN_CONSTITUENT_GETGIFTTOTALINCURRENCY_RESPECTSITE
(
@CONSTITUENTID uniqueidentifier = null,
@CURRENTAPPUSERID uniqueidentifier = null,
@CURRENCYID uniqueidentifier = null
)
returns money
as
begin
declare @r money
select @r = coalesce(sum(dbo.UFN_REVENUESPLIT_GETAMOUNTINCURRENCY(REVENUESPLIT.ID, @CURRENCYID)), 0)
from dbo.REVENUE
inner join dbo.REVENUESPLIT
on REVENUESPLIT.REVENUEID = REVENUE.ID
where REVENUE.CONSTITUENTID = @CONSTITUENTID
and
(
(REVENUE.TRANSACTIONTYPECODE = 0 and (REVENUESPLIT.APPLICATIONCODE in (0, 2, 3) or (REVENUESPLIT.APPLICATIONCODE = 1 and REVENUESPLIT.TYPECODE = 0)))
or
REVENUE.TRANSACTIONTYPECODE = 7
)
and dbo.UFN_REVENUE_USERHASSITEACCESS(REVENUE.ID,@CURRENTAPPUSERID) = 1
return @r
end