USP_DATAFORMTEMPLATE_EDIT_GENERATEEFTFILEPROCESS_1_3

The save procedure used by the edit dataform template "Generate Direct Debit File Process Edit Form 1.2".

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN The input ID parameter indicating the ID of the record being edited.
@CHANGEAGENTID uniqueidentifier IN Input parameter indicating the ID of the change agent invoking the procedure.
@NAME nvarchar(100) IN Name
@DESCRIPTION nvarchar(255) IN Description
@DATETYPECODE tinyint IN Financial processing date
@DATE datetime IN Specific date
@SPONSORINGINSTITUTIONID uniqueidentifier IN Sponsoring institution
@BANKACCOUNTID uniqueidentifier IN Bank account
@IMMEDIATEDESTINATIONNAME nvarchar(23) IN Immediate destination
@CREATECREDITOFFSETTRANSACTION bit IN Create credit offset transaction
@BATCHID uniqueidentifier IN Batch number
@IDSETREGISTERID uniqueidentifier IN Selection
@CUTOFFDATE datetime IN Specific date
@BATCHTEMPLATEID uniqueidentifier IN Payment batch design
@TRANSACTIONTYPECODE tinyint IN Transaction types
@OWNERID uniqueidentifier IN Payment batch owner
@DUEDATETYPECODE tinyint IN Payments due on or before
@DAYSAFTER int IN Days after
@FINDAYSAFTER int IN Days after
@CONSOLIDATEPAYMENTS bit IN Consolidate multiple commitments to a single payment by constituent
@CURRENTAPPUSERID uniqueidentifier IN Input parameter indicating the ID of the current user.
@SITEID uniqueidentifier IN Site

Definition

Copy

                    CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_GENERATEEFTFILEPROCESS_1_3
                    (
                        @ID uniqueidentifier,
                        @CHANGEAGENTID uniqueidentifier = null,                
                        @NAME nvarchar(100), 
                        @DESCRIPTION nvarchar(255),
                        @DATETYPECODE tinyint,
                        @DATE datetime,
                        @SPONSORINGINSTITUTIONID uniqueidentifier,
                        @BANKACCOUNTID uniqueidentifier,
                        @IMMEDIATEDESTINATIONNAME nvarchar(23),
                        @CREATECREDITOFFSETTRANSACTION bit,
                        @BATCHID uniqueidentifier,
                        @IDSETREGISTERID uniqueidentifier,
                        @CUTOFFDATE datetime,
                        @BATCHTEMPLATEID uniqueidentifier,
                        @TRANSACTIONTYPECODE tinyint,
                        @OWNERID uniqueidentifier,
                        @DUEDATETYPECODE tinyint,
                        @DAYSAFTER integer,
                        @FINDAYSAFTER integer,
                        @CONSOLIDATEPAYMENTS bit,
                        @CURRENTAPPUSERID uniqueidentifier,
                        @SITEID uniqueidentifier
                    )
                    as

                    set nocount on;

                    declare @CURRENTDATE datetime;                                        

                    if @ID is null
                        set @ID = NewID();

                    if @CHANGEAGENTID is null  
                        exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;

                    set @CURRENTDATE = GetDate();

                    begin try
                        if (@SITEID is not null
                        begin
                            if dbo.UFN_SITEALLOWEDFORUSER(@CURRENTAPPUSERID, @SITEID) = 0 
                            begin
                                raiserror ('ERR_SITE_NOACCESS',13,1);
                                return 1;
                            end
                        end

                        update 
                            dbo.GENERATEEFTFILEPROCESS
                        set
                            NAME = @NAME,
                            DESCRIPTION = @DESCRIPTION,
                            DATETYPECODE = @DATETYPECODE,
                            DATE = @DATE,
                            BATCHID = @BATCHID,
                            SPONSORINGINSTITUTIONID = @SPONSORINGINSTITUTIONID,
                            BANKACCOUNTID = @BANKACCOUNTID,
                            IMMEDIATEDESTINATIONNAME = @IMMEDIATEDESTINATIONNAME,
                            CREATECREDITOFFSETTRANSACTION = @CREATECREDITOFFSETTRANSACTION,
                            CHANGEDBYID = @CHANGEAGENTID,
                            DATECHANGED = @CURRENTDATE,
                            IDSETREGISTERID = @IDSETREGISTERID,
                            CUTOFFDATE = @CUTOFFDATE,
                            BATCHTEMPLATEID = @BATCHTEMPLATEID,
                            TRANSACTIONTYPECODE = @TRANSACTIONTYPECODE,
                            OWNERID = @OWNERID,
                            DUEDATETYPECODE = @DUEDATETYPECODE,
                            DAYSAFTER = @DAYSAFTER,
                            FINDAYSAFTER = @FINDAYSAFTER,
                            CONSOLIDATEPAYMENTS = @CONSOLIDATEPAYMENTS
                        where
                            ID = @ID;

                        update dbo.BUSINESSPROCESSINSTANCE set 
                            SITEID = @SITEID,
                            CHANGEDBYID = @CHANGEAGENTID,
                            DATECHANGED = @CURRENTDATE
                        where BUSINESSPROCESSINSTANCE.BUSINESSPROCESSPARAMETERSETID = @ID
                            and BUSINESSPROCESSINSTANCE.BUSINESSPROCESSCATALOGID = 'B7974F4F-60D8-4DF5-AD5B-7B1839ABE16A'
                            and (BUSINESSPROCESSINSTANCE.SITEID <> @SITEID 
                                or BUSINESSPROCESSINSTANCE.SITEID is null and @SITEID is not null 
                                or BUSINESSPROCESSINSTANCE.SITEID is not null and @SITEID is null);
                    end try

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

                    return 0;