From 67069747845d6daea1237971f73a82ac0740bced Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 24 Apr 2024 10:31:26 +0200 Subject: [PATCH 01/19] fix: refs #6731 fix ticketRequest --- .../vn/procedures/ticketRequest_Add.sql | 19 ------------ .../triggers/ticketRequest_beforeInsert.sql | 2 +- .../triggers/ticketRequest_beforeUpdate.sql | 4 --- .../11002-limeCarnation/00-firstScript.sql | 7 +++++ loopback/locale/en.json | 4 +-- .../ticket-request/specs/confirm.spec.js | 5 +--- modules/ticket/back/models/ticket-config.json | 10 +++++++ modules/ticket/back/models/ticket-request.js | 30 +++++++++++++------ 8 files changed, 42 insertions(+), 39 deletions(-) delete mode 100644 db/routines/vn/procedures/ticketRequest_Add.sql create mode 100644 db/versions/11002-limeCarnation/00-firstScript.sql diff --git a/db/routines/vn/procedures/ticketRequest_Add.sql b/db/routines/vn/procedures/ticketRequest_Add.sql deleted file mode 100644 index 5ba347fef..000000000 --- a/db/routines/vn/procedures/ticketRequest_Add.sql +++ /dev/null @@ -1,19 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketRequest_Add`(vDescription VARCHAR(255), vQuantity INT, vPrice DOUBLE, vTicketFk INT, vBuyerCode VARCHAR(3)) -BEGIN - - INSERT INTO vn.ticketRequest(description, - quantity, - price, - ticketFk, - buyerCode, - requesterFk) - VALUES(vDescription, - vQuantity, - vPrice, - vTicketFk, - vBuyerCode, - vn.getUser()); - -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/ticketRequest_beforeInsert.sql b/db/routines/vn/triggers/ticketRequest_beforeInsert.sql index d17459912..00e659abc 100644 --- a/db/routines/vn/triggers/ticketRequest_beforeInsert.sql +++ b/db/routines/vn/triggers/ticketRequest_beforeInsert.sql @@ -14,7 +14,7 @@ BEGIN END IF; IF NEW.attenderFk IS NULL THEN - SET NEW.attenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode); + SET NEW.attenderFk = (SELECT defaultAttenderFk FROM ticketConfig LIMIT 1); END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/ticketRequest_beforeUpdate.sql b/db/routines/vn/triggers/ticketRequest_beforeUpdate.sql index e5e9c307e..954df8ed3 100644 --- a/db/routines/vn/triggers/ticketRequest_beforeUpdate.sql +++ b/db/routines/vn/triggers/ticketRequest_beforeUpdate.sql @@ -12,9 +12,5 @@ BEGIN IF NEW.salesPersonCode <> OLD.salesPersonCode THEN SET NEW.requesterFk = (SELECT w.id FROM worker w WHERE w.code = NEW.salesPersonCode); END IF; - - IF NEW.buyerCode <> OLD.buyerCode THEN - SET NEW.attenderFk = (SELECT w.id FROM worker w WHERE w.code = NEW.buyerCode); - END IF; END$$ DELIMITER ; diff --git a/db/versions/11002-limeCarnation/00-firstScript.sql b/db/versions/11002-limeCarnation/00-firstScript.sql new file mode 100644 index 000000000..b1a49a309 --- /dev/null +++ b/db/versions/11002-limeCarnation/00-firstScript.sql @@ -0,0 +1,7 @@ +-- Place your SQL code here +ALTER TABLE `vn`.`ticketRequest` + CHANGE IF EXISTS `buyerCode` `buyerCode__` varchar(3) NOT NULL COMMENT '@deprecated 2024-04-23 refs #6731 field not used'; + +ALTER TABLE `vn`.`ticketConfig` ADD COLUMN IF NOT EXISTS `defaultAttenderFk` int unsigned; + +ALTER TABLE vn.ticketConfig ADD CONSTRAINT ticketConfig_worker_FK FOREIGN KEY (defaultAttenderFk) REFERENCES vn.worker(id); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 9a3a1f52a..93a54393d 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -223,7 +223,7 @@ "printerNotExists": "The printer does not exist", "There are not picking tickets": "There are not picking tickets", "ticketCommercial": "The ticket {{ ticket }} for the salesperson {{ salesMan }} is in preparation. (automatically generated message)", - "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", - "They're not your subordinate": "They're not your subordinate", + "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", + "They're not your subordinate": "They're not your subordinate", "InvoiceIn is already booked": "InvoiceIn is already booked" } \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js b/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js index de2817d87..668a991f4 100644 --- a/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js +++ b/modules/ticket/back/methods/ticket-request/specs/confirm.spec.js @@ -92,9 +92,7 @@ describe('ticket-request confirm()', () => { const request = await models.TicketRequest.findById(requestId, null, options); expect(request.saleFk).toBeNull(); - - await request.updateAttributes({saleFk: 2}, options); - + await request.updateAttributes({saleFk: 2}); ctx.args = { itemFk: itemId, id: requestId, @@ -102,7 +100,6 @@ describe('ticket-request confirm()', () => { }; await models.TicketRequest.confirm(ctx, options); - await tx.rollback(); } catch (e) { await tx.rollback(); diff --git a/modules/ticket/back/models/ticket-config.json b/modules/ticket/back/models/ticket-config.json index d757fbd1a..6dd2808ea 100644 --- a/modules/ticket/back/models/ticket-config.json +++ b/modules/ticket/back/models/ticket-config.json @@ -23,6 +23,16 @@ }, "daysForWarningClaim": { "type": "number" + }, + "defaultAttenderFk": { + "type": "number" + } + }, + "relations": { + "attender": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "defaultAttenderFk" } } } diff --git a/modules/ticket/back/models/ticket-request.js b/modules/ticket/back/models/ticket-request.js index d133f85d5..622cd7696 100644 --- a/modules/ticket/back/models/ticket-request.js +++ b/modules/ticket/back/models/ticket-request.js @@ -8,21 +8,21 @@ module.exports = function(Self) { require('../methods/ticket-request/getItemTypeWorker')(Self); Self.observe('before save', async function(ctx) { - if (ctx.isNewInstance) { - const loopBackContext = LoopBackContext.getCurrentContext(); - const filter = {where: {id: loopBackContext.active.accessToken.userId}}; - const models = Self.app.models; - const worker = await models.Worker.findOne(filter); + const loopBackContext = LoopBackContext.getCurrentContext(); + const filter = {where: {id: loopBackContext.active.accessToken.userId}}; + const models = Self.app.models; + const worker = await models.Worker.findOne(filter); + const instance = ctx.instance; + const attenderFk = instance?.attenderFk; - const instance = ctx.instance; + if (ctx.isNewInstance) { instance.requesterFk = worker.id; const httpCtx = {req: loopBackContext.active}; const httpRequest = httpCtx.req.http .req; const $t = httpRequest.__; - const attenderId = instance.attenderFk; - if (attenderId) { + if (attenderFk) { const ticket = await models.Ticket.findById(instance.ticketFk); let messageText = 'New ticket request has been created'; if (instance.price) @@ -35,8 +35,20 @@ module.exports = function(Self) { quantity: instance.quantity, price: instance.price }); - await models.Chat.sendCheckingPresence(httpCtx, attenderId, message); + await models.Chat.sendCheckingPresence(httpCtx, attenderFk, message); + } else { + const {defaultAttenderFk} = await models.TicketConfig.findOne(); + Object.assign(instance, {attenderFk: defaultAttenderFk}); } } }); + + Self.observe('after save', async function(ctx) { + const models = Self.app.models; + const instance = ctx.instance; + if (instance?.attenderFk === null && !ctx.isNewInstance) { + const {defaultAttenderFk} = await models.TicketConfig.findOne(); + await models.TicketRequest.updateAll({id: instance.id}, {attenderFk: defaultAttenderFk}); + } + }); }; From 46f2d790db3aeb03178f2b20eabbd584ffd400ba Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 25 Apr 2024 08:01:32 +0200 Subject: [PATCH 02/19] refs #6312 hotFix fix:replaceItem --- db/routines/vn/procedures/sale_replaceItem.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index 1d9f6ff71..fb68b3f3a 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -92,8 +92,8 @@ BEGIN START TRANSACTION; UPDATE sale - SET quantity = quantity - vQuantity - WHERE id = vSaleFk; + SET originalQuantity = quantity - vQuantity, + quantity = quantity - vQuantity INSERT INTO vn.sale(ticketFk, itemFk, From d4d31c6d9e1c7a7826b08ba411831e7f226c78fd Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 25 Apr 2024 08:35:59 +0200 Subject: [PATCH 03/19] refs #6312 hotFix fix:replaceItem --- db/routines/vn/procedures/sale_replaceItem.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index fb68b3f3a..9a431020b 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -94,6 +94,7 @@ BEGIN UPDATE sale SET originalQuantity = quantity - vQuantity, quantity = quantity - vQuantity + WHERE id = vSaleFk; INSERT INTO vn.sale(ticketFk, itemFk, From c819b921412792baee8b53a165bad10bb81c0f62 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 26 Apr 2024 09:09:22 +0200 Subject: [PATCH 04/19] fix: refs #177968 restore restriction --- db/routines/vn/procedures/sale_replaceItem.sql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index 9a431020b..e50f83b7f 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -81,6 +81,10 @@ BEGIN ORDER BY (vQuantity % `grouping`) ASC LIMIT 1; + IF vNewPrice IS NULL THEN + CALL util.throw('price retrieval failed'); + END IF; + IF vNewPrice > vOldPrice THEN SET vFinalPrice = vOldPrice; SET vOption = 'substitution'; @@ -103,7 +107,8 @@ BEGIN price) SELECT vTicketFk, vNewItemFk, - CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, CONCAT('+ ', i.name), + CEIL(vQuantity / vRoundQuantity) * vRoundQuantity, + CONCAT('+ ', i.name), vFinalPrice FROM vn.item i WHERE id = vNewItemFk; From 9e87b055b74ff8f35eb4c81c0b54695449f0bbdb Mon Sep 17 00:00:00 2001 From: Pako Date: Sat, 27 Apr 2024 12:36:21 +0200 Subject: [PATCH 05/19] hotFix --- db/routines/vn/procedures/collection_assign.sql | 8 +++++--- db/routines/vn/procedures/collection_new.sql | 8 +++++--- db/versions/11016-pinkAralia/00-firstScript.sql | 5 +++++ 3 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 db/versions/11016-pinkAralia/00-firstScript.sql diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index f6000e87d..1d656a0ed 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -30,8 +30,10 @@ BEGIN -- Si hay colecciones sin terminar, sale del proceso CALL collection_get(vUserFk); - SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0 - INTO vHasTooMuchCollections + SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, + pc.collection_assign_lockname + INTO vHasTooMuchCollections, + vLockName FROM tCollection JOIN productionConfig pc; @@ -47,7 +49,7 @@ BEGIN WHERE workerFk = vUserFk; SET vLockName = CONCAT_WS('/', - 'collection_assign', + vLockName, vWarehouseFk, vItemPackingTypeFk ); diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index f3767ddf3..8a1eff4a1 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -63,7 +63,8 @@ BEGIN o.numberOfWagons, o.trainFk, o.linesLimit, - o.volumeLimit + o.volumeLimit, + pc.collection_new_lockname INTO vMaxTickets, vHasUniqueCollectionTime, vWorkerCode, @@ -73,14 +74,15 @@ BEGIN vWagons, vTrainFk, vLinesLimit, - vVolumeLimit + vVolumeLimit, + vLockName FROM productionConfig pc JOIN worker w ON w.id = vUserFk JOIN state st ON st.`code` = 'ON_PREPARATION' JOIN operator o ON o.workerFk = vUserFk; SET vLockName = CONCAT_WS('/', - 'collection_new', + vLockName, vWarehouseFk, vItemPackingTypeFk ); diff --git a/db/versions/11016-pinkAralia/00-firstScript.sql b/db/versions/11016-pinkAralia/00-firstScript.sql new file mode 100644 index 000000000..675507254 --- /dev/null +++ b/db/versions/11016-pinkAralia/00-firstScript.sql @@ -0,0 +1,5 @@ +-- Place your SQL code here +ALTER TABLE vn.productionConfig ADD collection_new_lockname varchar(100) + DEFAULT 'collection_new' NOT NULL COMMENT 'Lockname value for proc vn.collection_new'; +ALTER TABLE vn.productionConfig ADD collection_assign_lockname varchar(100) + DEFAULT 'collection_assign' NULL COMMENT 'Lockname value for proc vn.collection_new'; From 3440bb1725a0ec8e8b67ed5762d815d20f66c75b Mon Sep 17 00:00:00 2001 From: Pako Date: Sat, 27 Apr 2024 12:43:15 +0200 Subject: [PATCH 06/19] hotFix --- db/routines/vn/procedures/collection_assign.sql | 8 +++++--- db/routines/vn/procedures/collection_new.sql | 8 +++++--- db/versions/11018-crimsonBamboo/00-firstScript.sql | 3 +++ 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 db/versions/11018-crimsonBamboo/00-firstScript.sql diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index f6000e87d..1d656a0ed 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -30,8 +30,10 @@ BEGIN -- Si hay colecciones sin terminar, sale del proceso CALL collection_get(vUserFk); - SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0 - INTO vHasTooMuchCollections + SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, + pc.collection_assign_lockname + INTO vHasTooMuchCollections, + vLockName FROM tCollection JOIN productionConfig pc; @@ -47,7 +49,7 @@ BEGIN WHERE workerFk = vUserFk; SET vLockName = CONCAT_WS('/', - 'collection_assign', + vLockName, vWarehouseFk, vItemPackingTypeFk ); diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index f3767ddf3..8a1eff4a1 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -63,7 +63,8 @@ BEGIN o.numberOfWagons, o.trainFk, o.linesLimit, - o.volumeLimit + o.volumeLimit, + pc.collection_new_lockname INTO vMaxTickets, vHasUniqueCollectionTime, vWorkerCode, @@ -73,14 +74,15 @@ BEGIN vWagons, vTrainFk, vLinesLimit, - vVolumeLimit + vVolumeLimit, + vLockName FROM productionConfig pc JOIN worker w ON w.id = vUserFk JOIN state st ON st.`code` = 'ON_PREPARATION' JOIN operator o ON o.workerFk = vUserFk; SET vLockName = CONCAT_WS('/', - 'collection_new', + vLockName, vWarehouseFk, vItemPackingTypeFk ); diff --git a/db/versions/11018-crimsonBamboo/00-firstScript.sql b/db/versions/11018-crimsonBamboo/00-firstScript.sql new file mode 100644 index 000000000..1d0c8f0bd --- /dev/null +++ b/db/versions/11018-crimsonBamboo/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.productionConfig ADD collection_new_lockname varchar(100) DEFAULT 'collection_new' NOT NULL COMMENT 'Lockname value for proc vn.collection_new'; +ALTER TABLE vn.productionConfig ADD collection_assign_lockname varchar(100) DEFAULT 'collection_assign' NULL COMMENT 'Lockname value for proc vn.collection_new'; From 9aa6e3f80a0455711bbef787b5bbcfd4eba37cea Mon Sep 17 00:00:00 2001 From: Pako Date: Sat, 27 Apr 2024 13:09:15 +0200 Subject: [PATCH 07/19] hotfix --- db/routines/vn/procedures/collection_assign.sql | 2 +- db/routines/vn/procedures/collection_new.sql | 2 +- db/versions/11016-pinkAralia/00-firstScript.sql | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index 1d656a0ed..47efa7cd3 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -31,7 +31,7 @@ BEGIN CALL collection_get(vUserFk); SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, - pc.collection_assign_lockname + pc.collectionAssignLockname INTO vHasTooMuchCollections, vLockName FROM tCollection diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index 8a1eff4a1..f207eb2b0 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -64,7 +64,7 @@ BEGIN o.trainFk, o.linesLimit, o.volumeLimit, - pc.collection_new_lockname + pc.collectionNewLockname INTO vMaxTickets, vHasUniqueCollectionTime, vWorkerCode, diff --git a/db/versions/11016-pinkAralia/00-firstScript.sql b/db/versions/11016-pinkAralia/00-firstScript.sql index 675507254..de090013d 100644 --- a/db/versions/11016-pinkAralia/00-firstScript.sql +++ b/db/versions/11016-pinkAralia/00-firstScript.sql @@ -1,5 +1,5 @@ -- Place your SQL code here -ALTER TABLE vn.productionConfig ADD collection_new_lockname varchar(100) +ALTER TABLE vn.productionConfig ADD collectionNewLockname varchar(100) DEFAULT 'collection_new' NOT NULL COMMENT 'Lockname value for proc vn.collection_new'; -ALTER TABLE vn.productionConfig ADD collection_assign_lockname varchar(100) +ALTER TABLE vn.productionConfig ADD collectionAssignLockname varchar(100) DEFAULT 'collection_assign' NULL COMMENT 'Lockname value for proc vn.collection_new'; From f2225b49a71415bb977dc39e6d3bb9c523b8510d Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 29 Apr 2024 08:19:18 +0200 Subject: [PATCH 08/19] refs #6275 hotFix fix:getExpeditionSummary --- modules/route/back/methods/route/getExpeditionSummary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/route/back/methods/route/getExpeditionSummary.js b/modules/route/back/methods/route/getExpeditionSummary.js index ee89401a8..4f95ded2a 100644 --- a/modules/route/back/methods/route/getExpeditionSummary.js +++ b/modules/route/back/methods/route/getExpeditionSummary.js @@ -49,7 +49,7 @@ module.exports = Self => { JOIN vn.agencyMode am ON am.id = r.agencyModeFk JOIN vn.agency ag ON ag.id = am.agencyFk LEFT JOIN vn.userConfig uc ON uc.userFk = account.myUser_getId() - WHERE (r.created = util.VN_CURDATE() OR r.created = util.yesterday()) + WHERE (r.created BETWEEN util.yesterday() AND util.VN_CURDATE() + INTERVAL 1 DAY) AND t.routeFk = ? GROUP BY t.addressFk, e.itemPackingTypeFk ) sub From f4767728bcdede8ed81fd56b9e27b7271572bcfb Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 29 Apr 2024 08:20:57 +0200 Subject: [PATCH 09/19] refs #6275 hotFix fix:getExpeditionSummary --- modules/route/back/methods/route/getExpeditionSummary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/route/back/methods/route/getExpeditionSummary.js b/modules/route/back/methods/route/getExpeditionSummary.js index 4f95ded2a..34f55feb2 100644 --- a/modules/route/back/methods/route/getExpeditionSummary.js +++ b/modules/route/back/methods/route/getExpeditionSummary.js @@ -49,7 +49,7 @@ module.exports = Self => { JOIN vn.agencyMode am ON am.id = r.agencyModeFk JOIN vn.agency ag ON ag.id = am.agencyFk LEFT JOIN vn.userConfig uc ON uc.userFk = account.myUser_getId() - WHERE (r.created BETWEEN util.yesterday() AND util.VN_CURDATE() + INTERVAL 1 DAY) + WHERE (r.created BETWEEN util.yesterday() AND util.VN_CURDATE() + INTERVAL 1 DAY) AND t.routeFk = ? GROUP BY t.addressFk, e.itemPackingTypeFk ) sub From a180f54390ebe454de3c9ed0b39d686c6170c58a Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 29 Apr 2024 08:59:12 +0200 Subject: [PATCH 10/19] refs #6275 hotFix fix:getExpeditionSummary --- modules/route/back/methods/route/getExpeditionSummary.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/route/back/methods/route/getExpeditionSummary.js b/modules/route/back/methods/route/getExpeditionSummary.js index 34f55feb2..2bd2ca43a 100644 --- a/modules/route/back/methods/route/getExpeditionSummary.js +++ b/modules/route/back/methods/route/getExpeditionSummary.js @@ -49,8 +49,7 @@ module.exports = Self => { JOIN vn.agencyMode am ON am.id = r.agencyModeFk JOIN vn.agency ag ON ag.id = am.agencyFk LEFT JOIN vn.userConfig uc ON uc.userFk = account.myUser_getId() - WHERE (r.created BETWEEN util.yesterday() AND util.VN_CURDATE() + INTERVAL 1 DAY) - AND t.routeFk = ? + WHERE t.routeFk = ? GROUP BY t.addressFk, e.itemPackingTypeFk ) sub GROUP BY addressFk From dcb6f90ab3241ef405a34733ce6572fc50eede99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 29 Apr 2024 14:42:16 +0200 Subject: [PATCH 11/19] hotfix collection_assign elimino vLockTime --- db/routines/vn/procedures/collection_assign.sql | 5 ----- 1 file changed, 5 deletions(-) diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index 47efa7cd3..8f23ebe4a 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -16,7 +16,6 @@ BEGIN DECLARE vItemPackingTypeFk VARCHAR(1); DECLARE vWarehouseFk INT; DECLARE vLockName VARCHAR(215); - DECLARE vLockTime INT DEFAULT 30; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN @@ -54,10 +53,6 @@ BEGIN vItemPackingTypeFk ); - IF NOT GET_LOCK(vLockName, vLockTime) THEN - CALL util.throw(CONCAT('Cannot get lock: ', vLockName)); - END IF; - -- Se eliminan las colecciones sin asignar que estan obsoletas INSERT INTO ticketTracking(stateFk, ticketFk) SELECT s.id, tc.ticketFk From 51c8736da2b707ee313cede6941c466386e2a4a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 29 Apr 2024 14:54:15 +0200 Subject: [PATCH 12/19] hotFix collection_assign --- db/routines/vn/procedures/collection_assign.sql | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index 8f23ebe4a..13bf7f836 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -16,6 +16,7 @@ BEGIN DECLARE vItemPackingTypeFk VARCHAR(1); DECLARE vWarehouseFk INT; DECLARE vLockName VARCHAR(215); + DECLARE vLockTime INT DEFAULT 30; DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN @@ -33,8 +34,8 @@ BEGIN pc.collectionAssignLockname INTO vHasTooMuchCollections, vLockName - FROM tCollection - JOIN productionConfig pc; + FROM productionConfig pc + LEFT JOIN tCollection; DROP TEMPORARY TABLE tCollection; @@ -53,6 +54,10 @@ BEGIN vItemPackingTypeFk ); + IF NOT GET_LOCK(vLockName, vLockTime) THEN + CALL util.throw(CONCAT('Cannot get lock: ', vLockName)); + END IF; + -- Se eliminan las colecciones sin asignar que estan obsoletas INSERT INTO ticketTracking(stateFk, ticketFk) SELECT s.id, tc.ticketFk From 7b7afb05c56d1a7f9131df0d60e311cbc398abcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 29 Apr 2024 15:01:20 +0200 Subject: [PATCH 13/19] hotfix collection_assign --- db/routines/vn/procedures/collection_assign.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index 13bf7f836..1c3ef06ab 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -35,7 +35,7 @@ BEGIN INTO vHasTooMuchCollections, vLockName FROM productionConfig pc - LEFT JOIN tCollection; + LEFT JOIN tCollection ON TRUE; DROP TEMPORARY TABLE tCollection; From 21a1e1eed307b29066877cd1345b7083d9a58e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 29 Apr 2024 16:59:56 +0200 Subject: [PATCH 14/19] Hotfix feat: new function to kill connections --- db/routines/util/procedures/connection_kill.sql | 11 +++++++++++ db/routines/vn/procedures/collection_assign.sql | 7 ++----- db/routines/vn/procedures/collection_new.sql | 8 +++----- db/versions/11021-bronzeErica/00-firstScript.sql | 4 ++++ 4 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 db/routines/util/procedures/connection_kill.sql create mode 100644 db/versions/11021-bronzeErica/00-firstScript.sql diff --git a/db/routines/util/procedures/connection_kill.sql b/db/routines/util/procedures/connection_kill.sql new file mode 100644 index 000000000..c321a5117 --- /dev/null +++ b/db/routines/util/procedures/connection_kill.sql @@ -0,0 +1,11 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`connection_kill`(vConnectionId BIGINT) +BEGIN +/** + * Kill a connection + * + * @param vConnectionId + */ + KILL vConnectionId; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/collection_assign.sql b/db/routines/vn/procedures/collection_assign.sql index 1c3ef06ab..e976367cd 100644 --- a/db/routines/vn/procedures/collection_assign.sql +++ b/db/routines/vn/procedures/collection_assign.sql @@ -30,10 +30,7 @@ BEGIN -- Si hay colecciones sin terminar, sale del proceso CALL collection_get(vUserFk); - SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0, - pc.collectionAssignLockname - INTO vHasTooMuchCollections, - vLockName + SELECT (pc.maxNotReadyCollections - COUNT(*)) <= 0 INTO vHasTooMuchCollections FROM productionConfig pc LEFT JOIN tCollection ON TRUE; @@ -49,7 +46,7 @@ BEGIN WHERE workerFk = vUserFk; SET vLockName = CONCAT_WS('/', - vLockName, + 'collection_assign', vWarehouseFk, vItemPackingTypeFk ); diff --git a/db/routines/vn/procedures/collection_new.sql b/db/routines/vn/procedures/collection_new.sql index f207eb2b0..f3767ddf3 100644 --- a/db/routines/vn/procedures/collection_new.sql +++ b/db/routines/vn/procedures/collection_new.sql @@ -63,8 +63,7 @@ BEGIN o.numberOfWagons, o.trainFk, o.linesLimit, - o.volumeLimit, - pc.collectionNewLockname + o.volumeLimit INTO vMaxTickets, vHasUniqueCollectionTime, vWorkerCode, @@ -74,15 +73,14 @@ BEGIN vWagons, vTrainFk, vLinesLimit, - vVolumeLimit, - vLockName + vVolumeLimit FROM productionConfig pc JOIN worker w ON w.id = vUserFk JOIN state st ON st.`code` = 'ON_PREPARATION' JOIN operator o ON o.workerFk = vUserFk; SET vLockName = CONCAT_WS('/', - vLockName, + 'collection_new', vWarehouseFk, vItemPackingTypeFk ); diff --git a/db/versions/11021-bronzeErica/00-firstScript.sql b/db/versions/11021-bronzeErica/00-firstScript.sql new file mode 100644 index 000000000..f08667f8e --- /dev/null +++ b/db/versions/11021-bronzeErica/00-firstScript.sql @@ -0,0 +1,4 @@ + + ALTER TABLE vn.productionConfig + DROP COLUMN IF EXISTS collectionNewLockname, + DROP COLUMN IF EXISTS collectionAssignLockname; \ No newline at end of file From e55658e6b3301674ecd23bdc9561604f4380e714 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 29 Apr 2024 17:02:47 +0200 Subject: [PATCH 15/19] Hotfix feat: new function to kill connections --- db/routines/util/procedures/connection_kill.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/routines/util/procedures/connection_kill.sql b/db/routines/util/procedures/connection_kill.sql index c321a5117..b38509d1b 100644 --- a/db/routines/util/procedures/connection_kill.sql +++ b/db/routines/util/procedures/connection_kill.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`connection_kill`(vConnectionId BIGINT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`connection_kill`( + vConnectionId BIGINT +) BEGIN /** * Kill a connection From e934b47e9831c88b35eb07339bc179cc8947526e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Mon, 29 Apr 2024 17:09:51 +0200 Subject: [PATCH 16/19] Hotfix feat: new function to kill connections --- db/versions/11021-bronzeErica/00-firstScript.sql | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/db/versions/11021-bronzeErica/00-firstScript.sql b/db/versions/11021-bronzeErica/00-firstScript.sql index f08667f8e..6f6b68d49 100644 --- a/db/versions/11021-bronzeErica/00-firstScript.sql +++ b/db/versions/11021-bronzeErica/00-firstScript.sql @@ -1,4 +1,13 @@ ALTER TABLE vn.productionConfig DROP COLUMN IF EXISTS collectionNewLockname, - DROP COLUMN IF EXISTS collectionAssignLockname; \ No newline at end of file + DROP COLUMN IF EXISTS collectionAssignLockname; + + DELIMITER $$ + CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `util`.`connection_kill`() + BEGIN + + END$$ + DELIMITER ; + + GRANT EXECUTE ON PROCEDURE util.connection_kill TO 'developer'; \ No newline at end of file From d44b8f7c9a1a167b0bc5eca4241ac3367f5470cf Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 30 Apr 2024 11:44:16 +0200 Subject: [PATCH 17/19] hotfix: ticket #179514 ticket_close packaging fix --- db/routines/vn/procedures/ticket_close.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/ticket_close.sql b/db/routines/vn/procedures/ticket_close.sql index 91e0979cd..47d748ddf 100644 --- a/db/routines/vn/procedures/ticket_close.sql +++ b/db/routines/vn/procedures/ticket_close.sql @@ -63,7 +63,7 @@ BEGIN INSERT INTO ticketPackaging (ticketFk, packagingFk, quantity) (SELECT vCurTicketFk, p.id, COUNT(*) FROM expedition e - JOIN packaging p ON p.itemFk = e.freightItemFk + JOIN packaging p ON p.id = e.packagingFk WHERE e.ticketFk = vCurTicketFk AND p.isPackageReturnable AND vWithPackage GROUP BY p.itemFk); From d18f08e676ab4099d352117bd03b3769f5356c4e Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 30 Apr 2024 12:15:27 +0200 Subject: [PATCH 18/19] hotFix(addSaleByCode) add userId --- modules/ticket/back/methods/ticket/addSaleByCode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/addSaleByCode.js b/modules/ticket/back/methods/ticket/addSaleByCode.js index a73628c86..ca3d2cb07 100644 --- a/modules/ticket/back/methods/ticket/addSaleByCode.js +++ b/modules/ticket/back/methods/ticket/addSaleByCode.js @@ -30,7 +30,7 @@ module.exports = Self => { }); Self.addSaleByCode = async(ctx, barcode, quantity, ticketFk, warehouseFk, options) => { - const myOptions = {}; + const myOptions = {userId: ctx.req.accessToken.userId}; let tx; if (typeof options == 'object') From b9267250216b6c84f26f28cacd8581a8d01f7d60 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 2 May 2024 08:04:44 +0200 Subject: [PATCH 19/19] hotfix: ticket#179915 Fix no worker exists --- db/routines/vn/triggers/ticketPackaging_beforeInsert.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/db/routines/vn/triggers/ticketPackaging_beforeInsert.sql b/db/routines/vn/triggers/ticketPackaging_beforeInsert.sql index a58955e0d..f47a7ae35 100644 --- a/db/routines/vn/triggers/ticketPackaging_beforeInsert.sql +++ b/db/routines/vn/triggers/ticketPackaging_beforeInsert.sql @@ -4,7 +4,5 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketPackaging_befor FOR EACH ROW BEGIN SET NEW.editorFk = account.myUser_getId(); - SET NEW.workerFk = account.myUser_getId(); - END$$ DELIMITER ;