Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix into 7565-testToMaster
gitea/salix/pipeline/pr-master This commit looks good
Details
gitea/salix/pipeline/pr-master This commit looks good
Details
This commit is contained in:
commit
282cf96336
|
@ -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 ;
|
||||
|
|
Loading…
Reference in New Issue