UFN_REVENUEGLDISTRIBUTION_VALIDAMOUNT

Checks that the amount of the credits is equal to the amount of the debits for a GL distribution.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN
@DISTRIBUTION xml IN

Definition

Copy


            CREATE function dbo.UFN_REVENUEGLDISTRIBUTION_VALIDAMOUNT
            (
                @ID uniqueidentifier,            
                @DISTRIBUTION xml
            )
            returns bit    
            with execute as caller
            as
            begin

                declare @ISVALID as bit;
                declare @DEBITAMOUNT as money;
                declare @CREDITAMOUNT as money;
                declare @REVENUEAMOUNT as money;

                select @DEBITAMOUNT = sum(AMOUNT) from dbo.UFN_REVENUE_GETGLDISTRIBUTION_FROMITEMLISTXML(@DISTRIBUTION) tf where tf.TRANSACTIONTYPECODE = 0;
                select @CREDITAMOUNT = sum(AMOUNT) from dbo.UFN_REVENUE_GETGLDISTRIBUTION_FROMITEMLISTXML(@DISTRIBUTION) tf where tf.TRANSACTIONTYPECODE = 1;

                select @REVENUEAMOUNT = AMOUNT from dbo.REVENUE where REVENUE.ID = @ID;

                if (@DEBITAMOUNT = @CREDITAMOUNT)
                    set @ISVALID = 1;
                else
                    set @ISVALID = 0;

                return @ISVALID;
            end