UFN_REVENUE_GETTEAMRAISEDTOTAL_NO_REVENUE_RULES

Provide team raised total in a given FAF event, excluding revenue rules

Return

Return Type
money

Parameters

Parameter Parameter Type Mode Description
@TEAMID uniqueidentifier IN
@EVENTID uniqueidentifier IN

Definition

Copy


create function [dbo].[UFN_REVENUE_GETTEAMRAISEDTOTAL_NO_REVENUE_RULES](
     @TEAMID    as uniqueidentifier
    ,@EVENTID    as uniqueidentifier
)
returns money
with execute as caller
as 
begin

    declare @TOTAL as money = 0.0;

     select  @TOTAL =  isnull(sum([dbo].[UFN_REVENUE_GETHOUSEHOLDRAISEDTOTAL_NO_REVENUE_RULES](TEAMFUNDRAISINGTEAM.ID,@EVENTID)),0)              
     from        dbo.TEAMFUNDRAISINGTEAM (nolock)
     inner join dbo.TEAMEXTENSION        (nolock)
     on        TEAMEXTENSION.TEAMFUNDRAISINGTEAMID=TEAMFUNDRAISINGTEAM.ID 
     and    TEAMEXTENSION.TYPECODE=3
     where    TEAMFUNDRAISINGTEAM.PARENTTEAMID=@TEAMID;

    -- Adding amount raised to the team

    return (
        select @TOTAL + isnull([dbo].[UFN_REVENUE_GETGROUPRAISEDTOTAL_NO_REVENUE_RULES](@EVENTID ,@TEAMID ,1),0)
    );
end