From 0284b138d7a26c97a93bd923d2a1d425020069e3 Mon Sep 17 00:00:00 2001 From: ivanm Date: Mon, 22 Apr 2024 15:03:08 +0200 Subject: [PATCH] refs #7191 requested modifications --- db/routines/vn/triggers/entry_beforeUpdate.sql | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/db/routines/vn/triggers/entry_beforeUpdate.sql b/db/routines/vn/triggers/entry_beforeUpdate.sql index afe1a25be..d4e50004c 100644 --- a/db/routines/vn/triggers/entry_beforeUpdate.sql +++ b/db/routines/vn/triggers/entry_beforeUpdate.sql @@ -6,17 +6,17 @@ BEGIN DECLARE vIsVirtual BOOL; DECLARE vPrintedCount INT; DECLARE vHasDistinctWarehouses BOOL; - DECLARE vEntryFkCount INT; + DECLARE vTotalBuy INT; IF NEW.isBooked = OLD.isBooked THEN CALL entry_checkBooked(OLD.id); - END IF; - - IF NEW.isBooked = 1 THEN - SELECT COUNT(*) INTO vEntryFkCount - FROM buy WHERE entryFk = NEW.id; - IF vEntryFkCount = 0 THEN - CALL util.throw('The entry cannot be marked as booked if it does not have lines'); + ELSE + IF NEW.isBooked = 1 THEN + SELECT COUNT(*) INTO vTotalBuy + FROM buy WHERE entryFk = NEW.id; + IF vTotalBuy = 0 THEN + CALL util.throw('The entry cannot be marked as booked if it does not have lines'); + END IF; END IF; END IF;