UFN_RESERVATIONRATESCALEAPPLICATION_INCLUDEDINFLATRATE

Indicates whether or not the item type on an application is included in the flat rate.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN

Definition

Copy


        CREATE function dbo.UFN_RESERVATIONRATESCALEAPPLICATION_INCLUDEDINFLATRATE
        (
            @ID uniqueidentifier
        )
        returns bit
        with execute as caller
        as 
        begin
            declare @ISINCLUDED bit = 0

            select
                @ISINCLUDED = 1
            from dbo.RESERVATIONRATESCALEAPPLICATION RRSA
            inner join dbo.RESERVATIONRATESCALE RRS on
                RRSA.RESERVATIONRATESCALEID = RRS.ID
            where
                RRSA.ID = @ID and
                (
                    (
                        RRSA.TYPECODE = 0 and
                        (
                            RRS.INCLUDEALLPROGRAMS = 1 or
                            exists
                            (
                                select 1 from dbo.RESERVATIONRATESCALEPROGRAM RRSP
                                where 
                                    RRSP.RESERVATIONRATESCALEID = RRS.ID and
                                    RRSP.PROGRAMID = RRSA.PROGRAMID
                            )
                        )
                    ) or
                    (
                        RRSA.TYPECODE = 1 and
                        (
                            RRS.INCLUDEALLFEES = 1 or
                            exists
                            (
                                select 1 from dbo.RESERVATIONRATESCALEFEE RRSF
                                where 
                                    RRSF.RESERVATIONRATESCALEID = RRS.ID and
                                    RRSF.FEEID = RRSA.FEEID
                            )
                        )
                    ) or
                    (
                        RRSA.TYPECODE = 2 and
                        (
                            RRS.INCLUDEALLRESOURCES = 1 or
                            exists
                            (
                                select 1 from dbo.RESERVATIONRATESCALERESOURCE RRSR
                                where 
                                    RRSR.RESERVATIONRATESCALEID = RRS.ID and
                                    RRSR.RESOURCEID = RRSA.RESOURCEID
                            )
                        )
                    ) or
                    (
                        RRSA.TYPECODE = 3 and
                        (
                            RRS.INCLUDEALLSTAFFRESOURCES = 1 or
                            exists
                            (
                                select 1 from dbo.RESERVATIONRATESCALESTAFFRESOURCE RRSSR
                                where 
                                    RRSSR.RESERVATIONRATESCALEID = RRS.ID and
                                    RRSSR.VOLUNTEERTYPEID = RRSA.VOLUNTEERTYPEID
                            )
                        )
                    )
                )

            return @ISINCLUDED
        end