SP_HELPTEXT  OP_GRABARVENTACSTORE 


 OP_GRABARVENTACSTORE 505501,'01 ','10021708','14',1,'76   ','PEN','00',
		'43644150            ','SYSADMIN','02/01/2007','08/06/2007','','',1300,
		411.39,1092.44,345.71,207.56,65.68,0,0,0,0,0,0,0,0,0,0,0,0,
		1300,0,'20135406245','20135406245','MINAS ARIRAHUAA S.A.','',0,
		'TCONV ',3.16,'',0,'PTOVTA04',0,'1','M', 1,2

SELECT * FROM OP_SALES

SELECT * FROM OP_BONUS
WHERE CUSTIDSS = '20135406245' AND NBRBONUS IN ('701','702','703','704','705','706','707','708','709','710','711')

SELECT * FROM TMP_OP_BONUS

DELETE  FROM OP_BONUS
WHERE CUSTIDSS = '20135406245' AND NBRBONUS IN ('701','702','703','704','705','706','707','708','709','710','711')

SELECT * FROM OP_SALES

SELECT * FROM OP_SALESTMP

SELECT * FROM OP_SALESVALEDET

SELECT * FROM OP_SALES

SELECT * FROM TMP_OP_BONUS

SELECT * FROM OP_BONUS


DELETE FROM OP_DOCANTI

SELECT * FROM OP_DOCANTI

---------------------
SELECT * FROM TMP_OP_BONUS
WHERE CUSTIDSS = '20135406245' AND NBRBONUS IN ('701','702','703','704','705','706','707','708','709','710','711')

SELECT * FROM OP_BONUS
WHERE CUSTIDSS = '20135406245' AND NBRBONUS IN ('701','702','703','704','705','706','707','708','709','710','711')

SELECT * FROM OP_SALES WHERE NBRDOCUMENT = 10021714
SELECT * FROM OP_SALESDET WHERE NBRDOCUMENT = 10021714


SELECT * FROM OP_DOCANTI WHERE NBRDOCUMENT = 10021714
---------------------

SP_HELPTEXT OP_Verificar_ExisteVale

SELECT * FROM TMP_OP_BONUS

DELETE FROM OP_BONUS 
WHERE CUSTIDSS = '20135406245' AND NBRBONUS IN ('701','702','703','704','705','706','707','708','709','710','711')


SP_HELPTEXT OP_GrabarValesProc

 OP_GRABARVENTACSTORE 505509,'01 ','10021714','14',1,'76   ','PEN','00','43644150            ','SYSADMIN','02/01/2007','08/06/2007','','',1200,379.75,1008.4,319.12,191.6,60.63,0,0,0,0,0,0,0,0,0,0,0,0,1200,0,'20135406245','20135406245','MINAS ARIRAHUAA S.A.','',0,'TCONV ',3.16,'',0,'PTOVTA04',0,'1','M', 1,1


 SELECT * FROM OP_BONUS WHERE CUSTIDSS = '20135406245' AND  NBRBONUS = 702


sp_helptext OP_GrabarTmp_Op_BonusProc

DELETE  from TMP_OP_BONUS WHERE NBRBONUS = 705

select * from OP_BONUS

select * from tmp_OP_BONUS

Select SEQUENCE,INVTIDSKU,DESCRINVENTORY,QTY,SLS_PRICE,SLSPRICESALE,TOTALPEN,TOTALUSD  FROM  TMP_OP_SALESDET WHERE CORRNBR=505538


SELECT custidss, NBRBONUS AS [Número_de_Orden_C],MONTOBONUS AS [Monto_de_Orden_C] FROM TMP_OP_BONUS WHERE CORRNBR=505536

SP_HELPTEXT OP_GrabarTmp_Op_BonusProc

sp_helptext OP_EliminarTmp_Op_AdelantoProc


SELECT * FROM TMP_OP_SALES

DELETE FROM TMP_OP_BONUS
WHERE CUSTIDSS = '20135406245' AND NBRBONUS IN ('701','702','703','704','705','706','707','708','709','710','711')


ALTER PROCEDURE OP_GrabarTmp_Op_BonusProc    
(@CORRNBR   INT,    
 @CUSTIDSS  UD_CODCLIENT,    
 @NBRBONUS  NUMERIC(10),    
 @MONTOVALE DECIMAL(10,2))    
as    
BEGIN    
    
   DECLARE @SITEID UD_IDSITE       
    
   SELECT @SITEID=SOURCESITE FROM SETUP       
    
   BEGIN TRAN    
        
   INSERT INTO TMP_OP_BONUS(CORRNBR,CUSTIDSS,SITEID,NBRBONUS,MONTOBONUS,stkmodify,stknew,stksend,stkdelete,stkreceive)              
               VALUES (@CORRNBR,@CUSTIDSS,@SITEID,@NBRBONUS,@MONTOVALE,0,0,0,0,0)     
        
   IF (@@error!=0 or @@rowcount=0)                    
      BEGIN    
         RAISERROR  20000 'No se pudo registrar Vale'     
         ROLLBACK TRAN    
         RETURN(1)        
      END      
    
   COMMIT TRAN        
       
END    


SELECT * FROM OP_BONUS

SELECT * FROM TMP_OP_SALESDET

SELECT * FROM OP_SALES ORDER BY DOCTYPEID,NBRDOCUMENT DESC

SELECT * FROM OP_DOCUMENTFREEDET

SP_HELPTEXT OP_GrabarValesProc


SELECT * FROM TMP_OP_SALESDET


 CABECERA_PLAYA_CIERREX_PROC 1,'08/06/2007','PTOVTA04'
