feat: refs #7564 Added ticket_setVolumeItemCost
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
1e5fd8002c
commit
2f8df96ba7
|
@ -0,0 +1,32 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setVolumeItemCost`(
|
||||
vItemFk INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Update the volume tickets of item
|
||||
*
|
||||
* @param vSelf Ticket id
|
||||
*/
|
||||
CREATE OR REPLACE TEMPORARY TABLE tTicket
|
||||
(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
|
||||
WHERE t.id IN (
|
||||
SELECT DISTINCT ticketFk
|
||||
FROM sale
|
||||
WHERE itemFk = vItemFk
|
||||
)
|
||||
GROUP BY t.id;
|
||||
|
||||
UPDATE ticket t
|
||||
JOIN tTicket tt ON tt.id = t.id
|
||||
SET t.volume = tt.volume;
|
||||
|
||||
DROP TEMPORARY TABLE tTicket;
|
||||
END$$
|
||||
DELIMITER ;
|
Loading…
Reference in New Issue