DROP PROCEDURE OP_MostrarCabeceraVentas
GO 
CREATE PROCEDURE OP_MostrarCabeceraVentas 
(@SITEID	UD_IDSITE,
 @NBRDOCUMENT  UD_CORRELATIVOS
) 
as
BEGIN
	DECLARE @DOCTYPEIDTICKET UD_DOCTYPEID
	SET @DOCTYPEIDTICKET =(SELECT DOCTYPEIDTICKET FROM OP_SETUP)

	SELECT S.DOCTYPEID,D.DESCR AS DESCDOC,S.NBRDOCUMENT,S.SITEID,S.TYPEPAYMENTID,S.CURYID,S.DOCSTATUSID,
	V.SALESPERNAME,S.DATEDOC,S.DATEPROCESALES,S.TOTALPEN,S.TOTALUSD,S.SUBTOTALPEN,S.SUBTOTALUSD,
	S.TAXIGVPEN,S.TAXIGVUSD,S.TAXISCPEN,S.TAXISCUSD,S.TOTALNOTAFFECTPEN,S.TOTALNOTAFFECTUSD,
	S.PORCENTDISCOUNT1,S.PORCENTDISCOUNT2,S.TOTDISCOUNTPEN,S.TOTDISCOUNTUSD,S.TOTRETURNEDPEN,
	S.TOTRETURNEDUSD,S.TOTCASHPEN,S.TOTCASHUSD,S.taxregnbr,S.CUSTNAME,CL.ADDR1,S.PLACA,S.NBRBONUS,
	C.SERIALNUMBER,S.SALESPOINT 
	FROM (((OP_SALES AS S JOIN OP_SALESPOINTSETTING AS C
	ON S.SALESPOINT=C.SALESPOINT) JOIN OP_SALESPERSON AS V
	ON S.SALESPERID=V.SALESPERID) LEFT JOIN CUSTOMER AS CL
	ON S.CUSTIDSS=CL.CUSTIDSS) JOIN DOCTYPE AS D
	ON S.DOCTYPEID=D.DOCTYPEID
	WHERE S.DOCTYPEID=@DOCTYPEIDTICKET AND S.NBRDOCUMENT=@NBRDOCUMENT AND S.SITEID=@SITEID

END
