7565-testToMaster #2567

Merged
alexm merged 250 commits from 7565-testToMaster into master 2024-06-11 06:31:18 +00:00
1 changed files with 8 additions and 6 deletions
Showing only changes of commit 282cf96336 - Show all commits

View File

@ -1,5 +1,5 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sales_merge`(vTicketFk INT)
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sales_merge`(vTicketFk INT)
BEGIN
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
@ -8,19 +8,21 @@ BEGIN
END;
CREATE OR REPLACE TEMPORARY TABLE tSalesToPreserve
(PRIMARY KEY (id))
ENGINE = MEMORY
SELECT s.id, s.itemFk, SUM(s.quantity) newQuantity
FROM sale s
JOIN item i ON i.id = s.itemFk
JOIN itemType it ON it.id = i.typeFk
WHERE s.ticketFk = vTicketFk
AND it.isMergeable
GROUP BY s.itemFk, s.price, s.discount;
GROUP BY s.itemFk, s.price, s.discount;
START TRANSACTION;
UPDATE sale s
JOIN tSalesToPreserve stp ON stp.id = s.id
SET quantity = newQuantity
SET s.quantity = newQuantity
WHERE s.ticketFk = vTicketFk;
DELETE s.*
@ -35,5 +37,5 @@ BEGIN
COMMIT;
DROP TEMPORARY TABLE tSalesToPreserve;
END$$
DELIMITER ;
END$$
DELIMITER ;