From dfdf3d68bffb6ef991d85f0985c74b1a0315b696 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 24 Nov 2022 09:36:05 +0100 Subject: [PATCH 01/37] changes needed for the worker Notification manager to work --- .../methods/notification/deleteSubcription.js | 56 +++++++++++++++++++ back/models/notificationAcl.json | 10 ++++ back/models/notificationSubscription.js | 3 + back/models/notificationSubscription.json | 1 - 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 back/methods/notification/deleteSubcription.js create mode 100644 back/models/notificationSubscription.js diff --git a/back/methods/notification/deleteSubcription.js b/back/methods/notification/deleteSubcription.js new file mode 100644 index 000000000..9095613fe --- /dev/null +++ b/back/methods/notification/deleteSubcription.js @@ -0,0 +1,56 @@ +module.exports = Self => { + Self.remoteMethod('deleteSubscription', { + description: 'delete a notification subscription', + accessType: 'WRITE', + accepts: [ + { + arg: 'notificationId', + type: 'string', + required: true + }, + { + arg: 'userId', + type: 'string', + required: true + } + ], + returns: { + type: 'object', + root: true + }, + http: { + path: `/deleteSubscription`, + verb: 'POST' + } + }); + + Self.deleteSubscription = async(notificationId, userId, options) => { + const myOptions = {}; + let tx; + + if (typeof options == 'object') + + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + + myOptions.transaction = tx; + } + + try { + const query = `DELETE FROM util.notificationSubscription + WHERE notificationFk = ? AND userFk = ?`; + + await Self.rawSql(query, [notificationId, userId], myOptions); + + if (tx) await tx.commit(); + + return {success: true}; + } catch (error) { + if (tx) await tx.rollback(); + + throw error; + } + }; +}; diff --git a/back/models/notificationAcl.json b/back/models/notificationAcl.json index e3e97f52d..a20187961 100644 --- a/back/models/notificationAcl.json +++ b/back/models/notificationAcl.json @@ -6,6 +6,16 @@ "table": "util.notificationAcl" } }, + "properties":{ + "notificationFk": { + "id": true, + "type": "number" + }, + "roleFk":{ + "id": true, + "type": "number" + } + }, "relations": { "notification": { "type": "belongsTo", diff --git a/back/models/notificationSubscription.js b/back/models/notificationSubscription.js new file mode 100644 index 000000000..ce5d89e8b --- /dev/null +++ b/back/models/notificationSubscription.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/notification/deleteSubcription')(Self); +}; diff --git a/back/models/notificationSubscription.json b/back/models/notificationSubscription.json index 43fa6db27..11dbde6fb 100644 --- a/back/models/notificationSubscription.json +++ b/back/models/notificationSubscription.json @@ -9,7 +9,6 @@ "properties": { "notificationFk": { "type": "number", - "id": true, "description": "Identifier" }, "userFk": { From 3e08650b6f7f1210f6905861818673dd3df402a3 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Fri, 25 Nov 2022 07:06:04 +0100 Subject: [PATCH 02/37] acls for the notifications --- db/changes/10503-november/00-acl-notifications.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/changes/10503-november/00-acl-notifications.sql diff --git a/db/changes/10503-november/00-acl-notifications.sql b/db/changes/10503-november/00-acl-notifications.sql new file mode 100644 index 000000000..b2377393b --- /dev/null +++ b/db/changes/10503-november/00-acl-notifications.sql @@ -0,0 +1,3 @@ +INSERT INTO salix.ACL (model,property,accessType,principalId) + VALUES ('NotificationSubscription','*','*','employee'), + VALUES ('NotificationAcl','*','*','employee'); \ No newline at end of file From 074763f633bd54113d9220a2a708c9074958668b Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Fri, 25 Nov 2022 11:47:23 +0100 Subject: [PATCH 03/37] rename files --- .../{00-acl-notifications.sql => 00-acl_notifications.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/changes/10503-november/{00-acl-notifications.sql => 00-acl_notifications.sql} (100%) diff --git a/db/changes/10503-november/00-acl-notifications.sql b/db/changes/10503-november/00-acl_notifications.sql similarity index 100% rename from db/changes/10503-november/00-acl-notifications.sql rename to db/changes/10503-november/00-acl_notifications.sql From aee7cd113ef7c6355ca51fffae9721a42ff92a04 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Mon, 28 Nov 2022 09:33:14 +0100 Subject: [PATCH 04/37] add template strings to sql --- db/changes/10503-november/00-acl_notifications.sql | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/db/changes/10503-november/00-acl_notifications.sql b/db/changes/10503-november/00-acl_notifications.sql index b2377393b..ee2e2e345 100644 --- a/db/changes/10503-november/00-acl_notifications.sql +++ b/db/changes/10503-november/00-acl_notifications.sql @@ -1,3 +1,4 @@ -INSERT INTO salix.ACL (model,property,accessType,principalId) - VALUES ('NotificationSubscription','*','*','employee'), - VALUES ('NotificationAcl','*','*','employee'); \ No newline at end of file +INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`principalId`) + VALUES + ('NotificationSubscription','*','*','employee'), + ('NotificationAcl','*','*','employee'); \ No newline at end of file From ada3e6f175da8e0564866a9b3608a39fa385cb8f Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 27 Dec 2022 10:10:37 +0100 Subject: [PATCH 05/37] update sql folder --- db/changes/224903/00-acl_notifications.sql | 4 ---- db/changes/230201/00-acl_notifications.sql | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) delete mode 100644 db/changes/224903/00-acl_notifications.sql create mode 100644 db/changes/230201/00-acl_notifications.sql diff --git a/db/changes/224903/00-acl_notifications.sql b/db/changes/224903/00-acl_notifications.sql deleted file mode 100644 index ee2e2e345..000000000 --- a/db/changes/224903/00-acl_notifications.sql +++ /dev/null @@ -1,4 +0,0 @@ -INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`principalId`) - VALUES - ('NotificationSubscription','*','*','employee'), - ('NotificationAcl','*','*','employee'); \ No newline at end of file diff --git a/db/changes/230201/00-acl_notifications.sql b/db/changes/230201/00-acl_notifications.sql new file mode 100644 index 000000000..ef710aca6 --- /dev/null +++ b/db/changes/230201/00-acl_notifications.sql @@ -0,0 +1,3 @@ + VALUES + ('NotificationSubscription','*','*','employee'), + ('NotificationAcl','*','*','employee'); \ No newline at end of file From 5eda1388efdbe94854308d31a6798982df6a4fc7 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 27 Dec 2022 10:26:56 +0100 Subject: [PATCH 06/37] refs #4927 unique key added --- CHANGELOG.md | 4 ++-- db/changes/230201/.gitkeep | 0 db/changes/230201/00-SupplierUniqueKey.sql | 1 + modules/supplier/back/models/supplier.js | 4 ---- 4 files changed, 3 insertions(+), 6 deletions(-) delete mode 100644 db/changes/230201/.gitkeep create mode 100644 db/changes/230201/00-SupplierUniqueKey.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 95b3028de..906dd002c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- +- ### Changed -- \ No newline at end of file +- Se permite añadir Proveedores con la misma razón social pero con países distintos diff --git a/db/changes/230201/.gitkeep b/db/changes/230201/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/db/changes/230201/00-SupplierUniqueKey.sql b/db/changes/230201/00-SupplierUniqueKey.sql new file mode 100644 index 000000000..9c0d4a192 --- /dev/null +++ b/db/changes/230201/00-SupplierUniqueKey.sql @@ -0,0 +1 @@ +ALTER TABLE `vn`.`supplier` ADD UNIQUE (name, countryFk); diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index 44549c65c..64c585b6a 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -16,10 +16,6 @@ module.exports = Self => { message: 'The social name cannot be empty' }); - Self.validatesUniquenessOf('name', { - message: 'The supplier name must be unique' - }); - if (this.city) { Self.validatesPresenceOf('city', { message: 'City cannot be empty' From 3ca1d1f4ee6e7b4853d4c8c04df17017f6e79ded Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 27 Dec 2022 10:29:15 +0100 Subject: [PATCH 07/37] remove error in fixtures --- db/dump/fixtures.sql | 4 ---- 1 file changed, 4 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 762e5411a..ff87b4bd0 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1954,10 +1954,6 @@ INSERT INTO `vn`.`workerBusinessType` (`id`, `name`, `isFullTime`, `isPermanent` (100, 'INDEFINIDO A TIEMPO COMPLETO', 1, 1, 1), (109, 'CONVERSION DE TEMPORAL EN INDEFINIDO T.COMPLETO', 1, 1, 1); -INSERT INTO `vn`.`businessCategory` (`id`, `description`, `rate`) - VALUES - (1, 'basic employee', 1); - UPDATE `vn`.`business` b SET `rate` = 7, `workerBusinessCategoryFk` = 1, From ea7f4b7c02172517a94f4077febf5d635409f846 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 27 Dec 2022 10:34:12 +0100 Subject: [PATCH 08/37] remove broken fixture --- db/dump/fixtures.sql | 4 ---- 1 file changed, 4 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index ff87b4bd0..b2501c6db 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2746,10 +2746,6 @@ INSERT INTO `vn`.`mdbApp` (`app`, `baselineBranchFk`, `userFk`, `locked`) VALUES ('foo', 'master', NULL, NULL), ('bar', 'test', 9, util.VN_NOW()); -INSERT INTO `vn`.`ticketLog` (`id`, `originFk`, `userFk`, `action`, `changedModel`, `oldInstance`, `newInstance`, `changedModelId`) - VALUES - (1, 1, 9, 'insert', 'Ticket', '{}', '{"clientFk":1, "nickname": "Bat cave"}', 1); - INSERT INTO `salix`.`url` (`appName`, `environment`, `url`) VALUES From ee0cd2174f78a5e4207c2026bf0218f282d9b3ae Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 27 Dec 2022 14:32:19 +0100 Subject: [PATCH 09/37] requested changes refs #4797 @2h --- .../methods/notification/deleteSubcription.js | 56 --------------- back/models/notificationSubscription.js | 72 ++++++++++++++++++- back/models/notificationSubscription.json | 1 + db/changes/230201/00-acl_notifications.sql | 14 +++- 4 files changed, 83 insertions(+), 60 deletions(-) delete mode 100644 back/methods/notification/deleteSubcription.js diff --git a/back/methods/notification/deleteSubcription.js b/back/methods/notification/deleteSubcription.js deleted file mode 100644 index 9095613fe..000000000 --- a/back/methods/notification/deleteSubcription.js +++ /dev/null @@ -1,56 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('deleteSubscription', { - description: 'delete a notification subscription', - accessType: 'WRITE', - accepts: [ - { - arg: 'notificationId', - type: 'string', - required: true - }, - { - arg: 'userId', - type: 'string', - required: true - } - ], - returns: { - type: 'object', - root: true - }, - http: { - path: `/deleteSubscription`, - verb: 'POST' - } - }); - - Self.deleteSubscription = async(notificationId, userId, options) => { - const myOptions = {}; - let tx; - - if (typeof options == 'object') - - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - - myOptions.transaction = tx; - } - - try { - const query = `DELETE FROM util.notificationSubscription - WHERE notificationFk = ? AND userFk = ?`; - - await Self.rawSql(query, [notificationId, userId], myOptions); - - if (tx) await tx.commit(); - - return {success: true}; - } catch (error) { - if (tx) await tx.rollback(); - - throw error; - } - }; -}; diff --git a/back/models/notificationSubscription.js b/back/models/notificationSubscription.js index ce5d89e8b..83f52047b 100644 --- a/back/models/notificationSubscription.js +++ b/back/models/notificationSubscription.js @@ -1,3 +1,73 @@ +const UserError = require('vn-loopback/util/user-error'); + module.exports = Self => { - require('../methods/notification/deleteSubcription')(Self); + Self.observe('before save', async function(ctx) { + let models = Self.app.models; + let userId = ctx.options.accessToken.userId; + let modifiedUser = await models.Worker.findOne({ + fields: ['id', 'bossFk'], + where: { + id: ctx.instance.userFk + } + }); + + if (userId == modifiedUser.id || userId == modifiedUser.bossFk) + return; + else + throw new UserError('You dont have permission to modify this user'); + }); + + Self.remoteMethod('deleteNotification', { + description: 'Gets the current user data', + accepts: [ + { + arg: 'ctx', + type: 'object', + http: {source: 'context'} + }, + { + arg: 'userId', + type: 'string' + }, + { + arg: 'notificationId', + type: 'number' + }, + { + arg: 'authorId', + type: 'number' + } + ], + returns: { + type: 'object', + root: true + }, + http: { + verb: 'POST', + path: '/deleteNotification' + } + }); + + Self.deleteNotification = async function(ctx) { + let models = Self.app.models; + let user = await ctx.args.authorId; + let notificationId = await ctx.args.notificationId; + let userId = await ctx.args.userId; + let modifiedUser = await models.Worker.findOne({ + fields: ['id', 'bossFk'], + where: { + id: ctx.args.userId + } + }); + + if (user == modifiedUser.id || modifiedUser.bossFk == user) { + const query = `DELETE FROM util.notificationSubscription + WHERE notificationFk = ? AND userFk = ?`; + + await Self.rawSql(query, [notificationId, userId]); + + return; + } else + throw new UserError('You dont have permission to modify this user'); + }; }; diff --git a/back/models/notificationSubscription.json b/back/models/notificationSubscription.json index 11dbde6fb..43fa6db27 100644 --- a/back/models/notificationSubscription.json +++ b/back/models/notificationSubscription.json @@ -9,6 +9,7 @@ "properties": { "notificationFk": { "type": "number", + "id": true, "description": "Identifier" }, "userFk": { diff --git a/db/changes/230201/00-acl_notifications.sql b/db/changes/230201/00-acl_notifications.sql index ef710aca6..c206dd27f 100644 --- a/db/changes/230201/00-acl_notifications.sql +++ b/db/changes/230201/00-acl_notifications.sql @@ -1,3 +1,11 @@ - VALUES - ('NotificationSubscription','*','*','employee'), - ('NotificationAcl','*','*','employee'); \ No newline at end of file +INSERT INTO + `salix`.`ACL` ( + `model`, + `property`, + `accessType`, + `permission`, + `principalId` + ) +VALUES + ('NotificationSubscription', '*', '*', 'employee'), + ('NotificationAcl', '*', '*', 'employee'); \ No newline at end of file From 0a602892e6f32326bd1b6ee477e69db59b55a55f Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 27 Dec 2022 14:59:23 +0100 Subject: [PATCH 10/37] changed let to const and removed duplicate code --- back/models/notificationSubscription.js | 36 ++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/back/models/notificationSubscription.js b/back/models/notificationSubscription.js index 83f52047b..811914634 100644 --- a/back/models/notificationSubscription.js +++ b/back/models/notificationSubscription.js @@ -2,14 +2,10 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.observe('before save', async function(ctx) { - let models = Self.app.models; - let userId = ctx.options.accessToken.userId; - let modifiedUser = await models.Worker.findOne({ - fields: ['id', 'bossFk'], - where: { - id: ctx.instance.userFk - } - }); + const models = Self.app.models; + const userId = ctx.options.accessToken.userId; + const user = await ctx.instance.userFk; + const modifiedUser = await getUserToModify(user, models); if (userId == modifiedUser.id || userId == modifiedUser.bossFk) return; @@ -49,16 +45,11 @@ module.exports = Self => { }); Self.deleteNotification = async function(ctx) { - let models = Self.app.models; - let user = await ctx.args.authorId; - let notificationId = await ctx.args.notificationId; - let userId = await ctx.args.userId; - let modifiedUser = await models.Worker.findOne({ - fields: ['id', 'bossFk'], - where: { - id: ctx.args.userId - } - }); + const models = Self.app.models; + const user = await ctx.args.authorId; + const notificationId = await ctx.args.notificationId; + const userId = await ctx.args.userId; + const modifiedUser = await getUserToModify(userId, models); if (user == modifiedUser.id || modifiedUser.bossFk == user) { const query = `DELETE FROM util.notificationSubscription @@ -70,4 +61,13 @@ module.exports = Self => { } else throw new UserError('You dont have permission to modify this user'); }; + + async function getUserToModify(user, models) { + return await models.Worker.findOne({ + fields: ['id', 'bossFk'], + where: { + id: user + } + }); + } }; From a55d00765581e2dd0b686c2dfdf533116b8bd420 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 3 Jan 2023 08:12:46 +0100 Subject: [PATCH 11/37] requested changes --- back/models/notificationSubscription.js | 20 +++++++------------- db/changes/230201/00-acl_notifications.sql | 15 ++++----------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/back/models/notificationSubscription.js b/back/models/notificationSubscription.js index 811914634..26fcc04df 100644 --- a/back/models/notificationSubscription.js +++ b/back/models/notificationSubscription.js @@ -14,7 +14,7 @@ module.exports = Self => { }); Self.remoteMethod('deleteNotification', { - description: 'Gets the current user data', + description: 'Deletes a notification subscription', accepts: [ { arg: 'ctx', @@ -22,15 +22,11 @@ module.exports = Self => { http: {source: 'context'} }, { - arg: 'userId', + arg: 'userFk', type: 'string' }, { - arg: 'notificationId', - type: 'number' - }, - { - arg: 'authorId', + arg: 'notificationFk', type: 'number' } ], @@ -44,18 +40,16 @@ module.exports = Self => { } }); - Self.deleteNotification = async function(ctx) { + Self.deleteNotification = async function(ctx, userFk, notificationFk) { const models = Self.app.models; - const user = await ctx.args.authorId; - const notificationId = await ctx.args.notificationId; - const userId = await ctx.args.userId; - const modifiedUser = await getUserToModify(userId, models); + const user = ctx.req.accessToken.userId; + const modifiedUser = await getUserToModify(userFk, models); if (user == modifiedUser.id || modifiedUser.bossFk == user) { const query = `DELETE FROM util.notificationSubscription WHERE notificationFk = ? AND userFk = ?`; - await Self.rawSql(query, [notificationId, userId]); + await Self.rawSql(query, [notificationFk, userFk]); return; } else diff --git a/db/changes/230201/00-acl_notifications.sql b/db/changes/230201/00-acl_notifications.sql index c206dd27f..4b86e2cd0 100644 --- a/db/changes/230201/00-acl_notifications.sql +++ b/db/changes/230201/00-acl_notifications.sql @@ -1,11 +1,4 @@ -INSERT INTO - `salix`.`ACL` ( - `model`, - `property`, - `accessType`, - `permission`, - `principalId` - ) -VALUES - ('NotificationSubscription', '*', '*', 'employee'), - ('NotificationAcl', '*', '*', 'employee'); \ No newline at end of file +INSERT INTO `salix`.`ACL` (model,property,accessType,principalId) + VALUES ('NotificationSubscription','*','*','employee'); +INSERT INTO `salix`.`ACL` (model,property,accessType,principalId) + VALUES ('NotificationAcl','*','*','employee'); From 24b8b172b9d3f361414798cde012e27d2b8be131 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 5 Jan 2023 14:13:42 +0100 Subject: [PATCH 12/37] use notification id --- back/models/notificationSubscription.js | 44 ++++++++++++----------- back/models/notificationSubscription.json | 11 +++--- db/dump/structure.sql | 3 +- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/back/models/notificationSubscription.js b/back/models/notificationSubscription.js index 26fcc04df..77ef8ffbe 100644 --- a/back/models/notificationSubscription.js +++ b/back/models/notificationSubscription.js @@ -22,13 +22,10 @@ module.exports = Self => { http: {source: 'context'} }, { - arg: 'userFk', - type: 'string' + arg: 'notificationId', + type: 'number', + required: true }, - { - arg: 'notificationFk', - type: 'number' - } ], returns: { type: 'object', @@ -40,28 +37,35 @@ module.exports = Self => { } }); - Self.deleteNotification = async function(ctx, userFk, notificationFk) { + Self.deleteNotification = async function(ctx, notificationId) { const models = Self.app.models; const user = ctx.req.accessToken.userId; - const modifiedUser = await getUserToModify(userFk, models); + const modifiedUser = await getUserToModify(notificationId, models); if (user == modifiedUser.id || modifiedUser.bossFk == user) { - const query = `DELETE FROM util.notificationSubscription - WHERE notificationFk = ? AND userFk = ?`; - - await Self.rawSql(query, [notificationFk, userFk]); - + await models.NotificationSubscription.destroyById(notificationId); return; } else throw new UserError('You dont have permission to modify this user'); }; - async function getUserToModify(user, models) { - return await models.Worker.findOne({ - fields: ['id', 'bossFk'], - where: { - id: user - } - }); + async function getUserToModify(notificationId = null, userFk = null, models) { + if (notificationId != null) { + const subscription = await models.NotificationSubscription.findById(notificationId); + const user = await subscription.userFk; + return await models.Worker.findOne({ + fields: ['id', 'bossFk'], + where: { + id: user + } + }); + } else { + return await models.Worker.findOne({ + fields: ['id', 'bossFk'], + where: { + id: userFk + } + }); + } } }; diff --git a/back/models/notificationSubscription.json b/back/models/notificationSubscription.json index 43fa6db27..a640e0917 100644 --- a/back/models/notificationSubscription.json +++ b/back/models/notificationSubscription.json @@ -7,15 +7,18 @@ } }, "properties": { - "notificationFk": { + "id": { "type": "number", "id": true, - "description": "Identifier" + "description": "Primary key" + }, + "notificationFk": { + "type": "number", + "description": "Foreign key to Notification" }, "userFk": { "type": "number", - "id": true, - "description": "Identifier" + "description": "Foreign key to Account" } }, "relations": { diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 47fdd6d74..510a51d94 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -19726,9 +19726,10 @@ DROP TABLE IF EXISTS `notificationSubscription`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `notificationSubscription` ( + `Id` int(11) NOT NULL AUTO_INCREMENT, `notificationFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, - PRIMARY KEY (`notificationFk`,`userFk`), + PRIMARY KEY (`Id`), KEY `notificationSubscription_ibfk_2` (`userFk`), CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `notification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `notificationSubscription_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE From 3b69d76525b604cd81a72cdaf58d9d88888f83b7 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Mon, 9 Jan 2023 08:43:11 +0100 Subject: [PATCH 13/37] fix error preventing subscriptions --- back/models/notificationSubscription.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/back/models/notificationSubscription.js b/back/models/notificationSubscription.js index 77ef8ffbe..eafa9d51b 100644 --- a/back/models/notificationSubscription.js +++ b/back/models/notificationSubscription.js @@ -5,7 +5,7 @@ module.exports = Self => { const models = Self.app.models; const userId = ctx.options.accessToken.userId; const user = await ctx.instance.userFk; - const modifiedUser = await getUserToModify(user, models); + const modifiedUser = await getUserToModify(null, user, models); if (userId == modifiedUser.id || userId == modifiedUser.bossFk) return; @@ -40,7 +40,7 @@ module.exports = Self => { Self.deleteNotification = async function(ctx, notificationId) { const models = Self.app.models; const user = ctx.req.accessToken.userId; - const modifiedUser = await getUserToModify(notificationId, models); + const modifiedUser = await getUserToModify(notificationId, null, models); if (user == modifiedUser.id || modifiedUser.bossFk == user) { await models.NotificationSubscription.destroyById(notificationId); From 41671e8a3a358ea8c3170b8c388c3e4d4640a398 Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 13 Jan 2023 08:38:29 +0100 Subject: [PATCH 14/37] refs #4927 modified hook to check name & country --- loopback/locale/es.json | 5 +++-- modules/supplier/back/models/supplier.js | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index ea83b36c4..f2acea939 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -252,5 +252,6 @@ "Receipt's bank was not found": "No se encontró el banco del recibo", "This receipt was not compensated": "Este recibo no ha sido compensado", "Client's email was not found": "No se encontró el email del cliente", - "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9" -} \ No newline at end of file + "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9", + "A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país." +} diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index 64c585b6a..cba220af8 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -116,13 +116,21 @@ module.exports = Self => { Self.observe('before save', async function(ctx) { const changes = ctx.data || ctx.instance; const orgData = ctx.currentInstance; - - const socialName = changes.name || orgData.name; const hasChanges = orgData && changes; - const socialNameChanged = hasChanges - && orgData.socialName != socialName; - if ((socialNameChanged) && !isAlpha(socialName)) - throw new UserError('The social name has an invalid format'); + if (hasChanges) { + const name = changes.name || orgData.name; + const nameChanged = hasChanges && orgData.name != name; + const countryFk = changes.countryFk || orgData.countryFk; + const countryChanged = hasChanges && orgData.countryFk != countryFk; + + if (nameChanged || countryChanged) { + if (!isAlpha(name)) throw new UserError('The social name has an invalid format'); + + const supplier = await Self.app.models.Supplier.findOne({where: {name, countryFk}, fields: ['id']}); + if (supplier) + throw new UserError('A supplier with the same name already exists. Change the country.'); + } + } }); }; From cc806cc08feaccc361a41850c9ee141696c86536 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Wed, 18 Jan 2023 07:41:10 +0100 Subject: [PATCH 15/37] requested changes --- back/models/notificationSubscription.js | 13 +++++-------- db/dump/structure.sql | 5 +++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/back/models/notificationSubscription.js b/back/models/notificationSubscription.js index eafa9d51b..674629413 100644 --- a/back/models/notificationSubscription.js +++ b/back/models/notificationSubscription.js @@ -7,9 +7,7 @@ module.exports = Self => { const user = await ctx.instance.userFk; const modifiedUser = await getUserToModify(null, user, models); - if (userId == modifiedUser.id || userId == modifiedUser.bossFk) - return; - else + if (userId != modifiedUser.id && userId != modifiedUser.bossFk) throw new UserError('You dont have permission to modify this user'); }); @@ -42,14 +40,13 @@ module.exports = Self => { const user = ctx.req.accessToken.userId; const modifiedUser = await getUserToModify(notificationId, null, models); - if (user == modifiedUser.id || modifiedUser.bossFk == user) { - await models.NotificationSubscription.destroyById(notificationId); - return; - } else + if (user != modifiedUser.id && user != modifiedUser.bossFk) throw new UserError('You dont have permission to modify this user'); + + await models.NotificationSubscription.destroyById(notificationId); }; - async function getUserToModify(notificationId = null, userFk = null, models) { + async function getUserToModify(notificationId, userFk, models) { if (notificationId != null) { const subscription = await models.NotificationSubscription.findById(notificationId); const user = await subscription.userFk; diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 510a51d94..4213f918a 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -19726,10 +19726,11 @@ DROP TABLE IF EXISTS `notificationSubscription`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `notificationSubscription` ( - `Id` int(11) NOT NULL AUTO_INCREMENT, + `id` int(11) NOT NULL AUTO_INCREMENT, `notificationFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, - PRIMARY KEY (`Id`), + PRIMARY KEY (`id`), + KEY `notificationSubscription_ibfk_1` (`notificationFk`), KEY `notificationSubscription_ibfk_2` (`userFk`), CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `notification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `notificationSubscription_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE From a5f83021dba3848bbb009c7cd86f3b658544d681 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Wed, 18 Jan 2023 09:06:17 +0100 Subject: [PATCH 16/37] requested changes --- back/models/notificationSubscription.js | 24 +++++++------------ .../00-uniqueKeyNotificationSubscription.sql | 4 ++++ 2 files changed, 13 insertions(+), 15 deletions(-) create mode 100644 db/changes/230201/00-uniqueKeyNotificationSubscription.sql diff --git a/back/models/notificationSubscription.js b/back/models/notificationSubscription.js index 674629413..f1b2811fa 100644 --- a/back/models/notificationSubscription.js +++ b/back/models/notificationSubscription.js @@ -47,22 +47,16 @@ module.exports = Self => { }; async function getUserToModify(notificationId, userFk, models) { - if (notificationId != null) { + let userToModify = userFk; + if (notificationId) { const subscription = await models.NotificationSubscription.findById(notificationId); - const user = await subscription.userFk; - return await models.Worker.findOne({ - fields: ['id', 'bossFk'], - where: { - id: user - } - }); - } else { - return await models.Worker.findOne({ - fields: ['id', 'bossFk'], - where: { - id: userFk - } - }); + userToModify = subscription.userFk; } + return await models.Worker.findOne({ + fields: ['id', 'bossFk'], + where: { + id: userToModify + } + }); } }; diff --git a/db/changes/230201/00-uniqueKeyNotificationSubscription.sql b/db/changes/230201/00-uniqueKeyNotificationSubscription.sql new file mode 100644 index 000000000..623ecf770 --- /dev/null +++ b/db/changes/230201/00-uniqueKeyNotificationSubscription.sql @@ -0,0 +1,4 @@ +ALTER TABLE + `util`.`notificationSubscription` +ADD + CONSTRAINT `notificationSubscription_UN` UNIQUE KEY (`notificationFk`, `userFk`); \ No newline at end of file From a425d54bf6bbcfe0294854ffb88e3a2e552728b3 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Wed, 18 Jan 2023 12:16:47 +0100 Subject: [PATCH 17/37] add back test --- .../specs/notificationSubscription.spec.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 back/models/specs/notificationSubscription.spec.js diff --git a/back/models/specs/notificationSubscription.spec.js b/back/models/specs/notificationSubscription.spec.js new file mode 100644 index 000000000..bcb1db9d8 --- /dev/null +++ b/back/models/specs/notificationSubscription.spec.js @@ -0,0 +1,22 @@ +const app = require('vn-loopback/server/server'); + +describe('loopback model NotificationSubscription', () => { + it('Should fail to delete a notification if the user is not editing itself or a subordinate', async() => { + const user = 9; + const notificationSubscriptionId = 2; + const ctx = {req: {accessToken: {userId: user}}}; + const models = app.models; + const notification = await models.NotificationSubscription.findById(notificationSubscriptionId); + + let error; + + try { + await models.NotificationSubscription.deleteNotification(ctx, notification.id); + } catch (e) { + error = e; + } + + expect(error.message).toContain('You dont have permission to modify this user'); + }); +}); + From f30b1ecff1f3e2e2811ffa5a318c919f7db48dd3 Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 20 Jan 2023 10:03:00 +0100 Subject: [PATCH 18/37] refs #4927 changed hook for validateAsync --- modules/supplier/back/models/supplier.js | 41 ++++++++++++++++-------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index cba220af8..4e509aafc 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -113,24 +113,37 @@ module.exports = Self => { throw new UserError('You can not modify is pay method checked'); }); + Self.validateAsync('name', 'countryFk', hasSupplierSameName, { + message: 'A supplier with the same name already exists. Change the country.' + }); + + async function hasSupplierSameName(err, done) { + if (!this.name || !this.countryFk) done(); + const supplier = await Self.app.models.Supplier.findOne( + { + where: { + name: this.name, + countryFk: this.countryFk + }, + fields: ['id'] + }); + + if (supplier && supplier.id != this.id) + err(); + + done(); + } + Self.observe('before save', async function(ctx) { const changes = ctx.data || ctx.instance; const orgData = ctx.currentInstance; + + const socialName = changes.name || orgData.name; const hasChanges = orgData && changes; + const socialNameChanged = hasChanges + && orgData.socialName != socialName; - if (hasChanges) { - const name = changes.name || orgData.name; - const nameChanged = hasChanges && orgData.name != name; - const countryFk = changes.countryFk || orgData.countryFk; - const countryChanged = hasChanges && orgData.countryFk != countryFk; - - if (nameChanged || countryChanged) { - if (!isAlpha(name)) throw new UserError('The social name has an invalid format'); - - const supplier = await Self.app.models.Supplier.findOne({where: {name, countryFk}, fields: ['id']}); - if (supplier) - throw new UserError('A supplier with the same name already exists. Change the country.'); - } - } + if ((socialNameChanged) && !isAlpha(socialName)) + throw new UserError('The social name has an invalid format'); }); }; From b281a51d90e7ef3b813bf418e74b0b4ce04b13c0 Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 20 Jan 2023 10:33:23 +0100 Subject: [PATCH 19/37] refs #4927 refresh structure --- db/dump/structure.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 772d6055d..4626279e4 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -80203,4 +80203,3 @@ USE `vncontrol`; -- Dump completed on 2022-11-21 7:57:28 - From c13bffcc573817e7b4e075f7fd872b40df330ceb Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 24 Jan 2023 10:11:16 +0100 Subject: [PATCH 20/37] refs #4797 @1h requested changes --- .../specs/notificationSubscription.spec.js | 78 +++++++++++++++---- .../00-acl_notifications.sql | 0 db/changes/230401/00-alter_notSubs.sql | 10 +++ db/dump/fixtures.sql | 5 +- 4 files changed, 79 insertions(+), 14 deletions(-) rename db/changes/{230201 => 230401}/00-acl_notifications.sql (100%) create mode 100644 db/changes/230401/00-alter_notSubs.sql diff --git a/back/models/specs/notificationSubscription.spec.js b/back/models/specs/notificationSubscription.spec.js index bcb1db9d8..b1a54e0c2 100644 --- a/back/models/specs/notificationSubscription.spec.js +++ b/back/models/specs/notificationSubscription.spec.js @@ -1,22 +1,74 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('loopback model NotificationSubscription', () => { it('Should fail to delete a notification if the user is not editing itself or a subordinate', async() => { - const user = 9; - const notificationSubscriptionId = 2; - const ctx = {req: {accessToken: {userId: user}}}; - const models = app.models; - const notification = await models.NotificationSubscription.findById(notificationSubscriptionId); - - let error; + const tx = await models.NotificationSubscription.beginTransaction({}); try { - await models.NotificationSubscription.deleteNotification(ctx, notification.id); - } catch (e) { - error = e; - } + const options = {transaction: tx}; + const user = 9; + const notificationSubscriptionId = 2; + const ctx = {req: {accessToken: {userId: user}}}; + const notification = await models.NotificationSubscription.findById(notificationSubscriptionId); - expect(error.message).toContain('You dont have permission to modify this user'); + let error; + + try { + await models.NotificationSubscription.deleteNotification(ctx, notification.id, options); + } catch (e) { + error = e; + } + + expect(error.message).toContain('You dont have permission to modify this user'); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('Should delete a notification if the user is editing itself', async() => { + const tx = await models.NotificationSubscription.beginTransaction({}); + + try { + const options = {transaction: tx}; + const user = 9; + const notificationSubscriptionId = 5; + const ctx = {req: {accessToken: {userId: user}}}; + const notification = await models.NotificationSubscription.findById(notificationSubscriptionId); + + await models.NotificationSubscription.deleteNotification(ctx, notification.id, options); + + const deletedNotification = await models.NotificationSubscription.findById(notificationSubscriptionId); + + expect(deletedNotification).toBeNull(); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('Should delete a notification if the user is editing a subordinate', async() => { + const tx = await models.NotificationSubscription.beginTransaction({}); + + try { + const options = {transaction: tx}; + const user = 9; + const notificationSubscriptionId = 6; + const ctx = {req: {accessToken: {userId: user}}}; + const notification = await models.NotificationSubscription.findById(notificationSubscriptionId); + + await models.NotificationSubscription.deleteNotification(ctx, notification.id, options); + + const deletedNotification = await models.NotificationSubscription.findById(notificationSubscriptionId); + + expect(deletedNotification).toBeNull(); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); }); diff --git a/db/changes/230201/00-acl_notifications.sql b/db/changes/230401/00-acl_notifications.sql similarity index 100% rename from db/changes/230201/00-acl_notifications.sql rename to db/changes/230401/00-acl_notifications.sql diff --git a/db/changes/230401/00-alter_notSubs.sql b/db/changes/230401/00-alter_notSubs.sql new file mode 100644 index 000000000..3ead323b0 --- /dev/null +++ b/db/changes/230401/00-alter_notSubs.sql @@ -0,0 +1,10 @@ +CREATE OR REPLACE TABLE `util`.`notificationSubscription` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `notificationFk` int(11) NOT NULL, + `userFk` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`), + KEY `notificationSubscription_ibfk_1` (`notificationFk`), + KEY `notificationSubscription_ibfk_2` (`userFk`), + CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `notification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `notificationSubscription_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 0783a06df..bb4f00ff5 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2701,7 +2701,10 @@ INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) VALUES (1, 1109), (1, 1110), - (3, 1109); + (3, 1109), + (1,9), + (1,3); + INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) VALUES From a2150b8b080cb62a207d05d4eb2e37c143d0fc1d Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 24 Jan 2023 10:15:32 +0100 Subject: [PATCH 21/37] change test to adhere to the fixtures --- back/models/specs/notificationSubscription.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/back/models/specs/notificationSubscription.spec.js b/back/models/specs/notificationSubscription.spec.js index b1a54e0c2..c7f37abed 100644 --- a/back/models/specs/notificationSubscription.spec.js +++ b/back/models/specs/notificationSubscription.spec.js @@ -33,7 +33,7 @@ describe('loopback model NotificationSubscription', () => { try { const options = {transaction: tx}; const user = 9; - const notificationSubscriptionId = 5; + const notificationSubscriptionId = 4; const ctx = {req: {accessToken: {userId: user}}}; const notification = await models.NotificationSubscription.findById(notificationSubscriptionId); @@ -55,7 +55,7 @@ describe('loopback model NotificationSubscription', () => { try { const options = {transaction: tx}; const user = 9; - const notificationSubscriptionId = 6; + const notificationSubscriptionId = 5; const ctx = {req: {accessToken: {userId: user}}}; const notification = await models.NotificationSubscription.findById(notificationSubscriptionId); From 3184dcd39d8d51974b9c62dd9e41035eb0ba891c Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 26 Jan 2023 08:41:12 +0100 Subject: [PATCH 22/37] requested changes --- db/changes/230401/00-acl_notifications.sql | 6 +++--- db/changes/230401/00-alter_notSubs.sql | 14 ++++---------- db/dump/structure.sql | 3 +-- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/db/changes/230401/00-acl_notifications.sql b/db/changes/230401/00-acl_notifications.sql index 4b86e2cd0..ab40b16a5 100644 --- a/db/changes/230401/00-acl_notifications.sql +++ b/db/changes/230401/00-acl_notifications.sql @@ -1,4 +1,4 @@ INSERT INTO `salix`.`ACL` (model,property,accessType,principalId) - VALUES ('NotificationSubscription','*','*','employee'); -INSERT INTO `salix`.`ACL` (model,property,accessType,principalId) - VALUES ('NotificationAcl','*','*','employee'); + VALUES + ('NotificationSubscription','*','*','employee'), + ('NotificationAcl','*','READ','employee'); diff --git a/db/changes/230401/00-alter_notSubs.sql b/db/changes/230401/00-alter_notSubs.sql index 3ead323b0..a4177bba4 100644 --- a/db/changes/230401/00-alter_notSubs.sql +++ b/db/changes/230401/00-alter_notSubs.sql @@ -1,10 +1,4 @@ -CREATE OR REPLACE TABLE `util`.`notificationSubscription` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `notificationFk` int(11) NOT NULL, - `userFk` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `notificationSubscription_ibfk_1` (`notificationFk`), - KEY `notificationSubscription_ibfk_2` (`userFk`), - CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `notification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `notificationSubscription_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +ALTER TABLE util.notificationSubscription +ADD Id int(11) auto_increment NULL, +DROP PRIMARY KEY, +ADD CONSTRAINT PRIMARY KEY (Id); diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 97d7603f6..831296bc6 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -19726,10 +19726,9 @@ DROP TABLE IF EXISTS `notificationSubscription`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `notificationSubscription` ( - `id` int(11) NOT NULL AUTO_INCREMENT, `notificationFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), + PRIMARY KEY (`notificationFk`,`userFk`), KEY `notificationSubscription_ibfk_1` (`notificationFk`), KEY `notificationSubscription_ibfk_2` (`userFk`), CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `notification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, From 35157207dd071ce44f6e65063149ba9f8eafa148 Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 27 Jan 2023 10:05:03 +0100 Subject: [PATCH 23/37] refs #5077 hours set 00:00:00 only when date change --- modules/ticket/front/basic-data/step-one/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/ticket/front/basic-data/step-one/index.js b/modules/ticket/front/basic-data/step-one/index.js index f532265e2..99782de44 100644 --- a/modules/ticket/front/basic-data/step-one/index.js +++ b/modules/ticket/front/basic-data/step-one/index.js @@ -75,8 +75,10 @@ class Controller extends Component { } set shipped(value) { + if (new Date(this.ticket.shipped).toDateString() != value.toDateString()) + value.setHours(0, 0, 0, 0); + this.ticket.shipped = value; - this.ticket.shipped.setHours(0, 0, 0, 0); this.getLanded({ shipped: value, addressFk: this.ticket.addressFk, From 03d75c5b72ce142e0683d6373ce79d23d868ba1b Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 30 Jan 2023 12:25:57 +0100 Subject: [PATCH 24/37] refs #4927 changelog modified --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57be4697b..7f7a28f0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - (Trabajadores -> Nuevo trabajador) Nueva sección ### Changed -- +- (Proveedores -> Crear/Editar) Permite añadir Proveedores con la misma razón social pero con países distintos ### Fixed - (Artículos -> Etiquetas) Permite intercambiar la relevancia entre dos etiquetas. @@ -29,7 +29,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - (Reclamaciones -> Descriptor) Cambiado el campo Agencia por Zona - (Tickets -> Líneas preparadas) Actualizada sección para que sea más visual -- (Proveedores -> Crear/Editar) Permite añadir Proveedores con la misma razón social pero con países distintos ### Fixed - (General) Al utilizar el traductor de Google se descuadraban los iconos From c08836a1d1a6ce44670ef55e85d78bb144d20113 Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 30 Jan 2023 12:38:29 +0100 Subject: [PATCH 25/37] refs #5077 changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d00cafc2b..f2b966850 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - (Artículos -> Etiquetas) Permite intercambiar la relevancia entre dos etiquetas. +- (Tickets -> Datos básicos) Permite guardar la hora de envío ## [2302.01] - 2023-01-26 From 331b278726e59558894857a31dd43c9a44b6c02a Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 13:00:25 +0100 Subject: [PATCH 26/37] refs #5131 checkbox pending origin destination --- db/changes/230401/00-ticket_canAdvance.sql | 100 ++++++++++++++++++ .../back/methods/ticket/getTicketsAdvance.js | 16 +-- .../front/advance-search-panel/index.html | 32 +++--- .../front/advance-search-panel/index.js | 15 --- .../front/advance-search-panel/locale/es.yml | 2 + 5 files changed, 122 insertions(+), 43 deletions(-) create mode 100644 db/changes/230401/00-ticket_canAdvance.sql diff --git a/db/changes/230401/00-ticket_canAdvance.sql b/db/changes/230401/00-ticket_canAdvance.sql new file mode 100644 index 000000000..497defebe --- /dev/null +++ b/db/changes/230401/00-ticket_canAdvance.sql @@ -0,0 +1,100 @@ +DROP PROCEDURE IF EXISTS vn.ticket_canAdvance; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) +BEGIN +/** + * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar. + * + * @param vDateFuture Fecha de los tickets que se quieren adelantar. + * @param vDateToAdvance Fecha a cuando se quiere adelantar. + * @param vWarehouseFk Almacén + */ + + DECLARE vDateInventory DATE; + + SELECT inventoried INTO vDateInventory FROM vn.config; + + DROP TEMPORARY TABLE IF EXISTS tmp.stock; + CREATE TEMPORARY TABLE tmp.stock + (itemFk INT PRIMARY KEY, + amount INT) + ENGINE = MEMORY; + + INSERT INTO tmp.stock(itemFk, amount) + SELECT itemFk, SUM(quantity) amount FROM + ( + SELECT itemFk, quantity + FROM vn.itemTicketOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM vn.itemEntryIn + WHERE landed >= vDateInventory + AND landed < vDateFuture + AND isVirtualStock = FALSE + AND warehouseInFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM vn.itemEntryOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseOutFk = vWarehouseFk + ) t + GROUP BY itemFk HAVING amount != 0; + + DROP TEMPORARY TABLE IF EXISTS tmp.filter; + CREATE TEMPORARY TABLE tmp.filter + (INDEX (id)) + SELECT s.ticketFk futureId, + t2.ticketFk id, + sum((s.quantity <= IFNULL(st.amount,0))) hasStock, + count(DISTINCT s.id) saleCount, + t2.state, + t2.isNotValidated, + st.name futureState, + st.isNotValidated futureIsNotValidated, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, + t2.ipt, + t.workerFk, + CAST(sum(litros) AS DECIMAL(10,0)) liters, + CAST(count(*) AS DECIMAL(10,0)) `lines`, + t2.shipped, + t.shipped futureShipped, + t2.totalWithVat, + t.totalWithVat futureTotalWithVat + FROM vn.ticket t + JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN vn.state st ON st.id = ts.stateFk + JOIN vn.saleVolume sv ON t.id = sv.ticketFk + JOIN (SELECT + t2.id ticketFk, + t2.addressFk, + st.isNotValidated, + st.name state, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, + t2.shipped, + t2.totalWithVat + FROM vn.ticket t2 + JOIN vn.sale s ON s.ticketFk = t2.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.ticketState ts ON ts.ticketFk = t2.id + JOIN vn.state st ON st.id = ts.stateFk + LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + WHERE t2.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) + AND t2.warehouseFk = vWarehouseFk + GROUP BY t2.id) t2 ON t2.addressFk = t.addressFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk + WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) + AND t.warehouseFk = vWarehouseFk + GROUP BY t.id; + + DROP TEMPORARY TABLE tmp.stock; +END$$ +DELIMITER ; diff --git a/modules/ticket/back/methods/ticket/getTicketsAdvance.js b/modules/ticket/back/methods/ticket/getTicketsAdvance.js index 19571bb51..a7dea56e2 100644 --- a/modules/ticket/back/methods/ticket/getTicketsAdvance.js +++ b/modules/ticket/back/methods/ticket/getTicketsAdvance.js @@ -50,14 +50,14 @@ module.exports = Self => { required: false }, { - arg: 'state', - type: 'string', + arg: 'isNotValidated', + type: 'boolean', description: 'Origin state', required: false }, { - arg: 'futureState', - type: 'string', + arg: 'futureIsNotValidated', + type: 'boolean', description: 'Destination state', required: false }, @@ -95,10 +95,10 @@ module.exports = Self => { return {'f.ipt': value}; case 'futureIpt': return {'f.futureIpt': value}; - case 'state': - return {'f.stateCode': {like: `%${value}%`}}; - case 'futureState': - return {'f.futureStateCode': {like: `%${value}%`}}; + case 'isNotValidated': + return {'f.isNotValidated': value}; + case 'futureIsNotValidated': + return {'f.futureIsNotValidated': value}; } }); diff --git a/modules/ticket/front/advance-search-panel/index.html b/modules/ticket/front/advance-search-panel/index.html index e8d5dc60d..dfe1f6b08 100644 --- a/modules/ticket/front/advance-search-panel/index.html +++ b/modules/ticket/front/advance-search-panel/index.html @@ -39,26 +39,18 @@ - - - {{name}} - - - - - {{name}} - - + + + + { - for (let state of res.data) { - groupedStates.push({ - id: state.id, - code: state.code, - name: this.$t(state.code) - }); - } - this.groupedStates = groupedStates; - }); - } - getItemPackingTypes() { let itemPackingTypes = []; const filter = { diff --git a/modules/ticket/front/advance-search-panel/locale/es.yml b/modules/ticket/front/advance-search-panel/locale/es.yml index 3dce7dae5..4ea2fc737 100644 --- a/modules/ticket/front/advance-search-panel/locale/es.yml +++ b/modules/ticket/front/advance-search-panel/locale/es.yml @@ -1 +1,3 @@ Advance tickets: Adelantar tickets +Pending Origin: Pendiente origen +Pending Destination: Pendiente destino From e5b7ebd8b4de413b4a73131fb6ebc1f8299df479 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 13:06:58 +0100 Subject: [PATCH 27/37] refs #5131 IPT null or value --- .../back/methods/ticket/getTicketsAdvance.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/getTicketsAdvance.js b/modules/ticket/back/methods/ticket/getTicketsAdvance.js index a7dea56e2..1e1646cba 100644 --- a/modules/ticket/back/methods/ticket/getTicketsAdvance.js +++ b/modules/ticket/back/methods/ticket/getTicketsAdvance.js @@ -92,9 +92,19 @@ module.exports = Self => { case 'futureId': return {'f.futureId': value}; case 'ipt': - return {'f.ipt': value}; + return {or: + [ + {'f.ipt': {like: `%${value}%`}}, + {'f.ipt': null} + ] + }; case 'futureIpt': - return {'f.futureIpt': value}; + return {or: + [ + {'f.futureIpt': {like: `%${value}%`}}, + {'f.futureIpt': null} + ] + }; case 'isNotValidated': return {'f.isNotValidated': value}; case 'futureIsNotValidated': From 87bef62e350544e8c5d83db990540cf85f49f79b Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 13:21:51 +0100 Subject: [PATCH 28/37] refs #5131 hasStock refers to origin --- db/changes/230401/00-ticket_canAdvance.sql | 21 +++++++++++---------- modules/ticket/front/advance/index.html | 8 ++++---- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/db/changes/230401/00-ticket_canAdvance.sql b/db/changes/230401/00-ticket_canAdvance.sql index 497defebe..05200aa57 100644 --- a/db/changes/230401/00-ticket_canAdvance.sql +++ b/db/changes/230401/00-ticket_canAdvance.sql @@ -51,7 +51,6 @@ BEGIN (INDEX (id)) SELECT s.ticketFk futureId, t2.ticketFk id, - sum((s.quantity <= IFNULL(st.amount,0))) hasStock, count(DISTINCT s.id) saleCount, t2.state, t2.isNotValidated, @@ -65,32 +64,34 @@ BEGIN t2.shipped, t.shipped futureShipped, t2.totalWithVat, - t.totalWithVat futureTotalWithVat + t.totalWithVat futureTotalWithVat, + t2.hasStock FROM vn.ticket t JOIN vn.ticketState ts ON ts.ticketFk = t.id JOIN vn.state st ON st.id = ts.stateFk JOIN vn.saleVolume sv ON t.id = sv.ticketFk JOIN (SELECT - t2.id ticketFk, - t2.addressFk, - st.isNotValidated, - st.name state, - GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, - t2.shipped, - t2.totalWithVat + t2.id ticketFk, + t2.addressFk, + st.isNotValidated, + st.name state, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, + t2.shipped, + t2.totalWithVat, + sum((s.quantity <= IFNULL(st.amount,0))) hasStock FROM vn.ticket t2 JOIN vn.sale s ON s.ticketFk = t2.id JOIN vn.item i ON i.id = s.itemFk JOIN vn.ticketState ts ON ts.ticketFk = t2.id JOIN vn.state st ON st.id = ts.stateFk LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk WHERE t2.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) AND t2.warehouseFk = vWarehouseFk GROUP BY t2.id) t2 ON t2.addressFk = t.addressFk JOIN vn.sale s ON s.ticketFk = t.id JOIN vn.item i ON i.id = s.itemFk LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk - LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) AND t.warehouseFk = vWarehouseFk GROUP BY t.id; diff --git a/modules/ticket/front/advance/index.html b/modules/ticket/front/advance/index.html index f63c0fbf7..bd274b7fb 100644 --- a/modules/ticket/front/advance/index.html +++ b/modules/ticket/front/advance/index.html @@ -55,6 +55,9 @@ State + + Stock + Import @@ -73,9 +76,6 @@ Liters - - Stock - Lines @@ -111,6 +111,7 @@ {{::ticket.futureState | dashIfEmpty}} + {{::ticket.hasStock | dashIfEmpty}} {{::(ticket.futureTotalWithVat ? ticket.futureTotalWithVat : 0) | currency: 'EUR': 2}} @@ -136,7 +137,6 @@ {{::ticket.liters | dashIfEmpty}} - {{::ticket.hasStock | dashIfEmpty}} {{::ticket.lines | dashIfEmpty}} From b70557ee868fd7b1cafe21db29d4ede57572f899 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 14:20:08 +0100 Subject: [PATCH 29/37] refs #5131 agencies icon --- db/changes/230401/00-ticket_canAdvance.sql | 7 ++++++- modules/ticket/front/advance/index.html | 15 ++++++++++++--- modules/ticket/front/advance/index.js | 6 ++++++ modules/ticket/front/advance/locale/es.yml | 3 +++ modules/ticket/front/advance/style.scss | 7 +++++++ 5 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 modules/ticket/front/advance/style.scss diff --git a/db/changes/230401/00-ticket_canAdvance.sql b/db/changes/230401/00-ticket_canAdvance.sql index 05200aa57..2072259b1 100644 --- a/db/changes/230401/00-ticket_canAdvance.sql +++ b/db/changes/230401/00-ticket_canAdvance.sql @@ -65,7 +65,9 @@ BEGIN t.shipped futureShipped, t2.totalWithVat, t.totalWithVat futureTotalWithVat, - t2.hasStock + t2.hasStock, + t2.agency, + am.name futureAgency FROM vn.ticket t JOIN vn.ticketState ts ON ts.ticketFk = t.id JOIN vn.state st ON st.id = ts.stateFk @@ -78,12 +80,14 @@ BEGIN GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, t2.shipped, t2.totalWithVat, + am.name agency, sum((s.quantity <= IFNULL(st.amount,0))) hasStock FROM vn.ticket t2 JOIN vn.sale s ON s.ticketFk = t2.id JOIN vn.item i ON i.id = s.itemFk JOIN vn.ticketState ts ON ts.ticketFk = t2.id JOIN vn.state st ON st.id = ts.stateFk + JOIN vn.agencyMode am ON t2.agencyModeFk = am.id LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk WHERE t2.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) @@ -91,6 +95,7 @@ BEGIN GROUP BY t2.id) t2 ON t2.addressFk = t.addressFk JOIN vn.sale s ON s.ticketFk = t.id JOIN vn.item i ON i.id = s.itemFk + JOIN vn.agencyMode am ON t.agencyModeFk = am.id LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) AND t.warehouseFk = vWarehouseFk diff --git a/modules/ticket/front/advance/index.html b/modules/ticket/front/advance/index.html index bd274b7fb..d82d8cc50 100644 --- a/modules/ticket/front/advance/index.html +++ b/modules/ticket/front/advance/index.html @@ -32,7 +32,7 @@ - Origin + Origin Destination @@ -43,13 +43,15 @@ check-field="checked"> + + ID Date - + IPT @@ -67,7 +69,7 @@ Date - + IPT @@ -92,6 +94,13 @@ vn-click-stop> + + + + ' + this.$t(`Destination agency`, {agency: agency}); + } + moveTicketsAdvance() { let ticketsToMove = []; this.checked.forEach(ticket => { diff --git a/modules/ticket/front/advance/locale/es.yml b/modules/ticket/front/advance/locale/es.yml index b444fbdd3..da22cd433 100644 --- a/modules/ticket/front/advance/locale/es.yml +++ b/modules/ticket/front/advance/locale/es.yml @@ -4,3 +4,6 @@ Advance confirmation: ¿Desea adelantar {{checked}} tickets? Success: Tickets movidos correctamente Lines: Líneas Liters: Litros +Item Packing Type: Encajado +Origin agency: "Agencia origen: {{agency}}" +Destination agency: "Agencia destino: {{agency}}" diff --git a/modules/ticket/front/advance/style.scss b/modules/ticket/front/advance/style.scss new file mode 100644 index 000000000..8fa9de438 --- /dev/null +++ b/modules/ticket/front/advance/style.scss @@ -0,0 +1,7 @@ +@import "variables"; + +vn-ticket-advance{ + vn-icon { + color: #f7931e + } +} From 19d7e7e6102a97b849501d5c199e49e93309ea6a Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 14:23:40 +0100 Subject: [PATCH 30/37] refs #5131 totalWithVat order --- modules/ticket/front/advance/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ticket/front/advance/index.html b/modules/ticket/front/advance/index.html index d82d8cc50..9f271b498 100644 --- a/modules/ticket/front/advance/index.html +++ b/modules/ticket/front/advance/index.html @@ -60,7 +60,7 @@ Stock - + Import @@ -81,7 +81,7 @@ Lines - + Import From 3622eda589eaadd9fc6a5216c4fa00bbd4c48436 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 15:09:16 +0100 Subject: [PATCH 31/37] refs #5131 added lines liters to origin ticket --- db/changes/230401/00-ticket_canAdvance.sql | 18 +++++++++++------- modules/ticket/front/advance/index.html | 12 ++++++++++-- modules/ticket/front/advance/index.js | 4 ++++ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/db/changes/230401/00-ticket_canAdvance.sql b/db/changes/230401/00-ticket_canAdvance.sql index 2072259b1..fd9d451bf 100644 --- a/db/changes/230401/00-ticket_canAdvance.sql +++ b/db/changes/230401/00-ticket_canAdvance.sql @@ -59,15 +59,17 @@ BEGIN GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, t2.ipt, t.workerFk, - CAST(sum(litros) AS DECIMAL(10,0)) liters, - CAST(count(*) AS DECIMAL(10,0)) `lines`, + CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, + CAST(COUNT(*) AS DECIMAL(10,0)) `futureLines`, t2.shipped, t.shipped futureShipped, t2.totalWithVat, t.totalWithVat futureTotalWithVat, - t2.hasStock, t2.agency, - am.name futureAgency + am.name futureAgency, + t2.lines, + t2.liters, + SUM((s.quantity <= IFNULL(st.amount,0))) hasStock FROM vn.ticket t JOIN vn.ticketState ts ON ts.ticketFk = t.id JOIN vn.state st ON st.id = ts.stateFk @@ -77,19 +79,20 @@ BEGIN t2.addressFk, st.isNotValidated, st.name state, - GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, t2.shipped, t2.totalWithVat, am.name agency, - sum((s.quantity <= IFNULL(st.amount,0))) hasStock + CAST(SUM(litros) AS DECIMAL(10,0)) liters, + CAST(COUNT(*) AS DECIMAL(10,0)) `lines` FROM vn.ticket t2 + JOIN vn.saleVolume sv ON t2.id = sv.ticketFk JOIN vn.sale s ON s.ticketFk = t2.id JOIN vn.item i ON i.id = s.itemFk JOIN vn.ticketState ts ON ts.ticketFk = t2.id JOIN vn.state st ON st.id = ts.stateFk JOIN vn.agencyMode am ON t2.agencyModeFk = am.id LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk - LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk WHERE t2.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) AND t2.warehouseFk = vWarehouseFk GROUP BY t2.id) t2 ON t2.addressFk = t.addressFk @@ -97,6 +100,7 @@ BEGIN JOIN vn.item i ON i.id = s.itemFk JOIN vn.agencyMode am ON t.agencyModeFk = am.id LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) AND t.warehouseFk = vWarehouseFk GROUP BY t.id; diff --git a/modules/ticket/front/advance/index.html b/modules/ticket/front/advance/index.html index 9f271b498..3dd52b909 100644 --- a/modules/ticket/front/advance/index.html +++ b/modules/ticket/front/advance/index.html @@ -32,8 +32,8 @@ - Origin - Destination + Origin + Destination @@ -57,9 +57,15 @@ State + + Liters + Stock + + Lines + Import @@ -120,7 +126,9 @@ {{::ticket.futureState | dashIfEmpty}} + {{::ticket.futureLiters | dashIfEmpty}} {{::ticket.hasStock | dashIfEmpty}} + {{::ticket.futureLines | dashIfEmpty}} {{::(ticket.futureTotalWithVat ? ticket.futureTotalWithVat : 0) | currency: 'EUR': 2}} diff --git a/modules/ticket/front/advance/index.js b/modules/ticket/front/advance/index.js index ae299b00c..a29d2db97 100644 --- a/modules/ticket/front/advance/index.js +++ b/modules/ticket/front/advance/index.js @@ -163,6 +163,10 @@ export default class Controller extends Section { return {'liters': value}; case 'lines': return {'lines': value}; + case 'futureLiters': + return {'futureLiters': value}; + case 'futureLines': + return {'futureLines': value}; case 'ipt': return {'ipt': value}; case 'futureIpt': From 349829e5ed51a9a8eff91b5754fdda2bfa24f89f Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 15:29:00 +0100 Subject: [PATCH 32/37] refs #5131 fixed tests --- e2e/helpers/selectors.js | 4 +- e2e/paths/05-ticket/22_advance.spec.js | 61 ++++++------------- .../ticket/specs/getTicketsAdvance.spec.js | 14 ++--- 3 files changed, 27 insertions(+), 52 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index a1412f431..347396c94 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -778,8 +778,8 @@ export default { ipt: 'vn-autocomplete[label="Destination IPT"]', tableIpt: 'vn-autocomplete[name="ipt"]', tableFutureIpt: 'vn-autocomplete[name="futureIpt"]', - futureState: 'vn-autocomplete[label="Origin Grouped State"]', - state: 'vn-autocomplete[label="Destination Grouped State"]', + futureState: 'vn-check[label="Pending Origin"]', + state: 'vn-check[label="Pending Destination"]', warehouseFk: 'vn-autocomplete[label="Warehouse"]', tableButtonSearch: 'vn-button[vn-tooltip="Search"]', moveButton: 'vn-button[vn-tooltip="Advance tickets"]', diff --git a/e2e/paths/05-ticket/22_advance.spec.js b/e2e/paths/05-ticket/22_advance.spec.js index 6aaa81591..3a6234fe9 100644 --- a/e2e/paths/05-ticket/22_advance.spec.js +++ b/e2e/paths/05-ticket/22_advance.spec.js @@ -50,7 +50,7 @@ describe('Ticket Advance path', () => { await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); await page.autocompleteSearch(selectors.ticketAdvance.ipt, 'Horizontal'); await page.waitToClick(selectors.ticketAdvance.submit); - await page.waitForNumberOfElements(selectors.ticketAdvance.table, 0); + await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); await page.clearInput(selectors.ticketAdvance.ipt); @@ -62,7 +62,7 @@ describe('Ticket Advance path', () => { await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); await page.autocompleteSearch(selectors.ticketAdvance.futureIpt, 'Horizontal'); await page.waitToClick(selectors.ticketAdvance.submit); - await page.waitForNumberOfElements(selectors.ticketAdvance.table, 0); + await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); await page.clearInput(selectors.ticketAdvance.futureIpt); @@ -70,26 +70,36 @@ describe('Ticket Advance path', () => { await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); }); - it('should search with the origin grouped state', async() => { + it('should search with the origin pending state', async() => { await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.autocompleteSearch(selectors.ticketAdvance.futureState, 'Free'); + await page.waitToClick(selectors.ticketAdvance.futureState); await page.waitToClick(selectors.ticketAdvance.submit); await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.clearInput(selectors.ticketAdvance.futureState); + await page.waitToClick(selectors.ticketAdvance.futureState); + await page.waitToClick(selectors.ticketAdvance.submit); + await page.waitForNumberOfElements(selectors.ticketAdvance.table, 0); + + await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); + await page.waitToClick(selectors.ticketAdvance.futureState); await page.waitToClick(selectors.ticketAdvance.submit); await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); }); it('should search with the destination grouped state', async() => { await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.autocompleteSearch(selectors.ticketAdvance.state, 'Free'); + await page.waitToClick(selectors.ticketAdvance.state); await page.waitToClick(selectors.ticketAdvance.submit); await page.waitForNumberOfElements(selectors.ticketAdvance.table, 0); await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.clearInput(selectors.ticketAdvance.state); + await page.waitToClick(selectors.ticketAdvance.state); + await page.waitToClick(selectors.ticketAdvance.submit); + await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); + + await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); + await page.waitToClick(selectors.ticketAdvance.state); await page.waitToClick(selectors.ticketAdvance.submit); await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); }); @@ -116,42 +126,7 @@ describe('Ticket Advance path', () => { await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); }); - it('should search in smart-table with stock', async() => { - await page.waitToClick(selectors.ticketAdvance.tableButtonSearch); - await page.write(selectors.ticketAdvance.tableStock, '5'); - await page.waitForNumberOfElements(selectors.ticketAdvance.table, 2); - - await page.waitToClick(selectors.ticketAdvance.tableButtonSearch); - await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.waitToClick(selectors.ticketAdvance.submit); - await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); - }); - - it('should search in smart-table with especified Lines', async() => { - await page.waitToClick(selectors.ticketAdvance.tableButtonSearch); - await page.write(selectors.ticketAdvance.tableLines, '0'); - await page.keyboard.press('Enter'); - await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); - - await page.waitToClick(selectors.ticketAdvance.tableButtonSearch); - await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.waitToClick(selectors.ticketAdvance.submit); - await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); - }); - - it('should search in smart-table with especified Liters', async() => { - await page.waitToClick(selectors.ticketAdvance.tableButtonSearch); - await page.write(selectors.ticketAdvance.tableLiters, '0'); - await page.keyboard.press('Enter'); - await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); - - await page.waitToClick(selectors.ticketAdvance.tableButtonSearch); - await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.waitToClick(selectors.ticketAdvance.submit); - await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); - }); - - it('should check the three last tickets and move to the future', async() => { + it('should check the one ticket and move to the present', async() => { await page.waitToClick(selectors.ticketAdvance.multiCheck); await page.waitToClick(selectors.ticketAdvance.moveButton); await page.waitToClick(selectors.ticketAdvance.acceptButton); diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js index aab053127..7d3bc174d 100644 --- a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js @@ -29,7 +29,7 @@ describe('TicketFuture getTicketsAdvance()', () => { } }); - it('should return the tickets matching the origin grouped state', async() => { + it('should return the tickets matching the origin pending state', async() => { const tx = await models.Ticket.beginTransaction({}); try { @@ -39,7 +39,7 @@ describe('TicketFuture getTicketsAdvance()', () => { dateFuture: tomorrow, dateToAdvance: today, warehouseFk: 1, - state: 'OK' + futureIsNotValidated: true }; const ctx = {req: {accessToken: {userId: 9}}, args}; @@ -54,7 +54,7 @@ describe('TicketFuture getTicketsAdvance()', () => { } }); - it('should return the tickets matching the destination grouped state', async() => { + it('should return the tickets matching the destination pending state', async() => { const tx = await models.Ticket.beginTransaction({}); try { @@ -64,13 +64,13 @@ describe('TicketFuture getTicketsAdvance()', () => { dateFuture: tomorrow, dateToAdvance: today, warehouseFk: 1, - futureState: 'FREE' + isNotValidated: true }; const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsAdvance(ctx, options); - expect(result.length).toBeGreaterThan(0); + expect(result.length).toEqual(0); await tx.rollback(); } catch (e) { @@ -89,7 +89,7 @@ describe('TicketFuture getTicketsAdvance()', () => { dateFuture: tomorrow, dateToAdvance: today, warehouseFk: 1, - ipt: 'Vertical' + ipt: 'V' }; const ctx = {req: {accessToken: {userId: 9}}, args}; @@ -114,7 +114,7 @@ describe('TicketFuture getTicketsAdvance()', () => { dateFuture: tomorrow, dateToAdvance: today, warehouseFk: 1, - tfIpt: 'Vertical' + tfIpt: 'V' }; const ctx = {req: {accessToken: {userId: 9}}, args}; From a3da71996ac56793e24fed3762d596f434dcb531 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 15:36:51 +0100 Subject: [PATCH 33/37] refs #5131 changelog --- CHANGELOG.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22efa1b28..d103f3194 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,14 +9,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - (Rutas) Al descargar varias facturas se comprime en un zip -- (Trabajadores -> Nuevo trabajador) Nueva sección +- (Trabajadores -> Nuevo trabajador) Nueva sección +- (Tickets -> Adelantar tickets) Añadidos campos "líneas" y "litros" al ticket origen +- (Tickets -> Adelantar tickets) Nuevo icono muestra cuando las agencias de los tickets origen/destino son distintas ### Changed -- +- (Tickets -> Adelantar tickets) Cambiados selectores de estado por checks "Pendiente origen/destino" +- (Tickets -> Adelantar tickets) Cambiado stock de destino a origen. ### Fixed - (Artículos -> Etiquetas) Permite intercambiar la relevancia entre dos etiquetas. - (Tickets -> Añadir pago) Eliminado "null" en las referencias +- (Tickets -> Adelantar tickets) Permite ordenar por importe +- (Tickets -> Adelantar tickets) El filtrado por encajado muestra también los tickets sin tipo de encajado ## [2302.01] - 2023-01-26 From 650cc68f4a789e427cecb1a87941e915e581823b Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Wed, 1 Feb 2023 08:42:20 +0100 Subject: [PATCH 34/37] requested changes --- db/changes/230401/00-alter_notSubs.sql | 4 ++-- .../00-uniqueKeyNotificationSubscription.sql | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename db/changes/{230201 => 230401}/00-uniqueKeyNotificationSubscription.sql (100%) diff --git a/db/changes/230401/00-alter_notSubs.sql b/db/changes/230401/00-alter_notSubs.sql index a4177bba4..992675837 100644 --- a/db/changes/230401/00-alter_notSubs.sql +++ b/db/changes/230401/00-alter_notSubs.sql @@ -1,4 +1,4 @@ ALTER TABLE util.notificationSubscription -ADD Id int(11) auto_increment NULL, +ADD id int(11) auto_increment NULL, DROP PRIMARY KEY, -ADD CONSTRAINT PRIMARY KEY (Id); +ADD CONSTRAINT PRIMARY KEY (id); diff --git a/db/changes/230201/00-uniqueKeyNotificationSubscription.sql b/db/changes/230401/00-uniqueKeyNotificationSubscription.sql similarity index 100% rename from db/changes/230201/00-uniqueKeyNotificationSubscription.sql rename to db/changes/230401/00-uniqueKeyNotificationSubscription.sql From 56f7794d87f632152bc1a6547efa21b2f6519cbb Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 1 Feb 2023 08:48:47 +0100 Subject: [PATCH 35/37] typo --- db/changes/230401/00-alter_notSubs.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/changes/230401/00-alter_notSubs.sql b/db/changes/230401/00-alter_notSubs.sql index 992675837..9cbfcbb3c 100644 --- a/db/changes/230401/00-alter_notSubs.sql +++ b/db/changes/230401/00-alter_notSubs.sql @@ -1,4 +1,4 @@ -ALTER TABLE util.notificationSubscription -ADD id int(11) auto_increment NULL, -DROP PRIMARY KEY, -ADD CONSTRAINT PRIMARY KEY (id); +ALTER TABLE `util`.`notificationSubscription` +ADD `id` int(11) auto_increment NULL, +DROP PRIMARY KEY, +ADD CONSTRAINT PRIMARY KEY (`id`); From 39d4b538723fcd698b209d87b8cece3212ddad6c Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 1 Feb 2023 09:00:49 +0100 Subject: [PATCH 36/37] fix: sql fail in real structure... --- .../230401/{00-alter_notSubs.sql => 01-alter_notSubs.sql} | 3 +++ db/dump/structure.sql | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) rename db/changes/230401/{00-alter_notSubs.sql => 01-alter_notSubs.sql} (55%) diff --git a/db/changes/230401/00-alter_notSubs.sql b/db/changes/230401/01-alter_notSubs.sql similarity index 55% rename from db/changes/230401/00-alter_notSubs.sql rename to db/changes/230401/01-alter_notSubs.sql index 9cbfcbb3c..07ea7c2bf 100644 --- a/db/changes/230401/00-alter_notSubs.sql +++ b/db/changes/230401/01-alter_notSubs.sql @@ -2,3 +2,6 @@ ALTER TABLE `util`.`notificationSubscription` ADD `id` int(11) auto_increment NULL, DROP PRIMARY KEY, ADD CONSTRAINT PRIMARY KEY (`id`); + +ALTER TABLE `util`.`notificationSubscription` +ADD KEY `notificationSubscription_ibfk_1` (`notificationFk`); diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 831296bc6..772d6055d 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -19729,7 +19729,6 @@ CREATE TABLE `notificationSubscription` ( `notificationFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, PRIMARY KEY (`notificationFk`,`userFk`), - KEY `notificationSubscription_ibfk_1` (`notificationFk`), KEY `notificationSubscription_ibfk_2` (`userFk`), CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `notification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `notificationSubscription_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE From 4d8af54b1ee8cae5e67fe41838a86bfc95b0d9d8 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 2 Feb 2023 09:21:12 +0100 Subject: [PATCH 37/37] Added version 23.06.01 --- CHANGELOG.md | 11 +++++++++++ db/changes/230601/.gitkeep | 0 package.json | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 db/changes/230601/.gitkeep diff --git a/CHANGELOG.md b/CHANGELOG.md index bf8cfd17c..91ce818a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2306.01] - 2023-02-23 + +### Added +- + +### Changed +- + +### Fixed +- + ## [2304.01] - 2023-02-09 ### Added diff --git a/db/changes/230601/.gitkeep b/db/changes/230601/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/package.json b/package.json index 46b7d4ffc..f9828624d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "23.04.01", + "version": "23.06.01", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0",