UFN_SPONSORSHIP_DELETEALLOWED
Returns 1 if a sponsorship may be deleted based on the specified criteria.
Return
Return Type |
---|
bit |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@SPONSORSHIPID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_SPONSORSHIP_DELETEALLOWED(
@SPONSORSHIPID uniqueidentifier
)
returns bit
with execute as caller
as begin
declare @INVALIDCOUNT smallint;
-----------------------------------------------------------
-- RULE 1 - can't delete if this sponsorship was created by a transfer/reassignment
-- or it was transferred/reassigned
select @INVALIDCOUNT = count(*)
from dbo.SPONSORSHIPTRANSACTION
where @SPONSORSHIPID in(CONTEXTSPONSORSHIPID,TARGETSPONSORSHIPID)
and ACTIONCODE in(1,5,6,7)
if @INVALIDCOUNT > 0
return 0
-----------------------------------------------------------
--RULE 2 - can't delete if there are any payments tied to the sponsorship
-- PhilGo Commenting out as this is now being handled after the user attempts to delete the sponsorship.
--select @INVALIDCOUNT = count(*)
--from dbo.SPONSORSHIP
--inner join dbo.REVENUESPLIT on REVENUESPLIT.ID = SPONSORSHIP.REVENUESPLITID
--inner join dbo.RECURRINGGIFTACTIVITY on RECURRINGGIFTACTIVITY.SOURCEREVENUEID = REVENUESPLIT.REVENUEID
--where SPONSORSHIP.ID = @SPONSORSHIPID
--and RECURRINGGIFTACTIVITY.TYPECODE = 0
--
--if @INVALIDCOUNT > 0
--return 0
return 1
end