From 52457b964230af1eac10f328785d6c1c48f4deb8 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 3 Apr 2024 07:09:07 +0200 Subject: [PATCH 01/18] feat: sin concatenar en el nombre --- db/routines/vn/procedures/itemTrash.sql | 56 ------------------- .../vn/procedures/item_setVisibleDiscard.sql | 8 +-- 2 files changed, 4 insertions(+), 60 deletions(-) delete mode 100644 db/routines/vn/procedures/itemTrash.sql diff --git a/db/routines/vn/procedures/itemTrash.sql b/db/routines/vn/procedures/itemTrash.sql deleted file mode 100644 index bbb30b78a..000000000 --- a/db/routines/vn/procedures/itemTrash.sql +++ /dev/null @@ -1,56 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemTrash`( - vItemFk INT, - vWarehouseFk INT, - vQuantity INT, - vIsTrash BOOLEAN) -BEGIN - DECLARE vTicketFk INT; - DECLARE vClientFk INT; - DECLARE vCompanyVnlFk INT DEFAULT 442; - DECLARE vCalc INT; - - SELECT barcodeToItem(vItemFk) INTO vItemFk; - - SELECT IF(vIsTrash, 200, 400) INTO vClientFk; - - SELECT t.id INTO vTicketFk - FROM ticket t - JOIN address a ON a.id=t.addressFk - WHERE t.warehouseFk = vWarehouseFk - AND t.clientFk = vClientFk - AND DATE(t.shipped) = util.VN_CURDATE() - AND a.isDefaultAddress - LIMIT 1; - - CALL cache.visible_refresh(vCalc, TRUE, vWarehouseFk); - - IF vTicketFk IS NULL THEN - CALL ticket_add( - vClientFk, - util.VN_CURDATE(), - vWarehouseFk, - vCompanyVnlFk, - NULL, - NULL, - NULL, - util.VN_CURDATE(), - account.myUser_getId(), - FALSE, - vTicketFk); - END IF; - - INSERT INTO sale(ticketFk, itemFk, concept, quantity) - SELECT vTicketFk, - vItemFk, - CONCAT(longName,' ',worker_getCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)), - vQuantity - FROM item - WHERE id = vItemFk; - - UPDATE cache.visible - SET visible = visible - vQuantity - WHERE calc_id = vCalc - AND item_id = vItemFk; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/item_setVisibleDiscard.sql b/db/routines/vn/procedures/item_setVisibleDiscard.sql index 1cc2a8871..c1792dbb9 100644 --- a/db/routines/vn/procedures/item_setVisibleDiscard.sql +++ b/db/routines/vn/procedures/item_setVisibleDiscard.sql @@ -23,11 +23,11 @@ BEGIN SELECT DEFAULT(companyFk) INTO vDefaultCompanyFk FROM vn.ticket LIMIT 1; - - IF vAddressFk IS NULL THEN + + IF vAddressFk IS NULL THEN SELECT pc.shortageAddressFk INTO vAddressShortage FROM productionConfig pc ; - ELSE + ELSE SET vAddressShortage = vAddressFk; END IF; @@ -65,7 +65,7 @@ BEGIN INSERT INTO sale(ticketFk, itemFk, concept, quantity) SELECT vTicketFk, vItemFk, - CONCAT(longName,' ', worker_getCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)), + longName, vQuantity FROM item WHERE id = vItemFk; From d71f3e0818e38a978a01ccb508ead3b409755cb1 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 3 Apr 2024 09:02:34 +0200 Subject: [PATCH 02/18] test --- db/routines/vn/procedures/item_setVisibleDiscard.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/routines/vn/procedures/item_setVisibleDiscard.sql b/db/routines/vn/procedures/item_setVisibleDiscard.sql index c1792dbb9..59ffa0f66 100644 --- a/db/routines/vn/procedures/item_setVisibleDiscard.sql +++ b/db/routines/vn/procedures/item_setVisibleDiscard.sql @@ -13,6 +13,7 @@ BEGIN * @param vQuantity a dar de alta/baja * @param vAddressFk id address */ + DECLARE vTicketFk INT; DECLARE vClientFk INT; DECLARE vDefaultCompanyFk INT; From 90c26959af27b5c7abe43c20abbcd665ac50260f Mon Sep 17 00:00:00 2001 From: ivanm Date: Tue, 9 Apr 2024 13:39:33 +0200 Subject: [PATCH 03/18] refs #7161 change longName to name --- db/routines/vn/procedures/item_setVisibleDiscard.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/item_setVisibleDiscard.sql b/db/routines/vn/procedures/item_setVisibleDiscard.sql index 59ffa0f66..1f2dbee93 100644 --- a/db/routines/vn/procedures/item_setVisibleDiscard.sql +++ b/db/routines/vn/procedures/item_setVisibleDiscard.sql @@ -66,7 +66,7 @@ BEGIN INSERT INTO sale(ticketFk, itemFk, concept, quantity) SELECT vTicketFk, vItemFk, - longName, + name, vQuantity FROM item WHERE id = vItemFk; From 622075a9aa41c22673b1b8828d4ce22747c954d7 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 12 Apr 2024 09:21:34 +0200 Subject: [PATCH 04/18] fix(util): refs #7205 fix util.slowLog_prune --- db/routines/util/procedures/slowLog_prune.sql | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/db/routines/util/procedures/slowLog_prune.sql b/db/routines/util/procedures/slowLog_prune.sql index 7294be2f6..8e8aec30f 100644 --- a/db/routines/util/procedures/slowLog_prune.sql +++ b/db/routines/util/procedures/slowLog_prune.sql @@ -6,11 +6,19 @@ BEGIN */ DECLARE vSlowQueryLog INT DEFAULT @@slow_query_log; DECLARE vSqlLogBin INT DEFAULT @@SESSION.sql_log_bin; + DECLARE vLogExists BOOL; SET sql_log_bin = OFF; SET GLOBAL slow_query_log = OFF; - RENAME TABLE `mysql`.`slow_log` TO `mysql`.`slow_log_temp`; + SELECT COUNT(*) INTO vLogExists + FROM information_schema.TABLES + WHERE TABLE_SCHEMA = 'mysql' AND TABLE_NAME = 'slow_log'; + + IF vLogExists THEN + DROP TEMPORARY TABLE IF EXISTS `mysql`.`slow_log_temp`; + RENAME TABLE `mysql`.`slow_log` TO `mysql`.`slow_log_temp`; + END IF; DELETE FROM `mysql`.`slow_log_temp` WHERE start_time < TIMESTAMPADD(WEEK, -1, util.VN_NOW()); From ccf77ed356bfb24ec80d11ea6546458d59d8c81f Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 12 Apr 2024 09:24:48 +0200 Subject: [PATCH 05/18] fix(util): refs #7205 util.slowLog_prune code clean --- db/routines/util/procedures/slowLog_prune.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/util/procedures/slowLog_prune.sql b/db/routines/util/procedures/slowLog_prune.sql index 8e8aec30f..d676ae3d9 100644 --- a/db/routines/util/procedures/slowLog_prune.sql +++ b/db/routines/util/procedures/slowLog_prune.sql @@ -11,19 +11,19 @@ BEGIN SET sql_log_bin = OFF; SET GLOBAL slow_query_log = OFF; - SELECT COUNT(*) INTO vLogExists + SELECT COUNT(*) > 0 INTO vLogExists FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'mysql' AND TABLE_NAME = 'slow_log'; IF vLogExists THEN - DROP TEMPORARY TABLE IF EXISTS `mysql`.`slow_log_temp`; - RENAME TABLE `mysql`.`slow_log` TO `mysql`.`slow_log_temp`; + DROP TEMPORARY TABLE IF EXISTS mysql.slow_log_temp; + RENAME TABLE mysql.slow_log TO mysql.slow_log_temp; END IF; - DELETE FROM `mysql`.`slow_log_temp` + DELETE FROM mysql.slow_log_temp WHERE start_time < TIMESTAMPADD(WEEK, -1, util.VN_NOW()); - RENAME TABLE `mysql`.`slow_log_temp` TO `mysql`.`slow_log`; + RENAME TABLE mysql.slow_log_temp TO mysql.slow_log; SET GLOBAL slow_query_log = vSlowQueryLog; SET sql_log_bin = vSqlLogBin; From b4862a8ce94dc86223967b38bc20da393841eeb5 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 12 Apr 2024 11:35:21 +0200 Subject: [PATCH 06/18] hotFix(claimBegginingModel): enable claimIsEditable and && --- modules/claim/back/models/claim-beginning.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/claim/back/models/claim-beginning.js b/modules/claim/back/models/claim-beginning.js index 4b870e5ea..d269b2285 100644 --- a/modules/claim/back/models/claim-beginning.js +++ b/modules/claim/back/models/claim-beginning.js @@ -19,7 +19,7 @@ module.exports = Self => { if (ticket.ticketFk != claim.ticketFk) throw new UserError(`Cannot create a new claimBeginning from a different ticket`); } - // await claimIsEditable(ctx); + await claimIsEditable(ctx); }); Self.observe('before delete', async ctx => { @@ -36,7 +36,7 @@ module.exports = Self => { if (ctx.options && ctx.options.transaction) myOptions.transaction = ctx.options.transaction; - const claimBeginning = await Self.findById(ctx.where.id); + const claimBeginning = ctx.instance ?? await Self.findById(ctx.where.id); const filter = { where: {id: claimBeginning.claimFk}, From 253465cf139491cb70836533f4f542baa8d9f8c6 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 15 Apr 2024 08:47:27 +0200 Subject: [PATCH 07/18] refs #7190 feat: renewToken for multimedia --- back/methods/vn-user/renew-token.js | 8 +++- .../methods/vn-user/specs/share-token.spec.js | 43 +++++++++++++++++-- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/back/methods/vn-user/renew-token.js b/back/methods/vn-user/renew-token.js index d00085d8a..bc432d7ad 100644 --- a/back/methods/vn-user/renew-token.js +++ b/back/methods/vn-user/renew-token.js @@ -40,9 +40,15 @@ module.exports = Self => { } }, courtesyTime * 1000); + // Get scopes + + let createTokenOptions = {}; + const {scopes} = token; + if (scopes) + createTokenOptions = {scopes: [scopes[0]]}; // Create new accessToken const user = await Self.findById(token.userId); - const accessToken = await user.createAccessToken(); + const accessToken = await user.accessTokens.create(createTokenOptions); return {id: accessToken.id, ttl: accessToken.ttl}; }; diff --git a/back/methods/vn-user/specs/share-token.spec.js b/back/methods/vn-user/specs/share-token.spec.js index aaa83817c..e072a4fa8 100644 --- a/back/methods/vn-user/specs/share-token.spec.js +++ b/back/methods/vn-user/specs/share-token.spec.js @@ -1,6 +1,9 @@ const {models} = require('vn-loopback/server/server'); +const TOKEN_MULTIMEDIA = 'read:multimedia'; describe('Share Token', () => { let ctx = null; + const startingTime = Date.now(); + let multimediaToken = null; beforeAll(async() => { const unAuthCtx = { req: { @@ -17,11 +20,45 @@ describe('Share Token', () => { ctx = {req: {accessToken: accessToken}}; }); - it('should renew token', async() => { - const multimediaToken = await models.VnUser.shareToken(ctx); + beforeEach(async() => { + multimediaToken = await models.VnUser.shareToken(ctx); + jasmine.clock().install(); + jasmine.clock().mockDate(new Date(startingTime)); + }); + afterEach(() => { + jasmine.clock().uninstall(); + }); + + it('should generate token', async() => { expect(Object.keys(multimediaToken).length).toEqual(1); expect(multimediaToken.multimediaToken.userId).toEqual(ctx.req.accessToken.userId); - expect(multimediaToken.multimediaToken.scopes[0]).toEqual('read:multimedia'); + expect(multimediaToken.multimediaToken.scopes[0]).toEqual(TOKEN_MULTIMEDIA); + }); + + it('NOT should renew', async() => { + let error; + let response; + try { + response = await models.VnUser.renewToken(ctx); + } catch (e) { + error = e; + } + + expect(error).toBeUndefined(); + expect(response.id).toEqual(ctx.req.accessToken.id); + }); + + it('should renew token', async() => { + const mockDate = new Date(startingTime + 26600000); + jasmine.clock().mockDate(mockDate); + + const newShareToken = await models.VnUser.renewToken({req: {accessToken: multimediaToken.multimediaToken}}); + const {id} = newShareToken; + + expect(id).not.toEqual(ctx.req.accessToken.id); + const newMultimediaToken = await models.AccessToken.findById(id); + + expect(newMultimediaToken.scopes[0]).toEqual(TOKEN_MULTIMEDIA); }); }); From 25b5c35dc6bbe6303982b7de4dd20baddc9c8750 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 15 Apr 2024 08:47:49 +0200 Subject: [PATCH 08/18] refs #6835 fix: issue --- back/methods/vn-user/renew-token.js | 3 ++- back/methods/vn-user/specs/renew-token.spec.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/back/methods/vn-user/renew-token.js b/back/methods/vn-user/renew-token.js index bc432d7ad..2fd1f43c0 100644 --- a/back/methods/vn-user/renew-token.js +++ b/back/methods/vn-user/renew-token.js @@ -33,7 +33,8 @@ module.exports = Self => { // Schedule to remove current token setTimeout(async() => { try { - await Self.logout(token.id); + const exists = await models.AccessToken.findById(token.id); + exists && await Self.logout(token.id); } catch (err) { // eslint-disable-next-line no-console console.error(err); diff --git a/back/methods/vn-user/specs/renew-token.spec.js b/back/methods/vn-user/specs/renew-token.spec.js index 8d9bbf11c..741388bf9 100644 --- a/back/methods/vn-user/specs/renew-token.spec.js +++ b/back/methods/vn-user/specs/renew-token.spec.js @@ -33,6 +33,17 @@ describe('Renew Token', () => { const {id} = await models.VnUser.renewToken(ctx); expect(id).not.toEqual(ctx.req.accessToken.id); + + await models.VnUser.logout(ctx.req.accessToken.id); + jasmine.clock().tick(70 * 1000); + let tokenNotExists; + try { + tokenNotExists = await models.AccessToken.findById(ctx.req.accessToken.id); + } catch (e) { + error = e; + } + + expect(tokenNotExists).toBeNull(); }); it('NOT should renew', async() => { From a68b8431c5915ec958478f3d5112c6d4c504080d Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 10:21:59 +0200 Subject: [PATCH 09/18] feat: refs #6938 add scope & acls --- .../10994-wheatLaurel/00-modifyAcls.sql | 4 ++ modules/worker/back/models/worker.json | 53 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 db/versions/10994-wheatLaurel/00-modifyAcls.sql diff --git a/db/versions/10994-wheatLaurel/00-modifyAcls.sql b/db/versions/10994-wheatLaurel/00-modifyAcls.sql new file mode 100644 index 000000000..5b264482a --- /dev/null +++ b/db/versions/10994-wheatLaurel/00-modifyAcls.sql @@ -0,0 +1,4 @@ +UPDATE salix.ACL SET principalId = "hr" WHERE property IN ('find','findById','findOne') AND model = "Worker"; + +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) + VALUES ('Worker', 'summary', 'READ', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index ed430f133..4b7e4a512 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -92,5 +92,58 @@ "model": "WorkerTeamCollegues", "foreignKey": "workerFk" } + }, + "scopes":{ + "summary": { + "fields": [ + [ + "id", + "firstName", + "lastName", + "bossFk", + "maritalStatus", + "originCountryFk", + "educationLevelFk", + "SSN", + "mobileExtension", + "code", + "locker", + "fi", + "birth", + "isF11Allowed" + ] + + ], + "include": [ + { + "relation": "user", + "scope": { + "fields": ["email", "name", "nickname", "roleFk"], + "include": { + "relation": "role", + "scope": { + "fields": ["name"] + } + } + } + }, { + "relation": "department", + "scope": { + "include": { + "relation": "department", + "scope": { + "fields": ["name"] + } + } + } + }, { + "relation": "boss" + }, { + "relation": "client" + }, { + "relation": "sip" + } + ] + } } } From 200cbd8d74bedf95605c3b8ab260fb2155100494 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 11:03:57 +0200 Subject: [PATCH 10/18] fix: refs #6938 acls & scope --- db/versions/10994-wheatLaurel/00-modifyAcls.sql | 2 +- modules/worker/back/models/worker.json | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/db/versions/10994-wheatLaurel/00-modifyAcls.sql b/db/versions/10994-wheatLaurel/00-modifyAcls.sql index 5b264482a..905f67aba 100644 --- a/db/versions/10994-wheatLaurel/00-modifyAcls.sql +++ b/db/versions/10994-wheatLaurel/00-modifyAcls.sql @@ -1,4 +1,4 @@ UPDATE salix.ACL SET principalId = "hr" WHERE property IN ('find','findById','findOne') AND model = "Worker"; INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) - VALUES ('Worker', 'summary', 'READ', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file + VALUES ('Worker', '__get__summary', 'READ', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 4b7e4a512..0c4f91118 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -96,7 +96,6 @@ "scopes":{ "summary": { "fields": [ - [ "id", "firstName", "lastName", @@ -112,8 +111,7 @@ "birth", "isF11Allowed" ] - - ], + , "include": [ { "relation": "user", From 42fe7fb1e23e47cf6b07d846dd0ea57a3f1e9481 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 15 Apr 2024 11:32:44 +0200 Subject: [PATCH 11/18] feat(binlog): refs #4409 Disable order recalc from triggers --- db/routines/hedera/events/order_doRecalc.sql | 2 +- db/routines/hedera/procedures/order_requestRecalc.sql | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/db/routines/hedera/events/order_doRecalc.sql b/db/routines/hedera/events/order_doRecalc.sql index d355e1a55..bbc61924f 100644 --- a/db/routines/hedera/events/order_doRecalc.sql +++ b/db/routines/hedera/events/order_doRecalc.sql @@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `hedera`.`order_doRecalc` ON SCHEDULE EVERY 10 SECOND STARTS '2019-08-29 14:18:04.000' ON COMPLETION PRESERVE - ENABLE + DISABLE DO CALL order_doRecalc$$ DELIMITER ; diff --git a/db/routines/hedera/procedures/order_requestRecalc.sql b/db/routines/hedera/procedures/order_requestRecalc.sql index 4bcb1010e..990894bb6 100644 --- a/db/routines/hedera/procedures/order_requestRecalc.sql +++ b/db/routines/hedera/procedures/order_requestRecalc.sql @@ -10,6 +10,7 @@ proc: BEGIN LEAVE proc; END IF; - INSERT INTO orderRecalc SET orderFk = vSelf; + -- #4409 Disable order recalc + -- INSERT INTO orderRecalc SET orderFk = vSelf; END$$ DELIMITER ; From d7b06fe637ca4662cdd8672ba287ca03a2f07c76 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 12:47:27 +0200 Subject: [PATCH 12/18] fix: refs #6938 scope --- modules/worker/back/models/worker.json | 67 +++++++++++++++++--------- 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 0c4f91118..10776af90 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -95,23 +95,6 @@ }, "scopes":{ "summary": { - "fields": [ - "id", - "firstName", - "lastName", - "bossFk", - "maritalStatus", - "originCountryFk", - "educationLevelFk", - "SSN", - "mobileExtension", - "code", - "locker", - "fi", - "birth", - "isF11Allowed" - ] - , "include": [ { "relation": "user", @@ -128,16 +111,56 @@ "relation": "department", "scope": { "include": { - "relation": "department", - "scope": { - "fields": ["name"] - } + "relation": "department" } } }, { "relation": "boss" }, { - "relation": "client" + "relation": "client", + "scope": { + "fields": [ + "id", + "name", + "fi", + "socialName", + "contact", + "street", + "city", + "postcode", + "email", + "mobile", + "isActive", + "credit", + "creditInsurance", + "iban", + "dueDay", + "isEqualizated", + "isFreezed", + "hasToInvoiceByAddress", + "hasToInvoice", + "isToBeMailed", + "hasSepaVnl", + "hasLcr", + "hasCoreVnl", + "hasCoreVnh", + "hasIncoterms", + "isTaxDataChecked", + "eypbc", + "quality", + "isVies", + "isRelevant", + "accountingAccount", + "created", + "sageTaxTypeFk", + "sageTransactionTypeFk", + "businessTypeFk", + "salesPersonFk", + "hasElectronicInvoice", + "rating", + "recommendedCredit" + ] + } }, { "relation": "sip" } From 3e1218463c03b2cda4ea390a262299b49d661fac Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 14:44:18 +0200 Subject: [PATCH 13/18] fix: refs #6938 filters & scope --- modules/worker/back/models/worker.json | 18 ++++++--- modules/worker/front/card/index.js | 32 ++-------------- modules/worker/front/descriptor/index.js | 36 ++--------------- modules/worker/front/summary/index.js | 49 +++--------------------- 4 files changed, 25 insertions(+), 110 deletions(-) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 10776af90..57dc80ec9 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -100,12 +100,20 @@ "relation": "user", "scope": { "fields": ["email", "name", "nickname", "roleFk"], - "include": { - "relation": "role", - "scope": { - "fields": ["name"] + "include": [ + { + "relation": "role", + "scope": { + "fields": ["name"] + } + }, + { + "relation": "emailUser", + "scope": { + "fields": ["email"] + } } - } + ] } }, { "relation": "department", diff --git a/modules/worker/front/card/index.js b/modules/worker/front/card/index.js index 9a40e31c2..1aa548db9 100644 --- a/modules/worker/front/card/index.js +++ b/modules/worker/front/card/index.js @@ -4,37 +4,13 @@ import ModuleCard from 'salix/components/module-card'; class Controller extends ModuleCard { reload() { const filter = { - include: [ - { - relation: 'user', - scope: { - fields: ['name', 'emailVerified'], - include: { - relation: 'emailUser', - scope: { - fields: ['email'] - } - } - } - }, { - relation: 'sip', - scope: { - fields: ['extension', 'secret'] - } - }, { - relation: 'department', - scope: { - include: { - relation: 'department' - } - } - } - ] + where: { + id: this.$params.id} }; return Promise.all([ - this.$http.get(`Workers/${this.$params.id}`, {filter}) - .then(res => this.worker = res.data), + this.$http.get(`Workers/summary`, {filter}) + .then(res => this.worker = res.data[0]), this.$http.get(`Workers/${this.$params.id}/activeContract`) .then(res => this.hasWorkCenter = res.data?.workCenterFk) ]); diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js index d7962369c..ebf3d65ed 100644 --- a/modules/worker/front/descriptor/index.js +++ b/modules/worker/front/descriptor/index.js @@ -37,41 +37,11 @@ class Controller extends Descriptor { loadData() { const filter = { - include: [ - { - relation: 'user', - scope: { - fields: ['name', 'emailVerified'], - include: { - relation: 'emailUser', - scope: { - fields: ['email'] - } - } - } - }, { - relation: 'client', - scope: { - fields: ['fi'] - } - }, { - relation: 'sip', - scope: { - fields: ['extension'] - } - }, { - relation: 'department', - scope: { - include: { - relation: 'department' - } - } - } - ] + where: {id: this.id}, }; - return this.getData(`Workers/${this.id}`, {filter}) - .then(res => this.entity = res.data); + return this.getData(`Workers/summary`, {filter}) + .then(res => this.entity = res.data[0]); } getPassRequirements() { diff --git a/modules/worker/front/summary/index.js b/modules/worker/front/summary/index.js index 212609f58..d1a27a6d4 100644 --- a/modules/worker/front/summary/index.js +++ b/modules/worker/front/summary/index.js @@ -10,53 +10,14 @@ class Controller extends Summary { this.$.worker = null; if (!value) return; - const query = `Workers/${value.id}`; const filter = { - include: [ - { - relation: 'user', - scope: { - fields: ['name', 'roleFk'], - include: [{ - relation: 'role', - scope: { - fields: ['name'] - } - }, - { - relation: 'emailUser', - scope: { - fields: ['email'] - } - }] - } - }, - { - relation: 'client', - scope: {fields: ['fi', 'phone']} - }, - { - relation: 'boss', - scope: {fields: ['id', 'name']} - }, - { - relation: 'sip', - scope: {fields: ['extension']} - }, - { - relation: 'department', - scope: { - include: { - relation: 'department', - scope: {fields: ['id', 'code', 'name']} - } - } - } - ] + where: { + id: value.id + } }; - this.$http.get(query, {params: {filter}}).then(res => { - this.$.worker = res.data; + this.$http.get(`Workers/summary`, {filter}).then(res => { + this.$.worker = res.data[0]; }); } From 3c9ac9634b6c4ab5890bb232d2d68b9d12eb9a63 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 15:02:45 +0200 Subject: [PATCH 14/18] fix: refs #6938 front tests --- modules/worker/front/descriptor/index.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/worker/front/descriptor/index.spec.js b/modules/worker/front/descriptor/index.spec.js index 4f7fa6a05..cee8b0def 100644 --- a/modules/worker/front/descriptor/index.spec.js +++ b/modules/worker/front/descriptor/index.spec.js @@ -14,14 +14,14 @@ describe('vnWorkerDescriptor', () => { describe('loadData()', () => { it(`should perform a get query to store the worker data into the controller`, () => { const id = 1; - const response = 'foo'; + const response = ['foo']; $httpBackend.whenGET('UserConfigs/getUserConfig').respond({}); - $httpBackend.expectRoute('GET', `Workers/${id}`).respond(response); + $httpBackend.expectRoute('GET', `Workers/summary`).respond(response); controller.id = id; $httpBackend.flush(); - expect(controller.worker).toEqual(response); + expect([controller.worker]).toEqual(response); }); }); From adb2249d2f8b4a74149e195b471963b2e317aade Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 15:09:41 +0200 Subject: [PATCH 15/18] fix: refs #6938 e2e tests --- e2e/paths/03-worker/01_summary.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/e2e/paths/03-worker/01_summary.spec.js b/e2e/paths/03-worker/01_summary.spec.js index 51992b41d..3c6149726 100644 --- a/e2e/paths/03-worker/01_summary.spec.js +++ b/e2e/paths/03-worker/01_summary.spec.js @@ -2,7 +2,6 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; describe('Worker summary path', () => { - const workerId = 3; let browser; let page; beforeAll(async() => { @@ -10,7 +9,7 @@ describe('Worker summary path', () => { page = browser.page; await page.loginAndModule('employee', 'worker'); const httpDataResponse = page.waitForResponse(response => { - return response.status() === 200 && response.url().includes(`Workers/${workerId}`); + return response.status() === 200 && response.url().includes(`Workers/summary`); }); await page.accessToSearchResult('agencyNick'); await httpDataResponse; From 6e183b74264099ed0cb928d5f6d6ad3698f6e848 Mon Sep 17 00:00:00 2001 From: ivanm Date: Mon, 15 Apr 2024 15:59:05 +0200 Subject: [PATCH 16/18] refs #7161 change vAddress to vAddressShortage --- db/routines/vn/procedures/itemTrash.sql | 56 +++++++++++++++++++ .../vn/procedures/item_setVisibleDiscard.sql | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 db/routines/vn/procedures/itemTrash.sql diff --git a/db/routines/vn/procedures/itemTrash.sql b/db/routines/vn/procedures/itemTrash.sql new file mode 100644 index 000000000..bbb30b78a --- /dev/null +++ b/db/routines/vn/procedures/itemTrash.sql @@ -0,0 +1,56 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemTrash`( + vItemFk INT, + vWarehouseFk INT, + vQuantity INT, + vIsTrash BOOLEAN) +BEGIN + DECLARE vTicketFk INT; + DECLARE vClientFk INT; + DECLARE vCompanyVnlFk INT DEFAULT 442; + DECLARE vCalc INT; + + SELECT barcodeToItem(vItemFk) INTO vItemFk; + + SELECT IF(vIsTrash, 200, 400) INTO vClientFk; + + SELECT t.id INTO vTicketFk + FROM ticket t + JOIN address a ON a.id=t.addressFk + WHERE t.warehouseFk = vWarehouseFk + AND t.clientFk = vClientFk + AND DATE(t.shipped) = util.VN_CURDATE() + AND a.isDefaultAddress + LIMIT 1; + + CALL cache.visible_refresh(vCalc, TRUE, vWarehouseFk); + + IF vTicketFk IS NULL THEN + CALL ticket_add( + vClientFk, + util.VN_CURDATE(), + vWarehouseFk, + vCompanyVnlFk, + NULL, + NULL, + NULL, + util.VN_CURDATE(), + account.myUser_getId(), + FALSE, + vTicketFk); + END IF; + + INSERT INTO sale(ticketFk, itemFk, concept, quantity) + SELECT vTicketFk, + vItemFk, + CONCAT(longName,' ',worker_getCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)), + vQuantity + FROM item + WHERE id = vItemFk; + + UPDATE cache.visible + SET visible = visible - vQuantity + WHERE calc_id = vCalc + AND item_id = vItemFk; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/item_setVisibleDiscard.sql b/db/routines/vn/procedures/item_setVisibleDiscard.sql index 1f2dbee93..0a6c54971 100644 --- a/db/routines/vn/procedures/item_setVisibleDiscard.sql +++ b/db/routines/vn/procedures/item_setVisibleDiscard.sql @@ -34,7 +34,7 @@ BEGIN SELECT a.clientFk INTO vClientFk FROM address a - WHERE a.id = vAddressFk; + WHERE a.id = vAddressShortage; SELECT t.id INTO vTicketFk FROM ticket t From 7fda58d4a4fef14dcd557c90fa7be07caadcf122 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 16 Apr 2024 12:29:44 +0200 Subject: [PATCH 17/18] hotfix: ticket#174308 Ekt load packing --- db/routines/edi/procedures/ekt_load.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/edi/procedures/ekt_load.sql b/db/routines/edi/procedures/ekt_load.sql index ccdcd1999..adbaf4628 100644 --- a/db/routines/edi/procedures/ekt_load.sql +++ b/db/routines/edi/procedures/ekt_load.sql @@ -147,7 +147,7 @@ proc:BEGIN (@t := IF(i.stems, i.stems, 1)) * e.pri / IFNULL(i.stemMultiplier, 1) buyingValue, IFNULL(vItem, vDefaultEntry) itemFk, e.qty stickers, - @pac := IFNULL(i.stemMultiplier, 1) * e.pac / @t packing, + @pac := GREATEST(1, i.stemMultiplier * e.pac / @t) packing, IFNULL(b.`grouping`, e.pac), @pac * e.qty, vForceToPacking, From db5b0d79676d2b3f9f75e5c44e3135dac3a08770 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 16 Apr 2024 17:19:25 +0200 Subject: [PATCH 18/18] hotfix: ticket#174761 Greatest fix null possibility --- db/routines/edi/procedures/ekt_load.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/edi/procedures/ekt_load.sql b/db/routines/edi/procedures/ekt_load.sql index adbaf4628..34814453b 100644 --- a/db/routines/edi/procedures/ekt_load.sql +++ b/db/routines/edi/procedures/ekt_load.sql @@ -147,7 +147,7 @@ proc:BEGIN (@t := IF(i.stems, i.stems, 1)) * e.pri / IFNULL(i.stemMultiplier, 1) buyingValue, IFNULL(vItem, vDefaultEntry) itemFk, e.qty stickers, - @pac := GREATEST(1, i.stemMultiplier * e.pac / @t) packing, + @pac := GREATEST(1, IFNULL(i.stemMultiplier * e.pac / @t, 0)) packing, IFNULL(b.`grouping`, e.pac), @pac * e.qty, vForceToPacking,