2024-07-02 07:36:23 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setVolume`(
|
|
|
|
vSelf INT
|
|
|
|
)
|
|
|
|
BEGIN
|
|
|
|
/**
|
2024-09-17 10:10:47 +00:00
|
|
|
* Update the volume ticket.
|
2024-07-02 07:36:23 +00:00
|
|
|
*
|
|
|
|
* @param vSelf Ticket id
|
|
|
|
*/
|
|
|
|
DECLARE vVolume DECIMAL(10,6);
|
|
|
|
|
|
|
|
SELECT SUM(s.quantity * ic.cm3delivery / 1000000) INTO vVolume
|
|
|
|
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 = vSelf;
|
|
|
|
|
|
|
|
UPDATE ticket
|
|
|
|
SET volume = vVolume
|
|
|
|
WHERE id = vSelf;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|