USP_DATAFORMTEMPLATE_EDIT_RECEIPTINGPROCESSMARKFORRERECEIPT
The save procedure used by the edit dataform template "ReceiptingProcessMarkForReReceipt 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. |
@RERECEIPTREASONCODEID | uniqueidentifier | IN | Reason |
@DETAILS | nvarchar(300) | IN | Details |
@NEWNUMBERONRERECEIPT | bit | IN | Generate a new receipt number? |
Definition
Copy
CREATE procedure dbo.USP_DATAFORMTEMPLATE_EDIT_RECEIPTINGPROCESSMARKFORRERECEIPT
(
@ID uniqueidentifier,
@CHANGEAGENTID uniqueidentifier = null,
@RERECEIPTREASONCODEID uniqueidentifier,
@DETAILS nvarchar(300),
@NEWNUMBERONRERECEIPT bit
)
as
set nocount on;
declare @REVENUERECEIPTID uniqueidentifier = null
if @CHANGEAGENTID is null
exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output
declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()
begin try
update
REVENUE_EXT
set
NEEDSRERECEIPT = 1,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CURRENTDATE
from dbo.REVENUE_EXT
join dbo.REVENUERECEIPT RR on RR.REVENUEID = REVENUE_EXT.ID
where
RR.RECEIPTINGPROCESSSTATUSID = @ID --and REVENUE_EXT.RECEIPTTYPECODE=0--payment;
update dbo.REVENUERECEIPTRERECEIPTDETAIL
set
RERECEIPTREASONCODEID = @RERECEIPTREASONCODEID,
NEWNUMBERONRERECEIPT = @NEWNUMBERONRERECEIPT,
DETAILS = @DETAILS,
CHANGEDBYID = @CHANGEAGENTID,
DATECHANGED = @CURRENTDATE
where
REVENUERECEIPTID in (select ID from REVENUERECEIPT where RECEIPTINGPROCESSSTATUSID = @ID)
insert into dbo.REVENUERECEIPTRERECEIPTDETAIL (ID, REVENUERECEIPTID, RERECEIPTREASONCODEID, NEWNUMBERONRERECEIPT, DETAILS, ADDEDBYID, CHANGEDBYID, DATEADDED, DATECHANGED)
select newid(), RR.ID, @RERECEIPTREASONCODEID, @NEWNUMBERONRERECEIPT, @DETAILS, @CHANGEAGENTID, @CHANGEAGENTID, @CURRENTDATE, @CURRENTDATE
from dbo.REVENUERECEIPT RR where RR.RECEIPTINGPROCESSSTATUSID = @ID and
not exists (select * from dbo.REVENUERECEIPTRERECEIPTDETAIL where REVENUERECEIPTID = RR.ID)
end try
begin catch
exec dbo.USP_RAISE_ERROR
return 1
end catch
return 0;