7983-testToMaster_2438 #2977

Merged
alexm merged 212 commits from 7983-testToMaster_2438 into master 2024-09-17 05:36:47 +00:00
2 changed files with 19 additions and 6 deletions
Showing only changes of commit 7fc47f0506 - Show all commits

View File

@ -16,11 +16,8 @@ BEGIN
JOIN ticket t ON t.id = s.ticketFk
JOIN itemCost ic ON ic.itemFk = s.itemFk
AND ic.warehouseFk = t.warehouseFk
WHERE t.id IN (
SELECT DISTINCT ticketFk
FROM sale
WHERE itemFk = vItemFk
)
WHERE s.itemFk = vItemFk
AND t.shipped >= util.VN_CURDATE()
GROUP BY t.id;
UPDATE ticket t

View File

@ -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;