DROP PROCEDURE ValidaPreciosEnListaPrecioClientesProc
GO
CREATE PROCEDURE ValidaPreciosEnListaPrecioClientesProc
(	@CORRNBR	INT,
	@CURYID		UD_CURYID
)
AS
BEGIN
	DECLARE @MONEDABASE 	UD_CURYID
      	SET @MONEDABASE =(SELECT CURYORIG FROM SETUP) 

	IF(@CURYID=@MONEDABASE)
	BEGIN
		SELECT TMP_OP_PRCLVLCUSTDET.SITEID as Almacen,TMP_OP_PRCLVLCUSTDET.INVTIDSKU as Codigo,DESCR as Descripcion,STDCOSTPEN AS Costo,SLS_PRICECUST as Precio
		FROM TMP_OP_PRCLVLCUSTDET JOIN IN_INVENTORYDAT
		ON TMP_OP_PRCLVLCUSTDET.SITEID=IN_INVENTORYDAT.SITEID AND TMP_OP_PRCLVLCUSTDET.INVTIDSKU=IN_INVENTORYDAT.INVTIDSKU 
		WHERE (SLS_PRICECUST<=0 OR SLS_PRICECUST<STDCOSTPEN) AND CORRNBR=@CORRNBR
	END 
	ELSE
	BEGIN
		SELECT TMP_OP_PRCLVLCUSTDET.SITEID as Almacen,TMP_OP_PRCLVLCUSTDET.INVTIDSKU as Codigo,DESCR as Descripcion,STDCOSTUSD AS Costo,SLS_PRICECUST as Precio
		FROM TMP_OP_PRCLVLCUSTDET JOIN IN_INVENTORYDAT
		ON TMP_OP_PRCLVLCUSTDET.SITEID=IN_INVENTORYDAT.SITEID AND TMP_OP_PRCLVLCUSTDET.INVTIDSKU=IN_INVENTORYDAT.INVTIDSKU 
		WHERE (SLS_PRICECUST<=0 OR SLS_PRICECUST<STDCOSTUSD) AND CORRNBR=@CORRNBR

	END 
END 

