From b2db076c2fc7c58b2292526f1456300942fbcc61 Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 16 May 2024 15:34:45 +0200 Subject: [PATCH 1/4] refs #7217 create travel_throwAWBError --- db/routines/vn/procedures/travel_throwAWBError.sql | 14 ++++++++++++++ db/routines/vn/triggers/entry_beforeInsert.sql | 4 ++-- db/routines/vn/triggers/entry_beforeUpdate.sql | 4 ++-- db/routines/vn/triggers/travel_beforeInsert.sql | 4 ++-- db/routines/vn/triggers/travel_beforeUpdate.sql | 4 ++-- 5 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 db/routines/vn/procedures/travel_throwAWBError.sql diff --git a/db/routines/vn/procedures/travel_throwAWBError.sql b/db/routines/vn/procedures/travel_throwAWBError.sql new file mode 100644 index 000000000..e01be5335 --- /dev/null +++ b/db/routines/vn/procedures/travel_throwAWBError.sql @@ -0,0 +1,14 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_throwAWBError`(vSelf INT) +BEGIN +/** + * Throws an error if travel does not have a logical AWB + * or there are several AWBs associated with the same DUA + * + * @param vSelf The travel id + */ + IF NOT travel_hasUniqueAwb(vSelf) THEN + CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries'); + END IF; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/entry_beforeInsert.sql b/db/routines/vn/triggers/entry_beforeInsert.sql index c0c0aa28c..6855033cb 100644 --- a/db/routines/vn/triggers/entry_beforeInsert.sql +++ b/db/routines/vn/triggers/entry_beforeInsert.sql @@ -7,8 +7,8 @@ BEGIN CALL supplier_checkIsActive(NEW.supplierFk); SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk); - IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN - CALL util.throw('The travel is incorrect, there is a different AWB in the associated entries'); + IF NEW.travelFk IS NOT NULL THEN + CALL travel_throwAWBError(NEW.travelFk); END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/entry_beforeUpdate.sql b/db/routines/vn/triggers/entry_beforeUpdate.sql index d56db5e01..1ef49f158 100644 --- a/db/routines/vn/triggers/entry_beforeUpdate.sql +++ b/db/routines/vn/triggers/entry_beforeUpdate.sql @@ -25,8 +25,8 @@ BEGIN IF NOT (NEW.travelFk <=> OLD.travelFk) THEN - IF NEW.travelFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.travelFk) THEN - CALL util.throw('The travel is incorrect, there is a different AWB in the associated entries'); + IF NEW.travelFk IS NOT NULL THEN + CALL travel_throwAWBError(NEW.travelFk); END IF; SELECT COUNT(*) > 0 INTO vIsVirtual diff --git a/db/routines/vn/triggers/travel_beforeInsert.sql b/db/routines/vn/triggers/travel_beforeInsert.sql index 817bd69bb..f95dee1ee 100644 --- a/db/routines/vn/triggers/travel_beforeInsert.sql +++ b/db/routines/vn/triggers/travel_beforeInsert.sql @@ -9,8 +9,8 @@ BEGIN CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk); - IF NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN - CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries'); + IF NEW.awbFk IS NOT NULL THEN + CALL travel_throwAWBError (NEW.id); END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/travel_beforeUpdate.sql b/db/routines/vn/triggers/travel_beforeUpdate.sql index 5e43c8761..d5b3e4727 100644 --- a/db/routines/vn/triggers/travel_beforeUpdate.sql +++ b/db/routines/vn/triggers/travel_beforeUpdate.sql @@ -33,8 +33,8 @@ BEGIN END IF; END IF; - IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL AND NOT travel_hasUniqueAwb(NEW.id) THEN - CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries'); + IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL THEN + CALL travel_throwAWBError(NEW.id); END IF; END$$ DELIMITER ; From 4bf36f2655711d66ab865769003d1191e39a1994 Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 17 May 2024 08:16:50 +0200 Subject: [PATCH 2/4] refs #7217 Modify proc name --- .../{travel_throwAWBError.sql => travel_throwAwb.sql} | 4 ++-- db/routines/vn/triggers/entry_beforeInsert.sql | 2 +- db/routines/vn/triggers/entry_beforeUpdate.sql | 2 +- db/routines/vn/triggers/travel_beforeInsert.sql | 2 +- db/routines/vn/triggers/travel_beforeUpdate.sql | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) rename db/routines/vn/procedures/{travel_throwAWBError.sql => travel_throwAwb.sql} (67%) diff --git a/db/routines/vn/procedures/travel_throwAWBError.sql b/db/routines/vn/procedures/travel_throwAwb.sql similarity index 67% rename from db/routines/vn/procedures/travel_throwAWBError.sql rename to db/routines/vn/procedures/travel_throwAwb.sql index e01be5335..3123ecbf3 100644 --- a/db/routines/vn/procedures/travel_throwAWBError.sql +++ b/db/routines/vn/procedures/travel_throwAwb.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_throwAWBError`(vSelf INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_throwAwb`(vSelf INT) BEGIN /** * Throws an error if travel does not have a logical AWB @@ -8,7 +8,7 @@ BEGIN * @param vSelf The travel id */ IF NOT travel_hasUniqueAwb(vSelf) THEN - CALL util.throw('The AWB is incorrect, there is a different AWB in the associated entries'); + CALL util.throw('The AWB is wrong; a different AWB is in the entries'); END IF; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/entry_beforeInsert.sql b/db/routines/vn/triggers/entry_beforeInsert.sql index 6855033cb..17831f1b8 100644 --- a/db/routines/vn/triggers/entry_beforeInsert.sql +++ b/db/routines/vn/triggers/entry_beforeInsert.sql @@ -8,7 +8,7 @@ BEGIN SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk,NEW.supplierFk); IF NEW.travelFk IS NOT NULL THEN - CALL travel_throwAWBError(NEW.travelFk); + CALL travel_throwAwb(NEW.travelFk); END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/entry_beforeUpdate.sql b/db/routines/vn/triggers/entry_beforeUpdate.sql index 1ef49f158..e99eb087d 100644 --- a/db/routines/vn/triggers/entry_beforeUpdate.sql +++ b/db/routines/vn/triggers/entry_beforeUpdate.sql @@ -26,7 +26,7 @@ BEGIN IF NOT (NEW.travelFk <=> OLD.travelFk) THEN IF NEW.travelFk IS NOT NULL THEN - CALL travel_throwAWBError(NEW.travelFk); + CALL travel_throwAwb(NEW.travelFk); END IF; SELECT COUNT(*) > 0 INTO vIsVirtual diff --git a/db/routines/vn/triggers/travel_beforeInsert.sql b/db/routines/vn/triggers/travel_beforeInsert.sql index f95dee1ee..e54a5d08b 100644 --- a/db/routines/vn/triggers/travel_beforeInsert.sql +++ b/db/routines/vn/triggers/travel_beforeInsert.sql @@ -10,7 +10,7 @@ BEGIN CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk); IF NEW.awbFk IS NOT NULL THEN - CALL travel_throwAWBError (NEW.id); + CALL travel_throwAwb(NEW.id); END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/travel_beforeUpdate.sql b/db/routines/vn/triggers/travel_beforeUpdate.sql index d5b3e4727..5e64ad5b3 100644 --- a/db/routines/vn/triggers/travel_beforeUpdate.sql +++ b/db/routines/vn/triggers/travel_beforeUpdate.sql @@ -34,7 +34,7 @@ BEGIN END IF; IF (NOT(NEW.awbFk <=> OLD.awbFk)) AND NEW.awbFk IS NOT NULL THEN - CALL travel_throwAWBError(NEW.id); + CALL travel_throwAwb(NEW.id); END IF; END$$ DELIMITER ; From db28bf335e2bb917a5b242c09d5774ae1e1307e1 Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 17 May 2024 09:53:17 +0200 Subject: [PATCH 3/4] refs #7217 Modify error message --- db/routines/vn/procedures/travel_throwAwb.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/travel_throwAwb.sql b/db/routines/vn/procedures/travel_throwAwb.sql index 3123ecbf3..c2c06816f 100644 --- a/db/routines/vn/procedures/travel_throwAwb.sql +++ b/db/routines/vn/procedures/travel_throwAwb.sql @@ -8,7 +8,7 @@ BEGIN * @param vSelf The travel id */ IF NOT travel_hasUniqueAwb(vSelf) THEN - CALL util.throw('The AWB is wrong; a different AWB is in the entries'); + CALL util.throw('The AWB is wrong. A different AWB is in the entries'); END IF; END$$ DELIMITER ; \ No newline at end of file From 7e22e19e624b65797b1cdc968953a59ded7fc220 Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 24 May 2024 10:21:35 +0200 Subject: [PATCH 4/4] refs #7217 Reduce error message --- db/routines/vn/procedures/travel_throwAwb.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/travel_throwAwb.sql b/db/routines/vn/procedures/travel_throwAwb.sql index c2c06816f..1b54f8532 100644 --- a/db/routines/vn/procedures/travel_throwAwb.sql +++ b/db/routines/vn/procedures/travel_throwAwb.sql @@ -8,7 +8,7 @@ BEGIN * @param vSelf The travel id */ IF NOT travel_hasUniqueAwb(vSelf) THEN - CALL util.throw('The AWB is wrong. A different AWB is in the entries'); - END IF; + CALL util.throw('A different AWB is found in the entries'); + END IF; END$$ DELIMITER ; \ No newline at end of file