UFN_REVENUEBATCH_GETCONSTITUENTFOROTHERCOMMITEMENT
Gets the constituent for the
Return
Return Type |
---|
uniqueidentifier |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@COMMITMENTID | nvarchar(60) | IN |
Definition
Copy
CREATE function dbo.UFN_REVENUEBATCH_GETCONSTITUENTFOROTHERCOMMITEMENT(
@COMMITMENTID as nvarchar(60) = null
)
returns uniqueidentifier
with execute as caller
as begin
declare @CONSTITUENTID uniqueidentifier;
if @COMMITMENTID is not null and len(@COMMITMENTID) >= 39
begin
declare @SINGLEAPPLICATIONID uniqueidentifier;
declare @APPLICATIONTYPECODE int;
declare @APPLICATIONAMOUNT money;
select
@SINGLEAPPLICATIONID = SINGLEAPPLICATIONID,
@APPLICATIONTYPECODE = APPLICATIONTYPECODE,
@APPLICATIONAMOUNT = APPLICATIONAMOUNT
from dbo.UFN_REVENUEBATCH_PARSEAPPLICATIONINFO(@COMMITMENTID)
if exists(
select case @APPLICATIONTYPECODE
--Memberships
when 2 then
(select MEMBER.CONSTITUENTID
from dbo.MEMBERSHIP
inner join dbo.MEMBER on MEMBERSHIP.ID = MEMBER.MEMBERSHIPID
where MEMBERSHIP.ID = @SINGLEAPPLICATIONID)
--Event Registration
when 7 then
(select REGISTRANT.CONSTITUENTID
from dbo.REGISTRANT
where REGISTRANT.ID = @SINGLEAPPLICATIONID)
--Revenue
else
(select REVENUE.CONSTITUENTID
from dbo.REVENUE
where REVENUE.ID = @SINGLEAPPLICATIONID)
end)
begin
select @CONSTITUENTID = case @APPLICATIONTYPECODE
--Memberships
when 2 then
(select MEMBER.CONSTITUENTID
from dbo.MEMBERSHIP
inner join dbo.MEMBER on MEMBERSHIP.ID = MEMBER.MEMBERSHIPID
where MEMBERSHIP.ID = @SINGLEAPPLICATIONID and MEMBER.ISPRIMARY = 1)
--Event Registration
when 7 then
(select REGISTRANT.CONSTITUENTID
from dbo.REGISTRANT
where REGISTRANT.ID = @SINGLEAPPLICATIONID)
--Revenue
else
(select REVENUE.CONSTITUENTID
from dbo.REVENUE
where REVENUE.ID = @SINGLEAPPLICATIONID)
end
end
else
set @CONSTITUENTID = null
end
return @CONSTITUENTID
end