DROP PROC VENTASCOMBUSTIBLE_PROC
GO
CREATE PROC VENTASCOMBUSTIBLE_PROC
( @SITEID	UD_IDSITE,
  @DATEPROCE	UD_FECHA 
)
AS

BEGIN 
	DECLARE @CODCATFUEL	UD_CATEGORY
	SET @CODCATFUEL=(SELECT CATEGORYFUEL FROM OP_SETUP)

	SELECT S.SITEID,S.INVTIDSKU AS CODIGO,A.DESCR AS Descripcion,SUM(S.QTY) AS Gal_Vendidos,S.SLSPRICESALE AS Precio_Gal,SUM(S.TOTALPEN) AS Monto FROM OP_SALESDET AS S JOIN IN_INVENTORY AS A
	ON S.INVTIDSKU=A.INVTIDSKU
	WHERE A.CLASSID=@CODCATFUEL AND SITEID=@SITEID AND DATEPROCESALES=@DATEPROCE AND S.DOCSTATUSID<>'AN'
	GROUP BY S.SITEID,S.INVTIDSKU,A.DESCR,S.SLSPRICESALE
	ORDER BY S.SITEID,S.INVTIDSKU

END

