From 411933a608718dc7e4e2af3c5dfaf0f7defaac21 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 3 May 2024 12:17:51 +0200 Subject: [PATCH 01/53] feat: refs #6598 acls back --- back/methods/vn-user/acls.js | 72 ++++++++++++++++++++++++++++++++++++ back/models/vn-user.js | 1 + back/models/vn-user.json | 7 ++++ 3 files changed, 80 insertions(+) create mode 100644 back/methods/vn-user/acls.js diff --git a/back/methods/vn-user/acls.js b/back/methods/vn-user/acls.js new file mode 100644 index 000000000..7da75ed2c --- /dev/null +++ b/back/methods/vn-user/acls.js @@ -0,0 +1,72 @@ +module.exports = Self => { + Self.remoteMethodCtx('acls', { + description: 'Get all of the current user acls', + returns: { + type: 'Object', + root: true + }, + http: { + path: '/acls', + verb: 'GET' + } + }); + + const staticAcls = new Map(); + const app = require('vn-loopback/server/server'); + app.on('started', function() { + for (const model of app.models()) { + for (const acl of model.settings.acls) { + if (acl.principalType == 'ROLE' && acl.permission == 'ALLOW') { + const staticAcl = { + model: model.name, + property: '*', + accessType: acl.accessType, + permission: acl.permission, + principalType: acl.principalType, + principalId: acl.principalId, + }; + if (staticAcls.has(acl.principalId)) + staticAcls.get(acl.principalId).push(staticAcl); + else + staticAcls.set(acl.principalId, [staticAcl]); + } + } + } + }); + + Self.acls = async function(ctx) { + const models = Self.app.models; + const acls = []; + const userId = ctx.req.accessToken.userId; + if (userId) { + const roleMapping = await models.RoleMapping.find({ + where: { + principalId: userId + }, + include: [ + { + relation: 'role', + scope: { + fields: [ + 'name' + ] + } + } + ] + }); + const dynamicAcls = await models.ACL.find({ + where: { + principalId: { + inq: roleMapping.map(rm => rm.role().name) + } + } + }); + dynamicAcls.forEach(acl => acls.push(acl)); + staticAcls.get('$authenticated').forEach(acl => acls.push(acl)); + } else + staticAcls.get('$unauthenticated').forEach(acl => acls.push(acl)); + + staticAcls.get('$everyone').forEach(acl => acls.push(acl)); + return acls; + }; +}; diff --git a/back/models/vn-user.js b/back/models/vn-user.js index b59f13ffa..08a4daf54 100644 --- a/back/models/vn-user.js +++ b/back/models/vn-user.js @@ -15,6 +15,7 @@ module.exports = function(Self) { require('../methods/vn-user/renew-token')(Self); require('../methods/vn-user/share-token')(Self); require('../methods/vn-user/update-user')(Self); + require('../methods/vn-user/acls')(Self); Self.definition.settings.acls = Self.definition.settings.acls.filter(acl => acl.property !== 'create'); diff --git a/back/models/vn-user.json b/back/models/vn-user.json index 5f6ac3f47..ebd2ea2f3 100644 --- a/back/models/vn-user.json +++ b/back/models/vn-user.json @@ -133,6 +133,13 @@ "principalType": "ROLE", "principalId": "$authenticated", "permission": "ALLOW" + }, + { + "property": "acls", + "accessType": "*", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" } ], "scopes": { From 40b2c32a00a30e2eb5e4e38921c336b52cf6e8b0 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 3 May 2024 17:37:36 +0200 Subject: [PATCH 02/53] feat: refs #6243 show all cmr --- db/dump/.dump/data.sql | 2 +- .../route/{getExternalCmrs.js => cmrs.js} | 30 ++++--------------- modules/route/back/models/route.js | 2 +- print/templates/reports/cmr/sql/data.sql | 3 +- 4 files changed, 9 insertions(+), 28 deletions(-) rename modules/route/back/methods/route/{getExternalCmrs.js => cmrs.js} (87%) diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index 8c6794a5b..a5a95d565 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -1783,7 +1783,7 @@ INSERT INTO `ACL` VALUES (761,'Route','downloadZip','READ','ALLOW','ROLE','emplo INSERT INTO `ACL` VALUES (762,'Route','filter','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (763,'Route','getByWorker','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (764,'Route','getDeliveryPoint','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (765,'Route','getExternalCmrs','READ','ALLOW','ROLE','employee'); +INSERT INTO `ACL` VALUES (765,'Route','cmrs','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (766,'Route','getSuggestedTickets','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (767,'Route','getTickets','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (768,'Route','guessPriority','WRITE','ALLOW','ROLE','employee'); diff --git a/modules/route/back/methods/route/getExternalCmrs.js b/modules/route/back/methods/route/cmrs.js similarity index 87% rename from modules/route/back/methods/route/getExternalCmrs.js rename to modules/route/back/methods/route/cmrs.js index b8cd1041a..814ff77c6 100644 --- a/modules/route/back/methods/route/getExternalCmrs.js +++ b/modules/route/back/methods/route/cmrs.js @@ -3,8 +3,8 @@ const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; module.exports = Self => { - Self.remoteMethod('getExternalCmrs', { - description: 'Returns an array of external cmrs', + Self.remoteMethod('cmrs', { + description: 'Returns an array of cmrs', accessType: 'READ', accepts: [ { @@ -53,31 +53,14 @@ module.exports = Self => { root: true }, http: { - path: `/getExternalCmrs`, + path: `/cmrs`, verb: 'GET' } }); - Self.getExternalCmrs = async( - filter, - cmrFk, - ticketFk, - routeFk, - country, - clientFk, - hasCmrDms, - shipped, - options + Self.cmrs = async(filter, cmrFk, ticketFk, routeFk, country, clientFk, hasCmrDms, shipped, options ) => { - const params = { - cmrFk, - ticketFk, - routeFk, - country, - clientFk, - hasCmrDms, - shipped, - }; + const params = {cmrFk, ticketFk, routeFk, country, clientFk, hasCmrDms, shipped}; const conn = Self.dataSource.connector; let where = buildFilter(params, (param, value) => { @@ -124,8 +107,7 @@ module.exports = Self => { JOIN dmsType dt ON dt.id = d.dmsTypeFk WHERE dt.name = 'cmr' ) sub ON sub.ticketFk = t.id - WHERE co.code <> 'ES' - AND am.name <> 'ABONO' + WHERE am.name <> 'ABONO' AND w.code = 'ALG' AND t.cmrFk ) sub diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js index bf1f26e74..ecc434108 100644 --- a/modules/route/back/models/route.js +++ b/modules/route/back/models/route.js @@ -15,7 +15,7 @@ module.exports = Self => { require('../methods/route/sendSms')(Self); require('../methods/route/downloadZip')(Self); require('../methods/route/cmr')(Self); - require('../methods/route/getExternalCmrs')(Self); + require('../methods/route/cmrs')(Self); require('../methods/route/downloadCmrsZip')(Self); require('../methods/route/cmrEmail')(Self); require('../methods/route/getExpeditionSummary')(Self); diff --git a/print/templates/reports/cmr/sql/data.sql b/print/templates/reports/cmr/sql/data.sql index e9500cc4b..09a42a718 100644 --- a/print/templates/reports/cmr/sql/data.sql +++ b/print/templates/reports/cmr/sql/data.sql @@ -39,8 +39,7 @@ SELECT c.id cmrFk, LEFT JOIN supplier s ON s.id = c.supplierFk LEFT JOIN country cou ON cou.id = s.countryFk LEFT JOIN company co ON co.id = c.companyFk - LEFT JOIN supplierAccount sa ON sa.id = co.supplierAccountFk - LEFT JOIN supplier s2 ON s2.id = sa.supplierFk + LEFT JOIN supplier s2 ON s2.id = c.companyFk LEFT JOIN country cou2 ON cou2.id = s2.countryFk LEFT JOIN `address` a ON a.id = c.addressToFk LEFT JOIN province p ON p.id = a.provinceFk From 5abc95af5122b53b4e03d412ba284bd288060034 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 17 May 2024 11:29:16 +0200 Subject: [PATCH 03/53] feat: refs #6598 back test --- back/methods/vn-user/specs/acls.spec.js | 36 +++++++++++++++++++++++++ back/tests-helper.js | 1 + 2 files changed, 37 insertions(+) create mode 100644 back/methods/vn-user/specs/acls.spec.js diff --git a/back/methods/vn-user/specs/acls.spec.js b/back/methods/vn-user/specs/acls.spec.js new file mode 100644 index 000000000..486d23bca --- /dev/null +++ b/back/methods/vn-user/specs/acls.spec.js @@ -0,0 +1,36 @@ +const {models} = require('vn-loopback/server/server'); +const id = {administrative: 5, employee: 1, productionBoss: 50}; + +describe('VnUser acls()', () => { + it('should get its owns acls', async() => { + const hasAdministrativeAcls = await hasAcl('administrative', id.administrative); + const hasProductionBossAcls = await hasAcl('productionBoss', id.productionBoss); + + expect(hasAdministrativeAcls).toBeTruthy(); + expect(hasProductionBossAcls).toBeTruthy(); + }); + + it('should not get administrative acls', async() => { + const hasAdministrativeAcls = await hasAcl('administrative', id.employee); + + expect(hasAdministrativeAcls).toBeFalsy(); + }); + + it('should get the $authenticated acls', async() => { + const hasAuthAcls = await hasAcl('$authenticated', id.employee); + + expect(hasAuthAcls).toBeTruthy(); + }); + + it('should get the $everyone acls', async() => { + const hasEveryoneAcls = await hasAcl('$everyone', id.employee); + + expect(hasEveryoneAcls).toBeTruthy(); + }); +}); + +const hasAcl = async(role, userId) => { + const ctx = {req: {accessToken: {userId}, headers: {origin: 'http://localhost'}}}; + const acls = await models.VnUser.acls(ctx); + return Object.values(acls).some(acl => acl.principalId === role); +}; diff --git a/back/tests-helper.js b/back/tests-helper.js index b88fa1fd6..6d465bc2a 100644 --- a/back/tests-helper.js +++ b/back/tests-helper.js @@ -17,6 +17,7 @@ async function init() { err => err ? reject(err) : resolve()); }); // FIXME: Workaround to wait for loopback to be ready + app.emit('started'); await app.models.Application.status(); } From 0e51fa861cb4ce8707ad2106ad5204f0a5c41706 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 17 May 2024 11:35:29 +0200 Subject: [PATCH 04/53] fix: refs #6598 drop variables --- back/methods/vn-user/specs/acls.spec.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/back/methods/vn-user/specs/acls.spec.js b/back/methods/vn-user/specs/acls.spec.js index 486d23bca..0349b39fb 100644 --- a/back/methods/vn-user/specs/acls.spec.js +++ b/back/methods/vn-user/specs/acls.spec.js @@ -3,29 +3,20 @@ const id = {administrative: 5, employee: 1, productionBoss: 50}; describe('VnUser acls()', () => { it('should get its owns acls', async() => { - const hasAdministrativeAcls = await hasAcl('administrative', id.administrative); - const hasProductionBossAcls = await hasAcl('productionBoss', id.productionBoss); - - expect(hasAdministrativeAcls).toBeTruthy(); - expect(hasProductionBossAcls).toBeTruthy(); + expect(await hasAcl('administrative', id.administrative)).toBeTruthy(); + expect(await hasAcl('productionBoss', id.productionBoss)).toBeTruthy(); }); it('should not get administrative acls', async() => { - const hasAdministrativeAcls = await hasAcl('administrative', id.employee); - - expect(hasAdministrativeAcls).toBeFalsy(); + expect(await hasAcl('administrative', id.employee)).toBeFalsy(); }); it('should get the $authenticated acls', async() => { - const hasAuthAcls = await hasAcl('$authenticated', id.employee); - - expect(hasAuthAcls).toBeTruthy(); + expect(await hasAcl('$authenticated', id.employee)).toBeTruthy(); }); it('should get the $everyone acls', async() => { - const hasEveryoneAcls = await hasAcl('$everyone', id.employee); - - expect(hasEveryoneAcls).toBeTruthy(); + expect(await hasAcl('$everyone', id.employee)).toBeTruthy(); }); }); From 49fed4e51e45f1d203ca43f13ed3c4cb02cd5cb2 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 22 May 2024 12:23:33 +0200 Subject: [PATCH 05/53] refs #6964 feat: hasItemOlder --- db/versions/11064-grayMedeola/00-firstScript.sql | 6 ++++++ .../back/methods/item-shelving/hasItemOlder.js | 15 ++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 db/versions/11064-grayMedeola/00-firstScript.sql diff --git a/db/versions/11064-grayMedeola/00-firstScript.sql b/db/versions/11064-grayMedeola/00-firstScript.sql new file mode 100644 index 000000000..301c0fef1 --- /dev/null +++ b/db/versions/11064-grayMedeola/00-firstScript.sql @@ -0,0 +1,6 @@ +-- Place your SQL code here + +USE vn; + +ALTER TABLE vn.sector ADD hasItemOlderReview BIGINT DEFAULT false NULL COMMENT 'Indica si el sector se revisa para comprobar si tiene ítems más viejos'; +ALTER TABLE vn.productionConfig ADD itemOlderReviewHours int(11) NULL COMMENT 'Horas que se tienen en cuenta para comprobar si un ítem es más viejo.'; diff --git a/modules/item/back/methods/item-shelving/hasItemOlder.js b/modules/item/back/methods/item-shelving/hasItemOlder.js index ee4cdc829..02cd14bb8 100644 --- a/modules/item/back/methods/item-shelving/hasItemOlder.js +++ b/modules/item/back/methods/item-shelving/hasItemOlder.js @@ -46,17 +46,22 @@ module.exports = Self => { SELECT COUNT(ish.id) countItemOlder FROM vn.itemShelving ish JOIN ( - SELECT ish.itemFk, created,shelvingFk + SELECT ish.itemFk, created, shelvingFk FROM vn.itemShelving ish JOIN vn.shelving s ON ish.shelvingFk = s.code + LEFT JOIN vn.parking p2 ON p2.id = s.parkingFk WHERE ish.shelvingFk = ? )sub ON sub.itemFK = ish.itemFk JOIN vn.shelving s ON s.code = ish.shelvingFk JOIN vn.parking p ON p.id = s.parkingFk - WHERE sub.created > ish.created - AND (p.code <> ? OR ? IS NULL) - AND (ish.shelvingFk <> ? OR ? IS NULL) - AND (ish.itemFk <> ? OR ? IS NULL)`, + JOIN vn.sector s2 ON s2.id = p.sectorFk + JOIN vn.productionConfig pc ON pc.itemOlderReviewHours + WHERE ish.created + INTERVAL pc.itemOlderReviewHours HOUR < sub.created + AND (p.code <> ? OR ? IS NULL) + AND (ish.shelvingFk <> ? OR ? IS NULL) + AND (ish.itemFk = ? OR ? IS NULL) + AND (p.pickingOrder < sub.pickingOrder OR sub.pickingOrder IS NULL) + AND (s2.hasItemOlderReview)`, [shelvingFkIn, parking, parking, shelvingFkOut, shelvingFkOut, itemFk, itemFk], myOptions); return result[0]['countItemOlder'] > 0; }; From 0914925a860d6978f848c9315a38456307e1cc3f Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 23 May 2024 13:43:00 +0200 Subject: [PATCH 06/53] refs #6964 feat: hasItemOlder --- modules/item/back/methods/item-shelving/hasItemOlder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/back/methods/item-shelving/hasItemOlder.js b/modules/item/back/methods/item-shelving/hasItemOlder.js index 02cd14bb8..9bea6fbe9 100644 --- a/modules/item/back/methods/item-shelving/hasItemOlder.js +++ b/modules/item/back/methods/item-shelving/hasItemOlder.js @@ -46,7 +46,7 @@ module.exports = Self => { SELECT COUNT(ish.id) countItemOlder FROM vn.itemShelving ish JOIN ( - SELECT ish.itemFk, created, shelvingFk + SELECT ish.itemFk, created, shelvingFk, pickingOrder FROM vn.itemShelving ish JOIN vn.shelving s ON ish.shelvingFk = s.code LEFT JOIN vn.parking p2 ON p2.id = s.parkingFk From 0e5a15dd4e1b9fc5ac5738280090663a6cf1f4b1 Mon Sep 17 00:00:00 2001 From: jgallego Date: Fri, 24 May 2024 15:14:20 +0200 Subject: [PATCH 07/53] con addressFk --- db/dump/.dump/data.sql | 4 +-- db/dump/fixtures.before.sql | 19 +++++++++----- .../vn/procedures/expeditionTruck_Add.sql | 9 ------- .../vn/procedures/expeditionTruck_List.sql | 12 --------- .../vn/views/expeditionTruck_Control.sql | 19 -------------- .../views/expeditionTruck_Control_Detail.sql | 18 ------------- .../expeditionTruck_Control_Detail_Pallet.sql | 22 ---------------- .../00-roadmapAddress.sql | 8 ++++++ .../11063-purpleAnthurium/01-roadmapStop.sql | 7 +++++ .../02-roadmapStopGrants.sql | 11 ++++++++ .../route/back/locale/routesMonitor/en.yml | 4 +-- .../route/back/locale/routesMonitor/es.yml | 4 +-- modules/route/back/methods/roadmap/clone.js | 11 +++----- modules/route/back/model-config.json | 3 +++ modules/route/back/models/roadmapAddress.json | 26 +++++++++++++++++++ modules/route/back/models/roadmapStop.json | 8 +++--- 16 files changed, 81 insertions(+), 104 deletions(-) delete mode 100644 db/routines/vn/procedures/expeditionTruck_Add.sql delete mode 100644 db/routines/vn/procedures/expeditionTruck_List.sql delete mode 100644 db/routines/vn/views/expeditionTruck_Control.sql delete mode 100644 db/routines/vn/views/expeditionTruck_Control_Detail.sql delete mode 100644 db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql create mode 100644 db/versions/11063-purpleAnthurium/00-roadmapAddress.sql create mode 100644 db/versions/11063-purpleAnthurium/01-roadmapStop.sql create mode 100644 db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql create mode 100644 modules/route/back/models/roadmapAddress.json diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index f49e3f0f9..b1a69dee9 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -1747,8 +1747,8 @@ INSERT INTO `ACL` VALUES (688,'ClientSms','create','WRITE','ALLOW','ROLE','emplo INSERT INTO `ACL` VALUES (689,'Vehicle','sorted','WRITE','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (690,'Roadmap','*','*','ALLOW','ROLE','palletizerBoss'); INSERT INTO `ACL` VALUES (691,'Roadmap','*','*','ALLOW','ROLE','productionBoss'); -INSERT INTO `ACL` VALUES (692,'ExpeditionTruck','*','*','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (693,'ExpeditionTruck','*','*','ALLOW','ROLE','productionBoss'); +INSERT INTO `ACL` VALUES (692,'roadmapStop','*','*','ALLOW','ROLE','production'); +INSERT INTO `ACL` VALUES (693,'roadmapStop','*','*','ALLOW','ROLE','productionBoss'); INSERT INTO `ACL` VALUES (695,'ViaexpressConfig','internationalExpedition','WRITE','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (696,'ViaexpressConfig','renderer','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (697,'Ticket','transferClient','WRITE','ALLOW','ROLE','administrative'); diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 3e6edf07d..ccd6ef1d5 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2670,13 +2670,20 @@ INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`) (3, 6, 5), (4, 7, 1); +INSERT INTO `vn`.`roadmapAddress` (`addressFk`) + VALUES + (1), + (2), + (3), + (4); + INSERT INTO `vn`.`roadmap` (`id`, `name`, `tractorPlate`, `trailerPlate`, `phone`, `supplierFk`, `etd`, `observations`, `userFk`, `price`, `driverName`) VALUES - (1, 'val-algemesi', 'RE-001', 'PO-001', '111111111', 1, util.VN_NOW(), 'this is test observation', 1, 15, 'Batman'), - (2, 'alg-valencia', 'RE-002', 'PO-002', '111111111', 1, util.VN_NOW(), 'test observation', 1, 20, 'Robin'), - (3, 'alz-algemesi', 'RE-003', 'PO-003', '222222222', 2, DATE_ADD(util.VN_NOW(), INTERVAL 2 DAY), 'observations...', 2, 25, 'Driverman'); + (1, 'val-algemesi', '1234-BCD', '9876-BCD', '111111111', 1, util.VN_NOW(), 'this is test observation', 1, 15, 'Batman'), + (2, 'alg-valencia', '2345-CDF', '8765-BCD', '111111111', 1, util.VN_NOW(), 'test observation', 1, 20, 'Robin'), + (3, 'alz-algemesi', '3456-DFG', '7654-BCD', '222222222', 2, DATE_ADD(util.VN_NOW(), INTERVAL 2 DAY), 'observations...', 2, 25, 'Driverman'); -INSERT INTO `vn`.`expeditionTruck` (`id`, `roadmapFk`, `warehouseFk`, `eta`, `description`, `userFk`) +INSERT INTO `vn`.`roadmapStop` (`id`, `roadmapFk`, `addressFk`, `eta`, `description`, `userFk`) VALUES (1, 1, 1, DATE_ADD(util.VN_NOW(), INTERVAL 1 DAY), 'Best truck in fleet', 1), (2, 1, 2, DATE_ADD(util.VN_NOW(), INTERVAL '1 2' DAY_HOUR), 'Second truck in fleet', 1), @@ -3788,7 +3795,7 @@ INSERT INTO vn.workerTeam(id, team, workerFk) VALUES (8, 1, 19); -INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment) +INSERT INTO vn.workCenter (id, name, payrollCenterFk, counter, warehouseFk, street, geoFk, deliveryManAdjustment) VALUES(100, 'workCenterOne', 1, NULL, 1, 'gotham', NULL, NULL); -UPDATE vn.locker SET workerFk = 1110 WHERE id = 147; \ No newline at end of file +UPDATE vn.locker SET workerFk = 1110 WHERE id = 147; diff --git a/db/routines/vn/procedures/expeditionTruck_Add.sql b/db/routines/vn/procedures/expeditionTruck_Add.sql deleted file mode 100644 index eabfa452c..000000000 --- a/db/routines/vn/procedures/expeditionTruck_Add.sql +++ /dev/null @@ -1,9 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionTruck_Add`(vHour VARCHAR(5), vDescription VARCHAR(45)) -BEGIN - - INSERT INTO vn.roadmapStop(eta,description) - VALUES(CONCAT(util.VN_CURDATE(), ' ', vHour), vDescription); - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/expeditionTruck_List.sql b/db/routines/vn/procedures/expeditionTruck_List.sql deleted file mode 100644 index c358df5e3..000000000 --- a/db/routines/vn/procedures/expeditionTruck_List.sql +++ /dev/null @@ -1,12 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`expeditionTruck_List`() -BEGIN - - SELECT id truckFk, - eta, - description Destino - FROM roadmapStop - WHERE eta BETWEEN util.VN_CURDATE() AND util.dayend(util.VN_CURDATE()) - ORDER BY eta; -END$$ -DELIMITER ; diff --git a/db/routines/vn/views/expeditionTruck_Control.sql b/db/routines/vn/views/expeditionTruck_Control.sql deleted file mode 100644 index 838e1f89e..000000000 --- a/db/routines/vn/views/expeditionTruck_Control.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`expeditionTruck_Control` -AS SELECT `e`.`truckFk` AS `id`, - `e`.`eta` AS `ETD`, - `e`.`description` AS `description`, - COUNT( - DISTINCT IF(`e`.`expeditionFk` IS NULL, `e`.`ticketFk`, NULL) - ) AS `ticketsSinBultos`, - COUNT(DISTINCT `e`.`palletFk`) AS `pallets`, - COUNT(DISTINCT `e`.`routeFk`) AS `routes`, - COUNT(DISTINCT `e`.`scanFk`) AS `scans`, - COUNT(DISTINCT `e`.`expeditionFk`) AS `expeditions`, - sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, - max(`e`.`lastPacked`) AS `lastPacked` -FROM `vn`.`expeditionCommon` `e` -GROUP BY `e`.`truckFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, - `e`.`eta` diff --git a/db/routines/vn/views/expeditionTruck_Control_Detail.sql b/db/routines/vn/views/expeditionTruck_Control_Detail.sql deleted file mode 100644 index 96a5b78e6..000000000 --- a/db/routines/vn/views/expeditionTruck_Control_Detail.sql +++ /dev/null @@ -1,18 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`expeditionTruck_Control_Detail` -AS SELECT `e`.`truckFk` AS `id`, - `e`.`eta` AS `eta`, - `e`.`description` AS `destino`, - `e`.`palletFk` AS `pallet`, - COUNT(DISTINCT `e`.`routeFk`) AS `routes`, - COUNT(DISTINCT `e`.`scanFk`) AS `scans`, - COUNT(DISTINCT `e`.`expeditionTruckFk`) AS `destinos`, - sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, - max(`e`.`lastPacked`) AS `lastPacked` -FROM `vn`.`expeditionCommon` `e` -GROUP BY `e`.`truckFk`, - `e`.`palletFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, - `e`.`eta`, - `e`.`truckFk` diff --git a/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql b/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql deleted file mode 100644 index 3f239432d..000000000 --- a/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql +++ /dev/null @@ -1,22 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn`.`expeditionTruck_Control_Detail_Pallet` -AS SELECT `e`.`truckFk` AS `id`, - `e`.`eta` AS `eta`, - `e`.`description` AS `destino`, - `e`.`palletFk` AS `pallet`, - `e`.`routeFk` AS `route`, - COUNT(DISTINCT `e`.`scanFk`) AS `scans`, - `rs`.`description` AS `destinos`, - sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, - `e`.`expeditionTruckFk` AS `expeditionTruckFk`, - max(`e`.`lastPacked`) AS `lastPacked` -FROM ( - `vn`.`expeditionCommon` `e` - LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `e`.`expeditionTruckFk`) - ) -GROUP BY `e`.`truckFk`, - `e`.`palletFk`, - `e`.`routeFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, - `e`.`palletFk` diff --git a/db/versions/11063-purpleAnthurium/00-roadmapAddress.sql b/db/versions/11063-purpleAnthurium/00-roadmapAddress.sql new file mode 100644 index 000000000..6435da1c9 --- /dev/null +++ b/db/versions/11063-purpleAnthurium/00-roadmapAddress.sql @@ -0,0 +1,8 @@ +CREATE TABLE `vn`.`roadmapAddress` ( + addressFk int(11) NULL, + isActive TINYINT DEFAULT 1 NULL, + PRIMARY KEY (addressFk) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Direcciones de los troncales'; + +ALTER TABLE vn.roadmapAddress + ADD CONSTRAINT roadmapAddress_address_FK FOREIGN KEY (addressFk) REFERENCES vn.address(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11063-purpleAnthurium/01-roadmapStop.sql b/db/versions/11063-purpleAnthurium/01-roadmapStop.sql new file mode 100644 index 000000000..844abf45f --- /dev/null +++ b/db/versions/11063-purpleAnthurium/01-roadmapStop.sql @@ -0,0 +1,7 @@ +ALTER TABLE vn.roadmapStop DROP FOREIGN KEY expeditionTruck_FK_1; +ALTER TABLE vn.roadmapStop DROP COLUMN warehouseFk; +ALTER TABLE vn.roadmapStop ADD addressFk int(11) NULL; +ALTER TABLE vn.roadmapStop CHANGE addressFk addressFk int(11) DEFAULT NULL NULL AFTER roadmapFk; + +ALTER TABLE vn.roadmapStop + ADD CONSTRAINT roadmapStop_roadmapAddress_FK FOREIGN KEY (addressFk) REFERENCES vn.roadmapAddress(addressFk) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql b/db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql new file mode 100644 index 000000000..d2c8354c0 --- /dev/null +++ b/db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql @@ -0,0 +1,11 @@ +DELETE FROM salix.ACL + WHERE model in ('expeditionTruck', 'Roadmap', 'roadmapStop', 'roadmapAddress'); + +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) + VALUES + ('roadmapAddress', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'), + ('roadmapAddress', '*', 'READ', 'ALLOW', 'ROLE', 'production'), + ('Roadmap', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'), + ('Roadmap', '*', 'READ', 'ALLOW', 'ROLE', 'production'), + ('RoadmapStop', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'), + ('RoadmapStop', '*', 'READ', 'ALLOW', 'ROLE', 'production'); diff --git a/modules/route/back/locale/routesMonitor/en.yml b/modules/route/back/locale/routesMonitor/en.yml index 8908ee636..0542ced54 100644 --- a/modules/route/back/locale/routesMonitor/en.yml +++ b/modules/route/back/locale/routesMonitor/en.yml @@ -13,7 +13,7 @@ columns: m3: m3 priority: priority etd: etd - expeditionTruckFk: truck + roadmapStopFk: truck m3boxes: m3 boxes bufferFk: buffer - isPickingAllowed: is picking allowed \ No newline at end of file + isPickingAllowed: is picking allowed diff --git a/modules/route/back/locale/routesMonitor/es.yml b/modules/route/back/locale/routesMonitor/es.yml index 9ded8983d..1ea0532c6 100644 --- a/modules/route/back/locale/routesMonitor/es.yml +++ b/modules/route/back/locale/routesMonitor/es.yml @@ -13,7 +13,7 @@ columns: m3: m3 priority: prioridad etd: etd - expeditionTruckFk: camión + roadmapStopFk: camión m3boxes: m3 cajas bufferFk: buffer - isPickingAllowed: está permitido recoger \ No newline at end of file + isPickingAllowed: está permitido recoger diff --git a/modules/route/back/methods/roadmap/clone.js b/modules/route/back/methods/roadmap/clone.js index b74cf803c..5f1ab9229 100644 --- a/modules/route/back/methods/roadmap/clone.js +++ b/modules/route/back/methods/roadmap/clone.js @@ -37,17 +37,12 @@ module.exports = Self => { fields: [ 'id', 'name', - 'tractorPlate', - 'trailerPlate', - 'phone', 'supplierFk', - 'etd', - 'observations', - 'price'], + 'etd'], include: [{ - relation: 'expeditionTruck', + relation: 'roadmapStop', scope: { - fields: ['roadmapFk', 'warehouseFk', 'eta', 'description'] + fields: ['roadmapFk', 'addressFk', 'eta', 'description'] } }] diff --git a/modules/route/back/model-config.json b/modules/route/back/model-config.json index 09cda6b2d..ccae87bd9 100644 --- a/modules/route/back/model-config.json +++ b/modules/route/back/model-config.json @@ -8,6 +8,9 @@ "DeliveryPoint": { "dataSource": "vn" }, + "RoadmapAddress": { + "dataSource": "vn" + }, "RoadmapStop": { "dataSource": "vn" }, diff --git a/modules/route/back/models/roadmapAddress.json b/modules/route/back/models/roadmapAddress.json new file mode 100644 index 000000000..0241ce0d8 --- /dev/null +++ b/modules/route/back/models/roadmapAddress.json @@ -0,0 +1,26 @@ +{ + "name": "RoadmapAddress", + "base": "VnModel", + "options": { + "mysql": { + "table": "roadmapAddress" + } + }, + "properties": { + "addressFk": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "isActive": { + "type": "number" + } + }, + "relations": { + "address": { + "type": "belongsTo", + "model": "Address", + "foreignKey": "addressFk" + } + } +} diff --git a/modules/route/back/models/roadmapStop.json b/modules/route/back/models/roadmapStop.json index 51aa3a6db..527bbae98 100644 --- a/modules/route/back/models/roadmapStop.json +++ b/modules/route/back/models/roadmapStop.json @@ -15,7 +15,7 @@ "roadmapFk": { "type": "number" }, - "warehouseFk": { + "addressFk": { "type": "number" }, "eta": { @@ -34,10 +34,10 @@ "model": "Roadmap", "foreignKey": "roadmapFk" }, - "warehouse": { + "address": { "type": "belongsTo", - "model": "Warehouse", - "foreignKey": "warehouseFk" + "model": "RoadmapAddress", + "foreignKey": "addressFk" } } } From eb503238d737858f100dc53f06af1d28a497fddb Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 27 May 2024 09:07:23 +0200 Subject: [PATCH 08/53] feat refs #7296 routesMonitor.expeditionTruckFk to routesMonitor.roadmapStopFk --- db/dump/fixtures.after.sql | 2 +- db/routines/dipole/procedures/expedition_add.sql | 2 +- db/routines/srt/functions/expedition_getDayMinute.sql | 2 +- db/routines/srt/views/bufferDayMinute.sql | 2 +- db/routines/srt/views/bufferStock.sql | 2 +- db/routines/srt/views/upperStickers.sql | 2 +- db/routines/vn/procedures/conveyorExpedition_Add.sql | 2 +- db/routines/vn/procedures/expedition_StateGet.sql | 2 +- db/routines/vn/procedures/expedition_getState.sql | 2 +- db/routines/vn/procedures/reportLabelCollection_get.sql | 2 +- db/routines/vn/procedures/routeMonitor_calculate.sql | 2 +- db/routines/vn/views/expeditionCommon.sql | 4 ++-- db/routines/vn/views/expeditionPallet_Print.sql | 4 ++-- db/routines/vn/views/expeditionRoute_Monitor.sql | 2 +- db/routines/vn/views/expeditionSticker.sql | 2 +- db/routines/vn/views/expeditionTicket_NoBoxes.sql | 2 +- db/routines/vn/views/expeditionTruck_Control.sql | 4 ++-- db/routines/vn/views/expeditionTruck_Control_Detail.sql | 6 +++--- .../vn/views/expeditionTruck_Control_Detail_Pallet.sql | 6 +++--- print/templates/reports/collection-label/sql/labelsData.sql | 2 +- .../reports/expedition-pallet-label/sql/labelData.sql | 4 ++-- 21 files changed, 29 insertions(+), 29 deletions(-) diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index fd940d8a6..562ea02d8 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -129,7 +129,7 @@ INSERT INTO vn.itemShelving (id,itemFk,visible,shelvingFk,`grouping`,packing,pac INSERT INTO vn.beach (code,warehouseFk) VALUES ('TEST',1); -INSERT INTO vn.routesMonitor (routeFk,name,beachFk,m3,expeditionTruckFk) VALUES +INSERT INTO vn.routesMonitor (routeFk,name,beachFk,m3,roadmapStopFk) VALUES (1,'TEST','TEST',1.0,1); /* #5483 INSERT INTO vn.ticket (clientFk, warehouseFk, shipped, nickname, refFk, addressFk, workerFk, observations, isSigned, isLabeled, isPrinted, packages, location, `hour`, created, isBlocked, solution, routeFk, priority, hasPriority, companyFk, agencyModeFk, landed, isBoxed, isDeleted, zoneFk, zonePrice, zoneBonus, totalWithVat, totalWithoutVat, weight) diff --git a/db/routines/dipole/procedures/expedition_add.sql b/db/routines/dipole/procedures/expedition_add.sql index e224cd2d2..70bc7930e 100644 --- a/db/routines/dipole/procedures/expedition_add.sql +++ b/db/routines/dipole/procedures/expedition_add.sql @@ -46,7 +46,7 @@ BEGIN JOIN vn.address a ON a.id = t.addressFk JOIN vn.province p ON p.id = a.provinceFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk LEFT JOIN vn.beach b ON b.code = rm.beachFk LEFT JOIN vn.`zone`z ON z.id = t.zoneFk JOIN vn.agencyMode am ON t.agencyModeFk = am.id diff --git a/db/routines/srt/functions/expedition_getDayMinute.sql b/db/routines/srt/functions/expedition_getDayMinute.sql index 9331f77e5..01ff534f5 100644 --- a/db/routines/srt/functions/expedition_getDayMinute.sql +++ b/db/routines/srt/functions/expedition_getDayMinute.sql @@ -22,7 +22,7 @@ BEGIN LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.routesMonitor rm ON t.routeFk = rm.routeFk - LEFT JOIN vn.roadmapStop rs ON rm.expeditionTruckFk = rs.id + LEFT JOIN vn.roadmapStop rs ON rm.roadmapStopFk = rs.id WHERE e.id = vExpeditionFk; RETURN vDayMinute; diff --git a/db/routines/srt/views/bufferDayMinute.sql b/db/routines/srt/views/bufferDayMinute.sql index 41db2bcf7..d2108e513 100644 --- a/db/routines/srt/views/bufferDayMinute.sql +++ b/db/routines/srt/views/bufferDayMinute.sql @@ -34,7 +34,7 @@ FROM ( ) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`) ) - LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`) + LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`roadmapStopFk` = `rs`.`id`) ) LEFT JOIN `vn`.`zone` `z` ON(`z`.`id` = `t`.`zoneFk`) ) diff --git a/db/routines/srt/views/bufferStock.sql b/db/routines/srt/views/bufferStock.sql index 7494cf0a9..ca04d3c01 100644 --- a/db/routines/srt/views/bufferStock.sql +++ b/db/routines/srt/views/bufferStock.sql @@ -45,7 +45,7 @@ FROM ( ) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`) ) - LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`) + LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`roadmapStopFk` = `rs`.`id`) ) JOIN `srt`.`config` `c` ) diff --git a/db/routines/srt/views/upperStickers.sql b/db/routines/srt/views/upperStickers.sql index a230408d9..1cd72c12b 100644 --- a/db/routines/srt/views/upperStickers.sql +++ b/db/routines/srt/views/upperStickers.sql @@ -32,7 +32,7 @@ FROM ( ) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`t`.`routeFk` = `rm`.`routeFk`) ) - LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`expeditionTruckFk` = `rs`.`id`) + LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rm`.`roadmapStopFk` = `rs`.`id`) ) JOIN `dipole`.`expedition_PrintOut` `epo` ON(`epo`.`expeditionFk` = `e`.`id`) ) diff --git a/db/routines/vn/procedures/conveyorExpedition_Add.sql b/db/routines/vn/procedures/conveyorExpedition_Add.sql index daaf33f2f..94cbc88e2 100644 --- a/db/routines/vn/procedures/conveyorExpedition_Add.sql +++ b/db/routines/vn/procedures/conveyorExpedition_Add.sql @@ -34,7 +34,7 @@ BEGIN LEFT JOIN vn.agencyMode am ON am.id = z.agencyModeFk LEFT JOIN vn.agency a ON a.id = am.agencyFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk JOIN vn.packagingConfig pc WHERE t.warehouseFk IN (60,1,44) AND e.created BETWEEN vStarted AND vEnded diff --git a/db/routines/vn/procedures/expedition_StateGet.sql b/db/routines/vn/procedures/expedition_StateGet.sql index e58ec3afd..c709841eb 100644 --- a/db/routines/vn/procedures/expedition_StateGet.sql +++ b/db/routines/vn/procedures/expedition_StateGet.sql @@ -67,7 +67,7 @@ BEGIN LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id - LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk WHERE e.id = vExpeditionFk; END$$ diff --git a/db/routines/vn/procedures/expedition_getState.sql b/db/routines/vn/procedures/expedition_getState.sql index f3f94a889..61d65f571 100644 --- a/db/routines/vn/procedures/expedition_getState.sql +++ b/db/routines/vn/procedures/expedition_getState.sql @@ -50,7 +50,7 @@ BEGIN LEFT JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.agencyMode am ON am.id = r.agencyModeFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id - LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk WHERE e.id = vExpeditionFk; END$$ diff --git a/db/routines/vn/procedures/reportLabelCollection_get.sql b/db/routines/vn/procedures/reportLabelCollection_get.sql index e7f8f2bc3..f3bcbfa28 100644 --- a/db/routines/vn/procedures/reportLabelCollection_get.sql +++ b/db/routines/vn/procedures/reportLabelCollection_get.sql @@ -47,7 +47,7 @@ BEGIN LEFT JOIN ticketTrolley tt ON tt.ticket = t.id LEFT JOIN zone zo ON t.zoneFk = zo.id LEFT JOIN routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN roadmapStop rs ON rs.id = rm.expeditionTruckFk + LEFT JOIN roadmapStop rs ON rs.id = rm.roadmapStopFk WHERE IF(vIsCollection, tc.collectionFk = vParam, tc.ticketFk = vParam) GROUP BY t.id ORDER BY cc.code; diff --git a/db/routines/vn/procedures/routeMonitor_calculate.sql b/db/routines/vn/procedures/routeMonitor_calculate.sql index 04a31a161..463c176ff 100644 --- a/db/routines/vn/procedures/routeMonitor_calculate.sql +++ b/db/routines/vn/procedures/routeMonitor_calculate.sql @@ -106,7 +106,7 @@ BEGIN SET rm.m3boxes = sub.m3boxes; UPDATE routesMonitor rm - JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk + JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk SET rm.etd = rs.eta; DROP TEMPORARY TABLE tmp.routesMonitor; diff --git a/db/routines/vn/views/expeditionCommon.sql b/db/routines/vn/views/expeditionCommon.sql index d1ce80880..46765e57c 100644 --- a/db/routines/vn/views/expeditionCommon.sql +++ b/db/routines/vn/views/expeditionCommon.sql @@ -8,7 +8,7 @@ AS SELECT `rs`.`id` AS `truckFk`, `t`.`routeFk` AS `routeFk`, `es`.`id` AS `scanFk`, `e`.`id` AS `expeditionFk`, - `r`.`expeditionTruckFk` AS `expeditionTruckFk`, + `r`.`roadmapStopFk` AS `expeditionTruckFk`, `t`.`warehouseFk` AS `warehouseFk`, `e`.`created` AS `lastPacked`, `t`.`id` AS `ticketFk` @@ -18,7 +18,7 @@ FROM ( ( ( `vn`.`roadmapStop` `rs` - LEFT JOIN `vn`.`routesMonitor` `r` ON(`rs`.`id` = `r`.`expeditionTruckFk`) + LEFT JOIN `vn`.`routesMonitor` `r` ON(`rs`.`id` = `r`.`roadmapStopFk`) ) LEFT JOIN `vn`.`ticket` `t` ON(`r`.`routeFk` = `t`.`routeFk`) ) diff --git a/db/routines/vn/views/expeditionPallet_Print.sql b/db/routines/vn/views/expeditionPallet_Print.sql index c0b8208c3..aab725ebe 100644 --- a/db/routines/vn/views/expeditionPallet_Print.sql +++ b/db/routines/vn/views/expeditionPallet_Print.sql @@ -6,7 +6,7 @@ AS SELECT `rs2`.`description` AS `truck`, `r`.`description` AS `zone`, COUNT(`es`.`id`) AS `eti`, `ep`.`id` AS `palletFk`, - `rs`.`id` <=> `rm`.`expeditionTruckFk` AS `isMatch`, + `rs`.`id` <=> `rm`.`roadmapStopFk` AS `isMatch`, `t`.`warehouseFk` AS `warehouseFk`, IF( `r`.`created` > `util`.`VN_CURDATE`() + INTERVAL 1 DAY, @@ -33,7 +33,7 @@ FROM ( ) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`rm`.`routeFk` = `r`.`id`) ) - LEFT JOIN `vn`.`roadmapStop` `rs2` ON(`rs2`.`id` = `rm`.`expeditionTruckFk`) + LEFT JOIN `vn`.`roadmapStop` `rs2` ON(`rs2`.`id` = `rm`.`roadmapStopFk`) ) GROUP BY `ep`.`id`, `t`.`routeFk` diff --git a/db/routines/vn/views/expeditionRoute_Monitor.sql b/db/routines/vn/views/expeditionRoute_Monitor.sql index cc1f16894..7eef40425 100644 --- a/db/routines/vn/views/expeditionRoute_Monitor.sql +++ b/db/routines/vn/views/expeditionRoute_Monitor.sql @@ -15,7 +15,7 @@ FROM ( `vn`.`route` `r` LEFT JOIN `vn`.`routesMonitor` `rm` ON(`r`.`id` = `rm`.`routeFk`) ) - LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`expeditionTruckFk`) + LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`roadmapStopFk`) ) JOIN `vn`.`ticket` `t` ON(`t`.`routeFk` = `r`.`id`) ) diff --git a/db/routines/vn/views/expeditionSticker.sql b/db/routines/vn/views/expeditionSticker.sql index 05fbc42a1..ef0743527 100644 --- a/db/routines/vn/views/expeditionSticker.sql +++ b/db/routines/vn/views/expeditionSticker.sql @@ -45,7 +45,7 @@ FROM ( ) LEFT JOIN `vn`.`routesMonitor` `rm` ON(`rm`.`routeFk` = `t`.`routeFk`) ) - LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`expeditionTruckFk`) + LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`roadmapStopFk`) ) LEFT JOIN `vn`.`beach` `b` ON(`b`.`code` = `rm`.`beachFk`) ) diff --git a/db/routines/vn/views/expeditionTicket_NoBoxes.sql b/db/routines/vn/views/expeditionTicket_NoBoxes.sql index 8acbe17fe..75218c7a9 100644 --- a/db/routines/vn/views/expeditionTicket_NoBoxes.sql +++ b/db/routines/vn/views/expeditionTicket_NoBoxes.sql @@ -13,7 +13,7 @@ FROM ( ) JOIN `vn`.`routesMonitor` `rm` ON(`rm`.`routeFk` = `t`.`routeFk`) ) - JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`expeditionTruckFk`) + JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `rm`.`roadmapStopFk`) ) WHERE `e`.`id` IS NULL AND `rs`.`eta` > `util`.`VN_CURDATE`() diff --git a/db/routines/vn/views/expeditionTruck_Control.sql b/db/routines/vn/views/expeditionTruck_Control.sql index 838e1f89e..818ae3ae6 100644 --- a/db/routines/vn/views/expeditionTruck_Control.sql +++ b/db/routines/vn/views/expeditionTruck_Control.sql @@ -11,9 +11,9 @@ AS SELECT `e`.`truckFk` AS `id`, COUNT(DISTINCT `e`.`routeFk`) AS `routes`, COUNT(DISTINCT `e`.`scanFk`) AS `scans`, COUNT(DISTINCT `e`.`expeditionFk`) AS `expeditions`, - sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, + sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`, max(`e`.`lastPacked`) AS `lastPacked` FROM `vn`.`expeditionCommon` `e` GROUP BY `e`.`truckFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, +ORDER BY sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC, `e`.`eta` diff --git a/db/routines/vn/views/expeditionTruck_Control_Detail.sql b/db/routines/vn/views/expeditionTruck_Control_Detail.sql index 96a5b78e6..51970544b 100644 --- a/db/routines/vn/views/expeditionTruck_Control_Detail.sql +++ b/db/routines/vn/views/expeditionTruck_Control_Detail.sql @@ -7,12 +7,12 @@ AS SELECT `e`.`truckFk` AS `id`, `e`.`palletFk` AS `pallet`, COUNT(DISTINCT `e`.`routeFk`) AS `routes`, COUNT(DISTINCT `e`.`scanFk`) AS `scans`, - COUNT(DISTINCT `e`.`expeditionTruckFk`) AS `destinos`, - sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, + COUNT(DISTINCT `e`.`roadmapStopFk`) AS `destinos`, + sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`, max(`e`.`lastPacked`) AS `lastPacked` FROM `vn`.`expeditionCommon` `e` GROUP BY `e`.`truckFk`, `e`.`palletFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, +ORDER BY sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC, `e`.`eta`, `e`.`truckFk` diff --git a/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql b/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql index 3f239432d..7e24d6b01 100644 --- a/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql +++ b/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql @@ -8,15 +8,15 @@ AS SELECT `e`.`truckFk` AS `id`, `e`.`routeFk` AS `route`, COUNT(DISTINCT `e`.`scanFk`) AS `scans`, `rs`.`description` AS `destinos`, - sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, + sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`, `e`.`expeditionTruckFk` AS `expeditionTruckFk`, max(`e`.`lastPacked`) AS `lastPacked` FROM ( `vn`.`expeditionCommon` `e` - LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `e`.`expeditionTruckFk`) + LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `e`.`roadmapStopFk`) ) GROUP BY `e`.`truckFk`, `e`.`palletFk`, `e`.`routeFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, +ORDER BY sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC, `e`.`palletFk` diff --git a/print/templates/reports/collection-label/sql/labelsData.sql b/print/templates/reports/collection-label/sql/labelsData.sql index 2ffa6d8db..c96817b9c 100644 --- a/print/templates/reports/collection-label/sql/labelsData.sql +++ b/print/templates/reports/collection-label/sql/labelsData.sql @@ -35,7 +35,7 @@ SELECT c.itemPackingTypeFk code, LEFT JOIN vn.ticketTrolley tt ON tt.ticket = t.id LEFT JOIN vn.`zone` zo ON t.zoneFk = zo.id LEFT JOIN vn.routesMonitor rm ON rm.routeFk = t.routeFk - LEFT JOIN vn.roadmapStop rs ON rs.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs ON rs.id = rm.roadmapStopFk LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleFk = s.id JOIN vn.productionConfig pc WHERE t.id IN (?) diff --git a/print/templates/reports/expedition-pallet-label/sql/labelData.sql b/print/templates/reports/expedition-pallet-label/sql/labelData.sql index 385614305..49a4031ae 100644 --- a/print/templates/reports/expedition-pallet-label/sql/labelData.sql +++ b/print/templates/reports/expedition-pallet-label/sql/labelData.sql @@ -5,7 +5,7 @@ SELECT ep.id palletFk, COUNT(es.id) labels, t.warehouseFk warehouseFk, dayname(r.created) `dayName`, - rs.id <=> rm.expeditionTruckFk isMatch + rs.id <=> rm.roadmapStopFk isMatch FROM vn.roadmapStop rs JOIN vn.expeditionPallet ep ON ep.truckFk = rs.id JOIN vn.expeditionScan es ON es.palletFk = ep.id @@ -13,7 +13,7 @@ SELECT ep.id palletFk, JOIN vn.ticket t ON t.id = e.ticketFk JOIN vn.route r ON r.id = t.routeFk LEFT JOIN vn.routesMonitor rm ON rm.routeFk = r.id - LEFT JOIN vn.roadmapStop rs2 ON rs2.id = rm.expeditionTruckFk + LEFT JOIN vn.roadmapStop rs2 ON rs2.id = rm.roadmapStopFk WHERE ep.id = ? GROUP BY ep.id, t.routeFk ORDER BY t.routeFk From aaea0c95f7c71734a070c1028fbc8b099a3fd96c Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 27 May 2024 09:41:28 +0200 Subject: [PATCH 09/53] feat: refs #7296 roadmapStopFk --- db/routines/vn/views/expeditionTruck_Control.sql | 4 ++-- db/routines/vn/views/expeditionTruck_Control_Detail.sql | 6 +++--- .../vn/views/expeditionTruck_Control_Detail_Pallet.sql | 6 +++--- db/versions/11070-turquoiseCordyline/00-firstScript.sql | 1 + 4 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 db/versions/11070-turquoiseCordyline/00-firstScript.sql diff --git a/db/routines/vn/views/expeditionTruck_Control.sql b/db/routines/vn/views/expeditionTruck_Control.sql index 818ae3ae6..838e1f89e 100644 --- a/db/routines/vn/views/expeditionTruck_Control.sql +++ b/db/routines/vn/views/expeditionTruck_Control.sql @@ -11,9 +11,9 @@ AS SELECT `e`.`truckFk` AS `id`, COUNT(DISTINCT `e`.`routeFk`) AS `routes`, COUNT(DISTINCT `e`.`scanFk`) AS `scans`, COUNT(DISTINCT `e`.`expeditionFk`) AS `expeditions`, - sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`, + sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, max(`e`.`lastPacked`) AS `lastPacked` FROM `vn`.`expeditionCommon` `e` GROUP BY `e`.`truckFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC, +ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, `e`.`eta` diff --git a/db/routines/vn/views/expeditionTruck_Control_Detail.sql b/db/routines/vn/views/expeditionTruck_Control_Detail.sql index 51970544b..96a5b78e6 100644 --- a/db/routines/vn/views/expeditionTruck_Control_Detail.sql +++ b/db/routines/vn/views/expeditionTruck_Control_Detail.sql @@ -7,12 +7,12 @@ AS SELECT `e`.`truckFk` AS `id`, `e`.`palletFk` AS `pallet`, COUNT(DISTINCT `e`.`routeFk`) AS `routes`, COUNT(DISTINCT `e`.`scanFk`) AS `scans`, - COUNT(DISTINCT `e`.`roadmapStopFk`) AS `destinos`, - sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`, + COUNT(DISTINCT `e`.`expeditionTruckFk`) AS `destinos`, + sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, max(`e`.`lastPacked`) AS `lastPacked` FROM `vn`.`expeditionCommon` `e` GROUP BY `e`.`truckFk`, `e`.`palletFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC, +ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, `e`.`eta`, `e`.`truckFk` diff --git a/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql b/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql index 7e24d6b01..3f239432d 100644 --- a/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql +++ b/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql @@ -8,15 +8,15 @@ AS SELECT `e`.`truckFk` AS `id`, `e`.`routeFk` AS `route`, COUNT(DISTINCT `e`.`scanFk`) AS `scans`, `rs`.`description` AS `destinos`, - sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`, + sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, `e`.`expeditionTruckFk` AS `expeditionTruckFk`, max(`e`.`lastPacked`) AS `lastPacked` FROM ( `vn`.`expeditionCommon` `e` - LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `e`.`roadmapStopFk`) + LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `e`.`expeditionTruckFk`) ) GROUP BY `e`.`truckFk`, `e`.`palletFk`, `e`.`routeFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC, +ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, `e`.`palletFk` diff --git a/db/versions/11070-turquoiseCordyline/00-firstScript.sql b/db/versions/11070-turquoiseCordyline/00-firstScript.sql new file mode 100644 index 000000000..494080033 --- /dev/null +++ b/db/versions/11070-turquoiseCordyline/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.routesMonitor CHANGE expeditionTruckFk roadmapStopFk int(11) DEFAULT NULL NULL; From 0b648d09af48ca8595f72187d531a01a087ea5aa Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 27 May 2024 11:45:22 +0200 Subject: [PATCH 10/53] feat: refs #7296 roadmapStopFk --- db/routines/vn/procedures/expeditionPallet_build.sql | 6 +++--- db/routines/vn/views/expeditionCommon.sql | 2 +- db/routines/vn/views/expeditionTruck_Control.sql | 4 ++-- .../vn/views/expeditionTruck_Control_Detail.sql | 6 +++--- .../vn/views/expeditionTruck_Control_Detail_Pallet.sql | 10 +++++----- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/db/routines/vn/procedures/expeditionPallet_build.sql b/db/routines/vn/procedures/expeditionPallet_build.sql index 9fbb60100..bea56eae6 100644 --- a/db/routines/vn/procedures/expeditionPallet_build.sql +++ b/db/routines/vn/procedures/expeditionPallet_build.sql @@ -56,13 +56,13 @@ BEGIN LIMIT 1; IF vPalletFk IS NULL THEN - SELECT expeditionTruckFk + SELECT roadmapStopFk INTO vTruckFk FROM ( - SELECT rm.expeditionTruckFk, count(*) n + SELECT rm.roadmapStopFk, count(*) n FROM vn.routesMonitor rm JOIN tExpedition e ON e.routeFk = rm.routeFk - GROUP BY expeditionTruckFk + GROUP BY roadmapStopFk ORDER BY n DESC LIMIT 1) sub; diff --git a/db/routines/vn/views/expeditionCommon.sql b/db/routines/vn/views/expeditionCommon.sql index 46765e57c..fcf36a7d8 100644 --- a/db/routines/vn/views/expeditionCommon.sql +++ b/db/routines/vn/views/expeditionCommon.sql @@ -8,7 +8,7 @@ AS SELECT `rs`.`id` AS `truckFk`, `t`.`routeFk` AS `routeFk`, `es`.`id` AS `scanFk`, `e`.`id` AS `expeditionFk`, - `r`.`roadmapStopFk` AS `expeditionTruckFk`, + `r`.`roadmapStopFk` AS `roadmapStopFk`, `t`.`warehouseFk` AS `warehouseFk`, `e`.`created` AS `lastPacked`, `t`.`id` AS `ticketFk` diff --git a/db/routines/vn/views/expeditionTruck_Control.sql b/db/routines/vn/views/expeditionTruck_Control.sql index 838e1f89e..818ae3ae6 100644 --- a/db/routines/vn/views/expeditionTruck_Control.sql +++ b/db/routines/vn/views/expeditionTruck_Control.sql @@ -11,9 +11,9 @@ AS SELECT `e`.`truckFk` AS `id`, COUNT(DISTINCT `e`.`routeFk`) AS `routes`, COUNT(DISTINCT `e`.`scanFk`) AS `scans`, COUNT(DISTINCT `e`.`expeditionFk`) AS `expeditions`, - sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, + sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`, max(`e`.`lastPacked`) AS `lastPacked` FROM `vn`.`expeditionCommon` `e` GROUP BY `e`.`truckFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, +ORDER BY sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC, `e`.`eta` diff --git a/db/routines/vn/views/expeditionTruck_Control_Detail.sql b/db/routines/vn/views/expeditionTruck_Control_Detail.sql index 96a5b78e6..51970544b 100644 --- a/db/routines/vn/views/expeditionTruck_Control_Detail.sql +++ b/db/routines/vn/views/expeditionTruck_Control_Detail.sql @@ -7,12 +7,12 @@ AS SELECT `e`.`truckFk` AS `id`, `e`.`palletFk` AS `pallet`, COUNT(DISTINCT `e`.`routeFk`) AS `routes`, COUNT(DISTINCT `e`.`scanFk`) AS `scans`, - COUNT(DISTINCT `e`.`expeditionTruckFk`) AS `destinos`, - sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, + COUNT(DISTINCT `e`.`roadmapStopFk`) AS `destinos`, + sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`, max(`e`.`lastPacked`) AS `lastPacked` FROM `vn`.`expeditionCommon` `e` GROUP BY `e`.`truckFk`, `e`.`palletFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, +ORDER BY sum(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC, `e`.`eta`, `e`.`truckFk` diff --git a/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql b/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql index 3f239432d..b7244ecf8 100644 --- a/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql +++ b/db/routines/vn/views/expeditionTruck_Control_Detail_Pallet.sql @@ -8,15 +8,15 @@ AS SELECT `e`.`truckFk` AS `id`, `e`.`routeFk` AS `route`, COUNT(DISTINCT `e`.`scanFk`) AS `scans`, `rs`.`description` AS `destinos`, - sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) AS `fallos`, - `e`.`expeditionTruckFk` AS `expeditionTruckFk`, - max(`e`.`lastPacked`) AS `lastPacked` + SUM(`e`.`truckFk` <> `e`.`roadmapStopFk`) AS `fallos`, + `e`.`roadmapStopFk` AS `roadmapStopFk`, + MAX(`e`.`lastPacked`) AS `lastPacked` FROM ( `vn`.`expeditionCommon` `e` - LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `e`.`expeditionTruckFk`) + LEFT JOIN `vn`.`roadmapStop` `rs` ON(`rs`.`id` = `e`.`roadmapStopFk`) ) GROUP BY `e`.`truckFk`, `e`.`palletFk`, `e`.`routeFk` -ORDER BY sum(`e`.`truckFk` <> `e`.`expeditionTruckFk`) DESC, +ORDER BY SUM(`e`.`truckFk` <> `e`.`roadmapStopFk`) DESC, `e`.`palletFk` From 7559875aff5c3a10cd971998dce6dfd549859dc0 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 27 May 2024 12:08:14 +0200 Subject: [PATCH 11/53] feat: refs #7296 roadmapStopFk --- db/versions/11070-turquoiseCordyline/00-firstScript.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db/versions/11070-turquoiseCordyline/00-firstScript.sql b/db/versions/11070-turquoiseCordyline/00-firstScript.sql index 494080033..db123eb55 100644 --- a/db/versions/11070-turquoiseCordyline/00-firstScript.sql +++ b/db/versions/11070-turquoiseCordyline/00-firstScript.sql @@ -1 +1,3 @@ ALTER TABLE vn.routesMonitor CHANGE expeditionTruckFk roadmapStopFk int(11) DEFAULT NULL NULL; + +ALTER TABLE vn.routesMonitor ADD COLUMN expeditionTruckFk int(11) AS (roadmapStopFk) VIRTUAL; \ No newline at end of file From ecd34e080d1e9b6549afc0b81dc285a595ef1ba7 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 3 Jun 2024 07:59:57 +0200 Subject: [PATCH 12/53] feat: refs #7039 deleteVirtualColumnCountry --- db/versions/11082-goldenCordyline/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11082-goldenCordyline/00-firstScript.sql diff --git a/db/versions/11082-goldenCordyline/00-firstScript.sql b/db/versions/11082-goldenCordyline/00-firstScript.sql new file mode 100644 index 000000000..71b98f4a9 --- /dev/null +++ b/db/versions/11082-goldenCordyline/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.country DROP COLUMN country; From 340a8c119ecb48cd8eeac87f76975405a2b71e42 Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 3 Jun 2024 09:35:44 +0200 Subject: [PATCH 13/53] refactor: refs #6753 fix saveSign --- modules/ticket/back/methods/ticket/saveSign.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/modules/ticket/back/methods/ticket/saveSign.js b/modules/ticket/back/methods/ticket/saveSign.js index 490b05320..b5c662089 100644 --- a/modules/ticket/back/methods/ticket/saveSign.js +++ b/modules/ticket/back/methods/ticket/saveSign.js @@ -140,14 +140,7 @@ module.exports = Self => { await models.TicketDms.create({ticketFk: ticket.id, dmsFk: dms[0].id}, myOptions); await ticket.updateAttribute('isSigned', true, myOptions); - const deliveryState = await models.State.findOne({ - where: {code: 'DELIVERED'} - }, myOptions); - - await models.Ticket.state(ctx, { - ticketFk: ticketId, - stateFk: deliveryState.id - }, myOptions); + await Self.rawSql(`CALL vn.ticket_setState(?, ?)`, [params.ticketFk, params.code], myOptions); if (ticket?.address()?.province()?.country()?.code != 'ES' && ticket.cmrFk) { await models.Ticket.saveCmr(ctx, [ticketId], myOptions); From 85d68890b898b7d3189f487ca2698dd4e9602b62 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 3 Jun 2024 12:11:26 +0200 Subject: [PATCH 14/53] refactor: refs #6701 New table clientRate --- db/routines/vn/triggers/claimRatio_afterInsert.sql | 9 +++++++++ db/versions/11084-whitePalmetto/00-firstScript.sql | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 db/routines/vn/triggers/claimRatio_afterInsert.sql create mode 100644 db/versions/11084-whitePalmetto/00-firstScript.sql diff --git a/db/routines/vn/triggers/claimRatio_afterInsert.sql b/db/routines/vn/triggers/claimRatio_afterInsert.sql new file mode 100644 index 000000000..080e636a2 --- /dev/null +++ b/db/routines/vn/triggers/claimRatio_afterInsert.sql @@ -0,0 +1,9 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimRatio_afterInsert` + AFTER INSERT ON `claimRatio` + FOR EACH ROW +BEGIN + INSERT INTO clientRate(clientFk, `value`) + VALUES(NEW.clientFk, NEW.priceIncreasing); +END$$ +DELIMITER ; diff --git a/db/versions/11084-whitePalmetto/00-firstScript.sql b/db/versions/11084-whitePalmetto/00-firstScript.sql new file mode 100644 index 000000000..c5f841ea4 --- /dev/null +++ b/db/versions/11084-whitePalmetto/00-firstScript.sql @@ -0,0 +1,9 @@ +CREATE TABLE `vn`.`clientRate` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `clientFk` int(11) NOT NULL, + `dated` date NOT NULL DEFAULT current_timestamp(), + `value` decimal(10,2) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `clientRate_unique` (`clientFk`,`dated`), + CONSTRAINT `clientRate_client_FK` FOREIGN KEY (`clientFk`) REFERENCES `client` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; \ No newline at end of file From d3584691fa1f88e7addef2e15323f61914720be4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 3 Jun 2024 12:16:33 +0200 Subject: [PATCH 15/53] refactor: refs #6701 Minor change --- db/routines/vn/triggers/claimRatio_afterInsert.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/triggers/claimRatio_afterInsert.sql b/db/routines/vn/triggers/claimRatio_afterInsert.sql index 080e636a2..ca618bb89 100644 --- a/db/routines/vn/triggers/claimRatio_afterInsert.sql +++ b/db/routines/vn/triggers/claimRatio_afterInsert.sql @@ -4,6 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimRatio_afterInser FOR EACH ROW BEGIN INSERT INTO clientRate(clientFk, `value`) - VALUES(NEW.clientFk, NEW.priceIncreasing); + VALUES(NEW.clientFk, NEW.priceIncreasing) + ON DUPLICATE KEY UPDATE + `value` = VALUES(`value`); END$$ DELIMITER ; From a13581ed9771469be59bbc0cec3ee8ecfe11b1f2 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 3 Jun 2024 16:31:38 +0200 Subject: [PATCH 16/53] feat: refs #6243 Add warehouseFk parameter --- modules/route/back/methods/route/cmrs.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/route/back/methods/route/cmrs.js b/modules/route/back/methods/route/cmrs.js index 48d074624..0c25cbca5 100644 --- a/modules/route/back/methods/route/cmrs.js +++ b/modules/route/back/methods/route/cmrs.js @@ -47,6 +47,10 @@ module.exports = Self => { type: 'date', description: 'The to date filter', }, + { + arg: 'warehouseFk', + type: 'integer', + } ], returns: { type: ['object'], @@ -58,9 +62,10 @@ module.exports = Self => { } }); - Self.cmrs = async(filter, cmrFk, ticketFk, routeFk, country, clientFk, hasCmrDms, shipped, options + Self.cmrs = async( + filter, cmrFk, ticketFk, routeFk, country, clientFk, hasCmrDms, shipped, warehouseFk, options ) => { - const params = {cmrFk, ticketFk, routeFk, country, clientFk, hasCmrDms, shipped}; + const params = {cmrFk, ticketFk, routeFk, country, clientFk, hasCmrDms, warehouseFk, shipped}; const conn = Self.dataSource.connector; let where = buildFilter(params, (param, value) => { @@ -89,7 +94,8 @@ module.exports = Self => { co.name country, t.clientFk, IF(sub.id, TRUE, FALSE) hasCmrDms, - DATE(t.shipped) shipped + DATE(t.shipped) shipped, + t.warehouseFk FROM ticket t JOIN ticketState ts ON ts.ticketFk = t.id JOIN state s ON s.id = ts.stateFk From a997ca0c58cd1fd383cdef456af5c469f2267eef Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 4 Jun 2024 10:08:17 +0200 Subject: [PATCH 17/53] build: add new version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index be361ce7b..8b8281e0d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.24.3", + "version": "24.26.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From da1b4649bb59414c6bde7be4511e73e6504754e6 Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 4 Jun 2024 11:58:39 +0200 Subject: [PATCH 18/53] feat: refs #4560 sin expeditionTruck --- .../11063-purpleAnthurium/02-roadmapStopGrants.sql | 4 ++-- modules/route/back/model-config.json | 3 --- modules/route/back/models/expedition-truck.json | 9 --------- modules/route/back/models/roadmapStop.json | 2 +- modules/route/back/models/routesMonitor.json | 3 --- 5 files changed, 3 insertions(+), 18 deletions(-) delete mode 100644 modules/route/back/models/expedition-truck.json diff --git a/db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql b/db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql index d2c8354c0..bba1c019c 100644 --- a/db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql +++ b/db/versions/11063-purpleAnthurium/02-roadmapStopGrants.sql @@ -3,8 +3,8 @@ DELETE FROM salix.ACL INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) VALUES - ('roadmapAddress', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'), - ('roadmapAddress', '*', 'READ', 'ALLOW', 'ROLE', 'production'), + ('RoadmapAddress', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'), + ('RoadmapAddress', '*', 'READ', 'ALLOW', 'ROLE', 'production'), ('Roadmap', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'), ('Roadmap', '*', 'READ', 'ALLOW', 'ROLE', 'production'), ('RoadmapStop', '*', 'WRITE', 'ALLOW', 'ROLE', 'palletizerBoss'), diff --git a/modules/route/back/model-config.json b/modules/route/back/model-config.json index c315891fd..ccae87bd9 100644 --- a/modules/route/back/model-config.json +++ b/modules/route/back/model-config.json @@ -28,8 +28,5 @@ }, "RoutesMonitor": { "dataSource": "vn" - }, - "ExpeditionTruck": { - "dataSource": "vn" } } diff --git a/modules/route/back/models/expedition-truck.json b/modules/route/back/models/expedition-truck.json deleted file mode 100644 index fc9cd90f0..000000000 --- a/modules/route/back/models/expedition-truck.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "ExpeditionTruck", - "base": "RoadmapStop", - "options": { - "mysql": { - "table": "expeditionTruck" - } - } -} diff --git a/modules/route/back/models/roadmapStop.json b/modules/route/back/models/roadmapStop.json index 527bbae98..74b02cd7a 100644 --- a/modules/route/back/models/roadmapStop.json +++ b/modules/route/back/models/roadmapStop.json @@ -36,7 +36,7 @@ }, "address": { "type": "belongsTo", - "model": "RoadmapAddress", + "model": "Address", "foreignKey": "addressFk" } } diff --git a/modules/route/back/models/routesMonitor.json b/modules/route/back/models/routesMonitor.json index 122026336..a14680b5c 100644 --- a/modules/route/back/models/routesMonitor.json +++ b/modules/route/back/models/routesMonitor.json @@ -48,9 +48,6 @@ "priority": { "type": "number" }, - "expeditionTruckFk": { - "type": "number" - }, "m3boxes": { "type": "number" }, From 4089c7deb3fbdd424ff3f8d4624673aca3f638ea Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 4 Jun 2024 12:23:28 +0200 Subject: [PATCH 19/53] feat: refs #4560 minorChanges --- db/dump/.dump/data.sql | 4 ++-- modules/route/back/locale/routesMonitor/en.yml | 1 - modules/route/back/locale/routesMonitor/es.yml | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index 8bc94e76f..3f2d8e22e 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -1772,8 +1772,8 @@ INSERT INTO `ACL` VALUES (688,'ClientSms','create','WRITE','ALLOW','ROLE','emplo INSERT INTO `ACL` VALUES (689,'Vehicle','sorted','WRITE','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (690,'Roadmap','*','*','ALLOW','ROLE','palletizerBoss'); INSERT INTO `ACL` VALUES (691,'Roadmap','*','*','ALLOW','ROLE','productionBoss'); -INSERT INTO `ACL` VALUES (692,'roadmapStop','*','*','ALLOW','ROLE','production'); -INSERT INTO `ACL` VALUES (693,'roadmapStop','*','*','ALLOW','ROLE','productionBoss'); +INSERT INTO `ACL` VALUES (692,'RoadmapStop','*','*','ALLOW','ROLE','production'); +INSERT INTO `ACL` VALUES (693,'RoadmapStop','*','*','ALLOW','ROLE','productionBoss'); INSERT INTO `ACL` VALUES (695,'ViaexpressConfig','internationalExpedition','WRITE','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (696,'ViaexpressConfig','renderer','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (697,'Ticket','transferClient','WRITE','ALLOW','ROLE','administrative'); diff --git a/modules/route/back/locale/routesMonitor/en.yml b/modules/route/back/locale/routesMonitor/en.yml index 0542ced54..c28c5cb4d 100644 --- a/modules/route/back/locale/routesMonitor/en.yml +++ b/modules/route/back/locale/routesMonitor/en.yml @@ -13,7 +13,6 @@ columns: m3: m3 priority: priority etd: etd - roadmapStopFk: truck m3boxes: m3 boxes bufferFk: buffer isPickingAllowed: is picking allowed diff --git a/modules/route/back/locale/routesMonitor/es.yml b/modules/route/back/locale/routesMonitor/es.yml index 1ea0532c6..a8e807626 100644 --- a/modules/route/back/locale/routesMonitor/es.yml +++ b/modules/route/back/locale/routesMonitor/es.yml @@ -13,7 +13,6 @@ columns: m3: m3 priority: prioridad etd: etd - roadmapStopFk: camión m3boxes: m3 cajas bufferFk: buffer isPickingAllowed: está permitido recoger From 143930bc86478d6b74c346430788bd1cfa32bbec Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 5 Jun 2024 07:07:13 +0200 Subject: [PATCH 20/53] fix: warmFix setDeleted checks ticketRequest not answered --- modules/ticket/back/methods/ticket/setDeleted.js | 5 ++++- modules/ticket/back/methods/ticket/specs/setDeleted.spec.js | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/setDeleted.js b/modules/ticket/back/methods/ticket/setDeleted.js index 9a9fd9056..2afdf44ac 100644 --- a/modules/ticket/back/methods/ticket/setDeleted.js +++ b/modules/ticket/back/methods/ticket/setDeleted.js @@ -71,7 +71,10 @@ module.exports = Self => { // Check for existing purchase requests const hasPurchaseRequests = await models.TicketRequest.count({ ticketFk: id, - isOk: true + or: [ + {isOk: true}, + {isOk: null} + ] }, myOptions); if (hasPurchaseRequests) diff --git a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js index 520a9e403..cb2a21d91 100644 --- a/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js +++ b/modules/ticket/back/methods/ticket/specs/setDeleted.spec.js @@ -49,7 +49,7 @@ describe('ticket setDeleted()', () => { ctx.req.__ = value => { return value; }; - const ticketId = 23; + const ticketId = 24; const [sectorCollectionBefore] = await models.Ticket.rawSql( `SELECT COUNT(*) numberRows FROM vn.sectorCollection`, [], options); @@ -87,7 +87,7 @@ describe('ticket setDeleted()', () => { const [ticketCollectionOld] = await models.Ticket.rawSql( `SELECT COUNT(*) numberRows FROM vn.ticketCollection`, [], options); - const ticketId = 23; + const ticketId = 34; await models.Ticket.setDeleted(ctx, ticketId, options); From 130d2b6b47d254f6294eaf694d3e90b592431c92 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 5 Jun 2024 08:05:46 +0200 Subject: [PATCH 21/53] feat: refs #7203 remove numbres alertLevel --- db/.pullinfo.json | 2 +- .../bi/procedures/claim_ratio_routine.sql | 3 +- .../hedera/procedures/item_getVisible.sql | 19 +++---- .../procedures/order_confirmWithUser.sql | 5 +- .../stock/procedures/log_refreshSale.sql | 3 +- db/routines/vn/procedures/invoiceOut_new.sql | 8 +-- .../vn/procedures/prepareTicketList.sql | 10 ++-- .../vn/procedures/productionControl.sql | 11 +++-- .../procedures/ticketGetVisibleAvailable.sql | 7 ++- .../vn/procedures/ticketMissed_List.sql | 49 ------------------- .../procedures/ticketParking_findSkipped.sql | 30 ++++++------ .../procedures/ticketStateToday_setState.sql | 27 +++++----- .../vn/procedures/ticketStateUpdate.sql | 26 ---------- .../vn/procedures/ticket_DelayTruck.sql | 3 +- .../vn/triggers/expedition_beforeInsert.sql | 14 +++--- 15 files changed, 80 insertions(+), 137 deletions(-) delete mode 100644 db/routines/vn/procedures/ticketMissed_List.sql delete mode 100644 db/routines/vn/procedures/ticketStateUpdate.sql diff --git a/db/.pullinfo.json b/db/.pullinfo.json index 0defed845..27d2c7535 100644 --- a/db/.pullinfo.json +++ b/db/.pullinfo.json @@ -9,7 +9,7 @@ }, "vn": { "view": { - "expeditionPallet_Print": "06613719475fcdba8309607c38cc78efc2e348cca7bc96b48dc3ae3c12426f54" + "expeditionPallet_Print": "ced2b84a114fcb99fce05f0c34f4fc03f3fa387bef92621be1bc306608a84345" } } } diff --git a/db/routines/bi/procedures/claim_ratio_routine.sql b/db/routines/bi/procedures/claim_ratio_routine.sql index 40b879483..3cf4bf8dc 100644 --- a/db/routines/bi/procedures/claim_ratio_routine.sql +++ b/db/routines/bi/procedures/claim_ratio_routine.sql @@ -65,11 +65,12 @@ BEGIN JOIN vn.ticketLastState ts ON ts.ticketFk = t.id JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk JOIN vn.state st ON st.id = tt.stateFk + JOIN vn.alertLevel al ON al.code = 'DELIVERED' WHERE sc.componentFk = 17 AND sc.isGreuge = 0 AND t.shipped >= '2016-10-01' AND t.shipped < util.VN_CURDATE() - AND st.alertLevel >= 3; + AND st.alertLevel >= al.id; DELETE g.* FROM vn.greuge g diff --git a/db/routines/hedera/procedures/item_getVisible.sql b/db/routines/hedera/procedures/item_getVisible.sql index 8e25eaab3..2f4ef32ab 100644 --- a/db/routines/hedera/procedures/item_getVisible.sql +++ b/db/routines/hedera/procedures/item_getVisible.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`item_getVisible vType INT, vPrefix VARCHAR(255)) BEGIN - + /** * Gets visible items of the specified type at specified date. * @@ -14,7 +14,7 @@ BEGIN * @param vType The type id * @param vPrefix The article prefix to filter or %NULL for all * @return tmp.itemVisible Visible items - */ + */ DECLARE vPrefixLen SMALLINT; DECLARE vFilter VARCHAR(255) DEFAULT NULL; DECLARE vDateInv DATE DEFAULT vn.getInventoryDate(); @@ -23,13 +23,13 @@ BEGIN GET DIAGNOSTICS CONDITION 1 @message = MESSAGE_TEXT; CALL vn.mail_insert( - 'cau@verdnatura.es', - NULL, + 'cau@verdnatura.es', + NULL, CONCAT('hedera.item_getVisible error: ', @message), CONCAT( - 'warehouse: ', IFNULL(vWarehouse, ''), - ', Fecha:', IFNULL(vDate, ''), - ', tipo: ', IFNULL(vType,''), + 'warehouse: ', IFNULL(vWarehouse, ''), + ', Fecha:', IFNULL(vDate, ''), + ', tipo: ', IFNULL(vType,''), ', prefijo: ', IFNULL(vPrefix,''))); RESIGNAL; END; @@ -74,9 +74,10 @@ BEGIN FROM vn.sale m JOIN vn.ticket t ON t.id = m.ticketFk JOIN vn.ticketState s ON s.ticketFk = t.id + JOIN vn.alertLevel al ON al.code = 'DELIVERED' WHERE t.shipped BETWEEN vDateInv AND util.VN_CURDATE() AND t.warehouseFk = vWarehouse - AND s.alertLevel = 3 + AND s.alertLevel = al.id ) t GROUP BY itemFk HAVING quantity > 0; @@ -108,7 +109,7 @@ BEGIN IF(p.depth > 0, p.depth, 0) depth, p.width, p.height, CEIL(s.quantity / t.packing) etiquetas FROM vn.item i - JOIN `filter` f ON f.itemFk = i.id + JOIN `filter` f ON f.itemFk = i.id JOIN currentStock s ON s.itemFk = i.id LEFT JOIN tmp t ON t.itemFk = i.id LEFT JOIN vn.packaging p ON p.id = t.packagingFk diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 0aeaaf65b..9c932aaa1 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -62,7 +62,7 @@ BEGIN END; -- Carga los datos del pedido - SELECT o.date_send, o.address_id, o.note, a.clientFk, + SELECT o.date_send, o.address_id, o.note, a.clientFk, o.company_id, o.agency_id, c.isTaxDataChecked INTO vDelivery, vAddress, vNotes, vClientId, vCompanyId, vAgencyModeId, vIsTaxDataChecked @@ -121,6 +121,7 @@ BEGIN ) SELECT t.id INTO vTicket FROM vn.ticket t + JOIN vn.alertLevel al ON al.code = 'FREE' LEFT JOIN tPrevia tp ON tp.ticketFk = t.id LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id JOIN hedera.`order` o @@ -131,7 +132,7 @@ BEGIN WHERE o.id = vSelf AND t.refFk IS NULL AND tp.ticketFk IS NULL - AND IFNULL(tls.alertLevel,0) = 0 + AND (tls.alertLevel IS NULL OR tls.alertLevel = al.id) LIMIT 1; -- Crea el ticket en el caso de no existir uno adecuado diff --git a/db/routines/stock/procedures/log_refreshSale.sql b/db/routines/stock/procedures/log_refreshSale.sql index 983616dca..3054f8ecb 100644 --- a/db/routines/stock/procedures/log_refreshSale.sql +++ b/db/routines/stock/procedures/log_refreshSale.sql @@ -16,12 +16,13 @@ BEGIN m.created, TIMESTAMPADD(DAY, tp.life, t.shipped) expired, m.quantity < 0 isIn, - m.isPicked OR s.alertLevel > 1 isPicked + m.isPicked OR s.alertLevel > al.id isPicked FROM vn.sale m JOIN vn.ticket t ON t.id = m.ticketFk JOIN vn.ticketState s ON s.ticketFk = t.id JOIN vn.item i ON i.id = m.itemFk JOIN vn.itemType tp ON tp.id = i.typeFk + JOIN vn.alertLevel al ON al.code = 'ON_PREPARATION' WHERE ( vTableId IS NULL OR (vTableName = 'ticket' AND t.id = vTableId) diff --git a/db/routines/vn/procedures/invoiceOut_new.sql b/db/routines/vn/procedures/invoiceOut_new.sql index 1b486df86..42c3f99da 100644 --- a/db/routines/vn/procedures/invoiceOut_new.sql +++ b/db/routines/vn/procedures/invoiceOut_new.sql @@ -80,8 +80,8 @@ BEGIN OR t.isDeleted OR c.hasToInvoice = FALSE OR itc.id IS NULL - OR a.id IS NULL - OR (vTaxArea = 'WORLD' + OR a.id IS NULL + OR (vTaxArea = 'WORLD' AND (a.customsAgentFk IS NULL OR a.incotermsFk IS NULL)); SELECT SUM(s.quantity * s.price * (100 - s.discount)/100) <> 0 @@ -153,7 +153,9 @@ BEGIN FROM tmp.ticketToInvoice ti LEFT JOIN ticketState ts ON ti.id = ts.ticketFk JOIN state s - WHERE IFNULL(ts.alertLevel, 0) < 3 and s.`code` = getAlert3State(ti.id); + JOIN alertLevel al ON al.code = 'DELIVERED' + WHERE (ts.alertLevel IS NULL OR ts.alertLevel < al.id) + AND s.`code` = getAlert3State(ti.id); INSERT INTO ticketTracking(stateFk, ticketFk, userFk) SELECT * FROM tmp.updateInter; diff --git a/db/routines/vn/procedures/prepareTicketList.sql b/db/routines/vn/procedures/prepareTicketList.sql index f0f47f9a2..29c95cc9f 100644 --- a/db/routines/vn/procedures/prepareTicketList.sql +++ b/db/routines/vn/procedures/prepareTicketList.sql @@ -6,14 +6,16 @@ BEGIN (PRIMARY KEY (ticketFk)) ENGINE = MEMORY SELECT t.id ticketFk, t.clientFk - FROM vn.ticket t - LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id - JOIN vn.client c ON c.id = t.clientFk + FROM ticket t + JOIN alertLevel al ON al.code = 'DELIVERED' + LEFT JOIN ticketState ts ON ts.ticketFk = t.id + JOIN client c ON c.id = t.clientFk + WHERE c.typeFk IN ('normal','handMaking','internalUse') AND ( t.shipped BETWEEN util.VN_CURDATE() AND vEndingDate OR ( - ts.alertLevel < 3 + ts.alertLevel < al.id AND t.shipped >= vStartingDate AND t.shipped < util.VN_CURDATE() ) diff --git a/db/routines/vn/procedures/productionControl.sql b/db/routines/vn/procedures/productionControl.sql index b42645d1e..6505473fa 100644 --- a/db/routines/vn/procedures/productionControl.sql +++ b/db/routines/vn/procedures/productionControl.sql @@ -1,6 +1,6 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`productionControl`( - vWarehouseFk INT, + vWarehouseFk INT, vScopeDays INT ) proc: BEGIN @@ -67,7 +67,7 @@ proc: BEGIN wk.code salesPersonCode, p.id provinceFk, tls.productionOrder, - IFNULL(tls.alertLevel, 0) alertLevel, + IFNULL(tls.alertLevel, al.id) alertLevel, t.isBoxed palletized, IF(rm.isPickingAllowed, rm.bufferFk, NULL) ubicacion, tlu.lastUpdated, @@ -81,6 +81,7 @@ proc: BEGIN rm.bufferFk FROM tmp.productionTicket tt JOIN ticket t ON tt.ticketFk = t.id + JOIN alertLevel al ON al.code = 'FREE' LEFT JOIN ticketStateToday tst ON tst.ticketFk = t.id LEFT JOIN `state` st ON st.id = tst.state LEFT JOIN client c ON c.id = t.clientFk @@ -101,7 +102,7 @@ proc: BEGIN LEFT JOIN parking pk ON pk.id = tp.parkingFk WHERE t.warehouseFk = vWarehouseFk AND dm.code IN ('AGENCY', 'DELIVERY', 'PICKUP'); - + UPDATE tmp.productionBuffer pb JOIN ( SELECT pb.ticketFk, GROUP_CONCAT(p.code) previaParking @@ -109,12 +110,12 @@ proc: BEGIN JOIN sale s ON s.ticketFk = pb.ticketFk JOIN saleGroupDetail sgd ON sgd.saleFk = s.id JOIN saleGroup sg ON sg.id = sgd.saleGroupFk - JOIN parking p ON p.id = sg.parkingFk + JOIN parking p ON p.id = sg.parkingFk GROUP BY pb.ticketFk ) t ON t.ticketFk = pb.ticketFk SET pb.previaParking = t.previaParking; - -- Problemas por ticket + -- Problemas por ticket ALTER TABLE tmp.productionBuffer CHANGE COLUMN `problem` `problem` VARCHAR(255), ADD COLUMN `collectionH` INT, diff --git a/db/routines/vn/procedures/ticketGetVisibleAvailable.sql b/db/routines/vn/procedures/ticketGetVisibleAvailable.sql index 07dfa69e5..3717d57e3 100644 --- a/db/routines/vn/procedures/ticketGetVisibleAvailable.sql +++ b/db/routines/vn/procedures/ticketGetVisibleAvailable.sql @@ -7,13 +7,16 @@ BEGIN DECLARE vShipped DATE; DECLARE vWarehouse TINYINT; DECLARE vAlertLevel INT; + DECLARE vAlertLevelFree INT; - SELECT t.warehouseFk, t.shipped, ts.alertLevel INTO vWarehouse, vShipped, vAlertLevel + SELECT t.warehouseFk, t.shipped, ts.alertLevel, al.id + INTO vWarehouse, vShipped, vAlertLevel, vAlertLevelFree FROM ticket t + JOIN alertLevel al ON al.code = 'FREE' LEFT JOIN ticketState ts ON ts.ticketFk = vTicket WHERE t.id = vTicket; - IF vAlertLevel IS NULL OR vAlertLevel = 0 THEN + IF vAlertLevel IS NULL OR vAlertLevel = vAlertLevelFree THEN IF vShipped >= util.VN_CURDATE() THEN CALL cache.available_refresh(vAvailableCalc, FALSE, vWarehouse, vShipped); END IF; diff --git a/db/routines/vn/procedures/ticketMissed_List.sql b/db/routines/vn/procedures/ticketMissed_List.sql deleted file mode 100644 index 6b0f66e6a..000000000 --- a/db/routines/vn/procedures/ticketMissed_List.sql +++ /dev/null @@ -1,49 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketMissed_List`(vTicketFk INT) -BEGIN - - DECLARE vParkingFk INT; - DECLARE vParked DATETIME; - DECLARE vLevel INT; - DECLARE vCollectionFk INT; - - SELECT IFNULL(`level`,0), IFNULL(collectionFk,0) - INTO vLevel, vCollectionFk - FROM vn.ticketCollection - WHERE ticketFk = vTicketFk - LIMIT 1; - - SELECT created, parkingFk - INTO vParked, vParkingFk - FROM vn.ticketParking - WHERE ticketFk = vTicketFk; - - SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia - FROM vn.ticketParking tp - JOIN vn.parking p ON p.id = tp.parkingFk - JOIN vn.sector sc ON sc.id = p.sectorFk - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk - JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk - JOIN vn.ticket t ON t.id = tp.ticketFk - JOIN vn.zone z ON z.id = t.zoneFk - JOIN vn.agencyMode am ON am.id = z.agencyModeFk - JOIN vn.state s ON s.id = tst.state - WHERE (s.alertLevel < 2 - AND tp.parkingFk = vParkingFk - AND sc.isPackagingArea - AND ( - ( - ( IFNULL(tc.collectionFk,-1) != IFNULL(@vCollectionFk,0) AND tp.created < vParked ) - OR - ( tc.collectionFk = vCollectionFk AND LEFT(tc.level,1) < LEFT(vLevel,1) ) - ) - )) -- Etiquetas que no se han escaneado y ya estamos con una posterior - OR - (s.alertLevel > 1 - AND tp.parkingFk = vParkingFk - AND sc.isPackagingArea - AND tp.created < vParked - AND t.packages <=> 0); - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/ticketParking_findSkipped.sql b/db/routines/vn/procedures/ticketParking_findSkipped.sql index b00006ffe..ff72110c7 100644 --- a/db/routines/vn/procedures/ticketParking_findSkipped.sql +++ b/db/routines/vn/procedures/ticketParking_findSkipped.sql @@ -1,37 +1,37 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketParking_findSkipped`(vTicketFk INT, vItemPackingTypeFk VARCHAR(1)) BEGIN - + /** * Averigua los tickets que se han saltado por un error en el proceso encajado * @param vTicketFk Ticket * @param vItemPackingTypeFk Modo de encajado * @return un select con los tickets afectados - */ + */ DECLARE vParkingFk INT; DECLARE vParked DATETIME; DECLARE vLevel INT; DECLARE vWagon INT; DECLARE vCollectionFk INT; - - SELECT IFNULL(`level`,0), IFNULL(`wagon`,0),IFNULL(collectionFk,0) + + SELECT IFNULL(`level`,0), IFNULL(`wagon`,0),IFNULL(collectionFk,0) INTO vLevel, vWagon, vCollectionFk FROM vn.ticketCollection tc JOIN vn.collection c ON c.id = tc.collectionFk AND c.itemPackingTypeFk = vItemPackingTypeFk WHERE ticketFk = vTicketFk ORDER BY c.id DESC LIMIT 1; - - SELECT created, parkingFk + + SELECT created, parkingFk INTO vParked, vParkingFk FROM vn.ticketParking tp - JOIN vn.parking p ON p.id = tp.parkingFk - JOIN vn.sector s ON s.id = p.sectorFk + JOIN vn.parking p ON p.id = tp.parkingFk + JOIN vn.sector s ON s.id = p.sectorFk WHERE ticketFk = vTicketFk AND s.itemPackingTypeFk = vItemPackingTypeFk AND s.isPackagingArea ; - + SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' ', tc.wagon, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia FROM vn.ticketParking tp JOIN vn.parking p ON p.id = tp.parkingFk @@ -42,23 +42,25 @@ BEGIN JOIN vn.zone z ON z.id = t.zoneFk JOIN vn.agencyMode am ON am.id = z.agencyModeFk JOIN vn.state s ON s.id = tst.state - WHERE (s.alertLevel < 2 + JOIN vn.alertLevel alPacked ON alPacked.code = 'PACKED' + JOIN vn.alertLevel alOnPreparation ON alOnPreparation.code = 'ON_PREPARATION' + WHERE (s.alertLevel < alPacked.id AND tp.parkingFk = vParkingFk AND sc.isPackagingArea AND ( ( IFNULL(tc.collectionFk,-1) != IFNULL(@vCollectionFk,0) AND tp.created < vParked ) OR - ( tc.collectionFk = vCollectionFk + ( tc.collectionFk = vCollectionFk AND (LEFT(tc.wagon,1) < LEFT(vWagon,1) - OR (LEFT(tc.wagon,1) = LEFT(vWagon,1) AND LEFT(tc.level,1) < LEFT(vLevel,1))) + OR (LEFT(tc.wagon,1) = LEFT(vWagon,1) AND LEFT(tc.level,1) < LEFT(vLevel,1))) ) ) ) -- Etiquetas que no se han escaneado y ya estamos con una posterior OR - (s.alertLevel > 1 + (s.alertLevel > alOnPreparation.id AND tp.parkingFk = vParkingFk AND sc.isPackagingArea - AND tp.created < vParked + AND tp.created < vParked AND t.packages <=> 0); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticketStateToday_setState.sql b/db/routines/vn/procedures/ticketStateToday_setState.sql index 73a92bbb5..bd79043b4 100644 --- a/db/routines/vn/procedures/ticketStateToday_setState.sql +++ b/db/routines/vn/procedures/ticketStateToday_setState.sql @@ -1,26 +1,29 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketStateToday_setState`(vTicketFk INT, vStateCode VARCHAR(45)) BEGIN - + /* Modifica el estado de un ticket de hoy - * + * * @param vTicketFk el id del ticket * @param vStateCode estado a modificar del ticket - * + * */ - + DECLARE vAlertLevel INT; - - SELECT s.alertLevel INTO vAlertLevel - FROM state s - JOIN ticketStateToday tst ON tst.state = s.id + DECLARE vAlertLevelPacked INT; + + SELECT s.alertLevel, al.id + INTO vAlertLevel, vAlertLevelPacked + FROM state s + JOIN ticketStateToday tst ON tst.state = s.id + JOIN alertLevel al ON al.code = 'PACKED' WHERE tst.ticketFk = vTicketFk LIMIT 1; - - IF vAlertLevel < 2 THEN - + + IF vAlertLevel < vAlertLevelPacked THEN + CALL vn.ticket_setState(vTicketFk, vStateCode); - + END IF; END$$ diff --git a/db/routines/vn/procedures/ticketStateUpdate.sql b/db/routines/vn/procedures/ticketStateUpdate.sql deleted file mode 100644 index 4e19b7eb4..000000000 --- a/db/routines/vn/procedures/ticketStateUpdate.sql +++ /dev/null @@ -1,26 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticketStateUpdate`(vTicketFk INT, vStateCode VARCHAR(45)) -BEGIN - - /* - * @deprecated:utilizar ticket_setState - */ - - DECLARE vAlertLevel INT; - - SELECT s.alertLevel INTO vAlertLevel - FROM vn.state s - JOIN vn.ticketState ts ON ts.stateFk = s.id - WHERE ts.ticketFk = vTicketFk; - - IF !(vStateCode = 'ON_CHECKING' AND vAlertLevel > 1) THEN - - INSERT INTO ticketTracking(stateFk, ticketFk, userFk) - SELECT id, vTicketFk, account.myUser_getId() - FROM vn.state - WHERE `code` = vStateCode collate utf8_unicode_ci; - - END IF; - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_DelayTruck.sql b/db/routines/vn/procedures/ticket_DelayTruck.sql index 7a3170d68..20601ee49 100644 --- a/db/routines/vn/procedures/ticket_DelayTruck.sql +++ b/db/routines/vn/procedures/ticket_DelayTruck.sql @@ -13,10 +13,11 @@ BEGIN CREATE TEMPORARY TABLE tmp.ticket SELECT ticketFk FROM tmp.productionBuffer + JOIN alertLevel al ON al.code = 'FREE' WHERE shipped = util.VN_CURDATE() AND problem LIKE '%I:%' AND (HH <= vHour OR HH = vHour AND mm < vMinute) - AND alertLevel = 0; + AND alertLevel = al.id; OPEN cur1; diff --git a/db/routines/vn/triggers/expedition_beforeInsert.sql b/db/routines/vn/triggers/expedition_beforeInsert.sql index 685de72cb..2e5644a19 100644 --- a/db/routines/vn/triggers/expedition_beforeInsert.sql +++ b/db/routines/vn/triggers/expedition_beforeInsert.sql @@ -4,21 +4,21 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expedition_beforeInse FOR EACH ROW BEGIN DECLARE intcounter INT; - DECLARE vShipFk INT; SET NEW.editorFk = account.myUser_getId(); - IF NEW.freightItemFk IS NOT NULL THEN + IF NEW.freightItemFk IS NOT NULL THEN UPDATE ticket SET packages = IFNULL(packages, 0) + 1 WHERE id = NEW.ticketFk; - SELECT IFNULL(MAX(counter),0) +1 INTO intcounter - FROM expedition e - INNER JOIN ticket t1 ON e.ticketFk = t1.id + SELECT IFNULL(MAX(counter),0) + 1 INTO intcounter + FROM expedition e + JOIN alertLevel al ON al.code = 'DELIVERED' + JOIN ticket t1 ON e.ticketFk = t1.id LEFT JOIN ticketState ts ON ts.ticketFk = t1.id - INNER JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped) + JOIN ticket t2 ON t2.addressFk = t1.addressFk AND DATE(t2.shipped) = DATE(t1.shipped) AND t1.warehouseFk = t2.warehouseFk - WHERE t2.id = NEW.ticketFk AND ts.alertLevel < 3 AND t1.companyFk = t2.companyFk + WHERE t2.id = NEW.ticketFk AND ts.alertLevel < al.id AND t1.companyFk = t2.companyFk AND t1.agencyModeFk = t2.agencyModeFk; SET NEW.`counter` = intcounter; From a0e79a778df7e229eaa17da67217c3ac86b20b38 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 5 Jun 2024 09:57:15 +0200 Subject: [PATCH 22/53] feat: refs #7496 deprecated ticket.isLabeled --- db/routines/vn2008/views/Saldos_Prevision.sql | 10 ---------- db/routines/vn2008/views/Tickets.sql | 1 - db/versions/11087-aquaDendro/00-firstScript.sql | 4 ++++ 3 files changed, 4 insertions(+), 11 deletions(-) delete mode 100644 db/routines/vn2008/views/Saldos_Prevision.sql create mode 100644 db/versions/11087-aquaDendro/00-firstScript.sql diff --git a/db/routines/vn2008/views/Saldos_Prevision.sql b/db/routines/vn2008/views/Saldos_Prevision.sql deleted file mode 100644 index f4749d30f..000000000 --- a/db/routines/vn2008/views/Saldos_Prevision.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Saldos_Prevision` -AS SELECT `fb`.`id` AS `Saldos_Prevision_id`, - `fb`.`description` AS `Descripcion`, - `fb`.`amount` AS `Importe`, - `fb`.`dated` AS `Fecha`, - `fb`.`accountingFk` AS `Id_Banco`, - `fb`.`companyFk` AS `empresa_id` -FROM `vn`.`forecastedBalance` `fb` \ No newline at end of file diff --git a/db/routines/vn2008/views/Tickets.sql b/db/routines/vn2008/views/Tickets.sql index c24b87b72..59dcb9100 100644 --- a/db/routines/vn2008/views/Tickets.sql +++ b/db/routines/vn2008/views/Tickets.sql @@ -21,7 +21,6 @@ AS SELECT `t`.`id` AS `Id_Ticket`, `t`.`workerFk` AS `Id_Trabajador`, `t`.`observations` AS `Observaciones`, `t`.`isSigned` AS `Firmado`, - `t`.`isLabeled` AS `Etiquetasemitidas`, `t`.`isPrinted` AS `PedidoImpreso`, `t`.`hour` AS `Hora`, `t`.`isBlocked` AS `blocked`, diff --git a/db/versions/11087-aquaDendro/00-firstScript.sql b/db/versions/11087-aquaDendro/00-firstScript.sql new file mode 100644 index 000000000..e53c231c3 --- /dev/null +++ b/db/versions/11087-aquaDendro/00-firstScript.sql @@ -0,0 +1,4 @@ +ALTER TABLE vn.ticket MODIFY COLUMN IF EXISTS isLabeled__ tinyint(1) DEFAULT 0 NOT NULL COMMENT 'refs #7496 deprecated 2024-06-20'; + +ALTER TABLE IF EXISTS vn.forecastedBalance RENAME vn2008.call_information__; +ALTER TABLE IF EXISTS vn.forecastedBalance COMMENT='@deprecated 2024-05-21'; \ No newline at end of file From 1fa22e71a980afc8f1ebed895b58e6ce4b22401f Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 5 Jun 2024 12:42:55 +0200 Subject: [PATCH 23/53] feat: refs #7203 nombre variables --- .../procedures/ticketParking_findSkipped.sql | 20 +++++++++---------- .../vn/triggers/expedition_beforeInsert.sql | 6 +++--- modules/account/back/models/role-inherit.json | 3 +++ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/db/routines/vn/procedures/ticketParking_findSkipped.sql b/db/routines/vn/procedures/ticketParking_findSkipped.sql index ff72110c7..7713d5b50 100644 --- a/db/routines/vn/procedures/ticketParking_findSkipped.sql +++ b/db/routines/vn/procedures/ticketParking_findSkipped.sql @@ -34,16 +34,16 @@ BEGIN SELECT tp.ticketFk, CONCAT(tc.collectionFk, ' ', tc.wagon, ' - ', tc.level) coleccion, tp.created, p.code, am.name as Agencia FROM vn.ticketParking tp - JOIN vn.parking p ON p.id = tp.parkingFk - JOIN vn.sector sc ON sc.id = p.sectorFk - LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk - JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk - JOIN vn.ticket t ON t.id = tp.ticketFk - JOIN vn.zone z ON z.id = t.zoneFk - JOIN vn.agencyMode am ON am.id = z.agencyModeFk - JOIN vn.state s ON s.id = tst.state - JOIN vn.alertLevel alPacked ON alPacked.code = 'PACKED' - JOIN vn.alertLevel alOnPreparation ON alOnPreparation.code = 'ON_PREPARATION' + JOIN vn.parking p ON p.id = tp.parkingFk + JOIN vn.sector sc ON sc.id = p.sectorFk + LEFT JOIN vn.ticketCollection tc ON tc.ticketFk = tp.ticketFk + JOIN vn.ticketStateToday tst ON tst.ticketFk = tp.ticketFk + JOIN vn.ticket t ON t.id = tp.ticketFk + JOIN vn.zone z ON z.id = t.zoneFk + JOIN vn.agencyMode am ON am.id = z.agencyModeFk + JOIN vn.state s ON s.id = tst.state + JOIN vn.alertLevel alPacked ON alPacked.code = 'PACKED' + JOIN vn.alertLevel alOnPreparation ON alOnPreparation.code = 'ON_PREPARATION' WHERE (s.alertLevel < alPacked.id AND tp.parkingFk = vParkingFk AND sc.isPackagingArea diff --git a/db/routines/vn/triggers/expedition_beforeInsert.sql b/db/routines/vn/triggers/expedition_beforeInsert.sql index 2e5644a19..e73ed9e49 100644 --- a/db/routines/vn/triggers/expedition_beforeInsert.sql +++ b/db/routines/vn/triggers/expedition_beforeInsert.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`expedition_beforeInse BEFORE INSERT ON `expedition` FOR EACH ROW BEGIN - DECLARE intcounter INT; + DECLARE vMaxCounter INT; SET NEW.editorFk = account.myUser_getId(); @@ -11,7 +11,7 @@ BEGIN UPDATE ticket SET packages = IFNULL(packages, 0) + 1 WHERE id = NEW.ticketFk; - SELECT IFNULL(MAX(counter),0) + 1 INTO intcounter + SELECT IFNULL(MAX(counter),0) + 1 INTO vMaxCounter FROM expedition e JOIN alertLevel al ON al.code = 'DELIVERED' JOIN ticket t1 ON e.ticketFk = t1.id @@ -21,7 +21,7 @@ BEGIN WHERE t2.id = NEW.ticketFk AND ts.alertLevel < al.id AND t1.companyFk = t2.companyFk AND t1.agencyModeFk = t2.agencyModeFk; - SET NEW.`counter` = intcounter; + SET NEW.`counter` = vMaxCounter; END IF; END$$ DELIMITER ; diff --git a/modules/account/back/models/role-inherit.json b/modules/account/back/models/role-inherit.json index a89f47b77..30d526471 100644 --- a/modules/account/back/models/role-inherit.json +++ b/modules/account/back/models/role-inherit.json @@ -1,6 +1,9 @@ { "name": "RoleInherit", "base": "VnModel", + "mixins": { + "Loggable": true + }, "options": { "mysql": { "table": "account.roleInherit" From 71ea1d1467af533a0d987908a90c88dfa79baa9d Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 5 Jun 2024 14:53:59 +0200 Subject: [PATCH 24/53] refs #7536 modify itemShelvingRadar --- db/routines/vn/procedures/itemShelvingRadar.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/itemShelvingRadar.sql b/db/routines/vn/procedures/itemShelvingRadar.sql index 7875c4791..aa95d0503 100644 --- a/db/routines/vn/procedures/itemShelvingRadar.sql +++ b/db/routines/vn/procedures/itemShelvingRadar.sql @@ -49,7 +49,7 @@ BEGIN ish.isChecked, sub.isAllChecked FROM itemShelvingStock iss - JOIN itemShelving ish ON ish.shelvingFk = iss.shelvingFk + JOIN itemShelving ish ON ish.id = iss.itemShelvingFk LEFT JOIN ( SELECT itemFk, IF( From a79285cd3d2373f000a130760985c44ef376c7b0 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 5 Jun 2024 16:27:00 +0200 Subject: [PATCH 25/53] feat: refs #6273 register freelance --- modules/worker/back/methods/worker/new.js | 369 ++++++++---------- .../back/methods/worker/specs/new.spec.js | 235 ++++------- modules/worker/back/models/worker.json | 32 +- 3 files changed, 268 insertions(+), 368 deletions(-) diff --git a/modules/worker/back/methods/worker/new.js b/modules/worker/back/methods/worker/new.js index 5316daf01..538d208fa 100644 --- a/modules/worker/back/methods/worker/new.js +++ b/modules/worker/back/methods/worker/new.js @@ -5,108 +5,80 @@ module.exports = Self => { Self.remoteMethodCtx('new', { description: 'Creates a new worker and returns the id', accessType: 'WRITE', - accepts: [ - { - arg: 'fi', - type: 'string', - description: `The worker fi`, - required: true, - }, - { - arg: 'name', - type: 'string', - description: `The user name`, - required: true, - }, - { - arg: 'firstName', - type: 'string', - description: `The worker firstname`, - required: true, - }, - { - arg: 'lastNames', - type: 'string', - description: `The worker lastnames`, - required: true, - }, - { - arg: 'email', - type: 'string', - description: `The worker email`, - required: true, - }, - { - arg: 'street', - type: 'string', - description: `The worker address`, - required: true, - }, - { - arg: 'city', - type: 'string', - description: `The worker city`, - required: true, - }, - { - arg: 'provinceFk', - type: 'number', - description: `The worker province`, - required: true, - }, - { - arg: 'companyFk', - type: 'number', - description: `The worker company`, - required: true, - }, - { - arg: 'postcode', - type: 'string', - description: `The worker postcode`, - required: true, - }, - { - arg: 'phone', - type: 'string', - description: `The worker phone`, - required: true, - }, - { - arg: 'code', - type: 'string', - description: `The worker code`, - required: true, - }, - { - arg: 'bossFk', - type: 'number', - description: `The worker boss`, - required: true, - }, - { - arg: 'birth', - type: 'date', - description: `The worker birth`, - required: true, - }, - { - arg: 'payMethodFk', - type: 'number', - description: `The client payMethod`, - required: true, - }, - { - arg: 'iban', - type: 'string', - description: `The client iban`, - }, - { - arg: 'bankEntityFk', - type: 'number', - description: `The client bank entity`, - } - ], + accepts: [{ + arg: 'fi', + type: 'string', + description: `The worker fi`, + }, { + arg: 'name', + type: 'string', + description: `The user name`, + }, { + arg: 'firstName', + type: 'string', + description: `The worker firstname`, + }, { + arg: 'lastNames', + type: 'string', + description: `The worker lastnames`, + }, { + arg: 'email', + type: 'string', + description: `The worker email`, + required: true, + }, { + arg: 'street', + type: 'string', + description: `The worker address`, + }, { + arg: 'city', + type: 'string', + description: `The worker city`, + }, { + arg: 'provinceFk', + type: 'number', + description: `The worker province`, + }, { + arg: 'companyFk', + type: 'number', + description: `The worker company`, + }, { + arg: 'postcode', + type: 'string', + description: `The worker postcode`, + }, { + arg: 'phone', + type: 'string', + description: `The worker phone`, + }, { + arg: 'code', + type: 'string', + description: `The worker code`, + }, { + arg: 'bossFk', + type: 'number', + description: `The worker boss`, + required: true, + }, { + arg: 'birth', + type: 'date', + description: `The worker birth`, + }, { + arg: 'payMethodFk', + type: 'number', + description: `The client payMethod`, + }, { + arg: 'iban', + type: 'string', + description: `The client iban`, + }, { + arg: 'bankEntityFk', + type: 'number', + description: `The client bank entity`, + }, { + arg: 'isFreelance', + type: 'boolean', + }], returns: { type: 'number', root: true, @@ -117,11 +89,30 @@ module.exports = Self => { }, }); - Self.new = async(ctx, options) => { + Self.new = async( + ctx, + fi, + name, + firstName, + lastNames, + email, + street, + city, + provinceFk, + companyFk, + postcode, + phone, + code, + bossFk, + birth, + payMethodFk, + iban, + bankEntityFk, + isFreelance, + options + ) => { const models = Self.app.models; const myOptions = {userId: ctx.req.accessToken.userId}; - const args = ctx.args; - let tx; if (typeof options == 'object') Object.assign(myOptions, options); @@ -132,131 +123,103 @@ module.exports = Self => { } let client; - + let user; try { - client = await models.Client.findOne( - { - where: {fi: args.fi}, - }, - myOptions - ); + client = await models.Client.findOne({where: {fi}}, myOptions); + const nickname = firstName.concat(' ', lastNames); + const {roleFk, businessTypeFk} = await models.WorkerConfig.findOne({fields: ['roleFk', 'businessTypeFk']}); - if (!client) { - const nickname = args.firstName.concat(' ', args.lastNames); - const workerConfig = await models.WorkerConfig.findOne({fields: ['roleFk', 'businessTypeFk']}); - const [randomPassword] = await models.Worker.rawSql( - 'SELECT account.passwordGenerate() as password;' - ); + if (!isFreelance) + if (!payMethodFk) throw new UserError('Payment method is required'); - const user = await models.VnUser.create( - { - name: args.name, - nickname, - password: randomPassword.password, - email: args.email, - roleFk: workerConfig.roleFk, - }, - myOptions - ); + if (isFreelance || !client) { + const [{password}] = await models.Worker.rawSql('SELECT account.passwordGenerate() as password;'); + user = await models.VnUser.create({ + name, + nickname, + password, + email, + roleFk, + }, myOptions); - await models.Account.create( - { - id: user.id, - }, - myOptions - ); + await models.Account.create({ + id: user.id + }, myOptions); + } else if (client) user = await models.VnUser.findById(client.id, null, myOptions); - const payMethod = await models.PayMethod.findById(args.payMethodFk, {fields: ['isIbanRequiredForClients']}); - if (payMethod.isIbanRequiredForClients && !args.iban) - throw new UserError(`That payment method requires an IBAN`); + if (!client && !isFreelance) { + const payMethod = await models.PayMethod.findById(payMethodFk, {fields: ['isIbanRequiredForClients']}); + if (payMethod.isIbanRequiredForClients && !iban) throw new UserError('That payment method requires an IBAN'); - await models.Worker.rawSql( - 'CALL vn.client_create(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', + await models.Worker.rawSql('CALL vn.client_create(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [ - args.firstName, - args.lastNames, - args.fi, - args.street, - args.postcode, - args.city, - args.provinceFk, - args.companyFk, - args.phone, - args.email, + firstName, + lastNames, + fi, + street, + postcode, + city, + provinceFk, + companyFk, + phone, + email, user.id, ], - myOptions - ); + myOptions); - const address = await models.Address.create( - { - clientFk: user.id, - street: args.street, - city: args.city, - provinceFk: args.provinceFk, - postalCode: args.postcode, - mobile: args.phone, - nickname: nickname, - isDefaultAddress: true, - }, - myOptions - ); + const address = await models.Address.create({ + clientFk: user.id, + street: street, + city: city, + provinceFk: provinceFk, + postalCode: postcode, + mobile: phone, + nickname: nickname, + isDefaultAddress: true, + }, myOptions); - client = await models.Client.findById( - user.id, - {fields: ['id', 'name', 'socialName', 'street', 'city', 'iban', 'bankEntityFk', 'defaultAddressFk', 'businessTypeFk', 'fi']}, - myOptions - ); + client = await models.Client.findById(user.id, { + fields: ['id', 'name', 'socialName', 'street', 'city', 'iban', 'bankEntityFk', 'defaultAddressFk', 'businessTypeFk', 'fi'] + }, myOptions); - await client.updateAttributes( - { - payMethod: args.payMethod, - iban: args.iban, - bankEntityFk: args.bankEntityFk, - defaultAddressFk: address.id, - businessTypeFk: workerConfig.businessTypeFk, - }, - myOptions - ); + await client.updateAttributes({ + payMethod: payMethodFk, + iban, + bankEntityFk, + defaultAddressFk: address.id, + businessTypeFk, + }, myOptions); } - const user = await models.VnUser.findById(client.id, null, myOptions); - await user.updateAttribute('email', args.email, myOptions); + await user.updateAttribute('email', email, myOptions); await models.Worker.create({ - id: client.id, - code: args.code, - firstName: args.firstName, - lastName: args.lastNames, - bossFk: args.bossFk, - fi: args.fi, - birth: args.birth, + id: isFreelance ? user.id : client.id, + firstName, + lastName: lastNames, + code, + bossFk, + fi, + birth, }, myOptions); if (tx) await tx.commit(); - } catch (error) { + } catch (e) { if (tx) await tx.rollback(); - const code = error.code; - const message = error.sqlMessage; + const code = e.code; + const message = e.sqlMessage; - if (error.message && error.message.includes(`Email already exists`)) - throw new UserError(`This personal mail already exists`); + if (e.message && e.message.includes(`Email already exists`)) throw new UserError(`This personal mail already exists`); - if (code === 'ER_DUP_ENTRY' && message.includes(`CodigoTrabajador_UNIQUE`)) - throw new UserError(`This worker code already exists`); + if (code === 'ER_DUP_ENTRY' && message.includes(`CodigoTrabajador_UNIQUE`)) throw new UserError(`This worker code already exists`); - if (code === 'ER_DUP_ENTRY' && message.includes(`PRIMARY`)) - throw new UserError(`This worker already exists`); + if (code === 'ER_DUP_ENTRY' && message.includes(`PRIMARY`)) throw new UserError(`This worker already exists`); - throw error; + throw e; } - await models.VnUser.resetPassword({ - email: args.email, - emailTemplate: 'worker-welcome', - id: client.id - }); + await models.VnUser.resetPassword({email, emailTemplate: 'worker-welcome', id: client.id}); return {id: client.id}; }; diff --git a/modules/worker/back/methods/worker/specs/new.spec.js b/modules/worker/back/methods/worker/specs/new.spec.js index 66959e0a7..42c0d4124 100644 --- a/modules/worker/back/methods/worker/specs/new.spec.js +++ b/modules/worker/back/methods/worker/specs/new.spec.js @@ -1,189 +1,101 @@ -const models = require('vn-loopback/server/server').models; +const {models} = require('vn-loopback/server/server'); const LoopBackContext = require('loopback-context'); describe('Worker new', () => { - beforeAll(async() => { - const activeCtx = { - accessToken: {userId: 9}, - http: { - req: { - headers: {origin: 'http://localhost'} - } - } - }; - - spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ - active: activeCtx - }); - }); - + const developerId = 9; const employeeId = 1; - const defaultWorker = { - fi: '78457139E', - name: 'defaulterworker', - firstName: 'DEFAULT', - lastNames: 'WORKER', - email: 'defaultWorker@mydomain.com', - street: 'S/ DEFAULTWORKERSTREET', - city: 'defaultWorkerCity', - provinceFk: 1, - companyFk: 442, - postcode: '46680', - phone: '123456789', - code: 'DWW', - bossFk: 9, - birth: '2022-12-11T23:00:00.000Z', - payMethodFk: 1, - roleFk: 1 - }; + const bruceWayneId = 1101; + const accessToken = {accessToken: {userId: developerId}}; + const ctx = {req: accessToken}; + let tx; + let opts; - const req = {accessToken: {userId: 9}}; - - it('should return error if personal mail already exists', async() => { - const user = await models.VnUser.findById(employeeId, {fields: ['email']}); - - const tx = await models.Worker.beginTransaction({}); - - let error; - try { - const options = {transaction: tx}; - const ctx = { - args: Object.assign({}, defaultWorker, {email: user.email}), - req - }; - - await models.Worker.new(ctx, options); - - await tx.rollback(); - } catch (e) { - error = e; - await tx.rollback(); - } - - expect(error.message).toEqual('This personal mail already exists'); + beforeAll(async() => { + const activeCtx = {accessToken, http: {req: {headers: {origin: 'http://localhost'}}}}; + spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: activeCtx}); }); - it('should return error if worker code already exists', async() => { - const worker = await models.Worker.findById(employeeId, {fields: ['code']}); - - const tx = await models.Worker.beginTransaction({}); - - let error; - try { - const options = {transaction: tx}; - const ctx = { - args: Object.assign({}, defaultWorker, {code: worker.code}), - req - }; - - await models.Worker.new(ctx, options); - - await tx.rollback(); - } catch (e) { - error = e; - await tx.rollback(); - } - - expect(error.message).toEqual('This worker code already exists'); - }); - - it('should return error if worker already exists', async() => { - const worker = await models.Client.findById(employeeId, {fields: ['fi']}); - - const tx = await models.Worker.beginTransaction({}); - - let error; - try { - const options = {transaction: tx}; - const ctx = { - args: Object.assign({}, defaultWorker, {fi: worker.fi}), - req - }; - await models.Worker.new(ctx, options); - - await tx.rollback(); - } catch (e) { - error = e; - await tx.rollback(); - } - - expect(error.message).toEqual('This worker already exists'); - }); - - it('should return error if payMethod require iban', async() => { - const payMethodIbanRequired = await models.PayMethod.findOne({ - where: { - isIbanRequiredForClients: true - }, - fields: ['id'] + describe('should return error', () => { + beforeEach(async() => { + tx = await models.Worker.beginTransaction({}); + opts = {transaction: tx}; }); - const tx = await models.Worker.beginTransaction({}); + afterEach(async() => await tx.rollback()); - let error; - try { - const options = {transaction: tx}; - const ctx = { - args: Object.assign({}, defaultWorker, {payMethodFk: payMethodIbanRequired.id}), - req - }; - await models.Worker.new(ctx, options); + it('if personal mail already exists', async() => { + const user = await models.VnUser.findById(employeeId, {fields: ['email']}); + try { + await createWorker(ctx, opts, {email: user.email}); + } catch (e) { + expect(e.message).toEqual('This personal mail already exists'); + } + }); - await tx.rollback(); - } catch (e) { - error = e; - await tx.rollback(); - } + it('if worker code already exists', async() => { + const worker = await models.Worker.findById(employeeId, {fields: ['code']}); + try { + await createWorker(ctx, opts, {code: worker.code}); + } catch (e) { + expect(e.message).toEqual('This worker code already exists'); + } + }); - expect(error.message).toEqual('That payment method requires an IBAN'); + it('if worker already exists', async() => { + const worker = await models.Client.findById(employeeId, {fields: ['fi']}); + try { + await createWorker(ctx, opts, {fi: worker.fi}); + } catch (e) { + expect(e.message).toEqual('This worker already exists'); + } + }); + + it('if payMethod require iban', async() => { + const payMethodIbanRequired = await models.PayMethod.findOne({ + fields: ['id'], where: {isIbanRequiredForClients: true} + }); + + try { + await createWorker(ctx, opts, {payMethodFk: payMethodIbanRequired.id}); + } catch (e) { + expect(e.message).toEqual('That payment method requires an IBAN'); + } + }); }); it('should create a new worker', async() => { let newWorker; try { - newWorker = await models.Worker.new({args: defaultWorker, req}); + newWorker = await createWorker(ctx); + + expect(newWorker.id).toBeDefined(); } finally { await removeWorker(newWorker.id); } - - expect(newWorker.id).toBeDefined(); }); it('should create a new client', async() => { let newWorker; - let client; try { - newWorker = await models.Worker.new({args: defaultWorker, req}); - client = await models.Client.findById(newWorker.id); + newWorker = await createWorker(ctx); + let client = await models.Client.findById(newWorker.id); + + expect(client).toBeDefined(); } finally { await removeWorker(newWorker.id); } - - expect(client).toBeDefined(); }); it('should create a new worker in client', async() => { - const bruceWayneId = 1101; const client = await models.Client.findById(bruceWayneId, {fields: ['fi', 'email']}); - - const newWorkerData = { - args: Object.assign( - {}, - defaultWorker, - { - fi: client.fi, - email: client.email - }), - req - }; let newWorker; try { - newWorker = await models.Worker.new(newWorkerData); + newWorker = await createWorker(ctx, undefined, {fi: client.fi, email: client.email}); + + expect(newWorker.id).toEqual(bruceWayneId); } finally { await models.Worker.destroyById(newWorker.id); } - - expect(newWorker.id).toEqual(bruceWayneId); }); }); @@ -194,3 +106,28 @@ async function removeWorker(id) { await models.Client.destroyById(id); await models.VnUser.destroyById(id); } + +async function createWorker(ctx, opts = undefined, params = {}) { + return models.Worker.new( + ctx, + params.fi ?? '78457139E', + params.name ?? 'defaulterworker', + params.firstName ?? 'DEFAULT', + params.lastNames ?? 'WORKER', + params.email ?? 'defaultWorker@mydomain.com', + params.street ?? 'S/ DEFAULTWORKERSTREET', + params.city ?? 'defaultWorkerCity', + params.provinceFk ?? 1, + params.companyFk ?? 442, + params.postcode ?? '46680', + params.phone ?? '123456789', + params.code ?? 'DWW', + params.bossFk ?? 9, + params.birth ?? '2022-12-11T23:00:00.000Z', + params.payMethodFk ?? 1, + undefined, + undefined, + params.isFreelance ?? false, + opts + ); +} diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 4e7617aab..4796c6373 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -25,43 +25,44 @@ "required": true }, "phone": { - "type" : "string" + "type": "string" }, "bossFk": { - "type" : "number" + "type": "number" }, "maritalStatus": { - "type" : "string" + "type": "string" }, "originCountryFk": { - "type" : "number" + "type": "number" }, "educationLevelFk": { - "type" : "number" + "type": "number" }, "SSN": { - "type" : "string" + "type": "string" }, "mobileExtension": { - "type" : "number" + "type": "number" }, "code": { - "type" : "string" + "type": "string", + "required": true }, "fi": { - "type" : "string" + "type": "string" }, "birth": { - "type" : "date" + "type": "date" }, "isF11Allowed": { - "type" : "boolean" + "type": "boolean" }, "sex": { - "type" : "string" + "type": "string" }, "isFreelance": { - "type" : "boolean" + "type": "boolean" }, "fiDueDate": { "type": "date" @@ -78,7 +79,6 @@ "isSsDiscounted": { "type": "boolean" } - }, "relations": { "user": { @@ -117,7 +117,7 @@ "foreignKey": "workerFk" } }, - "acls":[ + "acls": [ { "property": "__get__locker", "accessType": "READ", @@ -126,4 +126,4 @@ "principalId": "$owner" } ] -} +} \ No newline at end of file From 8188bdbcb01821bcac21066eb6c0c825d2d1d6d8 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 5 Jun 2024 17:12:37 +0200 Subject: [PATCH 26/53] fix: refs #6273 use userId --- modules/worker/back/methods/worker/new.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/worker/back/methods/worker/new.js b/modules/worker/back/methods/worker/new.js index 538d208fa..b9a303d18 100644 --- a/modules/worker/back/methods/worker/new.js +++ b/modules/worker/back/methods/worker/new.js @@ -194,7 +194,7 @@ module.exports = Self => { await user.updateAttribute('email', email, myOptions); await models.Worker.create({ - id: isFreelance ? user.id : client.id, + id: user.id, firstName, lastName: lastNames, code, @@ -219,8 +219,8 @@ module.exports = Self => { throw e; } - await models.VnUser.resetPassword({email, emailTemplate: 'worker-welcome', id: client.id}); + await models.VnUser.resetPassword({email, emailTemplate: 'worker-welcome', id: user.id}); - return {id: client.id}; + return {id: user.id}; }; }; From 14afd8246ac82ad4629e0d5677a7c4fe9da8cc18 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 5 Jun 2024 17:38:48 +0200 Subject: [PATCH 27/53] feat: refs #6273 add back test --- modules/worker/back/methods/worker/new.js | 4 +++- .../worker/back/methods/worker/specs/new.spec.js | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/worker/back/methods/worker/new.js b/modules/worker/back/methods/worker/new.js index b9a303d18..4a4bd9449 100644 --- a/modules/worker/back/methods/worker/new.js +++ b/modules/worker/back/methods/worker/new.js @@ -134,12 +134,14 @@ module.exports = Self => { if (isFreelance || !client) { const [{password}] = await models.Worker.rawSql('SELECT account.passwordGenerate() as password;'); + const freelancer = isFreelance && await models.VnRole.findOne({fields: ['id'], where: {name: 'freelancer'}}); + user = await models.VnUser.create({ name, nickname, password, email, - roleFk, + roleFk: freelancer ? freelancer.id : roleFk, }, myOptions); await models.Account.create({ diff --git a/modules/worker/back/methods/worker/specs/new.spec.js b/modules/worker/back/methods/worker/specs/new.spec.js index 42c0d4124..5a5649154 100644 --- a/modules/worker/back/methods/worker/specs/new.spec.js +++ b/modules/worker/back/methods/worker/specs/new.spec.js @@ -97,6 +97,19 @@ describe('Worker new', () => { await models.Worker.destroyById(newWorker.id); } }); + + it('should create a new external worker', async() => { + let newWorker; + try { + newWorker = await createWorker(ctx, undefined, {isFreelance: true}); + const client = await models.Client.findById(newWorker.id); + + expect(newWorker.id).toBeDefined(); + expect(client).toBeNull(); + } finally { + await removeWorker(newWorker.id); + } + }); }); async function removeWorker(id) { From 268c0a984cfb9e4b0b2b1b8c0db12fe51bd34480 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 6 Jun 2024 12:28:34 +0200 Subject: [PATCH 28/53] feat isScanned refs #7276 --- db/.pullinfo.json | 2 +- db/versions/11089-blueMastic/00-firstScript.sql | 5 +++++ .../expedition-state/addExpeditionState.js | 2 ++ .../ticket/back/models/expedition-state.json | 17 ++++++++++------- 4 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 db/versions/11089-blueMastic/00-firstScript.sql diff --git a/db/.pullinfo.json b/db/.pullinfo.json index 0defed845..27d2c7535 100644 --- a/db/.pullinfo.json +++ b/db/.pullinfo.json @@ -9,7 +9,7 @@ }, "vn": { "view": { - "expeditionPallet_Print": "06613719475fcdba8309607c38cc78efc2e348cca7bc96b48dc3ae3c12426f54" + "expeditionPallet_Print": "ced2b84a114fcb99fce05f0c34f4fc03f3fa387bef92621be1bc306608a84345" } } } diff --git a/db/versions/11089-blueMastic/00-firstScript.sql b/db/versions/11089-blueMastic/00-firstScript.sql new file mode 100644 index 000000000..a3a92c56c --- /dev/null +++ b/db/versions/11089-blueMastic/00-firstScript.sql @@ -0,0 +1,5 @@ +-- Place your SQL code here + +USE vn; + +ALTER TABLE vn.expeditionState ADD isScanned tinyint(1) DEFAULT false NOT NULL; diff --git a/modules/ticket/back/methods/expedition-state/addExpeditionState.js b/modules/ticket/back/methods/expedition-state/addExpeditionState.js index 8eab1a838..80d74ee92 100644 --- a/modules/ticket/back/methods/expedition-state/addExpeditionState.js +++ b/modules/ticket/back/methods/expedition-state/addExpeditionState.js @@ -44,11 +44,13 @@ module.exports = Self => { const typeFk = expeditionStateType.id; expeditionId = expedition.expeditionFk; + const isScannedExpedition = expedition.isScanned ?? false; await models.ExpeditionState.create({ expeditionFk: expedition.expeditionFk, typeFk, userFk: userId, + isScanned: isScannedExpedition, }, myOptions); } diff --git a/modules/ticket/back/models/expedition-state.json b/modules/ticket/back/models/expedition-state.json index eda0f79fd..159a9275e 100644 --- a/modules/ticket/back/models/expedition-state.json +++ b/modules/ticket/back/models/expedition-state.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "expeditionState" + "table": "expeditionState" } }, "properties": { @@ -23,13 +23,16 @@ }, "userFk": { "type": "number" + }, + "isScanned": { + "type": "boolean" } }, "relations": { - "expeditionStateType": { - "type": "belongsTo", - "model": "ExpeditionStateType", - "foreignKey": "typeFk" - } + "expeditionStateType": { + "type": "belongsTo", + "model": "ExpeditionStateType", + "foreignKey": "typeFk" + } } -} +} \ No newline at end of file From f7c2fd824f529fe40826c249894fe7f515e8ddf7 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 7 Jun 2024 07:05:22 +0200 Subject: [PATCH 29/53] feat: refs #7496 changesRequested --- db/versions/11087-aquaDendro/00-firstScript.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/versions/11087-aquaDendro/00-firstScript.sql b/db/versions/11087-aquaDendro/00-firstScript.sql index e53c231c3..3490919a9 100644 --- a/db/versions/11087-aquaDendro/00-firstScript.sql +++ b/db/versions/11087-aquaDendro/00-firstScript.sql @@ -1,4 +1,4 @@ ALTER TABLE vn.ticket MODIFY COLUMN IF EXISTS isLabeled__ tinyint(1) DEFAULT 0 NOT NULL COMMENT 'refs #7496 deprecated 2024-06-20'; -ALTER TABLE IF EXISTS vn.forecastedBalance RENAME vn2008.call_information__; -ALTER TABLE IF EXISTS vn.forecastedBalance COMMENT='@deprecated 2024-05-21'; \ No newline at end of file +ALTER TABLE IF EXISTS vn.forecastedBalance RENAME vn.forecastedBalance__ ; +ALTER TABLE IF EXISTS vn.forecastedBalance__ COMMENT='@deprecated 2024-05-21'; \ No newline at end of file From 7c0fa6dbb9f27bbabbd78a08612f6f6e0b1e9c14 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 7 Jun 2024 09:18:52 +0200 Subject: [PATCH 30/53] feat isScannedExpedition refs #7276 --- db/routines/vn/procedures/expedition_getFromRoute.sql | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/expedition_getFromRoute.sql b/db/routines/vn/procedures/expedition_getFromRoute.sql index 2b4de5662..3742ef4fb 100644 --- a/db/routines/vn/procedures/expedition_getFromRoute.sql +++ b/db/routines/vn/procedures/expedition_getFromRoute.sql @@ -15,7 +15,8 @@ BEGIN t.addressFk, a.nickname, sub2.itemPackingTypeConcat, - est.code + est.code, + sub5.isScanned FROM expedition e JOIN ticket t ON t.id = e.ticketFk JOIN ticketState ts ON ts.ticketFk = e.ticketFk @@ -33,6 +34,11 @@ BEGIN GROUP BY sub.ticketFk ) sub2 ON sub2.ticketFk = t.id LEFT JOIN expeditionStateType est ON est.id = e.stateTypeFk + LEFT JOIN (SELECT es.expeditionFk, isScanned + FROM expeditionState es + JOIN (SELECT expeditionFk, MAX(id) maxId + FROM expeditionState es + GROUP BY expeditionFk)sub4 ON sub4.maxId = es.id)sub5 ON sub5.expeditionFk = e.id WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE ORDER BY r.created, t.priority DESC; END$$ From 96a3a2e69b2349ba13cd96d57af6df75c92b45a0 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 7 Jun 2024 11:50:16 +0200 Subject: [PATCH 31/53] fix: refs #6243 rollback --- db/dump/.dump/data.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index 778f6f23b..3be9dd4f5 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -1842,7 +1842,7 @@ INSERT INTO `ACL` VALUES (761,'Route','downloadZip','READ','ALLOW','ROLE','emplo INSERT INTO `ACL` VALUES (762,'Route','filter','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (763,'Route','getByWorker','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (764,'Route','getDeliveryPoint','READ','ALLOW','ROLE','employee'); -INSERT INTO `ACL` VALUES (765,'Route','cmrs','READ','ALLOW','ROLE','employee'); +INSERT INTO `ACL` VALUES (765,'Route','getExternalCmrs','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (766,'Route','getSuggestedTickets','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (767,'Route','getTickets','READ','ALLOW','ROLE','employee'); INSERT INTO `ACL` VALUES (768,'Route','guessPriority','WRITE','ALLOW','ROLE','employee'); From 521f3f14469ce825c2026c213675d2ff66b65ea6 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 7 Jun 2024 11:52:24 +0200 Subject: [PATCH 32/53] feat: refs #6243 update ACL --- db/versions/11093-purpleGerbera/00-firstScript.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 db/versions/11093-purpleGerbera/00-firstScript.sql diff --git a/db/versions/11093-purpleGerbera/00-firstScript.sql b/db/versions/11093-purpleGerbera/00-firstScript.sql new file mode 100644 index 000000000..024b0bb59 --- /dev/null +++ b/db/versions/11093-purpleGerbera/00-firstScript.sql @@ -0,0 +1,4 @@ +UPDATE salix.ACL + SET property = 'cmrs' + WHERE property = 'getExternalCmrs' + AND model = 'Route'; \ No newline at end of file From 479e4f3f8a27e2974626199a4564a5a2739299a5 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 7 Jun 2024 13:55:56 +0200 Subject: [PATCH 33/53] feat: refs #6273 required payMethod for internals --- loopback/locale/es.json | 7 ++++--- modules/worker/back/methods/worker/new.js | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index e876c1bbb..714475374 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -359,10 +359,11 @@ "Select ticket or client": "Elija un ticket o un client", "It was not able to create the invoice": "No se pudo crear la factura", "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)", - "Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE", + "Incoterms and Customs agent are required for a non UEE member": "Se requieren Incoterms y agente de aduanas para un no miembro de la UEE", "You can not use the same password": "No puedes usar la misma contraseña", "This PDA is already assigned to another user": "Este PDA ya está asignado a otro usuario", "You can only have one PDA": "Solo puedes tener un PDA", "It has been invoiced but the PDF could not be generated": "Se ha facturado pero no se ha podido generar el PDF", - "It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono" -} + "It has been invoiced but the PDF of refund not be generated": "Se ha facturado pero no se ha podido generar el PDF del abono", + "Payment method is required": "El método de pago es obligatorio" +} \ No newline at end of file diff --git a/modules/worker/back/methods/worker/new.js b/modules/worker/back/methods/worker/new.js index 4a4bd9449..ba9dc3853 100644 --- a/modules/worker/back/methods/worker/new.js +++ b/modules/worker/back/methods/worker/new.js @@ -129,8 +129,7 @@ module.exports = Self => { const nickname = firstName.concat(' ', lastNames); const {roleFk, businessTypeFk} = await models.WorkerConfig.findOne({fields: ['roleFk', 'businessTypeFk']}); - if (!isFreelance) - if (!payMethodFk) throw new UserError('Payment method is required'); + if (!isFreelance && !payMethodFk) throw new UserError('Payment method is required'); if (isFreelance || !client) { const [{password}] = await models.Worker.rawSql('SELECT account.passwordGenerate() as password;'); From cac1278c080451d9760d4f48f7dadd0a9e066945 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 7 Jun 2024 16:29:51 +0200 Subject: [PATCH 34/53] feat hsItemOlder refs $6964 --- .../11064-grayMedeola/00-firstScript.sql | 3 +- loopback/locale/es.json | 3 +- .../methods/item-shelving/getListItemNewer.js | 68 +++++++++++++++++++ .../methods/item-shelving/hasItemOlder.js | 68 ------------------- .../specs/getListItemNewer.spec.js | 40 +++++++++++ .../item-shelving/specs/hasItemOlder.spec.js | 45 ------------ modules/item/back/models/item-shelving.js | 2 +- 7 files changed, 112 insertions(+), 117 deletions(-) create mode 100644 modules/item/back/methods/item-shelving/getListItemNewer.js delete mode 100644 modules/item/back/methods/item-shelving/hasItemOlder.js create mode 100644 modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js delete mode 100644 modules/item/back/methods/item-shelving/specs/hasItemOlder.spec.js diff --git a/db/versions/11064-grayMedeola/00-firstScript.sql b/db/versions/11064-grayMedeola/00-firstScript.sql index 301c0fef1..b5af3599b 100644 --- a/db/versions/11064-grayMedeola/00-firstScript.sql +++ b/db/versions/11064-grayMedeola/00-firstScript.sql @@ -2,5 +2,4 @@ USE vn; -ALTER TABLE vn.sector ADD hasItemOlderReview BIGINT DEFAULT false NULL COMMENT 'Indica si el sector se revisa para comprobar si tiene ítems más viejos'; -ALTER TABLE vn.productionConfig ADD itemOlderReviewHours int(11) NULL COMMENT 'Horas que se tienen en cuenta para comprobar si un ítem es más viejo.'; +ALTER TABLE vn.productionConfig ADD itemOlderReviewHours int(11) DEFAULT 0 NOT NULL COMMENT 'Horas que se tienen en cuenta para comprobar si un ítem es más viejo.'; diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 77e707590..8244deb8a 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -358,5 +358,6 @@ "Select ticket or client": "Elija un ticket o un client", "It was not able to create the invoice": "No se pudo crear la factura", "This PDA is already assigned to another user": "This PDA is already assigned to another user", - "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)" + "ticketCommercial": "El ticket {{ ticket }} para el vendedor {{ salesMan }} está en preparación. (mensaje generado automáticamente)", + "parkingNotExist": "parkingNotExist" } \ No newline at end of file diff --git a/modules/item/back/methods/item-shelving/getListItemNewer.js b/modules/item/back/methods/item-shelving/getListItemNewer.js new file mode 100644 index 000000000..a6ab0e5f1 --- /dev/null +++ b/modules/item/back/methods/item-shelving/getListItemNewer.js @@ -0,0 +1,68 @@ +module.exports = Self => { + Self.remoteMethod('getListItemNewer', { + description: + 'Get boolean if any or specific item of the shelving has older created in another shelving or parking', + accessType: 'READ', + accepts: [{ + arg: 'shelvingFk', + type: 'string', + required: true, + description: 'Shelving code' + }, + { + arg: 'parking', + type: 'string', + required: true, + description: 'Parking code' + }, + ], + returns: { + type: 'Object', + root: true + }, + http: { + path: `/getListItemNewer`, + verb: 'GET' + } + }); + + Self.getListItemNewer = async(shelvingFk, parking, options) => { + const myOptions = {}; + if (typeof options == 'object') + Object.assign(myOptions, options); + + const isParkingToReview = await Self.rawSql(` + SELECT COUNT(p.id) parkingToReview + FROM vn.parking p + JOIN vn.sector s ON s.id = p.sectorFk + WHERE p.code = ? AND s.code = "CAMARA SECTOR D";`, + [parking], myOptions); + + if (isParkingToReview[0]['parkingToReview'] > 0) { + const result = await Self.rawSql(` + WITH tItemShelving AS( + SELECT is2.itemFk, is2.created, p.sectorFK, is2.id + FROM vn.itemShelving is2 + JOIN vn.shelving sh ON sh.code = is2.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + JOIN vn.sector s ON s.id = p.sectorFk + WHERE is2.shelvingFk = ? AND s.code = "NAVE ALGEMESI" + ), tItemInSector AS ( + SELECT is2.itemFk, is2.created, is2.shelvingFk + FROM vn.itemShelving is2 + JOIN vn.shelving sh ON sh.code = is2.shelvingFk + JOIN vn.parking p ON p.id = sh.parkingFk + JOIN vn.sector s ON s.id = p.sectorFk + WHERE is2.shelvingFk <> ? + AND s.code = "NAVE ALGEMESI") + SELECT ti.itemFK, tis.shelvingFk + FROM tItemShelving ti + JOIN tItemInSector tis ON tis.itemFk = ti.itemFk + JOIN vn.productionConfig pc + WHERE ti.created > tis.created + INTERVAL pc.itemOlderReviewHours HOUR;`, + [shelvingFk, shelvingFk], myOptions); + return result; + } else + return []; + }; +}; diff --git a/modules/item/back/methods/item-shelving/hasItemOlder.js b/modules/item/back/methods/item-shelving/hasItemOlder.js deleted file mode 100644 index 9bea6fbe9..000000000 --- a/modules/item/back/methods/item-shelving/hasItemOlder.js +++ /dev/null @@ -1,68 +0,0 @@ -const UserError = require('vn-loopback/util/user-error'); -module.exports = Self => { - Self.remoteMethod('hasItemOlder', { - description: - 'Get boolean if any or specific item of the shelving has older created in another shelving or parking', - accessType: 'READ', - accepts: [{ - arg: 'shelvingFkIn', - type: 'string', - required: true, - description: 'Shelving code' - }, - { - arg: 'parking', - type: 'string', - description: 'Parking code' - }, - { - arg: 'shelvingFkOut', - type: 'string', - description: 'Shelving code' - }, - { - arg: 'itemFk', - type: 'integer', - description: 'Item id' - }], - returns: { - type: 'boolean', - root: true - }, - http: { - path: `/hasItemOlder`, - verb: 'GET' - } - }); - - Self.hasItemOlder = async(shelvingFkIn, parking, shelvingFkOut, itemFk, options) => { - if (!parking && !shelvingFkOut) throw new UserError('Missing data: parking or shelving'); - - const myOptions = {}; - if (typeof options == 'object') - Object.assign(myOptions, options); - - const result = await Self.rawSql(` - SELECT COUNT(ish.id) countItemOlder - FROM vn.itemShelving ish - JOIN ( - SELECT ish.itemFk, created, shelvingFk, pickingOrder - FROM vn.itemShelving ish - JOIN vn.shelving s ON ish.shelvingFk = s.code - LEFT JOIN vn.parking p2 ON p2.id = s.parkingFk - WHERE ish.shelvingFk = ? - )sub ON sub.itemFK = ish.itemFk - JOIN vn.shelving s ON s.code = ish.shelvingFk - JOIN vn.parking p ON p.id = s.parkingFk - JOIN vn.sector s2 ON s2.id = p.sectorFk - JOIN vn.productionConfig pc ON pc.itemOlderReviewHours - WHERE ish.created + INTERVAL pc.itemOlderReviewHours HOUR < sub.created - AND (p.code <> ? OR ? IS NULL) - AND (ish.shelvingFk <> ? OR ? IS NULL) - AND (ish.itemFk = ? OR ? IS NULL) - AND (p.pickingOrder < sub.pickingOrder OR sub.pickingOrder IS NULL) - AND (s2.hasItemOlderReview)`, - [shelvingFkIn, parking, parking, shelvingFkOut, shelvingFkOut, itemFk, itemFk], myOptions); - return result[0]['countItemOlder'] > 0; - }; -}; diff --git a/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js b/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js new file mode 100644 index 000000000..5f0f7d826 --- /dev/null +++ b/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js @@ -0,0 +1,40 @@ + +const {models} = require('vn-loopback/server/server'); + +describe('itemShelving getListItemNewer()', () => { + fit('should return true because there is an older item', async() => { + const shelving = 'NCC'; + const parking = 'A-47-1'; + const sectorCam = 1; + const sectorCamCode = 'CAMARA SECTOR D'; + const sectorCamHigh = 9991; + const sectorCamHighCode = 'NAVE ALGEMESI'; + + const tx = await models.Sector.beginTransaction({}); + const myOptions = {transaction: tx}; + + const filter = {where: {id: sectorCam}}; + const filterHigh = {where: {id: sectorCamHigh}}; + + try { + const sectorCamBefore = await models.Sector.findOne(filter, myOptions); + + await sectorCamBefore.updateAttributes({ + code: sectorCamCode + }, myOptions); + + const sectorCamHighBefore = await models.Sector.findOne(filterHigh, myOptions); + await sectorCamHighBefore.updateAttributes({ + code: sectorCamHighCode + }, myOptions); + + const result = await models.ItemShelving.getListItemNewer(shelving, parking, myOptions); + + expect(result.length).toEqual(2); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/item/back/methods/item-shelving/specs/hasItemOlder.spec.js b/modules/item/back/methods/item-shelving/specs/hasItemOlder.spec.js deleted file mode 100644 index abffead53..000000000 --- a/modules/item/back/methods/item-shelving/specs/hasItemOlder.spec.js +++ /dev/null @@ -1,45 +0,0 @@ - -const {models} = require('vn-loopback/server/server'); - -describe('itemShelving hasOlder()', () => { - it('should return false because there are not older items', async() => { - const shelvingFkIn = 'GVC'; - const shelvingFkOut = 'HEJ'; - const result = await models.ItemShelving.hasItemOlder(shelvingFkIn, null, shelvingFkOut); - - expect(result).toBe(false); - }); - - it('should return false because there are not older items in parking', async() => { - const shelvingFkIn = 'HEJ'; - const parking = '700-01'; - const result = await models.ItemShelving.hasItemOlder(shelvingFkIn, parking); - - expect(result).toBe(false); - }); - - it('should return true because there is an older item', async() => { - const shelvingFkIn = 'UXN'; - const shelvingFkOut = 'PCC'; - const parking = 'A-01-1'; - const itemFk = 1; - - const tx = await models.ItemShelving.beginTransaction({}); - const myOptions = {transaction: tx}; - const filter = {where: {shelvingFk: shelvingFkOut} - }; - try { - const itemShelvingBefore = await models.ItemShelving.findOne(filter, myOptions); - await itemShelvingBefore.updateAttributes({ - itemFk: itemFk - }, myOptions); - const result = await models.ItemShelving.hasItemOlder(shelvingFkIn, parking, null, null, myOptions); - - expect(result).toBe(true); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); -}); diff --git a/modules/item/back/models/item-shelving.js b/modules/item/back/models/item-shelving.js index d48ee10d5..be72dac37 100644 --- a/modules/item/back/models/item-shelving.js +++ b/modules/item/back/models/item-shelving.js @@ -4,5 +4,5 @@ module.exports = Self => { require('../methods/item-shelving/getInventory')(Self); require('../methods/item-shelving/getAlternative')(Self); require('../methods/item-shelving/updateFromSale')(Self); - require('../methods/item-shelving/hasItemOlder')(Self); + require('../methods/item-shelving/getListItemNewer')(Self); }; From 4cf5c0775c672439c9584391cbfe2d3e04e6962e Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 10 Jun 2024 07:30:33 +0200 Subject: [PATCH 35/53] feat isScannedExpedition refs #7276 --- db/routines/vn/procedures/expedition_getFromRoute.sql | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/expedition_getFromRoute.sql b/db/routines/vn/procedures/expedition_getFromRoute.sql index 3742ef4fb..2b726fa7d 100644 --- a/db/routines/vn/procedures/expedition_getFromRoute.sql +++ b/db/routines/vn/procedures/expedition_getFromRoute.sql @@ -16,7 +16,7 @@ BEGIN a.nickname, sub2.itemPackingTypeConcat, est.code, - sub5.isScanned + es.isScanned FROM expedition e JOIN ticket t ON t.id = e.ticketFk JOIN ticketState ts ON ts.ticketFk = e.ticketFk @@ -34,11 +34,10 @@ BEGIN GROUP BY sub.ticketFk ) sub2 ON sub2.ticketFk = t.id LEFT JOIN expeditionStateType est ON est.id = e.stateTypeFk - LEFT JOIN (SELECT es.expeditionFk, isScanned - FROM expeditionState es - JOIN (SELECT expeditionFk, MAX(id) maxId - FROM expeditionState es - GROUP BY expeditionFk)sub4 ON sub4.maxId = es.id)sub5 ON sub5.expeditionFk = e.id + LEFT JOIN expeditionState es ON es.id = ( + SELECT MAX(id) + FROM expeditionState es + WHERE expeditionFk = e.id) WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE ORDER BY r.created, t.priority DESC; END$$ From 2e8d28d7959d0bdab9386813812700f36964e4d5 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 10 Jun 2024 09:08:26 +0200 Subject: [PATCH 36/53] refactor: refs #7517 Added throw --- db/routines/vn/procedures/buy_afterUpsert.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/routines/vn/procedures/buy_afterUpsert.sql b/db/routines/vn/procedures/buy_afterUpsert.sql index 17e84177c..8af53ddfb 100644 --- a/db/routines/vn/procedures/buy_afterUpsert.sql +++ b/db/routines/vn/procedures/buy_afterUpsert.sql @@ -47,6 +47,9 @@ BEGIN WHERE e.id = vEntryFk; IF vIsMerchandise THEN + IF vWarehouse IS NULL THEN + CALL util.throw('The entry does not have travel'); + END IF; REPLACE itemCost SET itemFk = vItemFk, From ca7d67451b23bc95a586103e0e6f9b5310c5e97d Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 10 Jun 2024 09:09:11 +0200 Subject: [PATCH 37/53] refactor: refs #7517 Minor changes --- db/routines/vn/procedures/buy_afterUpsert.sql | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/buy_afterUpsert.sql b/db/routines/vn/procedures/buy_afterUpsert.sql index 8af53ddfb..76f60d1e5 100644 --- a/db/routines/vn/procedures/buy_afterUpsert.sql +++ b/db/routines/vn/procedures/buy_afterUpsert.sql @@ -1,5 +1,7 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_afterUpsert`(vSelf INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_afterUpsert`( + vSelf INT +) BEGIN /** * Triggered actions when a buy is updated or inserted. @@ -16,7 +18,7 @@ BEGIN DECLARE vIsFeedStock BOOL; DECLARE vWeight DECIMAL(10,2); DECLARE vPacking INT; - + SELECT b.entryFk, b.itemFk, i.packingOut, @@ -51,7 +53,7 @@ BEGIN CALL util.throw('The entry does not have travel'); END IF; - REPLACE itemCost SET + REPLACE itemCost SET itemFk = vItemFk, warehouseFk = vWarehouse, cm3 = buy_getUnitVolume(vSelf), @@ -77,7 +79,7 @@ BEGIN WHERE b.id = vSelf; END IF; - CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck + CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck SELECT vSelf id; CALL buy_checkItem(); END$$ From e081c4504dadd3787ab4b7ed239992a48cc2d7c5 Mon Sep 17 00:00:00 2001 From: jgallego Date: Mon, 10 Jun 2024 14:51:48 +0200 Subject: [PATCH 38/53] feat: refs #7548 link a grafana --- modules/ticket/back/methods/ticket/summary.js | 1 + modules/ticket/back/models/ticket.json | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/modules/ticket/back/methods/ticket/summary.js b/modules/ticket/back/methods/ticket/summary.js index 1ce91e1b2..6bfa478ec 100644 --- a/modules/ticket/back/methods/ticket/summary.js +++ b/modules/ticket/back/methods/ticket/summary.js @@ -56,6 +56,7 @@ module.exports = Self => { const filter = { include: [ {relation: 'warehouse', scope: {fields: ['name']}}, + {relation: 'ticketCollections', scope: {fields: ['collectionFk']}}, {relation: 'agencyMode', scope: {fields: ['name']}}, {relation: 'zone', scope: {fields: ['name']}}, {relation: 'client', diff --git a/modules/ticket/back/models/ticket.json b/modules/ticket/back/models/ticket.json index 248c0312f..2d14de808 100644 --- a/modules/ticket/back/models/ticket.json +++ b/modules/ticket/back/models/ticket.json @@ -147,6 +147,11 @@ "type": "belongsTo", "model": "Cmr", "foreignKey": "cmrFk" + }, + "ticketCollections": { + "type": "hasMany", + "model": "TicketCollection", + "foreignKey": "ticketFk" } } } From 76f76b8304ccc75458216b7cceda417723024341 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 11 Jun 2024 10:48:24 +0200 Subject: [PATCH 39/53] feat: refs #7568 Added freelancer exception --- db/routines/vn/procedures/ticket_doCmr.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/ticket_doCmr.sql b/db/routines/vn/procedures/ticket_doCmr.sql index 2da8464b4..e9cd1d659 100644 --- a/db/routines/vn/procedures/ticket_doCmr.sql +++ b/db/routines/vn/procedures/ticket_doCmr.sql @@ -18,7 +18,7 @@ BEGIN com.id companyFk, a.id addressFk, c2.defaultAddressFk, - su.id supplierFk, + IFNULL(sat.supplierFk, su.id) supplierFk, t.landed FROM ticket t JOIN ticketState ts ON ts.ticketFk = t.id @@ -28,15 +28,18 @@ BEGIN JOIN `address` a ON a.id = t.addressFk JOIN province p ON p.id = a.provinceFk JOIN country co ON co.id = p.countryFk - JOIN agencyMode am ON am.id = t.agencyModeFk JOIN warehouse w ON w.id = t.warehouseFk JOIN company com ON com.id = t.companyFk JOIN client c2 ON c2.id = com.clientFk - JOIN supplierAccount sa ON sa.id = com.supplierAccountFk + JOIN supplierAccount sa ON sa.id = com.supplierAccountFk JOIN supplier su ON su.id = sa.supplierFk LEFT JOIN route r ON r.id = t.routeFk LEFT JOIN worker wo ON wo.id = r.workerFk LEFT JOIN vehicle v ON v.id = r.vehicleFk + LEFT JOIN agencyMode am ON am.id = r.agencyModeFk + LEFT JOIN agency ag ON ag.id = am.agencyFk + LEFT JOIN supplierAgencyTerm sat ON sat.agencyFk = ag.id + AND wo.isFreelance WHERE al.code IN ('PACKED', 'DELIVERED') AND co.code <> 'ES' AND am.name <> 'ABONO' From 13d1d0a61cd8d2f406799ff5ebe60704b3858925 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 11 Jun 2024 14:29:16 +0200 Subject: [PATCH 40/53] feat: refs #7499 add printedStickers --- modules/entry/back/methods/entry/getBuys.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/entry/back/methods/entry/getBuys.js b/modules/entry/back/methods/entry/getBuys.js index 90c1bb9d0..0ed77e8d1 100644 --- a/modules/entry/back/methods/entry/getBuys.js +++ b/modules/entry/back/methods/entry/getBuys.js @@ -48,7 +48,8 @@ module.exports = Self => { 'weight', 'buyingValue', 'price2', - 'price3' + 'price3', + 'printedStickers' ], include: { relation: 'item', From 17fa1e10f64993e99141c353da9eb74fb51347ba Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 12 Jun 2024 07:33:10 +0200 Subject: [PATCH 41/53] feat: refs #6701 Added claimRatio_afterInsert --- db/routines/vn/triggers/claimRatio_afterUpdate.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 db/routines/vn/triggers/claimRatio_afterUpdate.sql diff --git a/db/routines/vn/triggers/claimRatio_afterUpdate.sql b/db/routines/vn/triggers/claimRatio_afterUpdate.sql new file mode 100644 index 000000000..daae7ecf0 --- /dev/null +++ b/db/routines/vn/triggers/claimRatio_afterUpdate.sql @@ -0,0 +1,11 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`claimRatio_afterUpdate` + AFTER UPDATE ON `claimRatio` + FOR EACH ROW +BEGIN + INSERT INTO clientRate(clientFk, `value`) + VALUES(NEW.clientFk, NEW.priceIncreasing) + ON DUPLICATE KEY UPDATE + `value` = VALUES(`value`); +END$$ +DELIMITER ; From 615fd3e97bfbc9f38a8fc82e1f1d2473ec6284d3 Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 13 Jun 2024 15:10:04 +0200 Subject: [PATCH 42/53] refs #7530 delete trigger deviceProductionConfig_afterUpdate --- .../triggers/deviceProductionConfig_afterUpdate.sql | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 db/routines/vn/triggers/deviceProductionConfig_afterUpdate.sql diff --git a/db/routines/vn/triggers/deviceProductionConfig_afterUpdate.sql b/db/routines/vn/triggers/deviceProductionConfig_afterUpdate.sql deleted file mode 100644 index 98e4f844f..000000000 --- a/db/routines/vn/triggers/deviceProductionConfig_afterUpdate.sql +++ /dev/null @@ -1,13 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`deviceProductionConfig_afterUpdate` - AFTER UPDATE ON `deviceProductionConfig` - FOR EACH ROW -BEGIN - IF NEW.isAllUsersAllowed = 1 OR NEW.isAllUsersAllowed = -1 THEN - SET @username := (SELECT account.myUser_getName()); - INSERT INTO vn.mail (receiver, subject, body) - VALUES ('cau@verdnatura.es', 'Se ha activado la autenticación sin restricciones en la app', - CONCAT('El usuario ', @username,' ha habilitado la opción para que todos los usuarios puedan acceder a la app sin restricciones')); - END IF; -END$$ -DELIMITER ; From 189c67bd2d9eccbe2ea6cd9c27d981c64d9da720 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 14 Jun 2024 09:43:10 +0200 Subject: [PATCH 43/53] warmFix change if --- db/dump/fixtures.before.sql | 38 +++++++++++++++++-- loopback/locale/en.json | 8 ++-- .../back/methods/worker/createAbsence.js | 3 +- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 592297894..591716a83 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -767,7 +767,7 @@ INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeF (35, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Somewhere in Philippines', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL), (36, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1102, 'Ant-Man Adventure', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL), (37, 1, 1, 1, 3, util.VN_CURDATE(), util.VN_CURDATE(), 1110, 'Deadpool swords', 123, NULL, 0, 1, 16, 0, util.VN_CURDATE(), NULL, NULL); - + INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `description`) VALUES (1, 11, 1, 'ready'), @@ -3841,7 +3841,7 @@ INSERT INTO `vn`.`ledgerConfig` SET INSERT INTO vn.sectorCollection SET id = 2, userFk = 18, - sectorFk = 1; + sectorFk = 1; INSERT INTO vn.sectorCollectionSaleGroup SET id = 8, @@ -3855,9 +3855,39 @@ INSERT INTO vn.saleGroup (userFk, parkingFk, sectorFk, ticketFk) INSERT INTO vn.sectorCollection SET id = 3, userFk = 18, - sectorFk = 1; + sectorFk = 1; INSERT INTO vn.sectorCollectionSaleGroup SET id = 9, sectorCollectionFk = 3, - saleGroupFk = 6; \ No newline at end of file + saleGroupFk = 6; + + +INSERT INTO vn.calendarHolidays +(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) +VALUES(2, 1, '2001-05-08', 1, 1); +INSERT INTO vn.calendarHolidays +(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) +VALUES(3, 1, '2001-05-09', 1, 1); +INSERT INTO vn.calendarHolidays +(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) +VALUES(4, 1, '2001-05-10', 1, 1); +INSERT INTO vn.calendarHolidays +(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) +VALUES(5, 1, '2001-05-11', 1, 1); +INSERT INTO vn.calendarHolidays +(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) +VALUES(6, 1, '2001-05-14', 1, 5); +INSERT INTO vn.calendarHolidays +(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) +VALUES(7, 1, '2001-05-15', 1, 5); +INSERT INTO vn.calendarHolidays +(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) +VALUES(8, 1, '2001-05-16', 1, 5); +INSERT INTO vn.calendarHolidays +(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) +VALUES(9, 1, '2001-05-17', 1, 5); +INSERT INTO vn.calendarHolidays +(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) +VALUES(10, 1, '2001-05-18', 1, 5); + diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 740b50bcd..a2332fdca 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -229,8 +229,8 @@ "InvoiceIn is already booked": "InvoiceIn is already booked", "This workCenter is already assigned to this agency": "This workCenter is already assigned to this agency", "You can only have one PDA": "You can only have one PDA", - "Incoterms and Customs agent are required for a non UEE member": "Incoterms and Customs agent are required for a non UEE member", + "Incoterms and Customs agent are required for a non UEE member": "Incoterms and Customs agent are required for a non UEE member", "It has been invoiced but the PDF could not be generated": "It has been invoiced but the PDF could not be generated", - "It has been invoiced but the PDF of refund not be generated": "It has been invoiced but the PDF of refund not be generated" - -} + "It has been invoiced but the PDF of refund not be generated": "It has been invoiced but the PDF of refund not be generated", + "Cannot add holidays on this day": "Cannot add holidays on this day" +} \ No newline at end of file diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 2de1d6e4d..0397886cf 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -110,8 +110,7 @@ module.exports = Self => { workCenterFk: workCenter.workCenterFk } }); - - if (holiday && isFestive) + if ((holiday && isFestive) && (workCenter.workcenterFk === holiday.workCenterFk)) throw new UserError(`Cannot add holidays on this day`); const absence = await models.Calendar.create({ From e3e9706fb86b95de180471178b277fee467b1d3c Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 14 Jun 2024 09:53:50 +0200 Subject: [PATCH 44/53] fix fixtures --- db/dump/fixtures.before.sql | 38 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 591716a83..b1fe01cb3 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3863,31 +3863,15 @@ INSERT INTO vn.sectorCollectionSaleGroup saleGroupFk = 6; -INSERT INTO vn.calendarHolidays -(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) -VALUES(2, 1, '2001-05-08', 1, 1); -INSERT INTO vn.calendarHolidays -(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) -VALUES(3, 1, '2001-05-09', 1, 1); -INSERT INTO vn.calendarHolidays -(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) -VALUES(4, 1, '2001-05-10', 1, 1); -INSERT INTO vn.calendarHolidays -(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) -VALUES(5, 1, '2001-05-11', 1, 1); -INSERT INTO vn.calendarHolidays -(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) -VALUES(6, 1, '2001-05-14', 1, 5); -INSERT INTO vn.calendarHolidays -(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) -VALUES(7, 1, '2001-05-15', 1, 5); -INSERT INTO vn.calendarHolidays -(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) -VALUES(8, 1, '2001-05-16', 1, 5); -INSERT INTO vn.calendarHolidays -(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) -VALUES(9, 1, '2001-05-17', 1, 5); -INSERT INTO vn.calendarHolidays -(id, calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) -VALUES(10, 1, '2001-05-18', 1, 5); +INSERT INTO `vn`.`calendarHolidays` (calendarHolidaysTypeFk, dated, calendarHolidaysNameFk, workCenterFk) + VALUES + (1, '2001-05-08', 1, 1), + (1, '2001-05-09', 1, 1), + (1, '2001-05-10', 1, 1), + (1, '2001-05-11', 1, 1), + (1, '2001-05-14', 1, 5), + (1, '2001-05-15', 1, 5), + (1, '2001-05-16', 1, 5), + (1, '2001-05-17', 1, 5), + (1, '2001-05-18', 1, 5); From cfa0b8789859e73beef2336567325f04b75f6e39 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 17 Jun 2024 11:50:25 +0200 Subject: [PATCH 45/53] feat: refs #7296 RoutesMonitor --- modules/route/back/models/routesMonitor.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/route/back/models/routesMonitor.json b/modules/route/back/models/routesMonitor.json index a14680b5c..c5fe4c1ce 100644 --- a/modules/route/back/models/routesMonitor.json +++ b/modules/route/back/models/routesMonitor.json @@ -48,6 +48,9 @@ "priority": { "type": "number" }, + "roadmapStopFk": { + "type": "number" + }, "m3boxes": { "type": "number" }, From eaaf83561c8bf949cb4dcda8252ffcd4abed9d91 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 17 Jun 2024 13:03:02 +0200 Subject: [PATCH 46/53] fix: refs #5995 Optimized downloadCmrsZip --- modules/route/back/methods/route/downloadCmrsZip.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/route/back/methods/route/downloadCmrsZip.js b/modules/route/back/methods/route/downloadCmrsZip.js index c6934edca..895ff7a16 100644 --- a/modules/route/back/methods/route/downloadCmrsZip.js +++ b/modules/route/back/methods/route/downloadCmrsZip.js @@ -41,14 +41,16 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - ids = ids.split(','); - - for (const id of ids) { + const downloadAddZip = async id => { ctx.args = ctx.args || {}; ctx.args.id = Number(id); const [data] = await models.Route.cmr(ctx, myOptions); zip.file(`${id}.pdf`, data, {binary: true}); - } + }; + + ids = ids.split(','); + const promises = ids.map(id => downloadAddZip(id)); + await Promise.all(promises); const zipStream = zip.generateNodeStream({streamFiles: true}); return [zipStream, 'application/zip', `filename="cmrs.zip"`]; }; From eedcdb54fad2773fba8d4e3f5e985a327a894a6e Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 17 Jun 2024 19:50:51 +0200 Subject: [PATCH 47/53] feat hasItemOlder refs#6964 --- db/versions/11106-salmonPhormium/00-firstScript.sql | 9 +++++++++ .../item/back/methods/item-shelving/getListItemNewer.js | 9 ++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 db/versions/11106-salmonPhormium/00-firstScript.sql diff --git a/db/versions/11106-salmonPhormium/00-firstScript.sql b/db/versions/11106-salmonPhormium/00-firstScript.sql new file mode 100644 index 000000000..b7cd5de4c --- /dev/null +++ b/db/versions/11106-salmonPhormium/00-firstScript.sql @@ -0,0 +1,9 @@ +-- Place your SQL code here + +USE vn; + +ALTER TABLE vn.productionConfig ADD sectorFromCode varchar(11) NULL COMMENT 'Sector origen que se revisa ítems más nuevos al parkinear'; +ALTER TABLE vn.productionConfig ADD sectorToCode varchar(11) NULL COMMENT 'Sector destino que se revisa ítems más nuevos al parkinear'; + +ALTER TABLE vn.productionConfig ADD CONSTRAINT productionConfig_sector_FK FOREIGN KEY (sectorFromCode) REFERENCES vn.sector(code) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE vn.productionConfig ADD CONSTRAINT productionConfig_sector_FK_1 FOREIGN KEY (sectorToCode) REFERENCES vn.sector(code) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/modules/item/back/methods/item-shelving/getListItemNewer.js b/modules/item/back/methods/item-shelving/getListItemNewer.js index a6ab0e5f1..3978fa26e 100644 --- a/modules/item/back/methods/item-shelving/getListItemNewer.js +++ b/modules/item/back/methods/item-shelving/getListItemNewer.js @@ -35,7 +35,8 @@ module.exports = Self => { SELECT COUNT(p.id) parkingToReview FROM vn.parking p JOIN vn.sector s ON s.id = p.sectorFk - WHERE p.code = ? AND s.code = "CAMARA SECTOR D";`, + JOIN vn.productionConfig pc + WHERE p.code = ? AND s.code = pc.sectorToCode;`, [parking], myOptions); if (isParkingToReview[0]['parkingToReview'] > 0) { @@ -46,15 +47,17 @@ module.exports = Self => { JOIN vn.shelving sh ON sh.code = is2.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.sector s ON s.id = p.sectorFk - WHERE is2.shelvingFk = ? AND s.code = "NAVE ALGEMESI" + JOIN vn.productionConfig pc + WHERE is2.shelvingFk = ? AND s.code = c.sectorFromCode ), tItemInSector AS ( SELECT is2.itemFk, is2.created, is2.shelvingFk FROM vn.itemShelving is2 JOIN vn.shelving sh ON sh.code = is2.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.sector s ON s.id = p.sectorFk + JOIN vn.productionConfig pc WHERE is2.shelvingFk <> ? - AND s.code = "NAVE ALGEMESI") + AND s.code = c.sectorFromCode) SELECT ti.itemFK, tis.shelvingFk FROM tItemShelving ti JOIN tItemInSector tis ON tis.itemFk = ti.itemFk From 46cd20a1fde5601fd9aa1642d5f1bfa79008d591 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 18 Jun 2024 08:24:15 +0200 Subject: [PATCH 48/53] feat hasItemOlder refs#6964 --- .../methods/item-shelving/getListItemNewer.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/modules/item/back/methods/item-shelving/getListItemNewer.js b/modules/item/back/methods/item-shelving/getListItemNewer.js index 3978fa26e..708b81108 100644 --- a/modules/item/back/methods/item-shelving/getListItemNewer.js +++ b/modules/item/back/methods/item-shelving/getListItemNewer.js @@ -17,7 +17,7 @@ module.exports = Self => { }, ], returns: { - type: 'Object', + type: 'Array', root: true }, http: { @@ -31,7 +31,7 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const isParkingToReview = await Self.rawSql(` + const [isParkingToReview] = await Self.rawSql(` SELECT COUNT(p.id) parkingToReview FROM vn.parking p JOIN vn.sector s ON s.id = p.sectorFk @@ -39,8 +39,9 @@ module.exports = Self => { WHERE p.code = ? AND s.code = pc.sectorToCode;`, [parking], myOptions); - if (isParkingToReview[0]['parkingToReview'] > 0) { - const result = await Self.rawSql(` + if (isParkingToReview['parkingToReview'] < 1) return []; + + const result = await Self.rawSql(` WITH tItemShelving AS( SELECT is2.itemFk, is2.created, p.sectorFK, is2.id FROM vn.itemShelving is2 @@ -63,9 +64,7 @@ module.exports = Self => { JOIN tItemInSector tis ON tis.itemFk = ti.itemFk JOIN vn.productionConfig pc WHERE ti.created > tis.created + INTERVAL pc.itemOlderReviewHours HOUR;`, - [shelvingFk, shelvingFk], myOptions); - return result; - } else - return []; + [shelvingFk, shelvingFk], myOptions); + return result; }; }; From 239814e6b4315009f404a96457a41bd71766ddb3 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 18 Jun 2024 10:08:40 +0200 Subject: [PATCH 49/53] feat hasItemOlder refs#6964 --- back/models/production-config.json | 12 ++++-- .../11106-salmonPhormium/00-firstScript.sql | 8 ++-- .../methods/item-shelving/getListItemNewer.js | 4 +- .../specs/getListItemNewer.spec.js | 39 +++++++++++-------- 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/back/models/production-config.json b/back/models/production-config.json index 3800dbbf2..2fc6d71ff 100644 --- a/back/models/production-config.json +++ b/back/models/production-config.json @@ -3,17 +3,23 @@ "base": "VnModel", "options": { "mysql": { - "table": "productionConfig" + "table": "productionConfig" } - }, + }, "properties": { "id": { "type": "number", "required": true, "id": true }, + "sectorFromCode": { + "type": "string" + }, + "sectorToCode": { + "type": "string" + }, "backupPrinterNotificationDelay": { "type": "string" } } -} +} \ No newline at end of file diff --git a/db/versions/11106-salmonPhormium/00-firstScript.sql b/db/versions/11106-salmonPhormium/00-firstScript.sql index b7cd5de4c..9f63e6075 100644 --- a/db/versions/11106-salmonPhormium/00-firstScript.sql +++ b/db/versions/11106-salmonPhormium/00-firstScript.sql @@ -2,8 +2,8 @@ USE vn; -ALTER TABLE vn.productionConfig ADD sectorFromCode varchar(11) NULL COMMENT 'Sector origen que se revisa ítems más nuevos al parkinear'; -ALTER TABLE vn.productionConfig ADD sectorToCode varchar(11) NULL COMMENT 'Sector destino que se revisa ítems más nuevos al parkinear'; +ALTER TABLE vn.productionConfig ADD sectorFromCode varchar(15) NULL COMMENT 'Sector origen que se revisa ítems más nuevos al parkinear'; +ALTER TABLE vn.productionConfig ADD sectorToCode varchar(15) NULL COMMENT 'Sector destino que se revisa ítems más nuevos al parkinear'; -ALTER TABLE vn.productionConfig ADD CONSTRAINT productionConfig_sector_FK FOREIGN KEY (sectorFromCode) REFERENCES vn.sector(code) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE vn.productionConfig ADD CONSTRAINT productionConfig_sector_FK_1 FOREIGN KEY (sectorToCode) REFERENCES vn.sector(code) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE vn.productionConfig ADD CONSTRAINT productionConfig_sector_FK FOREIGN KEY (sectorFromCode) REFERENCES vn.sector(code) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE vn.productionConfig ADD CONSTRAINT productionConfig_sector_FK_1 FOREIGN KEY (sectorToCode) REFERENCES vn.sector(code) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/modules/item/back/methods/item-shelving/getListItemNewer.js b/modules/item/back/methods/item-shelving/getListItemNewer.js index 708b81108..1702bb05b 100644 --- a/modules/item/back/methods/item-shelving/getListItemNewer.js +++ b/modules/item/back/methods/item-shelving/getListItemNewer.js @@ -49,7 +49,7 @@ module.exports = Self => { JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.sector s ON s.id = p.sectorFk JOIN vn.productionConfig pc - WHERE is2.shelvingFk = ? AND s.code = c.sectorFromCode + WHERE is2.shelvingFk = ? AND s.code = pc.sectorFromCode ), tItemInSector AS ( SELECT is2.itemFk, is2.created, is2.shelvingFk FROM vn.itemShelving is2 @@ -58,7 +58,7 @@ module.exports = Self => { JOIN vn.sector s ON s.id = p.sectorFk JOIN vn.productionConfig pc WHERE is2.shelvingFk <> ? - AND s.code = c.sectorFromCode) + AND s.code = pc.sectorFromCode) SELECT ti.itemFK, tis.shelvingFk FROM tItemShelving ti JOIN tItemInSector tis ON tis.itemFk = ti.itemFk diff --git a/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js b/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js index 5f0f7d826..15c480992 100644 --- a/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js +++ b/modules/item/back/methods/item-shelving/specs/getListItemNewer.spec.js @@ -2,31 +2,36 @@ const {models} = require('vn-loopback/server/server'); describe('itemShelving getListItemNewer()', () => { - fit('should return true because there is an older item', async() => { + it('should return true because there is an older item', async() => { const shelving = 'NCC'; const parking = 'A-47-1'; - const sectorCam = 1; - const sectorCamCode = 'CAMARA SECTOR D'; - const sectorCamHigh = 9991; - const sectorCamHighCode = 'NAVE ALGEMESI'; + + const sectorCamHighCode = 'CAMARA SECTOR D'; + const sectorCamCode = 'NAVE ALGEMESI'; + + const sectorCamCodeHighId = 1; + const sectorCamCodeId = 9991; const tx = await models.Sector.beginTransaction({}); const myOptions = {transaction: tx}; - const filter = {where: {id: sectorCam}}; - const filterHigh = {where: {id: sectorCamHigh}}; - try { - const sectorCamBefore = await models.Sector.findOne(filter, myOptions); - - await sectorCamBefore.updateAttributes({ - code: sectorCamCode - }, myOptions); - - const sectorCamHighBefore = await models.Sector.findOne(filterHigh, myOptions); - await sectorCamHighBefore.updateAttributes({ + const sectorHighCam = await models.Sector.findById(sectorCamCodeHighId, null, myOptions); + await sectorHighCam.updateAttributes({ code: sectorCamHighCode - }, myOptions); + }); + + const sectorCam = await models.Sector.findById(sectorCamCodeId, null, myOptions); + await sectorCam.updateAttributes({ + code: sectorCamCode + }); + + const config = await models.ProductionConfig.findOne(); + + await config.updateAttributes({ + sectorToCode: sectorCamHighCode, + sectorFromCode: sectorCamCode + }); const result = await models.ItemShelving.getListItemNewer(shelving, parking, myOptions); From 24cf23dddc0ef4c42407ef7576689fff1767132f Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 21 Jun 2024 13:16:01 +0200 Subject: [PATCH 50/53] feat: refs #62add travelKgPercentage table and model --- .../11114-goldenDracena/00-firstScript.sql | 18 ++++++++++++++++ .../methods/travel/extraCommunityFilter.js | 14 ++++++++++++- modules/travel/back/model-config.json | 5 ++++- .../back/models/travel-kg-percentage.json | 21 +++++++++++++++++++ 4 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 db/versions/11114-goldenDracena/00-firstScript.sql create mode 100644 modules/travel/back/models/travel-kg-percentage.json diff --git a/db/versions/11114-goldenDracena/00-firstScript.sql b/db/versions/11114-goldenDracena/00-firstScript.sql new file mode 100644 index 000000000..0b6581faf --- /dev/null +++ b/db/versions/11114-goldenDracena/00-firstScript.sql @@ -0,0 +1,18 @@ +-- Place your SQL code here +CREATE TABLE IF NOT EXISTS travelKgPercentage ( + value INT(3) PRIMARY KEY, + className VARCHAR(50) +); + +INSERT IGNORE INTO travelKgPercentage (value, className) + VALUES + (80, 'primary'), + (100, 'alert'); + +INSERT IGNORE INTO salix.ACL + SET model = 'TravelKgPercentage', + property = '*', + accessType = 'READ', + permission = 'ALLOW', + principalType = 'ROLE', + principalId = 'employee'; \ No newline at end of file diff --git a/modules/travel/back/methods/travel/extraCommunityFilter.js b/modules/travel/back/methods/travel/extraCommunityFilter.js index 488297318..dcb704ff5 100644 --- a/modules/travel/back/methods/travel/extraCommunityFilter.js +++ b/modules/travel/back/methods/travel/extraCommunityFilter.js @@ -138,7 +138,19 @@ module.exports = Self => { b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) as DECIMAL(10,0) - ) as volumeKg + ) as volumeKg, + GREATEST( + CAST(SUM(b.weight * b.stickers) AS INT), + CAST( + SUM(vc.aerealVolumetricDensity * + b.stickers * + IF(pkg.volume, + pkg.volume, + pkg.width * pkg.depth * pkg.height + ) / 1000000 + ) AS INT + ) + / t.kg * 100, 0) percentageKg FROM travel t LEFT JOIN supplier s ON s.id = t.cargoSupplierFk LEFT JOIN entry e ON e.travelFk = t.id diff --git a/modules/travel/back/model-config.json b/modules/travel/back/model-config.json index ed5c071b3..952ce0d20 100644 --- a/modules/travel/back/model-config.json +++ b/modules/travel/back/model-config.json @@ -11,6 +11,9 @@ "Thermograph": { "dataSource": "vn" }, + "TravelKgPercentage": { + "dataSource": "vn" + }, "TravelThermograph": { "dataSource": "vn" }, @@ -20,4 +23,4 @@ "Temperature": { "dataSource": "vn" } -} +} \ No newline at end of file diff --git a/modules/travel/back/models/travel-kg-percentage.json b/modules/travel/back/models/travel-kg-percentage.json new file mode 100644 index 000000000..e99a88999 --- /dev/null +++ b/modules/travel/back/models/travel-kg-percentage.json @@ -0,0 +1,21 @@ +{ + "name": "TravelKgPercentage", + "base": "VnModel", + "mixins": { + "Loggable": true + }, + "options": { + "mysql": { + "table": "travelKgPercentage" + } + }, + "properties": { + "value": { + "type": "number", + "id": true + }, + "className": { + "type": "string" + } + } +} \ No newline at end of file From 5ef0dffa3e23d82a10a63ed26b126da05def2230 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 21 Jun 2024 13:38:00 +0200 Subject: [PATCH 51/53] fix: refs #6238 add scheme --- db/versions/11114-goldenDracena/00-firstScript.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/versions/11114-goldenDracena/00-firstScript.sql b/db/versions/11114-goldenDracena/00-firstScript.sql index 0b6581faf..cc283f418 100644 --- a/db/versions/11114-goldenDracena/00-firstScript.sql +++ b/db/versions/11114-goldenDracena/00-firstScript.sql @@ -1,10 +1,10 @@ -- Place your SQL code here -CREATE TABLE IF NOT EXISTS travelKgPercentage ( +CREATE TABLE IF NOT EXISTS vn.travelKgPercentage ( value INT(3) PRIMARY KEY, className VARCHAR(50) ); -INSERT IGNORE INTO travelKgPercentage (value, className) +INSERT IGNORE INTO vn.travelKgPercentage (value, className) VALUES (80, 'primary'), (100, 'alert'); From 8c5f468087cd7f50ac00d574961f1c556441c0a6 Mon Sep 17 00:00:00 2001 From: Pako Date: Mon, 24 Jun 2024 10:30:25 +0200 Subject: [PATCH 52/53] tested proc --- .../supplierPackaging_ReportSource.sql | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql index a3401843a..2426417c5 100644 --- a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql +++ b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql @@ -1,14 +1,14 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`supplierPackaging_ReportSource`( +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`supplierPackaging_ReportSource`( vFromDated DATE, vSupplierFk INT ) BEGIN /** -* Selecciona los embalajes de un proveedor a partir de una fecha +* Create a report with packaging balance * -* @param vFromDated Fecha de la que partir -* @param vSupplierFk Id del proveedor +* @param vFromDated Starting date +* @param vSupplierFk Supplier ID */ SET @vBalance = 0; SET @vItemFk = NULL; @@ -22,7 +22,7 @@ BEGIN landed, `in`, `out`, - warehouse, + sref, buyingValue, IF ( NOT (@vItemFk <=> sub.itemFk), @@ -31,19 +31,20 @@ BEGIN ) balance, @vItemFk := sub.itemFk previousItemFk FROM ( - SELECT supplierFk, - itemFk, - longName, - supplier, - CONCAT('E',entryFk) entryFk, - landed, - `in`, - `out`, - warehouse, - buyingValue - FROM supplierPackaging - WHERE supplierFk = vSupplierFk - AND landed >= vFromDated + SELECT sp.supplierFk, + sp.itemFk, + sp.longName, + sp.supplier, + CONCAT('E',sp.entryFk) entryFk, + sp.landed, + sp.`in`, + sp.`out`, + e.invoiceNumber sref, + sp.buyingValue + FROM supplierPackaging sp + JOIN entry e ON e.id = sp.entryFk + WHERE sp.supplierFk = vSupplierFk + AND sp.landed >= vFromDated UNION ALL SELECT vSupplierFk, itemFk, @@ -68,7 +69,7 @@ BEGIN DATE(t.shipped), -LEAST(s.quantity,0) `in`, GREATEST(s.quantity,0) `out`, - t.warehouseFk, + t.cmrFk, s.price * (100 - s.discount) / 100 FROM sale s JOIN item i ON i.id = s.itemFk @@ -99,6 +100,7 @@ BEGIN WHERE su.id = vSupplierFk AND t.shipped < vFromDated AND p.isPackageReturnable + AND NOT t.isDeleted GROUP BY s.itemFk UNION ALL SELECT vSupplierFk, @@ -109,7 +111,7 @@ BEGIN DATE(t.shipped), -LEAST(tp.quantity,0) `in`, GREATEST(tp.quantity,0) `out`, - t.warehouseFk, + t.cmrFk, 0 FROM ticketPackaging tp JOIN packaging p ON p.id = tp.packagingFk @@ -138,8 +140,9 @@ BEGIN JOIN client c ON c.id = t.clientFk JOIN supplier su ON su.nif = c.fi WHERE su.id = vSupplierFk - AND t.shipped >= vFromDated + AND t.shipped < vFromDated AND p.isPackageReturnable + AND NOT t.isDeleted GROUP BY p.itemFk ORDER BY itemFk, landed, entryFk ) sub @@ -153,7 +156,7 @@ BEGIN landed, CAST(`in` AS DECIMAL(10,0)) `in`, CAST(`out` AS DECIMAL(10,0)) `out`, - warehouse, + sref, buyingValue, balance FROM tSupplierPackaging From 5f329fde38055a153436297a05f9145c8c82959c Mon Sep 17 00:00:00 2001 From: Pako Date: Mon, 24 Jun 2024 10:32:51 +0200 Subject: [PATCH 53/53] or replace --- db/routines/vn/procedures/supplierPackaging_ReportSource.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql index 2426417c5..63285203b 100644 --- a/db/routines/vn/procedures/supplierPackaging_ReportSource.sql +++ b/db/routines/vn/procedures/supplierPackaging_ReportSource.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`supplierPackaging_ReportSource`( +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`supplierPackaging_ReportSource`( vFromDated DATE, vSupplierFk INT )