ALTER PROCEDURE [dbo].[sp_invDetalle_Solicitud]
(
@coddoc int,
@numinv int
)
AS
	SELECT    D.numlin, 
				D.codbus, 
				D.nomart, 
				U.abruni, 
				D.cantidad, 
				D.preuni, 
				D.preuniadi, 
				D.pretot, 
				D.pretotadi, 
				D.fecent, 
				D.glolin, 
				D.numlinorden,
				D.canalt,
				D.salcan,
			0.000 AS porcdescuento,0.000 AS descuento,0 AS tip_impadi, 0 AS porcadicional,0 AS adicional, D.codcen AS codcen,
			D.codana AS codana,'' as checkglolin ,d.item, D.unialt
			,saldoGral,stockGral,D.costo,D.fechacosto,COALESCE(stockBodega,0) AS stockBodega
	,stockBodegaOrigen,stockBodegaDes,stockGralOrigen, stockGralDestino, stockBodega,exento,A.codfam,A.codsub,A.codart,A.coduni, D.idLinea
	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     A.codbus = D.codbus 
	AND	  A.coduni = U.coduni
	AND	  D.coddoc = @coddoc
	AND   D.numinv = @numinv
	--AND   D.salcan > 0
	ORDER BY 1