
Create PROCEDURE [dbo].[sp_VenEncabezadoFolioOfflineRead]
    @sucursal INT,
    @caja INT,
    @codsii INT,
    @folio INT OUTPUT
AS
BEGIN
    SET NOCOUNT ON;

    SELECT @folio = ISNULL(MAX(NUMINV), 0) + 1
    FROM VENENCABEZADO 
    WHERE codloc = @sucursal 
    AND CAJA = @caja 
    AND codsii = @codsii;
END;
