#7896 - 24.36 Dev To Test #2884
|
@ -14,16 +14,28 @@ BEGIN
|
||||||
DECLARE vTicketFk INT;
|
DECLARE vTicketFk INT;
|
||||||
|
|
||||||
DECLARE cTickets CURSOR FOR
|
DECLARE cTickets CURSOR FOR
|
||||||
SELECT id FROM ticket
|
SELECT DISTINCT t.id
|
||||||
WHERE refFk IS NULL
|
FROM ticket t
|
||||||
AND ((vScope = 'client' AND clientFk = vId)
|
LEFT JOIN tItems ti ON ti.id = t.id
|
||||||
OR (vScope = 'address' AND addressFk = vId));
|
WHERE t.refFk IS NULL
|
||||||
|
AND ((vScope = 'client' AND t.clientFk = vId)
|
||||||
|
OR (vScope = 'address' AND t.addressFk = vId)
|
||||||
|
OR (vScope = 'item' AND ti.id)
|
||||||
|
);
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
SET vDone = TRUE;
|
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tItems
|
||||||
|
(PRIMARY KEY (id))
|
||||||
|
ENGINE = MEMORY
|
||||||
|
SELECT DISTINCT t.id
|
||||||
|
FROM ticket t
|
||||||
|
JOIN sale s ON s.ticketFk = t.id
|
||||||
|
JOIN itemTaxCountry itc ON itc.itemFk = s.itemFk
|
||||||
|
WHERE t.refFk IS NULL
|
||||||
|
AND (vScope = 'item' AND itc.itemFk = vId);
|
||||||
|
|
||||||
OPEN cTickets;
|
OPEN cTickets;
|
||||||
|
|
||||||
myLoop: LOOP
|
myLoop: LOOP
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
FETCH cTickets INTO vTicketFk;
|
FETCH cTickets INTO vTicketFk;
|
||||||
|
@ -34,7 +46,8 @@ BEGIN
|
||||||
|
|
||||||
CALL ticket_recalc(vTicketFk, NULL);
|
CALL ticket_recalc(vTicketFk, NULL);
|
||||||
END LOOP;
|
END LOOP;
|
||||||
|
|
||||||
CLOSE cTickets;
|
CLOSE cTickets;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tItems;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
Loading…
Reference in New Issue