USP_DATAFORMTEMPLATE_EDIT_PAYMENTGIFTFEEOVERRIDE

The save procedure used by the edit dataform template "Payment Gift Fee Override Edit Form".

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN The input ID parameter indicating the ID of the record being edited.
@GIFTFEES xml IN Gift fees
@REASONCODEID uniqueidentifier IN Reason code
@COMMENTS nvarchar(255) IN Details
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.

Definition

Copy


                CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_PAYMENTGIFTFEEOVERRIDE
                    (
                        @ID uniqueidentifier,
                        @GIFTFEES xml,
                        @REASONCODEID uniqueidentifier,
                        @COMMENTS nvarchar(255),
                        @CHANGEAGENTID uniqueidentifier = null
                    )
                as
                    begin try
                        set nocount on;

                        -- Ensure that the gift fee isn't greater than the application amount

                        if exists (    select 1
                                    from dbo.UFN_REVENUE_GETGIFTFEES_2_FROMITEMLISTXML(@GIFTFEES)
                                    where TRANSACTIONFEE > AMOUNT)
                            raiserror('BBERR_FEEGREATERTHANAMOUNT', 13, 1);

                        exec dbo.USP_REVENUE_PAYMENTGIFTFEE_SAVE_2 @ID, @GIFTFEES, @REASONCODEID, @COMMENTS, @CHANGEAGENTID;

                        --update gl distributions 

                        declare @contextCache varbinary(128);
                        set @contextCache = CONTEXT_INFO();
                        if not @CHANGEAGENTID is null
                            set CONTEXT_INFO @CHANGEAGENTID;

                        delete from dbo.GIFTFEEGLDISTRIBUTION where REVENUEID = @ID and OUTDATED = 0;

                        if not @contextCache is null
                            set CONTEXT_INFO @contextCache;

                        declare @POSTSTATUSCODE tinyint;

                        select @POSTSTATUSCODE = case when REVENUE.DONOTPOST = 1 then 2 when REVENUEPOSTED.ID is not null then 0 else 1 end
                        from dbo.REVENUE
                        left join dbo.REVENUEPOSTED on REVENUEPOSTED.ID = REVENUE.ID
                        where 
                            REVENUE.ID = @ID

                        if @POSTSTATUSCODE <> 2
                            exec dbo.USP_SAVE_GIFTFEEGLDISTRIBUTION @ID, @CHANGEAGENTID
                    end try

                    begin catch
                        exec dbo.USP_RAISE_ERROR;
                        return 1;
                    end catch

                    return 0;