USP_FAFREVENUERECOGNITIONUPDATE
Update recognition for gifts
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@REVENUEID | uniqueidentifier | IN | |
@RECOGNITIONCONSTITUENTID | uniqueidentifier | IN |
Definition
Copy
CREATE procedure dbo.USP_FAFREVENUERECOGNITIONUPDATE
(
@REVENUEID uniqueidentifier,
@RECOGNITIONCONSTITUENTID uniqueidentifier -- participant / team constituentid
)
as
begin
;with AllGifts as
(
SELECT RS.ID
FROM dbo.REVENUE R (NOLOCK)
INNER JOIN dbo.REVENUESPLIT RS (NOLOCK) ON R.ID = RS.REVENUEID
where R.TRANSACTIONTYPECODE in (0,1,2,9) ---0 (payments), 1 (recurring payments), 2 (pledges), 9(pending gift); this only updates transactions that have completed;a pending gift sent to be updated should only be one that has been completed
and R.ID = @REVENUEID
UNION ALL
select PAYMENTID from INSTALLMENTSPLITPAYMENT
where PLEDGEID = @REVENUEID
)
UPDATE dbo.REVENUERECOGNITION
SET CONSTITUENTID = @RECOGNITIONCONSTITUENTID
WHERE REVENUESPLITID in (select ID from AllGifts)
end