USP_DATAFORMTEMPLATE_EDIT_AUCTIONPURCHASEGLDISTRIBUTION
The save procedure used by the edit dataform template "Auction Purchase GL Distribution Edit Data Form".
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. |
@GLDISTRIBUTION | xml | IN | Revenue GL distribution |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_AUCTIONPURCHASEGLDISTRIBUTION (
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@GLDISTRIBUTION xml
)
as
set nocount on;
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()
begin try
if (dbo.UFN_GLDISTRIBUTION_DEBITSEQUALCREDITS(@GLDISTRIBUTION) = 0)
begin
if (select sum(case transactiontypecode when 1 then -1 * AMOUNT else AMOUNT end)
from dbo.UFN_REVENUE_GETGLDISTRIBUTION_FROMITEMLISTXML(@GLDISTRIBUTION)) != 0
raiserror('The sum of the debit accounts must equal the sum of the credit accounts.', 13, 1)
end
--if (dbo.UFN_GLDISTRIBUTION_ACCOUNTEXISTS(@GLDISTRIBUTION) = 0)
-- raiserror('One or more of the edited accounts do not exist.', 13, 1)
if (dbo.UFN_GLDISTRIBUTION_ACCOUNTEXISTS_2(@GLDISTRIBUTION,@ID) = 0)
raiserror('One or more of the edited accounts do not exist.', 13, 1)
declare @POSTDATE datetime;
select @POSTDATE = POSTDATE from dbo.REVENUE where ID = @ID;
set @GLDISTRIBUTION = dbo.UFN_GLDISTRIBUTION_AUCTIONPURCHASE_CONVERTAMOUNTSINXML(@GLDISTRIBUTION,@ID);
exec dbo.USP_REVENUE_GETAUCTIONPURCHASEGLDISTRIBUTION_CUSTOMUPDATEFROMXML_2 @ID, @GLDISTRIBUTION, @POSTDATE, @CHANGEAGENTID;
end try
begin catch
exec dbo.USP_RAISE_ERROR
return 1
end catch
return 0;