refactor: refs #8210 ticket_splitItemPackingType
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
43abb52efc
commit
031c4398ae
|
@ -18,7 +18,7 @@ BEGIN
|
|||
DECLARE vDefaultPackingType VARCHAR(1);
|
||||
DECLARE vHasOriginalPackingType BOOLEAN;
|
||||
DECLARE vNewTicketFk INT;
|
||||
DECLARE vThrowAway INT;
|
||||
DECLARE vTicketFk INT;
|
||||
|
||||
DECLARE vItemPackingTypes CURSOR FOR
|
||||
SELECT DISTINCT itemPackingTypeFk FROM tSalesToMove;
|
||||
|
@ -37,15 +37,12 @@ BEGIN
|
|||
itemPackingTypeFk VARCHAR(1)
|
||||
) ENGINE=MEMORY;
|
||||
|
||||
SELECT defaultPackingTypeFk INTO vDefaultPackingType FROM itemConfig LIMIT 1;
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
SELECT t.id INTO vThrowAway
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.id = t.id
|
||||
WHERE t.id = vSelf
|
||||
FOR UPDATE;
|
||||
SELECT COALESCE(MAX(ic.defaultPackingTypeFk), MAX(i.itemPackingTypeFk)) INTO vDefaultPackingType
|
||||
FROM vn.sale s
|
||||
JOIN item i ON i.id = s.itemFk
|
||||
LEFT JOIN itemConfig ic ON ic.defaultPackingTypeFk = i.itemPackingTypeFk
|
||||
WHERE s.ticketFk = vSelf
|
||||
GROUP BY s.ticketFk;
|
||||
|
||||
SELECT EXISTS (
|
||||
SELECT TRUE
|
||||
|
@ -59,6 +56,14 @@ BEGIN
|
|||
SET vOriginalItemPackingTypeFk = vDefaultPackingType;
|
||||
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)
|
||||
SELECT s.id, i.itemPackingTypeFk
|
||||
FROM sale s
|
||||
|
@ -77,7 +82,7 @@ BEGIN
|
|||
|
||||
CALL ticket_Clone(vSelf, vNewTicketFk);
|
||||
|
||||
SELECT id INTO vThrowAway
|
||||
SELECT id INTO vTicketFk
|
||||
FROM ticket t
|
||||
WHERE t.id = vNewTicketFk
|
||||
FOR UPDATE;
|
||||
|
|
Loading…
Reference in New Issue