feat: refs #7564 Requested changes
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
2f8df96ba7
commit
7fc47f0506
|
@ -16,17 +16,14 @@ BEGIN
|
||||||
JOIN ticket t ON t.id = s.ticketFk
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
JOIN itemCost ic ON ic.itemFk = s.itemFk
|
JOIN itemCost ic ON ic.itemFk = s.itemFk
|
||||||
AND ic.warehouseFk = t.warehouseFk
|
AND ic.warehouseFk = t.warehouseFk
|
||||||
WHERE t.id IN (
|
WHERE s.itemFk = vItemFk
|
||||||
SELECT DISTINCT ticketFk
|
AND t.shipped >= util.VN_CURDATE()
|
||||||
FROM sale
|
|
||||||
WHERE itemFk = vItemFk
|
|
||||||
)
|
|
||||||
GROUP BY t.id;
|
GROUP BY t.id;
|
||||||
|
|
||||||
UPDATE ticket t
|
UPDATE ticket t
|
||||||
JOIN tTicket tt ON tt.id = t.id
|
JOIN tTicket tt ON tt.id = t.id
|
||||||
SET t.volume = tt.volume;
|
SET t.volume = tt.volume;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tTicket;
|
DROP TEMPORARY TABLE tTicket;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
-- Calculamos todos los volumenes de todos los tickets una sola vez
|
||||||
|
CREATE OR REPLACE TEMPORARY TABLE tTicketVolume
|
||||||
|
(PRIMARY KEY (id))
|
||||||
|
ENGINE = MEMORY
|
||||||
|
SELECT t.id, SUM(s.quantity * ic.cm3delivery / 1000000) volume
|
||||||
|
FROM sale s
|
||||||
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
|
JOIN itemCost ic ON ic.itemFk = s.itemFk
|
||||||
|
AND ic.warehouseFk = t.warehouseFk
|
||||||
|
GROUP BY t.id;
|
||||||
|
|
||||||
|
UPDATE ticket t
|
||||||
|
JOIN tTicketVolume tv ON tv.id = t.id
|
||||||
|
SET t.volume = tv.volume;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE tTicketVolume;
|
Loading…
Reference in New Issue