
ALTER   PROCEDURE [dbo].[sp_invDetalle]
(
@coddoc int,
@numinv int
)	
AS 
	SELECT  D.numlin, D.codbus, D.nomart, U.abruni, D.cantidad, D.canalt, D.preuni, D.preuniadi, D.pretot, 
			D.pretotadi, D.fecent, D.glolin, D.numlinorden, D.nomart AS nomprod, D.salcan,
			porcdescuento, descuento, tip_impadi, porcadicional, adicional,codcen,codana,'' as checkglolin
            ,item,saldoGral,stockGral,D.costo,D.fechacosto,costobodega,COALESCE(stockBodega,0) AS stockBodega
	,stockBodegaOrigen,stockBodegaDes,stockGralOrigen, stockGralDestino, stockBodega,exento,A.codfam,A.codsub,A.codart,A.coduni, D.idLinea,codbod
	FROM            invUnidadMedida AS U INNER JOIN
                         invArticulos AS A ON U.coduni = A.coduni INNER JOIN
                         invFamilia ON A.codfam = invFamilia.codfam RIGHT OUTER JOIN
                         invDetalle AS D ON A.codbus = D.codbus
	WHERE     D.coddoc = @coddoc
	AND 	  D.numinv = @numinv
	ORDER BY 1