DROP PROCEDURE IN_ObtieneDetalleDeFormulaProc
GO
CREATE PROCEDURE IN_ObtieneDetalleDeFormulaProc
( @KITID	UD_KITID
)
AS
BEGIN

/****** VARIABLES QUE VIENEN DEL SETUP PARA EL REDONDEO ********************/ 
	DECLARE @ND_COSTOSETUP Tinyint
	DECLARE @ND_STOCKSETUP Tinyint

	SET @ND_COSTOSETUP=(Select Floatcost from setup)
 	SET @ND_STOCKSETUP=(Select Floatqty from setup)	
/*******************************************************************************************************/


	SELECT 	IN_KITCOMPONENT.SEQUENCE AS Registro,IN_KITCOMPONENT.INVTIDSKU AS Codigo,IN_INVENTORY.DESCR AS Descripcion,
			IN_INVENTORY.STKUNITID AS Unidad,IN_KITCOMPONENT.QTY AS Cantidad,IN_KITCOMPONENT.STDCOSTPEN AS Costo_Soles,
			IN_KITCOMPONENT.STDCOSTUSD AS Costo_Dolares,ROUND((IN_KITCOMPONENT.QTY*IN_KITCOMPONENT.STDCOSTPEN),@ND_COSTOSETUP) as Total_Soles,
			ROUND((IN_KITCOMPONENT.QTY*IN_KITCOMPONENT.STDCOSTUSD),@ND_COSTOSETUP) as Total_Dolares
	FROM 		IN_KITCOMPONENT JOIN IN_INVENTORY
	ON		IN_KITCOMPONENT.INVTIDSKU=IN_INVENTORY.INVTIDSKU
	WHERE	IN_KITCOMPONENT.KITID=@KITID
	ORDER BY	IN_KITCOMPONENT.SEQUENCE ASC

END	