UFN_REVENUE_GETREVALUATIONASOF

Returns the most recent commitment revaluation record for the given revenue as of the given date.

Return

Return Type
uniqueidentifier

Parameters

Parameter Parameter Type Mode Description
@REVENUEID uniqueidentifier IN
@ASOFDATE datetime IN

Definition

Copy


        create function dbo.UFN_REVENUE_GETREVALUATIONASOF
        (
            @REVENUEID uniqueidentifier,
            @ASOFDATE datetime
        )
        returns uniqueidentifier
        as
        begin
            declare @COMMITMENTREVALUATIONID uniqueidentifier;

            select top 1
                @COMMITMENTREVALUATIONID = COMMITMENTREVALUATION.ID
            from
                dbo.REVENUECOMMITMENTREVALUATION
                inner join dbo.COMMITMENTREVALUATION on REVENUECOMMITMENTREVALUATION.COMMITMENTREVALUATIONID = COMMITMENTREVALUATION.ID
            where
                REVENUECOMMITMENTREVALUATION.REVENUEID = @REVENUEID
                and COMMITMENTREVALUATION.DATE <= @ASOFDATE
            order by
                COMMITMENTREVALUATION.DATE desc, COMMITMENTREVALUATION.SEQUENCE desc;

            return @COMMITMENTREVALUATIONID;

        end