2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sale_PriceFix`(vTicketFk INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
|
|
|
|
DELETE sc.*
|
|
|
|
FROM vn.saleComponent sc
|
|
|
|
JOIN vn.sale s ON s.id = sc.saleFk
|
|
|
|
JOIN vn.component c ON c.id = sc.componentFk
|
|
|
|
JOIN vn.componentType ct ON ct.id = c.typeFk
|
|
|
|
WHERE s.ticketFk = vTicketFk
|
2024-07-01 09:11:16 +00:00
|
|
|
AND ct.code = 'other';
|
2024-01-15 11:31:03 +00:00
|
|
|
|
|
|
|
UPDATE vn.sale s
|
|
|
|
JOIN (
|
|
|
|
SELECT sc.saleFk, sum(sc.value ) price
|
|
|
|
FROM vn.saleComponent sc
|
|
|
|
JOIN vn.sale s ON s.id = sc.saleFk
|
|
|
|
WHERE s.ticketFk = vTicketFk
|
|
|
|
GROUP BY sc.saleFk) sub ON sub.saleFk = s.id
|
|
|
|
SET s.price = sub.price;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|