From 03358170d3281404a694196cbbfb6fea2727ca81 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 6 Aug 2024 14:10:16 +0200 Subject: [PATCH] fix: refs #7740 ticket route throw --- db/routines/vn/triggers/ticket_beforeUpdate.sql | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/triggers/ticket_beforeUpdate.sql b/db/routines/vn/triggers/ticket_beforeUpdate.sql index 34b6711ff..6d5d7f908 100644 --- a/db/routines/vn/triggers/ticket_beforeUpdate.sql +++ b/db/routines/vn/triggers/ticket_beforeUpdate.sql @@ -8,7 +8,13 @@ BEGIN SET NEW.editorFk = account.myUser_getId(); IF NOT (NEW.routeFk <=> OLD.routeFk) THEN - IF NEW.isSigned THEN + IF NEW.isSigned AND NOT ( + SELECT (COUNT(s.id) = COUNT(cb.saleFk) + AND SUM(s.quantity) = SUM(cb.quantity)) + FROM sale s + LEFT JOIN claimBeginning cb ON cb.saleFk = s.id + WHERE s.ticketFk = NEW.id + ) THEN CALL util.throw('A signed ticket cannot be rerouted'); END IF; INSERT IGNORE INTO routeRecalc(routeFk)