USP_GLACCOUNTCODE_ADD
The save procedure used by the add dataform template "Account Code Add Form".
Parameters
Parameter | Parameter Type | Mode | Description |
---|---|---|---|
@ID | uniqueidentifier | INOUT | The output parameter indicating the ID of the record added. |
@CHANGEAGENTID | uniqueidentifier | IN | Input parameter indicating the ID of the change agent invoking the procedure. |
@SHORTID | nvarchar(100) | IN | ID |
@DESCRIPTION | nvarchar(60) | IN | Description |
@ACTIVE | bit | IN | Active |
@CONTRAACCOUNT | bit | IN | Contra account |
@CASHFLOW | uniqueidentifier | IN | Cash Flow |
@WORKINGCAPITAL | uniqueidentifier | IN | Working Capital |
@CATEGORYCODE | tinyint | IN | Category |
@SUBCATEGORYCODE | tinyint | IN | Subcategory |
Definition
Copy
CREATE procedure [dbo].[USP_GLACCOUNTCODE_ADD]
(
@ID uniqueidentifier = null output,
@CHANGEAGENTID uniqueidentifier = null,
@SHORTID nvarchar(100) = '',
@DESCRIPTION nvarchar(60) = '',
@ACTIVE bit = null,
@CONTRAACCOUNT bit = null,
@CASHFLOW uniqueidentifier = null,
@WORKINGCAPITAL uniqueidentifier = null,
@CATEGORYCODE tinyint = 0,
@SUBCATEGORYCODE tinyint = 0
)
as
set nocount on;
if @ID is null
set @ID = newid()
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()
declare @PDACCOUNTSYSTEMID uniqueidentifier = '4B121C2C-CCE6-440D-894C-EA0DEF80D50B'
declare @GLACCOUNTSTRUCTUREID uniqueidentifier
select @GLACCOUNTSTRUCTUREID = ID from dbo.PDACCOUNTSTRUCTURE WHERE ELEMENTDEFINITIONCODE = 1 and PDACCOUNTSYSTEMID = @PDACCOUNTSYSTEMID and ISBASICGL = 0
begin try
begin transaction
--Populate the accounting element table first for common fields
exec dbo.USP_DATAELEMENT_ADD @ID output, @SHORTID, @DESCRIPTION, 1, 0,null,null,0,null,null, @GLACCOUNTSTRUCTUREID, @CHANGEAGENTID
-- Set the Active Flag
Update dbo.PDACCOUNTSEGMENTVALUE Set IsActive = @ACTIVE Where ID = @ID
insert into dbo.ACCOUNTCODE
(ID, CONTRAACCOUNT, CASHFLOWCODEID, WORKINGCAPITALCODEID, CATEGORYCODE,SUBCATEGORYCODE, ADDEDBYID, CHANGEDBYID, DATEADDED, DATECHANGED)
values
(@ID, @CONTRAACCOUNT, @CASHFLOW, @WORKINGCAPITAL, @CATEGORYCODE, isnull(@SUBCATEGORYCODE,0), @CHANGEAGENTID, @CHANGEAGENTID, @CURRENTDATE, @CURRENTDATE);
commit transaction
end try
begin catch
exec dbo.USP_RAISE_ERROR
return 1
end catch
return 0