31 lines
691 B
SQL
31 lines
691 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketNotInvoicedByClient`(vClientFk INT)
|
|
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 ;
|