2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` PROCEDURE `vn`.`ticketNotInvoicedByClient`(vClientFk INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
|
|
|
|
|
|
|
|
CREATE TEMPORARY TABLE tmp.ticket
|
|
|
|
SELECT id ticketFk
|
|
|
|
FROM ticket
|
|
|
|
WHERE refFk IS NULL
|
|
|
|
AND clientFk = vClientFk
|
|
|
|
AND shipped > '2001-01-01';
|
|
|
|
|
|
|
|
CALL vn.ticketGetTotal(NULL);
|
|
|
|
|
|
|
|
SELECT c.id,
|
|
|
|
c.name as Cliente,
|
|
|
|
t.shipped as Fecha,
|
|
|
|
t.id as Id_Ticket,
|
|
|
|
CAST(tt.total AS DECIMAL(10,2)) as Importe
|
|
|
|
FROM tmp.ticketTotal tt
|
|
|
|
JOIN ticket t ON t.id = tt.ticketFk
|
|
|
|
JOIN client c ON c.id = t.ClientFk;
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE
|
|
|
|
tmp.ticket,
|
|
|
|
tmp.ticketTotal;
|
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|