
CREATE PROCEDURE [dbo].[sp_VenFoliosCajaCheckFolioOffline]
    @folio INT,
    @sucursal INT,
    @caja INT,
	@tipoDoc INT,
    @isValid BIT OUTPUT
AS
BEGIN
    SET NOCOUNT ON;

    IF EXISTS (
        SELECT 1
        FROM venfolioscaja 
        WHERE folioini <= @folio 
        AND foliofin >= @folio 
        AND sucursal = @sucursal 
        AND CAJA = @caja
		AND tipoDoc = @tipoDoc 
    )
    BEGIN
        SET @isValid = 1;
    END
    ELSE
    BEGIN
        SET @isValid = 0;
    END
END;
