UFN_EVENTREGISTRANT_GETBALANCE
Returns the balance for an event registrant.
Return
Return Type |
---|
money |
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@REGISTRANTID | uniqueidentifier | IN |
Definition
Copy
CREATE function dbo.UFN_EVENTREGISTRANT_GETBALANCE
(
@REGISTRANTID uniqueidentifier
)
returns money
as
begin
--NOTE: UFN_REVENUE_CONSTITUENTSWITHCOMMITMENTS does balance calculations inline. Any changes to the way balances are calculated needs to be
-- made there as well.
declare @REGISTRANTAMOUNT money;
declare @PAIDAMOUNT money;
declare @CREDITEDAMOUNT money;
set @PAIDAMOUNT = 0;
set @CREDITEDAMOUNT = 0;
set @REGISTRANTAMOUNT= 0;
select
@REGISTRANTAMOUNT= sum(AMOUNT)
from dbo.REGISTRANTREGISTRATION
where REGISTRANTID = @REGISTRANTID;
select
@PAIDAMOUNT = sum(EVENTREGISTRANTPAYMENT.AMOUNT)
from dbo.EVENTREGISTRANTPAYMENT
where EVENTREGISTRANTPAYMENT.REGISTRANTID = @REGISTRANTID;
-- RobertDi 6/14/2010 - Credit items are an Arts and Cultural feature right now;
-- this will need to be updated for multicurrency when the rest of
-- the A&C features are.
select @CREDITEDAMOUNT = sum([CREDITITEMS].[TOTAL])
from dbo.[UFN_REGISTRANT_GETCREDITITEMS](@REGISTRANTID) as [CREDITITEMS]
return coalesce(@REGISTRANTAMOUNT, 0) - coalesce(@PAIDAMOUNT, 0) + coalesce(@CREDITEDAMOUNT, 0);
end