From 62bd2ae03bfb7ebd54bdf725a6455ccdfb0e0fff Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 2 Oct 2024 11:27:09 +0200 Subject: [PATCH 01/14] refactor: refs #6824 Throw for no delete itemShelving with itemShelvingSale --- .../vn/triggers/itemShelving_beforeDelete.sql | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/db/routines/vn/triggers/itemShelving_beforeDelete.sql b/db/routines/vn/triggers/itemShelving_beforeDelete.sql index 89737a841..8313e3ed9 100644 --- a/db/routines/vn/triggers/itemShelving_beforeDelete.sql +++ b/db/routines/vn/triggers/itemShelving_beforeDelete.sql @@ -2,14 +2,26 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_beforeDelete` BEFORE DELETE ON `itemShelving` FOR EACH ROW -INSERT INTO vn.itemShelvingLog(itemShelvingFk, - workerFk, - accion, - shelvingFk, - itemFk) - VALUES( OLD.id, - account.myUser_getId(), - 'ELIMINADO', - OLD.shelvingFk, - OLD.itemFk)$$ +BEGIN + DECLARE vItemShelvingSaleExists BOOL; + + SELECT COUNT(*) INTO vItemShelvingSaleExists + FROM itemShelvingSale + WHERE itemShelvingFk = OLD.id; + + IF vItemShelvingSaleExists AND @canDeleteItemShelvingSale IS NULL THEN + CALL util.throw('Cannot delete item shelving with item shelving sale'); + END IF; + + INSERT INTO vn.itemShelvingLog(itemShelvingFk, + workerFk, + accion, + shelvingFk, + itemFk) + VALUES( OLD.id, + account.myUser_getId(), + 'ELIMINADO', + OLD.shelvingFk, + OLD.itemFk); +END$$ DELIMITER ; From 2655e20ef64759f9f6a2574f8f3aa72979ab745a Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 2 Oct 2024 11:32:20 +0200 Subject: [PATCH 02/14] refactor: refs #6824 Throw for no delete itemShelving with itemShelvingSale --- db/routines/vn/procedures/clean.sql | 2 ++ db/routines/vn/triggers/itemShelving_beforeDelete.sql | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index 4a1f526fc..1e0697997 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -23,7 +23,9 @@ BEGIN DELETE FROM messageInbox WHERE sendDate < v2Months; DELETE FROM messageInbox WHERE sendDate < v2Months; DELETE FROM workerTimeControl WHERE timed < v4Years; + SET @canDeleteItemShelvingSale = TRUE; DELETE FROM itemShelving WHERE created < util.VN_CURDATE() AND visible = 0; + SET @canDeleteItemShelvingSale = NULL; DELETE FROM ticketDown WHERE created < util.yesterday(); DELETE IGNORE FROM expedition WHERE created < v26Months; DELETE cs diff --git a/db/routines/vn/triggers/itemShelving_beforeDelete.sql b/db/routines/vn/triggers/itemShelving_beforeDelete.sql index 8313e3ed9..dbe21dabd 100644 --- a/db/routines/vn/triggers/itemShelving_beforeDelete.sql +++ b/db/routines/vn/triggers/itemShelving_beforeDelete.sql @@ -9,7 +9,9 @@ BEGIN FROM itemShelvingSale WHERE itemShelvingFk = OLD.id; - IF vItemShelvingSaleExists AND @canDeleteItemShelvingSale IS NULL THEN + IF vItemShelvingSaleExists AND (NOT @canDeleteItemShelvingSale + OR @canDeleteItemShelvingSale IS NULL) THEN + CALL util.throw('Cannot delete item shelving with item shelving sale'); END IF; From 486c7f4fa3322c2c23895c45b95c757a0f7c292d Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 3 Oct 2024 20:07:24 +0000 Subject: [PATCH 03/14] fix(salix): Redirect to Lilium from create claim --- front/core/services/app.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/front/core/services/app.js b/front/core/services/app.js index fa129c3fc..199bd8b58 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -66,17 +66,17 @@ export default class App { ]} }; + const hasId = !isNaN(parseFloat(route.split('/')[1])); + if (this.logger.$params.q) { let tableValue = this.logger.$params.q; const q = JSON.parse(tableValue); if (typeof q === 'number') tableValue = JSON.stringify({id: tableValue}); newRoute = newRoute.concat(`?table=${tableValue}`); - } - - if (this.logger.$params.id && newRoute.indexOf(this.logger.$params.id) < 0) + } else if (!hasId && this.logger.$params.id && newRoute.indexOf(this.logger.$params.id) < 0) newRoute = newRoute.concat(`${this.logger.$params.id}`); - + return this.logger.$http.get('Urls/findOne', {filter}) .then(res => { if (res && res.data) From b85989105bf67243ede70b8c58d656388aad0d29 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 3 Oct 2024 22:29:01 +0200 Subject: [PATCH 04/14] fix(salix): redirect from travel to addEntry --- front/core/services/app.js | 2 +- modules/travel/front/descriptor-menu/index.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/front/core/services/app.js b/front/core/services/app.js index 199bd8b58..d9d16816d 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -76,7 +76,7 @@ export default class App { newRoute = newRoute.concat(`?table=${tableValue}`); } else if (!hasId && this.logger.$params.id && newRoute.indexOf(this.logger.$params.id) < 0) newRoute = newRoute.concat(`${this.logger.$params.id}`); - + return this.logger.$http.get('Urls/findOne', {filter}) .then(res => { if (res && res.data) diff --git a/modules/travel/front/descriptor-menu/index.js b/modules/travel/front/descriptor-menu/index.js index f68502ec3..854148ca0 100644 --- a/modules/travel/front/descriptor-menu/index.js +++ b/modules/travel/front/descriptor-menu/index.js @@ -75,7 +75,8 @@ class Controller extends Section { async redirectToCreateEntry() { this.$state.go('home'); - window.location.href = await this.vnApp.getUrl(`entry/create?travelFk=${this.travelId}`); + const createForm = JSON.stringify({travelFk: this.travelId}); + window.location.href = await this.vnApp.getUrl(`entry/list?createForm=${createForm}`); } onCloneWithEntriesAccept() { From 4f9c9dbacea739ea04665e44811ee80e11aa40a9 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 3 Oct 2024 22:32:54 +0200 Subject: [PATCH 05/14] perf(salix): remove space --- front/core/services/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/core/services/app.js b/front/core/services/app.js index 199bd8b58..d9d16816d 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -76,7 +76,7 @@ export default class App { newRoute = newRoute.concat(`?table=${tableValue}`); } else if (!hasId && this.logger.$params.id && newRoute.indexOf(this.logger.$params.id) < 0) newRoute = newRoute.concat(`${this.logger.$params.id}`); - + return this.logger.$http.get('Urls/findOne', {filter}) .then(res => { if (res && res.data) From 83f0f113323a3edfd05cd01cdb5144791ff90b92 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 3 Oct 2024 22:33:56 +0200 Subject: [PATCH 06/14] fix(salix): redirect from travel to addEntry --- modules/travel/front/descriptor-menu/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/travel/front/descriptor-menu/index.js b/modules/travel/front/descriptor-menu/index.js index 854148ca0..f68502ec3 100644 --- a/modules/travel/front/descriptor-menu/index.js +++ b/modules/travel/front/descriptor-menu/index.js @@ -75,8 +75,7 @@ class Controller extends Section { async redirectToCreateEntry() { this.$state.go('home'); - const createForm = JSON.stringify({travelFk: this.travelId}); - window.location.href = await this.vnApp.getUrl(`entry/list?createForm=${createForm}`); + window.location.href = await this.vnApp.getUrl(`entry/create?travelFk=${this.travelId}`); } onCloneWithEntriesAccept() { From 9843d001b5d30b5cb3a12390a1897e140dfa9732 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 4 Oct 2024 07:09:59 +0000 Subject: [PATCH 07/14] fix(salix): change parse method --- front/core/services/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/front/core/services/app.js b/front/core/services/app.js index d9d16816d..dba6e70bf 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -66,7 +66,7 @@ export default class App { ]} }; - const hasId = !isNaN(parseFloat(route.split('/')[1])); + const hasId = !isNaN(parseInt(route.split('/')[1])); if (this.logger.$params.q) { let tableValue = this.logger.$params.q; From 6766cebd2a68e2b91432d56e913e438fff43941f Mon Sep 17 00:00:00 2001 From: Pako Date: Fri, 4 Oct 2024 13:56:54 +0200 Subject: [PATCH 08/14] fix: refs #8069 call moved upper than transaction start --- .../procedures/order_confirmWithUser.sql | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index b3aab522e..026f589e9 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -98,22 +98,8 @@ BEGIN SELECT employeeFk INTO vUserFk FROM orderConfig; END IF; - START TRANSACTION; - - CALL order_checkEditable(vSelf); - CALL orderRow_updateOverstocking(vSelf); - -- Check order is not empty - SELECT COUNT(*) > 0 INTO vHasRows - FROM orderRow - WHERE orderFk = vSelf - AND amount > 0; - - IF NOT vHasRows THEN - CALL util.throw('ORDER_EMPTY'); - END IF; - -- Check if any product has a quantity of 0 SELECT EXISTS ( SELECT id @@ -125,6 +111,20 @@ BEGIN IF vHas0Amount THEN CALL util.throw('Remove lines with quantity = 0 before confirming'); END IF; + + START TRANSACTION; + + CALL order_checkEditable(vSelf); + + -- Check order is not empty + SELECT COUNT(*) > 0 INTO vHasRows + FROM orderRow + WHERE orderFk = vSelf + AND amount > 0; + + IF NOT vHasRows THEN + CALL util.throw('ORDER_EMPTY'); + END IF; -- Crea los tickets del pedido OPEN vDates; From 4a17d9ec0e0f29364bc6006920b700d76d9b3ef4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Sun, 6 Oct 2024 09:07:48 +0200 Subject: [PATCH 09/14] fix: refs #7760 collection_assing --- db/routines/vn/procedures/collection_assign.sql | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index ba83f1fbb..c2d4a34ef 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -118,9 +118,19 @@ BEGIN IF vCollectionFk IS NULL THEN CALL collection_new(vUserFk, vCollectionFk); - UPDATE `collection` - SET workerFk = vUserFk - WHERE id = vCollectionFk; + START TRANSACTION; + + SELECT workerFk INTO vCollectionWorker + FROM `collection` + WHERE id = vCollectionFk FOR UPDATE; + + IF vCollectionWorker IS NULL THEN + UPDATE `collection` + SET workerFk = vUserFk + WHERE id = vCollectionFk; + END IF; + + COMMIT; END IF; END$$ DELIMITER ; \ No newline at end of file From ba9d0743b525e484b9f62f7eba13d473c69c5f12 Mon Sep 17 00:00:00 2001 From: guillermo Date: Sun, 6 Oct 2024 10:20:34 +0200 Subject: [PATCH 10/14] refactor: refs #6824 Throw for no delete itemShelving with itemShelvingSale --- db/routines/vn/procedures/clean.sql | 9 +++++++-- db/routines/vn/triggers/itemShelving_beforeDelete.sql | 4 +--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index 1e0697997..249290c10 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -23,9 +23,14 @@ BEGIN DELETE FROM messageInbox WHERE sendDate < v2Months; DELETE FROM messageInbox WHERE sendDate < v2Months; DELETE FROM workerTimeControl WHERE timed < v4Years; - SET @canDeleteItemShelvingSale = TRUE; + DELETE FROM itemShelvingSale + WHERE itemShelvingFk IN ( + SELECT id + FROM itemShelving + WHERE created < util.VN_CURDATE() + AND visible = 0 + ); DELETE FROM itemShelving WHERE created < util.VN_CURDATE() AND visible = 0; - SET @canDeleteItemShelvingSale = NULL; DELETE FROM ticketDown WHERE created < util.yesterday(); DELETE IGNORE FROM expedition WHERE created < v26Months; DELETE cs diff --git a/db/routines/vn/triggers/itemShelving_beforeDelete.sql b/db/routines/vn/triggers/itemShelving_beforeDelete.sql index dbe21dabd..dbfb63849 100644 --- a/db/routines/vn/triggers/itemShelving_beforeDelete.sql +++ b/db/routines/vn/triggers/itemShelving_beforeDelete.sql @@ -9,9 +9,7 @@ BEGIN FROM itemShelvingSale WHERE itemShelvingFk = OLD.id; - IF vItemShelvingSaleExists AND (NOT @canDeleteItemShelvingSale - OR @canDeleteItemShelvingSale IS NULL) THEN - + IF vItemShelvingSaleExists THEN CALL util.throw('Cannot delete item shelving with item shelving sale'); END IF; From 7fc2e34af917d82781590e06dc65ac0d81bcbfa3 Mon Sep 17 00:00:00 2001 From: guillermo Date: Sun, 6 Oct 2024 10:54:51 +0200 Subject: [PATCH 11/14] refactor: refs #6824 Fix tests --- .../item/back/methods/item-shelving/deleteItemShelvings.js | 5 +++++ .../methods/item-shelving/specs/deleteItemShelvings.spec.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/item/back/methods/item-shelving/deleteItemShelvings.js b/modules/item/back/methods/item-shelving/deleteItemShelvings.js index f534b4e9a..fbc354cce 100644 --- a/modules/item/back/methods/item-shelving/deleteItemShelvings.js +++ b/modules/item/back/methods/item-shelving/deleteItemShelvings.js @@ -34,6 +34,11 @@ module.exports = Self => { try { const promises = []; for (let itemShelvingId of itemShelvingIds) { + const itemShelvingSaleToDelete = models.ItemShelvingSale.destroyAll({ + itemShelvingFk: itemShelvingId + }, myOptions); + promises.push(itemShelvingSaleToDelete); + const itemShelvingToDelete = models.ItemShelving.destroyById(itemShelvingId, myOptions); promises.push(itemShelvingToDelete); } diff --git a/modules/item/back/methods/item-shelving/specs/deleteItemShelvings.spec.js b/modules/item/back/methods/item-shelving/specs/deleteItemShelvings.spec.js index b4113d7cf..541a529cb 100644 --- a/modules/item/back/methods/item-shelving/specs/deleteItemShelvings.spec.js +++ b/modules/item/back/methods/item-shelving/specs/deleteItemShelvings.spec.js @@ -10,7 +10,7 @@ describe('ItemShelving deleteItemShelvings()', () => { const itemShelvingIds = [1, 2]; const result = await models.ItemShelving.deleteItemShelvings(itemShelvingIds, options); - expect(result.length).toEqual(2); + expect(result.length).toEqual(4); await tx.rollback(); } catch (e) { From 6b7f161d9a7bcb713722704127bf3d2abb9a6ace Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 7 Oct 2024 06:39:41 +0200 Subject: [PATCH 12/14] fix: refs #7844 sale_problems llena --- db/routines/vn/procedures/sale_getProblems.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index 2bba8fbc3..b50b4784d 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -40,7 +40,7 @@ BEGIN isTooLittle BOOL DEFAULT FALSE, isVip BOOL DEFAULT FALSE, PRIMARY KEY (ticketFk, saleFk) - ) ENGINE = MEMORY; + ); -- No memory INSERT INTO tmp.sale_problems(ticketFk, saleFk, From 7b4d15cb23592446f9a1f2ffda92b822b64286d8 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 7 Oct 2024 07:30:36 +0200 Subject: [PATCH 13/14] refactor: refs #6824 Requested changes --- .../vn/triggers/itemShelving_beforeDelete.sql | 32 ++++++------------- .../11283-redAspidistra/00-firstScript.sql | 3 ++ 2 files changed, 13 insertions(+), 22 deletions(-) create mode 100644 db/versions/11283-redAspidistra/00-firstScript.sql diff --git a/db/routines/vn/triggers/itemShelving_beforeDelete.sql b/db/routines/vn/triggers/itemShelving_beforeDelete.sql index dbfb63849..89737a841 100644 --- a/db/routines/vn/triggers/itemShelving_beforeDelete.sql +++ b/db/routines/vn/triggers/itemShelving_beforeDelete.sql @@ -2,26 +2,14 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`itemShelving_beforeDelete` BEFORE DELETE ON `itemShelving` FOR EACH ROW -BEGIN - DECLARE vItemShelvingSaleExists BOOL; - - SELECT COUNT(*) INTO vItemShelvingSaleExists - FROM itemShelvingSale - WHERE itemShelvingFk = OLD.id; - - IF vItemShelvingSaleExists THEN - CALL util.throw('Cannot delete item shelving with item shelving sale'); - END IF; - - INSERT INTO vn.itemShelvingLog(itemShelvingFk, - workerFk, - accion, - shelvingFk, - itemFk) - VALUES( OLD.id, - account.myUser_getId(), - 'ELIMINADO', - OLD.shelvingFk, - OLD.itemFk); -END$$ +INSERT INTO vn.itemShelvingLog(itemShelvingFk, + workerFk, + accion, + shelvingFk, + itemFk) + VALUES( OLD.id, + account.myUser_getId(), + 'ELIMINADO', + OLD.shelvingFk, + OLD.itemFk)$$ DELIMITER ; diff --git a/db/versions/11283-redAspidistra/00-firstScript.sql b/db/versions/11283-redAspidistra/00-firstScript.sql new file mode 100644 index 000000000..a88091297 --- /dev/null +++ b/db/versions/11283-redAspidistra/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.itemShelving DROP FOREIGN KEY itemShelving_fk2; +ALTER TABLE vn.itemShelving ADD CONSTRAINT itemShelving_fk2 + FOREIGN KEY (shelvingFk) REFERENCES vn.shelving(code) ON DELETE RESTRICT ON UPDATE CASCADE; From 4da63900a2d69064f69d400b0c740c8f86ed948f Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 7 Oct 2024 07:36:50 +0200 Subject: [PATCH 14/14] fix: refs #7760 collection_assing added global handler sqlexception --- db/routines/vn/procedures/collection_assign.sql | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index c2d4a34ef..a4c861c96 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`collection_assign`( vUserFk INT, OUT vCollectionFk INT ) -BEGIN +BEGIN /** * Comprueba si existen colecciones libres que se ajustan * al perfil del usuario y le asigna la más antigua. @@ -45,6 +45,12 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; -- Si hay colecciones sin terminar, sale del proceso + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + CALL collection_get(vUserFk); SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, pc.maxNotAssignedCollectionLifeTime