DROP PROC op_aumentarnrodocumento
GO

CREATE PROC op_aumentarnrodocumento
@DOCTYPEID ud_doctypeid,
@NBRSERIES numeric(3,0),
@SITEID	ud_idsite,
@SALESPOINT ud_ptovta,
@NBRDOC NUMERIC(7)
as

BEGIN TRAN

	update OP_DOCSERIES set NBRDOC =@NBRDOC +1
	where DOCTYPEID=@DOCTYPEID AND  NBRSERIES=@NBRSERIES AND  SITEID=@SITEID

	 IF (@@error!=0)
	    BEGIN
	        RAISERROR  20000 'OP_GRABARVENTASCTORE: Error al Grabar Transaccion'
	        ROLLBACK TRAN
	        RETURN(1)    
	    END

	update OP_SALESPOINTSETTING set BATNBRSALES = BATNBRSALES+1  
	where SALESPOINT=@SALESPOINT

	 IF (@@error!=0)
	    BEGIN
	        RAISERROR  20000 'OP_GRABARVENTASCTORE: Error al Grabar Transaccion'
	        ROLLBACK TRAN
	        RETURN(1)    
	    END

    COMMIT TRAN   

RETURN (0)   

go

