From e44568ff4b0a415953335437aeeaacaf0b1d09ba Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 7 May 2024 08:00:26 +0200 Subject: [PATCH 1/3] feat: refs #6585 Added call ticket_afterUpdate --- db/routines/vn/triggers/ticket_afterUpdate.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db/routines/vn/triggers/ticket_afterUpdate.sql b/db/routines/vn/triggers/ticket_afterUpdate.sql index f1ad394ef..0ce13e0a5 100644 --- a/db/routines/vn/triggers/ticket_afterUpdate.sql +++ b/db/routines/vn/triggers/ticket_afterUpdate.sql @@ -7,6 +7,8 @@ BEGIN UPDATE expedition SET hasNewRoute = TRUE WHERE ticketFk = NEW.id; + + CALL ticket_doCmr(NEW.id); END IF; END$$ DELIMITER ; -- 2.40.1 From 2adf96cb379ded5aaf2be24be1b75e8b2fd87dae Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 7 May 2024 13:03:50 +0200 Subject: [PATCH 2/3] refactor: #6585 Deleted transaction ticket_doCmr --- db/routines/vn/procedures/ticket_doCmr.sql | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/db/routines/vn/procedures/ticket_doCmr.sql b/db/routines/vn/procedures/ticket_doCmr.sql index 61d8da5f9..40af388c7 100644 --- a/db/routines/vn/procedures/ticket_doCmr.sql +++ b/db/routines/vn/procedures/ticket_doCmr.sql @@ -7,7 +7,7 @@ BEGIN * * @param vSelf El id del ticket */ - DECLARE vCmrFk, vPreviousCmrFk, vCurrentCmrFk INT; + DECLARE vCmrFk INT; SELECT cmrFk INTO vCmrFk FROM ticket WHERE id = vSelf; @@ -44,8 +44,6 @@ BEGIN AND t.id = vSelf GROUP BY t.id; - START TRANSACTION; - IF vCmrFk THEN UPDATE cmr c JOIN tTicket t @@ -57,9 +55,7 @@ BEGIN c.supplierFk = t.supplierFk, c.ead = t.landed WHERE id = vCmrFk; - ELSE - SELECT MAX(id) INTO vPreviousCmrFk FROM cmr; - + ELSE INSERT INTO cmr ( senderInstruccions, truckPlate, @@ -70,17 +66,14 @@ BEGIN ead ) SELECT * FROM tTicket; - - SELECT MAX(id) INTO vCurrentCmrFk FROM cmr; - IF vPreviousCmrFk <> vCurrentCmrFk THEN + IF (SELECT EXISTS(SELECT * FROM tTicket)) THEN UPDATE ticket SET cmrFk = vCurrentCmrFk - WHERE id = vSelf; + WHERE id = LAST_INSERT_ID(); END IF; END IF; - COMMIT; DROP TEMPORARY TABLE tTicket; END$$ DELIMITER ; -- 2.40.1 From 6cde2e81700858c4fb8b8f5bb54724208c4c6ff8 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 8 May 2024 08:48:08 +0200 Subject: [PATCH 3/3] fix: refs #6585 Requested changes --- db/routines/vn/procedures/ticket_doCmr.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/ticket_doCmr.sql b/db/routines/vn/procedures/ticket_doCmr.sql index 40af388c7..2da8464b4 100644 --- a/db/routines/vn/procedures/ticket_doCmr.sql +++ b/db/routines/vn/procedures/ticket_doCmr.sql @@ -69,8 +69,8 @@ BEGIN IF (SELECT EXISTS(SELECT * FROM tTicket)) THEN UPDATE ticket - SET cmrFk = vCurrentCmrFk - WHERE id = LAST_INSERT_ID(); + SET cmrFk = LAST_INSERT_ID() + WHERE id = vSelf; END IF; END IF; -- 2.40.1