UFN_PLEDGE_GETAMOUNTPAIDIGNOREPAYMENT

Returns the amount paid off (excluding write-offs) for a given pledge, ignoring the given payment.

Return

Return Type
money

Parameters

Parameter Parameter Type Mode Description
@PLEDGEID uniqueidentifier IN
@PAYMENTID uniqueidentifier IN

Definition

Copy


            create function dbo.UFN_PLEDGE_GETAMOUNTPAIDIGNOREPAYMENT(
                @PLEDGEID uniqueidentifier, 
                @PAYMENTID uniqueidentifier
            ) 
            returns money
            with execute as caller
            as begin
                declare @RESULT money;

                select @RESULT = 
                    coalesce(
                        (
                            select
                            sum (INSTALLMENTPAYMENT.AMOUNT)
                            from dbo.INSTALLMENTPAYMENT
                                inner join dbo.REVENUESPLIT on REVENUESPLIT.ID = INSTALLMENTPAYMENT.PAYMENTID
                            where INSTALLMENTPAYMENT.PLEDGEID = @PLEDGEID
                                and REVENUESPLIT.REVENUEID <> @PAYMENTID
                        ) 
                    ,0);

                return @RESULT;
            end