8267-devToTest #3270

Merged
alexm merged 131 commits from 8267-devToTest into test 2024-12-03 12:18:21 +00:00
1 changed files with 16 additions and 11 deletions
Showing only changes of commit 031c4398ae - Show all commits

View File

@ -18,7 +18,7 @@ BEGIN
DECLARE vDefaultPackingType VARCHAR(1); DECLARE vDefaultPackingType VARCHAR(1);
DECLARE vHasOriginalPackingType BOOLEAN; DECLARE vHasOriginalPackingType BOOLEAN;
DECLARE vNewTicketFk INT; DECLARE vNewTicketFk INT;
DECLARE vThrowAway INT; DECLARE vTicketFk INT;
DECLARE vItemPackingTypes CURSOR FOR DECLARE vItemPackingTypes CURSOR FOR
SELECT DISTINCT itemPackingTypeFk FROM tSalesToMove; SELECT DISTINCT itemPackingTypeFk FROM tSalesToMove;
@ -37,15 +37,12 @@ BEGIN
itemPackingTypeFk VARCHAR(1) itemPackingTypeFk VARCHAR(1)
) ENGINE=MEMORY; ) ENGINE=MEMORY;
SELECT defaultPackingTypeFk INTO vDefaultPackingType FROM itemConfig LIMIT 1; SELECT COALESCE(MAX(ic.defaultPackingTypeFk), MAX(i.itemPackingTypeFk)) INTO vDefaultPackingType
FROM vn.sale s
START TRANSACTION; JOIN item i ON i.id = s.itemFk
LEFT JOIN itemConfig ic ON ic.defaultPackingTypeFk = i.itemPackingTypeFk
SELECT t.id INTO vThrowAway WHERE s.ticketFk = vSelf
FROM ticket t GROUP BY s.ticketFk;
JOIN sale s ON s.id = t.id
WHERE t.id = vSelf
FOR UPDATE;
SELECT EXISTS ( SELECT EXISTS (
SELECT TRUE SELECT TRUE
@ -59,6 +56,14 @@ BEGIN
SET vOriginalItemPackingTypeFk = vDefaultPackingType; SET vOriginalItemPackingTypeFk = vDefaultPackingType;
END IF; END IF;
START TRANSACTION;
SELECT t.id INTO vTicketFk
FROM ticket t
JOIN sale s ON s.id = t.id
WHERE t.id = vSelf
FOR UPDATE;
INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk) INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk)
SELECT s.id, i.itemPackingTypeFk SELECT s.id, i.itemPackingTypeFk
FROM sale s FROM sale s
@ -77,7 +82,7 @@ BEGIN
CALL ticket_Clone(vSelf, vNewTicketFk); CALL ticket_Clone(vSelf, vNewTicketFk);
SELECT id INTO vThrowAway SELECT id INTO vTicketFk
FROM ticket t FROM ticket t
WHERE t.id = vNewTicketFk WHERE t.id = vNewTicketFk
FOR UPDATE; FOR UPDATE;