 ALTER PROCEDURE IN_CalculaTotalesProc  
( @CURYID  UD_CURYID,  
  @CORRNBR INT)  
AS   
BEGIN  
  
      DECLARE @MONEDABASE  char(3)  
      SET @MONEDABASE =(SELECT CURYORIG FROM SETUP)   
  
/****** VARIABLES QUE VIENEN DEL SETUP PARA EL REDONDEO **************	******/   
 DECLARE @ND_COSTOSETUP Tinyint  
 DECLARE @ND_STOCKSETUP Tinyint  
 DECLARE @ND_RESULTADOSETUP Tinyint  
  
 SET @ND_COSTOSETUP=(Select Floatcost from setup)  
  SET @ND_STOCKSETUP=(Select Floatqty from setup)  
 SET @ND_RESULTADOSETUP=(Select Floatoutput from setup)  
/*******************************************************************************************************/  
  
   IF @CURYID=@MONEDABASE  
      SELECT SUM(ROUND(STDCOSTPEN*QTY,@ND_RESULTADOSETUP)) AS VALVENTA,   
      ROUND(SUM(ROUND(STDCOSTPEN*QTY,@ND_RESULTADOSETUP)*TAXIGV/100),@ND_RESULTADOSETUP) AS IGV,
      SUM(ROUND(INTPERCPEN,@ND_RESULTADOSETUP)) AS PERCEPCION
      FROM TMP_IN_INTRAITEM  
      WHERE CORRNBR=@CORRNBR  
   ELSE  
      SELECT SUM(ROUND(STDCOSTUSD*QTY,@ND_RESULTADOSETUP)) AS VALVENTA,   
      ROUND(SUM(ROUND(STDCOSTUSD*QTY,@ND_RESULTADOSETUP)*TAXIGV/100),@ND_RESULTADOSETUP) AS IGV  ,
      SUM(ROUND(INTPERCUSD,@ND_RESULTADOSETUP)) AS PERCEPCION
      FROM TMP_IN_INTRAITEM  
      WHERE CORRNBR=@CORRNBR  
END  
