From 7895decf4eea09243c552d6cd94ad3d9d7ffae78 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 19 Jul 2022 15:17:22 +0200 Subject: [PATCH 01/93] feat(notification): create models --- back/methods/notification/clean.js | 0 back/methods/notification/send.js | 18 ++++++ back/models/notifcation.json | 22 +++++++ back/models/notifcationAcl.json | 21 +++++++ back/models/notifcationConfig.json | 19 ++++++ back/models/notifcationQueue.json | 37 ++++++++++++ back/models/notification.js | 4 ++ back/models/notificationSubscription.json | 21 +++++++ db/dump/fixtures.sql | 5 +- db/dump/structure.sql | 71 ++++++++++++++++++++++- 10 files changed, 214 insertions(+), 4 deletions(-) create mode 100644 back/methods/notification/clean.js create mode 100644 back/methods/notification/send.js create mode 100644 back/models/notifcation.json create mode 100644 back/models/notifcationAcl.json create mode 100644 back/models/notifcationConfig.json create mode 100644 back/models/notifcationQueue.json create mode 100644 back/models/notification.js create mode 100644 back/models/notificationSubscription.json diff --git a/back/methods/notification/clean.js b/back/methods/notification/clean.js new file mode 100644 index 000000000..e69de29bb diff --git a/back/methods/notification/send.js b/back/methods/notification/send.js new file mode 100644 index 000000000..bb2d79f2a --- /dev/null +++ b/back/methods/notification/send.js @@ -0,0 +1,18 @@ +module.exports = Self => { + Self.remoteMethod('send', { + description: 'Send notifications from queue', + accessType: 'WRITE', + returns: { + type: 'object', + root: true + }, + http: { + path: `/send`, + verb: 'POST' + } + }); + + Self.send = async() => { + + }; +}; diff --git a/back/models/notifcation.json b/back/models/notifcation.json new file mode 100644 index 000000000..e4f0be17e --- /dev/null +++ b/back/models/notifcation.json @@ -0,0 +1,22 @@ +{ + "name": "Notificacion", + "base": "VnModel", + "options": { + "mysql": { + "table": "notificacion" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/back/models/notifcationAcl.json b/back/models/notifcationAcl.json new file mode 100644 index 000000000..f5861943f --- /dev/null +++ b/back/models/notifcationAcl.json @@ -0,0 +1,21 @@ +{ + "name": "NotificacionAcl", + "base": "VnModel", + "options": { + "mysql": { + "table": "notificacionAcl" + } + }, + "relations": { + "notificacion": { + "type": "belongsTo", + "model": "Notificacion", + "foreignKey": "notificacionFk" + }, + "role": { + "type": "belongsTo", + "model": "Role", + "foreignKey": "roleFk" + } + } +} \ No newline at end of file diff --git a/back/models/notifcationConfig.json b/back/models/notifcationConfig.json new file mode 100644 index 000000000..73882b6b7 --- /dev/null +++ b/back/models/notifcationConfig.json @@ -0,0 +1,19 @@ +{ + "name": "NotificationConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "notificationConfig" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "cleanDays": { + "type": "number" + } + } +} \ No newline at end of file diff --git a/back/models/notifcationQueue.json b/back/models/notifcationQueue.json new file mode 100644 index 000000000..7a9199bc0 --- /dev/null +++ b/back/models/notifcationQueue.json @@ -0,0 +1,37 @@ +{ + "name": "NotificacionQueue", + "base": "VnModel", + "options": { + "mysql": { + "table": "notificacionQueue" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "params": { + "type": "string" + }, + "status": { + "type": "string" + }, + "created": { + "type": "date" + } + }, + "relations": { + "notificacion": { + "type": "belongsTo", + "model": "Notificacion", + "foreignKey": "notificacionFk" + }, + "author": { + "type": "belongsTo", + "model": "User", + "foreignKey": "authorFk" + } + } +} \ No newline at end of file diff --git a/back/models/notification.js b/back/models/notification.js new file mode 100644 index 000000000..da766d442 --- /dev/null +++ b/back/models/notification.js @@ -0,0 +1,4 @@ +module.exports = Self => { + require('../methods/notification/send')(Self); + require('../methods/notification/clear')(Self); +}; diff --git a/back/models/notificationSubscription.json b/back/models/notificationSubscription.json new file mode 100644 index 000000000..ed8bb1907 --- /dev/null +++ b/back/models/notificationSubscription.json @@ -0,0 +1,21 @@ +{ + "name": "NotificationSubscription", + "base": "VnModel", + "options": { + "mysql": { + "table": "notificationSubscription" + } + }, + "relations": { + "notificacion": { + "type": "belongsTo", + "model": "Notificacion", + "foreignKey": "notificacionFk" + }, + "user": { + "type": "belongsTo", + "model": "User", + "foreignKey": "userFk" + } + } +} \ No newline at end of file diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 0609a6a6a..dabc73139 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2610,4 +2610,7 @@ INSERT INTO `vn`.`sectorCollectionSaleGroup` (`sectorCollectionFk`, `saleGroupFk INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`) VALUES - (1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13); \ No newline at end of file + (1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13); + +INSERT INTO `util`.`notificationConfig` + SET `cleanDays` = 90; \ No newline at end of file diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 2c0e8231a..923855762 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -20849,9 +20849,74 @@ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `util` /*!40100 DEFAULT CHARACTER SET u USE `util`; --- --- Table structure for table `config` --- +CREATE TABLE notification( + id INT PRIMARY KEY, + `name` VARCHAR(255) UNIQUE, + `description` VARCHAR(255) +); + +CREATE TABLE notificationAcl ( + notificationFk INT(11), + roleFk INT(10) unsigned, + PRIMARY KEY(notificationFk, roleFk), + CONSTRAINT `notificationAcl_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `notification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `notificationAcl_ibfk_2` FOREIGN KEY (`roleFk`) REFERENCES `account`.`role` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE TABLE notificationSubscription( + notificationFk INT, + userFk INT(10) unsigned, + PRIMARY KEY(notificationFk, 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 +); + +CREATE TABLE notificationQueue( + id INT PRIMARY KEY AUTO_INCREMENT, + notificationFk VARCHAR(255), + params TEXT, + authorFk INT(10) unsigned NULL, + `status` ENUM('pending', 'sent', 'error') NOT NULL DEFAULT 'pending', + created DATETIME DEFAULT CURRENT_TIMESTAMP, + INDEX(notificationFk), + INDEX(authorFk), + INDEX(status), + CONSTRAINT `notificationQueue_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `notification` (`name`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `notificationQueue_ibfk_2` FOREIGN KEY (`authorFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE TABLE notificationConfig( + id INT PRIMARY KEY AUTO_INCREMENT, + cleanDays MEDIUMINT +); + +DROP FUNCTION IF EXISTS util.notification_send; +DELIMITER $$ +CREATE FUNCTION util.notification_send(vNotificationName VARCHAR(255), vParams TEXT, vAuthorFk INT) + RETURNS INT +BEGIN +/** + * Sends a notification. + * + * @param vNotificationName The notification name + * @param vParams The notification parameters formatted as JSON + * @param vAuthorFk The notification author or %NULL if there is no author + * @return The notification id + */ + DECLARE vNotificationFk INT; + + SELECT id INTO vNotificationFk + FROM `notification` + WHERE `name` = vNotificationName; + + INSERT INTO notificationQueue + SET notificationFk = vNotificationFk, + params = vParams, + authorFk = vAuthorFk; + + RETURN LAST_INSERT_ID(); +END$$ +DELIMITER ; DROP TABLE IF EXISTS `config`; /*!40101 SET @saved_cs_client = @@character_set_client */; From 9b48cbb07866be87502d33cee7d6648243606a0d Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 20 Jul 2022 14:54:50 +0200 Subject: [PATCH 02/93] feat(notification): send --- back/methods/notification/send.js | 19 ++++++++++++++++++- back/model-config.json | 15 +++++++++++++++ back/models/notification.js | 1 - .../{notifcation.json => notification.json} | 4 ++-- ...tifcationAcl.json => notificationAcl.json} | 10 +++++----- ...ionConfig.json => notificationConfig.json} | 2 +- ...ationQueue.json => notificationQueue.json} | 10 +++++----- back/models/notificationSubscription.json | 8 ++++---- .../10490-goldenSummer/00-aclNotification.sql | 3 +++ db/dump/fixtures.sql | 18 +++++++++++++++++- 10 files changed, 70 insertions(+), 20 deletions(-) rename back/models/{notifcation.json => notification.json} (84%) rename back/models/{notifcationAcl.json => notificationAcl.json} (59%) rename back/models/{notifcationConfig.json => notificationConfig.json} (88%) rename back/models/{notifcationQueue.json => notificationQueue.json} (76%) create mode 100644 db/changes/10490-goldenSummer/00-aclNotification.sql diff --git a/back/methods/notification/send.js b/back/methods/notification/send.js index bb2d79f2a..d5149fc59 100644 --- a/back/methods/notification/send.js +++ b/back/methods/notification/send.js @@ -1,7 +1,7 @@ module.exports = Self => { Self.remoteMethod('send', { description: 'Send notifications from queue', - accessType: 'WRITE', + accessType: 'READ', returns: { type: 'object', root: true @@ -13,6 +13,23 @@ module.exports = Self => { }); Self.send = async() => { + const status = 'pending'; + const myOptions = {}; + let tx; + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + const notificationQueue = await Self.app.models.NotificationQueue.find({ + where: {code: status}, + include: [{ + relation: 'notificationSubscription' + }] + }, myOptions); + + console.log(notificationQueue); }; }; diff --git a/back/model-config.json b/back/model-config.json index 343210383..755f449de 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -77,6 +77,21 @@ "Module": { "dataSource": "vn" }, + "Notification": { + "dataSource": "vn" + }, + "NotificationAcl": { + "dataSource": "vn" + }, + "NotificationConfig": { + "dataSource": "vn" + }, + "NotificationQueue": { + "dataSource": "vn" + }, + "NotificationSubscription": { + "dataSource": "vn" + }, "Province": { "dataSource": "vn" }, diff --git a/back/models/notification.js b/back/models/notification.js index da766d442..46378bd02 100644 --- a/back/models/notification.js +++ b/back/models/notification.js @@ -1,4 +1,3 @@ module.exports = Self => { require('../methods/notification/send')(Self); - require('../methods/notification/clear')(Self); }; diff --git a/back/models/notifcation.json b/back/models/notification.json similarity index 84% rename from back/models/notifcation.json rename to back/models/notification.json index e4f0be17e..9422d03b3 100644 --- a/back/models/notifcation.json +++ b/back/models/notification.json @@ -1,9 +1,9 @@ { - "name": "Notificacion", + "name": "Notification", "base": "VnModel", "options": { "mysql": { - "table": "notificacion" + "table": "util.notification" } }, "properties": { diff --git a/back/models/notifcationAcl.json b/back/models/notificationAcl.json similarity index 59% rename from back/models/notifcationAcl.json rename to back/models/notificationAcl.json index f5861943f..e3e97f52d 100644 --- a/back/models/notifcationAcl.json +++ b/back/models/notificationAcl.json @@ -1,16 +1,16 @@ { - "name": "NotificacionAcl", + "name": "NotificationAcl", "base": "VnModel", "options": { "mysql": { - "table": "notificacionAcl" + "table": "util.notificationAcl" } }, "relations": { - "notificacion": { + "notification": { "type": "belongsTo", - "model": "Notificacion", - "foreignKey": "notificacionFk" + "model": "Notification", + "foreignKey": "notificationFk" }, "role": { "type": "belongsTo", diff --git a/back/models/notifcationConfig.json b/back/models/notificationConfig.json similarity index 88% rename from back/models/notifcationConfig.json rename to back/models/notificationConfig.json index 73882b6b7..b00ed3675 100644 --- a/back/models/notifcationConfig.json +++ b/back/models/notificationConfig.json @@ -3,7 +3,7 @@ "base": "VnModel", "options": { "mysql": { - "table": "notificationConfig" + "table": "util.notificationConfig" } }, "properties": { diff --git a/back/models/notifcationQueue.json b/back/models/notificationQueue.json similarity index 76% rename from back/models/notifcationQueue.json rename to back/models/notificationQueue.json index 7a9199bc0..122d3816d 100644 --- a/back/models/notifcationQueue.json +++ b/back/models/notificationQueue.json @@ -1,9 +1,9 @@ { - "name": "NotificacionQueue", + "name": "NotificationQueue", "base": "VnModel", "options": { "mysql": { - "table": "notificacionQueue" + "table": "util.notificationQueue" } }, "properties": { @@ -23,10 +23,10 @@ } }, "relations": { - "notificacion": { + "notification": { "type": "belongsTo", - "model": "Notificacion", - "foreignKey": "notificacionFk" + "model": "Notification", + "foreignKey": "notificationFk" }, "author": { "type": "belongsTo", diff --git a/back/models/notificationSubscription.json b/back/models/notificationSubscription.json index ed8bb1907..14b305ca8 100644 --- a/back/models/notificationSubscription.json +++ b/back/models/notificationSubscription.json @@ -3,14 +3,14 @@ "base": "VnModel", "options": { "mysql": { - "table": "notificationSubscription" + "table": "util.notificationSubscription" } }, "relations": { - "notificacion": { + "notification": { "type": "belongsTo", - "model": "Notificacion", - "foreignKey": "notificacionFk" + "model": "Notification", + "foreignKey": "notificationFk" }, "user": { "type": "belongsTo", diff --git a/db/changes/10490-goldenSummer/00-aclNotification.sql b/db/changes/10490-goldenSummer/00-aclNotification.sql new file mode 100644 index 000000000..aa4e32cee --- /dev/null +++ b/db/changes/10490-goldenSummer/00-aclNotification.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('Notification', '*', 'READ', 'ALLOW', 'ROLE', 'developer'); diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index dabc73139..f73210a96 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2613,4 +2613,20 @@ INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, (1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13); INSERT INTO `util`.`notificationConfig` - SET `cleanDays` = 90; \ No newline at end of file + SET `cleanDays` = 90; + +INSERT INTO `util`.`notification` (`id`, `name`, `description`) + VALUES + (1, 'notification one', 'notification fixture one'); + +INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) + VALUES + (1, 9); + +INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`) + VALUES + (1, 'notification one', 'randomParams', 9, 'pending', util.VN_CURDATE()); + +INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) + VALUES + (1, 1110); \ No newline at end of file From 8048d4ce90d22d08ffa8e24bd8671f5497baee8d Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 25 Jul 2022 08:25:10 +0200 Subject: [PATCH 03/93] feat(notification): basic functionality and test --- back/methods/notification/clean.js | 46 ++++++++++++++ back/methods/notification/send.js | 63 ++++++++++++++++--- back/methods/notification/specs/clean.spec.js | 42 +++++++++++++ back/methods/notification/specs/send.spec.js | 33 ++++++++++ back/models/notification.js | 1 + back/models/notification.json | 10 ++- back/models/notificationQueue.json | 5 +- back/models/notificationSubscription.json | 14 ++++- .../10490-goldenSummer/00-aclNotification.sql | 2 +- db/dump/fixtures.sql | 4 +- 10 files changed, 205 insertions(+), 15 deletions(-) create mode 100644 back/methods/notification/specs/clean.spec.js create mode 100644 back/methods/notification/specs/send.spec.js diff --git a/back/methods/notification/clean.js b/back/methods/notification/clean.js index e69de29bb..e6da58af8 100644 --- a/back/methods/notification/clean.js +++ b/back/methods/notification/clean.js @@ -0,0 +1,46 @@ +module.exports = Self => { + Self.remoteMethod('clean', { + description: 'clean notifications from queue', + accessType: 'WRITE', + returns: { + type: 'object', + root: true + }, + http: { + path: `/clean`, + verb: 'POST' + } + }); + + Self.clean = async options => { + const models = Self.app.models; + const status = ['sent', 'error']; + + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const config = await models.NotificationConfig.findOne({}, myOptions); + const cleanDate = new Date(); + cleanDate.setDate(cleanDate.getDate() - config.cleanDays); + + await models.NotificationQueue.destroyAll({ + where: {status: {inq: status}}, + created: {lt: cleanDate} + }, myOptions); + + if (tx) await tx.commit(); + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/back/methods/notification/send.js b/back/methods/notification/send.js index d5149fc59..b56d9d6c0 100644 --- a/back/methods/notification/send.js +++ b/back/methods/notification/send.js @@ -1,7 +1,9 @@ +const axios = require('axios'); + module.exports = Self => { Self.remoteMethod('send', { description: 'Send notifications from queue', - accessType: 'READ', + accessType: 'WRITE', returns: { type: 'object', root: true @@ -12,24 +14,69 @@ module.exports = Self => { } }); - Self.send = async() => { + Self.send = async options => { + // const headers = ctx.req.headers; + // const origin = headers.origin || 'http://' + headers.host; + // const auth = ctx.req.accessToken; + // console.log(origin); + + const models = Self.app.models; const status = 'pending'; const myOptions = {}; let tx; + if (typeof options == 'object') + Object.assign(myOptions, options); + if (!myOptions.transaction) { tx = await Self.beginTransaction({}); myOptions.transaction = tx; } - const notificationQueue = await Self.app.models.NotificationQueue.find({ - where: {code: status}, - include: [{ - relation: 'notificationSubscription' - }] + const notificationQueue = await models.NotificationQueue.find({ + where: {status: status}, + include: [ + { + relation: 'notification', + scope: { + include: { + relation: 'subscription', + scope: { + include: { + relation: 'user', + scope: { + fields: ['name'] + } + } + } + } + } + + } + ] }, myOptions); - console.log(notificationQueue); + const statusSent = 'sent'; + const statusError = 'error'; + for (const queue of notificationQueue) { + // console.log(queue); + // console.log(origin); + // console.log(auth); + // console.log(queue.notification().name); + // console.log(queue.params); + + // const queueParams = Object.assign({}, JSON.parse(queue.params)); + // queueParams.authorization = auth.id; + + try { + // await print axios.get(`print`, queueParams) + await queue.updateAttribute('status', statusSent); + } catch (error) { + await queue.updateAttribute('status', statusError); + } + } + + return notificationQueue; }; }; diff --git a/back/methods/notification/specs/clean.spec.js b/back/methods/notification/specs/clean.spec.js new file mode 100644 index 000000000..c9441a98b --- /dev/null +++ b/back/methods/notification/specs/clean.spec.js @@ -0,0 +1,42 @@ +const models = require('vn-loopback/server/server').models; + +fdescribe('Notification Clean()', () => { + it('should delete old rows with error', async() => { + const userId = 9; + const status = 'error'; + const tx = await models.NotificationQueue.beginTransaction({}); + const options = {transaction: tx}; + + const notification = await models.Notification.findOne({}, options); + const notificationConfig = await models.NotificationConfig.findOne({}); + + const cleanDate = new Date(); + cleanDate.setDate(cleanDate.getDate() - (notificationConfig.cleanDays + 1)); + + let before; + let after; + + try { + const notificationDelete = await models.NotificationQueue.create({ + notificationFk: notification.name, + authorFk: userId, + status: status, + created: cleanDate + }, options); + + before = await models.NotificationQueue.findById(notificationDelete.id, null, options); + + await models.Notification.clean(options); + + after = await models.NotificationQueue.findById(notificationDelete.id, null, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + + expect(before.notificationFk).toEqual(notification.name); + expect(after).toBe(null); + }); +}); diff --git a/back/methods/notification/specs/send.spec.js b/back/methods/notification/specs/send.spec.js new file mode 100644 index 000000000..ce03b4f3f --- /dev/null +++ b/back/methods/notification/specs/send.spec.js @@ -0,0 +1,33 @@ +const models = require('vn-loopback/server/server').models; + +fdescribe('Notification Send()', () => { + it('should send notification', async() => { + const statusPending = 'pending'; + const tx = await models.NotificationQueue.beginTransaction({}); + const options = {transaction: tx}; + const filter = { + where: { + status: statusPending + } + }; + + let before; + let after; + + try { + before = await models.NotificationQueue.find(filter, options); + + await models.Notification.send(options); + + after = await models.NotificationQueue.find(filter, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + + expect(before.length).toEqual(1); + expect(after.length).toEqual(0); + }); +}); diff --git a/back/models/notification.js b/back/models/notification.js index 46378bd02..65e82e3c7 100644 --- a/back/models/notification.js +++ b/back/models/notification.js @@ -1,3 +1,4 @@ module.exports = Self => { require('../methods/notification/send')(Self); + require('../methods/notification/clean')(Self); }; diff --git a/back/models/notification.json b/back/models/notification.json index 9422d03b3..56f66bf1d 100644 --- a/back/models/notification.json +++ b/back/models/notification.json @@ -13,10 +13,18 @@ "description": "Identifier" }, "name": { - "type": "string" + "type": "string", + "required": true }, "description": { "type": "string" } + }, + "relations": { + "subscription": { + "type": "hasMany", + "model": "NotificationSubscription", + "foreignKey": "notificationFk" + } } } \ No newline at end of file diff --git a/back/models/notificationQueue.json b/back/models/notificationQueue.json index 122d3816d..9790ea595 100644 --- a/back/models/notificationQueue.json +++ b/back/models/notificationQueue.json @@ -26,11 +26,12 @@ "notification": { "type": "belongsTo", "model": "Notification", - "foreignKey": "notificationFk" + "foreignKey": "notificationFk", + "primaryKey": "name" }, "author": { "type": "belongsTo", - "model": "User", + "model": "Account", "foreignKey": "authorFk" } } diff --git a/back/models/notificationSubscription.json b/back/models/notificationSubscription.json index 14b305ca8..43fa6db27 100644 --- a/back/models/notificationSubscription.json +++ b/back/models/notificationSubscription.json @@ -6,6 +6,18 @@ "table": "util.notificationSubscription" } }, + "properties": { + "notificationFk": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "userFk": { + "type": "number", + "id": true, + "description": "Identifier" + } + }, "relations": { "notification": { "type": "belongsTo", @@ -14,7 +26,7 @@ }, "user": { "type": "belongsTo", - "model": "User", + "model": "Account", "foreignKey": "userFk" } } diff --git a/db/changes/10490-goldenSummer/00-aclNotification.sql b/db/changes/10490-goldenSummer/00-aclNotification.sql index aa4e32cee..51d6b2471 100644 --- a/db/changes/10490-goldenSummer/00-aclNotification.sql +++ b/db/changes/10490-goldenSummer/00-aclNotification.sql @@ -1,3 +1,3 @@ INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES - ('Notification', '*', 'READ', 'ALLOW', 'ROLE', 'developer'); + ('Notification', '*', 'WRITE', 'ALLOW', 'ROLE', 'developer'); diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index f73210a96..7731755e4 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2617,7 +2617,7 @@ INSERT INTO `util`.`notificationConfig` INSERT INTO `util`.`notification` (`id`, `name`, `description`) VALUES - (1, 'notification one', 'notification fixture one'); + (1, 'invoice', 'notification fixture one'); INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) VALUES @@ -2625,7 +2625,7 @@ INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`) VALUES - (1, 'notification one', 'randomParams', 9, 'pending', util.VN_CURDATE()); + (1, 'invoice', '{"invoiceId": 1}', 9, 'pending', util.VN_CURDATE()); INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) VALUES From 2b19688ca4a9e0d6bcb9cad1fb2e330a33877755 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 25 Jul 2022 08:25:46 +0200 Subject: [PATCH 04/93] quit focus --- back/methods/notification/specs/clean.spec.js | 2 +- back/methods/notification/specs/send.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/back/methods/notification/specs/clean.spec.js b/back/methods/notification/specs/clean.spec.js index c9441a98b..4c9dc563d 100644 --- a/back/methods/notification/specs/clean.spec.js +++ b/back/methods/notification/specs/clean.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('Notification Clean()', () => { +describe('Notification Clean()', () => { it('should delete old rows with error', async() => { const userId = 9; const status = 'error'; diff --git a/back/methods/notification/specs/send.spec.js b/back/methods/notification/specs/send.spec.js index ce03b4f3f..015d1cb4d 100644 --- a/back/methods/notification/specs/send.spec.js +++ b/back/methods/notification/specs/send.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('Notification Send()', () => { +describe('Notification Send()', () => { it('should send notification', async() => { const statusPending = 'pending'; const tx = await models.NotificationQueue.beginTransaction({}); From 3fd34e08618fe9ea1b260f8103bddb9b6d9421fd Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 25 Jul 2022 14:49:39 +0200 Subject: [PATCH 05/93] feat(claim_pickup_order): modify email --- db/dump/fixtures.sql | 256 +++++++++--------- modules/claim/front/basic-data/index.html | 4 +- modules/claim/front/basic-data/locale/es.yml | 4 +- modules/claim/front/descriptor/index.js | 5 +- modules/claim/front/summary/index.html | 47 ++-- .../claim-pickup-order.html | 9 +- .../claim-pickup-order/claim-pickup-order.js | 12 + .../email/claim-pickup-order/locale/es.yml | 13 +- .../claim-pickup-order.html | 9 +- .../claim-pickup-order/claim-pickup-order.js | 4 - .../reports/claim-pickup-order/locale/es.yml | 4 - .../claim-pickup-order/sql/claimConfig.sql | 2 - 12 files changed, 192 insertions(+), 177 deletions(-) delete mode 100644 print/templates/reports/claim-pickup-order/sql/claimConfig.sql diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 0609a6a6a..746e77ffd 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1,7 +1,7 @@ CREATE SCHEMA IF NOT EXISTS `vn2008`; CREATE SCHEMA IF NOT EXISTS `tmp`; -UPDATE `util`.`config` +UPDATE `util`.`config` SET `environment`= 'test'; ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1; @@ -9,11 +9,11 @@ ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1; -INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`) - VALUES +INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`) + VALUES ('DEFAULT_TOKEN', '1209600', util.VN_CURDATE(), 66); -INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) +INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) VALUES ('1', '6'); @@ -22,11 +22,11 @@ INSERT INTO `vn`.`bionicConfig` (`generalInflationCoeficient`, `minimumDensityVo (1.30, 167.00, 138000, 71); INSERT INTO `vn`.`chatConfig` (`host`, `api`) - VALUES + VALUES ('https://chat.verdnatura.es', 'https://chat.verdnatura.es/api/v1'); -INSERT IGNORE INTO `vn`.`greugeConfig`(`id`, `freightPickUpPrice`) - VALUES +INSERT IGNORE INTO `vn`.`greugeConfig`(`id`, `freightPickUpPrice`) + VALUES ('1', '11'); INSERT INTO `vn`.`packagingConfig`(`upperGap`) @@ -52,11 +52,11 @@ INSERT INTO `account`.`account`(`id`) INSERT INTO `vn`.`educationLevel` (`id`, `name`) VALUES (1, 'ESTUDIOS PRIMARIOS COMPLETOS'), - (2, 'ENSEÑANZAS DE BACHILLERATO'); + (2, 'ENSEÑANZAS DE BACHILLERATO'); INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`) SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9 - FROM `vn`.`user`; + FROM `vn`.`user`; UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20; UPDATE `vn`.`worker` SET bossFk = 20 WHERE id = 1 OR id = 9; @@ -69,7 +69,7 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType` (1, 978, 1, 0, 2000, 9, 0); INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`, `image`) - VALUES + VALUES (1101, 'BruceWayne', 'Bruce Wayne', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'BruceWayne@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'), (1102, 'PetterParker', 'Petter Parker', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'PetterParker@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), (1103, 'ClarkKent', 'Clark Kent', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'ClarkKent@mydomain.com', 'fr', 'e7723f0b24ff05b32ed09d95196f2f29'), @@ -113,7 +113,7 @@ INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossF (1107, 'ANT', 'Hank' , 'Pym' , 1107, 19, 432978107, NULL, 1), (1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108, 1, NULL), (1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109, 1, 2), - (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110, 2, 1); + (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110, 2, 1); INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`) VALUES @@ -123,7 +123,7 @@ INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`) (4, 'JPY', 'Yen Japones', 1); INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `politicalCountryFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`) - VALUES + VALUES (1, 'España', 1, 'ES', 1, 1, 24, 4, 0, 1), (2, 'Italia', 1, 'IT', 1, 2, 27, 4, 0, 1), (3, 'Alemania', 1, 'DE', 1, 3, 22, 4, 0, 1), @@ -153,19 +153,19 @@ INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPrepare (1, 'First sector', 1, 1, 'FIRST'), (2, 'Second sector', 2, 0, 'SECOND'); -INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`) - VALUES +INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`) + VALUES ('1', '700', '01', '1', '700-01', '70001'), ('2', '700', '02', '2', '700-02', '70002'); -INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `parked`, `userFk`) - VALUES +INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `parked`, `userFk`) + VALUES ('GVC', 1, 0, 1, 0, 1106), ('HEJ', 2, 0, 1, 0, 1106), ('UXN', 1, 0, 1, 0, 1106); INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`, `daysInFuture`) - VALUES + VALUES (1, 'CC and credit policies', 'Transfers', 'wireTransfer', NULL, 1), (2, 'Cash', 'Cash', 'cash', 1000, 0), (3, 'Credit card', 'Credit Card', 'creditCard', NULL, 0), @@ -180,8 +180,8 @@ INSERT INTO `vn`.`bankEntity`(`id`, `countryFk`, `name`, `bic`) (128, 1, 'The Best Bank', 'BBKKESMMMMMM'), (2100, 1, 'Caixa Bank', 'CAIXESBB'); -INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`) - VALUES +INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`) + VALUES (1, 'Pay on receipt', '5720000001', 3, 128, 1, 1), (2, 'Cash', '5700000001', 2, 128, 1, 1), (3, 'Compensation', '4000000000', 8, 128, 1, 1), @@ -235,7 +235,7 @@ UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com' UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23; INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt`, `isIbanRequiredForClients`, `isIbanRequiredForSuppliers`, `hasVerified`) - VALUES + VALUES (1, NULL, 'PayMethod one', 0, 001, 0, 0, 0), (2, NULL, 'PayMethod two', 10, 001, 0, 0, 1), (3, 'compensation', 'PayMethod three', 0, 001, 0, 0, 0), @@ -244,7 +244,7 @@ INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt (8,'wireTransfer', 'WireTransfer', 5, 001, 1, 1, 0); INSERT INTO `vn`.`payDem`(`id`, `payDem`) - VALUES + VALUES (1, 10), (2, 20); @@ -273,7 +273,7 @@ INSERT INTO `vn`.`town`(`id`, `name`, `provinceFk`) (5, 'Quito', 5); INSERT INTO `vn`.`postCode`(`code`, `townFk`, `geoFk`) - VALUES + VALUES ('46000', 1, 6), ('46460', 2, 6), ('46680', 3, 6), @@ -481,7 +481,7 @@ INSERT INTO `vn`.`supplierActivity`(`code`, `name`) ('complements', 'Other complements'), ('flowerPlants', 'Wholesale of flowers and plants'), ('vegetablesFruits', 'Fruit and vegetable trade'); - + INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`, `healthRegister`) VALUES (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), @@ -498,7 +498,7 @@ INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`, (442 , 'VNL', 241, 30, 2 , 1, NULL, 2, 'VNL Company - Plant passport'), (567 , 'VNH', NULL, 30, NULL, 4, NULL, 1, 'VNH Company - Plant passport'), (791 , 'FTH', NULL, 30, NULL, 3, '2015-11-30', 1, NULL), - (1381, 'ORN', NULL, 30, NULL, 7, NULL, 1, 'ORN Company - Plant passport'); + (1381, 'ORN', NULL, 30, NULL, 7, NULL, 1, 'ORN Company - Plant passport'); INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion`) VALUES @@ -519,7 +519,7 @@ INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaF INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`) VALUES (1, 'T', 1014.24, util.VN_CURDATE(), 1101, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), - (2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), + (2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), (3, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), (4, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), (5, 'A', 8.88, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 0); @@ -531,7 +531,7 @@ UPDATE `vn`.`invoiceOut` SET ref = 'T4444444' WHERE id = 4; UPDATE `vn`.`invoiceOut` SET ref = 'A1111111' WHERE id = 5; INSERT INTO `vn`.`invoiceOutTax` (`invoiceOutFk`, `taxableBase`, `vat`, `pgcFk`) - VALUES + VALUES (1, 895.76, 89.58, 4722000010), (1, 33.80, 7.10, 4722000021), (2, 110.33, 11.03, 4770000010), @@ -552,7 +552,7 @@ INSERT INTO `vn`.`expence`(`id`, `taxTypeFk`, `name`, `isWithheld`) (7001000000, 1, 'Mercaderia', 0), (7050000000, 1, 'Prestacion de servicios', 1); - + INSERT INTO `vn`.`invoiceOutExpence`(`id`, `invoiceOutFk`, `amount`, `expenceFk`, `created`) VALUES (1, 1, 813.06, 2000000000, util.VN_CURDATE()), @@ -564,7 +564,7 @@ INSERT INTO `vn`.`invoiceOutExpence`(`id`, `invoiceOutFk`, `amount`, `expenceFk` (7, 5, 8.07, 2000000000, util.VN_CURDATE()); INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `agencyModeFk`, `travelingDays`, `price`, `bonus`, `itemMaxSize`) - VALUES + VALUES (1, 'Zone pickup A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100), (2, 'Zone pickup B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100), (3, 'Zone 247 A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100), @@ -580,7 +580,7 @@ INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `agencyModeFk`, `travelingDays`, (13, 'Zone quantum break', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 5, 0, 0, 0, 100); INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`) - VALUES + VALUES (1, 1, 1), (2, 2, 2), (3, 3, 1), @@ -596,7 +596,7 @@ INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`) (13, 13, 5); INSERT INTO `vn`.`zoneClosure` (`zoneFk`, `dated`, `hour`) - VALUES + VALUES (1, util.VN_CURDATE(), '23:59'), (2, util.VN_CURDATE(), '23:59'), (3, util.VN_CURDATE(), '23:59'), @@ -668,7 +668,7 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des (11, 24, 4, 'Reclama ticket: 7'), (12, 11, 3, 'Delivery after 10am'); --- FIX for state hours on local, inter_afterInsert +-- FIX for state hours on local, inter_afterInsert UPDATE vncontrol.inter SET odbc_date = DATE_ADD(util.VN_CURDATE(), INTERVAL -10 SECOND); INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`) @@ -764,7 +764,7 @@ INSERT INTO `vn`.`itemCategory`(`id`, `name`, `display`, `color`, `icon`, `code` INSERT INTO `vn`.`temperature`(`code`, `name`, `description`) VALUES ('warm', 'Warm', 'Warm'), - ('cool', 'Cool', 'Cool'); + ('cool', 'Cool', 'Cool'); INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `warehouseFk`, `life`,`workerFk`, `isPackaging`, `temperatureFk`) VALUES @@ -818,7 +818,7 @@ INSERT INTO `vn`.`taxClassCode`(`taxClassFk`, `effectived`, `taxCodeFk`) (1, util.VN_CURDATE(), 1), (1, util.VN_CURDATE(), 21), (2, util.VN_CURDATE(), 2); - + INSERT INTO `vn`.`intrastat`(`id`, `description`, `taxClassFk`, `taxCodeFk`) VALUES (05080000, 'Coral y materiales similares', 2, 2), @@ -830,7 +830,7 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`) ('SER', 'Services'), ('VT', 'Sales'); -INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`, +INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`, `comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`) VALUES (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V', 0, 15), @@ -966,7 +966,7 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (3, 39, 0.994), (4, 28, 1.25), (4, 29, 0.42), - (4, 39, 0.017), + (4, 39, 0.017), (5, 17, 9.94), (5, 28, 50), (5, 29, 49.4), @@ -988,8 +988,8 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (9, 15, 3.0949), (9, 21, 0.001), (9, 28, 53), - (9, 29, 46.4), - (9, 39, 0.994), + (9, 29, 46.4), + (9, 39, 0.994), (10, 15, 0.0199), (10, 28, 7), (10, 29, 0), @@ -1088,14 +1088,14 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (32, 36, -92.324), (32, 39, 0.994); -INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `shelve`, `visible`, `grouping`, `packing`, `userFk`) - VALUES +INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `shelve`, `visible`, `grouping`, `packing`, `userFk`) + VALUES (2, 'GVC', 'A', 1, 1, 1, 1106), (4, 'HEJ', 'A', 1, 1, 1, 1106), (1, 'UXN', 'A', 2, 12, 12, 1106); -INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`) - VALUES +INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`) + VALUES ('1', '1', '1', '', '1106'), ('2', '2', '5', '', '1106'), ('1', '7', '1', '', '1106'), @@ -1137,8 +1137,8 @@ INSERT INTO `vn`.`ticketCollection`(`ticketFk`, `collectionFk`, `level`) (3, 2, NULL), (23, 1, NULL); -INSERT INTO `vn`.`parking` (`column`, `row`, `sectorFk`, `code`, `pickingOrder`) - VALUES +INSERT INTO `vn`.`parking` (`column`, `row`, `sectorFk`, `code`, `pickingOrder`) + VALUES ('100', '01', 1, '100-01', 1); INSERT INTO `vn`.`genus`(`id`, `name`) @@ -1292,7 +1292,7 @@ INSERT INTO `vn`.`itemTypeTag`(`id`, `itemTypeFk`, `tagFk`, `priority`) CALL `vn`.`itemRefreshTags`(NULL); INSERT INTO `vn`.`itemLog` (`id`, `originFk`, `userFk`, `action`, `description`) - VALUES + VALUES ('1', '1', '1', 'insert', 'We made a change!'); INSERT INTO `vn`.`recovery`(`id`, `clientFk`, `started`, `finished`, `amount`, `period`) @@ -1484,8 +1484,8 @@ INSERT INTO `hedera`.`orderRowComponent`(`rowFk`, `componentFk`, `price`) (4, 21, -0.001), (4, 28, 20.72), (4, 29, -19.72), - (4, 37, 2), - (4, 39, 0.01), + (4, 37, 2), + (4, 39, 0.01), (5, 15, 0.58), (5, 23, 6.5), (5, 28, 20.72), @@ -1704,7 +1704,7 @@ INSERT INTO `vn`.`workerManaExcluded`(`workerFk`) La otra manera es poner el calculo con los 2 trabajadores que utilizamos ahora mismo para los tickets */ -call vn.manaSpellersRequery(19); +call vn.manaSpellersRequery(19); call vn.manaSpellersRequery(18); INSERT INTO `vn`.`clientSample`(`id`, `clientFk`, `typeFk`, `created`, `workerFk`, `userFk`, `companyFk`) @@ -1772,8 +1772,8 @@ INSERT INTO `hedera`.`tpvMerchant`(`id`, `description`, `companyFk`, `bankFk`, ` (1, 'Arkham Bank', 442, 1, 'h12387193H10238'), (2, 'NewYork Bank', 442, 1, '7981ugsgd1hsdad'); -INSERT INTO `hedera`.`tpvTransaction`(`id`,`merchantFk`, `clientFk`,`receiptFk`, `amount`, `response`, `errorCode`, `status`, `created`) - VALUES +INSERT INTO `hedera`.`tpvTransaction`(`id`,`merchantFk`, `clientFk`,`receiptFk`, `amount`, `response`, `errorCode`, `status`, `created`) + VALUES (1, 1, 1101, NULL, 2000, NULL, 'SIS0042', 'ok', util.VN_CURDATE()), (2, 1, 1101, NULL, 1000, NULL, 'SIS0051', 'started', util.VN_CURDATE()), (3, 2, 1101, NULL, 7268, NULL, NULL, 'ok', util.VN_CURDATE()), @@ -1787,32 +1787,32 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`) (2, 2), (3, 3), (4, 4), - (5, 5), - (6, 6), - (7, 7), - (8, 8), - (9, 9), - (10, 10), - (11, 11), - (12, 12), - (13, 13), - (14, 14), + (5, 5), + (6, 6), + (7, 7), + (8, 8), + (9, 9), + (10, 10), + (11, 11), + (12, 12), + (13, 13), + (14, 14), (15, 15), (16, 16), (17, 17), (18, 18), (19, 19), - (20, 20), - (21, 21), + (20, 20), + (21, 21), (22, 22); -INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`) +INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`) VALUES (1, 1, 69), - (5, 1, 442), + (5, 1, 442), (9, 1, 442), (18, 3, 567); - + INSERT INTO `vn`.`receipt`(`id`, `invoiceFk`, `amountPaid`, `payed`, `workerFk`, `bankFk`, `clientFk`, `created`, `companyFk`, `isConciliate`) VALUES (1, 'Cobro web', 100.50, util.VN_CURDATE(), 9, 1, 1101, util.VN_CURDATE(), 442, 1), @@ -1895,14 +1895,14 @@ INSERT INTO `postgresql`.`business_labour` (`business_id`, `notes`, `department_ VALUES (1111, NULL, 23, 1, 0.0, 1, 1, 1, 1); -UPDATE `postgresql`.`business_labour` bl +UPDATE `postgresql`.`business_labour` bl JOIN `postgresql`.`business` b ON b.business_id = bl.business_id JOIN `postgresql`.`profile` pr ON pr.profile_id = b.client_id JOIN `postgresql`.`person` p ON p.person_id = pr.person_id SET bl.`professional_category_id` = 31 WHERE p.`Id_trabajador` = 1110; -UPDATE `postgresql`.`business_labour` bl +UPDATE `postgresql`.`business_labour` bl SET bl.`department_id` = 43 WHERE business_id IN(18, 19); @@ -1917,18 +1917,18 @@ INSERT INTO `postgresql`.`profile_media`(`profile_media_id`, `profile_id`, `medi (2, 1107, 2); INSERT INTO `vn`.`workCenterHoliday` (`workCenterFk`, `days`, `year`) - VALUES + VALUES ('1', '27.5', YEAR(util.VN_CURDATE())), ('5', '22', YEAR(util.VN_CURDATE())), - ('1', '24.5', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))), + ('1', '24.5', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))), ('5', '23', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))); -INSERT INTO `vn`.`absenceType` (`id`, `name`, `rgb`, `code`, `holidayEntitlementRate`, `discountRate`) - VALUES +INSERT INTO `vn`.`absenceType` (`id`, `name`, `rgb`, `code`, `holidayEntitlementRate`, `discountRate`) + VALUES (1, 'Holidays', '#FF4444', 'holiday', 0, 0), (2, 'Leave of absence', '#C71585', 'absence', 0, 1), (6, 'Half holiday', '#E65F00', 'halfHoliday', 0, 0.5), - (15, 'Half Paid Leave', '#5151c0', 'halfPaidLeave', 0, 1), + (15, 'Half Paid Leave', '#5151c0', 'halfPaidLeave', 0, 1), (20, 'Furlough', '#97B92F', 'furlough', 1, 1), (21, 'Furlough half day', '#778899', 'halfFurlough', 0.5, 1); @@ -1945,10 +1945,10 @@ INSERT INTO `postgresql`.`business_labour_payroll` (`business_id`, `cod_tarifa`, (1, 7, 12, 100, 900.50), (1106, 7, 12, 100, 1263.03), (1107, 7, 12, 100, 2000), - (1108, 7, 12, 100, 1500); + (1108, 7, 12, 100, 1500); -INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id`, `date`) - VALUES +INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id`, `date`) + VALUES (1, 6, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))), (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))), (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -11 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 11 DAY))), @@ -1966,8 +1966,8 @@ INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id` (1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 7 DAY))), (1107, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL - 16 DAY)); -INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`, `apiKey`) - VALUES +INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`, `apiKey`) + VALUES ('1', 'https://api.gateway360.com/api/3.0/sms/send', 'Verdnatura', '5715476da95b46d686a5a255e6459523'); INSERT INTO `vn`.`sharingClient`(`id`, `workerFk`, `started`, `ended`, `clientFk`) @@ -1983,37 +1983,37 @@ CALL `vn`.zoneGeo_calcTree(); -- this is an auto calculate for table vn.zoneGeo, INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`) VALUES - (1, 3, 0), - (1, 4, 0), - (1, 5, 0), + (1, 3, 0), + (1, 4, 0), + (1, 5, 0), (1, 1, 1), - (2, 3, 0), - (2, 4, 0), - (2, 5, 0), + (2, 3, 0), + (2, 4, 0), + (2, 5, 0), (2, 1, 1), - (3, 3, 0), - (3, 4, 0), - (3, 5, 0), + (3, 3, 0), + (3, 4, 0), + (3, 5, 0), (3, 1, 1), - (4, 3, 0), - (4, 4, 0), - (4, 5, 0), + (4, 3, 0), + (4, 4, 0), + (4, 5, 0), (4, 1, 1), - (5, 3, 1), - (5, 4, 0), - (5, 5, 1), + (5, 3, 1), + (5, 4, 0), + (5, 5, 1), (5, 1, 1), - (6, 3, 1), - (6, 4, 0), - (6, 5, 1), + (6, 3, 1), + (6, 4, 0), + (6, 5, 1), (6, 1, 1), - (7, 3, 0), - (7, 4, 0), - (7, 5, 0), + (7, 3, 0), + (7, 4, 0), + (7, 5, 0), (7, 1, 1), - (8, 3, 0), - (8, 4, 0), - (8, 5, 0), + (8, 3, 0), + (8, 4, 0), + (8, 5, 0), (8, 1, 1), (10, 14, 1); @@ -2226,12 +2226,12 @@ INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `dated`) (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)); INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `weekDays`) - VALUES + VALUES (8, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun'), (10, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun'); INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `started`, `ended`) - VALUES + VALUES (9, 'range', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR)); INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`) @@ -2294,8 +2294,8 @@ INSERT INTO `vn`.`workerDocument`(`id`, `worker`, `document`,`isReadableByWorker (1, 1106, 4, TRUE), (2, 1107, 3, FALSE); -INSERT INTO `vn`.`device` (`sn`, `model`, `userFk`) - VALUES +INSERT INTO `vn`.`device` (`sn`, `model`, `userFk`) + VALUES ('aaa', 'android', '9'); INSERT INTO `vn`.`queuePriority`(`id`, `priority`) @@ -2309,7 +2309,7 @@ INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `week (1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000); INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11'); - + INSERT INTO `vn`.`thermograph`(`id`, `model`) VALUES ('TMM190901395', 'TEMPMATE'), @@ -2327,21 +2327,21 @@ INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`, ('138350-0', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', NULL, 5), ('138350-0', util.VN_CURDATE(), 1, NULL, 'COOL', NULL, NULL); -REPLACE INTO `vn`.`incoterms`(`code`, `name`) - VALUES +REPLACE INTO `vn`.`incoterms`(`code`, `name`) + VALUES ('FAS', 'Free Alongside Ship'); -REPLACE INTO `vn`.`customsAgent`(`id`, `fiscalName`, `street`, `nif`, `phone`, `email`) - VALUES +REPLACE INTO `vn`.`customsAgent`(`id`, `fiscalName`, `street`, `nif`, `phone`, `email`) + VALUES (1, 'Agent one', '1007 Mountain Drive, Gotham', 'N1111111111', '111111111', 'agentone@gotham.com'), (2, 'Agent two', '1007 Mountain Drive, Gotham', 'N2222222222', '222222222', 'agenttwo@gotham.com'); -INSERT INTO `vn`.`tablet`(`uuid`, `name`, `place`, `macwifi`) - VALUES +INSERT INTO `vn`.`tablet`(`uuid`, `name`, `place`, `macwifi`) + VALUES ('1', 'TEST', 'ON THE FIXTURES', '0'), ('2', 'DEV', 'OTHER TABLET', '0'); -INSERT INTO `vn`.`tabletDepartment`(`tabletFk`, `departmentFk`) +INSERT INTO `vn`.`tabletDepartment`(`tabletFk`, `departmentFk`) VALUES (1, 23), (2, 1); @@ -2374,8 +2374,8 @@ INSERT INTO `vn`.`rate`(`dated`, `warehouseFk`, `rate0`, `rate1`, `rate2`, `rate (DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), 1, 10, 15, 20, 25), (util.VN_CURDATE(), 1, 12, 17, 22, 27); -INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk) - VALUES +INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk) + VALUES (1, '07546501420', 67, 671, util.VN_CURDATE(), 1761, 1, 1), (2, '07546491421', 252, 2769, util.VN_CURDATE(), 5231, 1, 1), (3, '07546500823', 102, 1495, util.VN_CURDATE(), 3221, 1, 1), @@ -2387,8 +2387,8 @@ INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk (9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1), (10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1); -INSERT INTO `vn`.`dua` (id, code, awbFk, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk) - VALUES +INSERT INTO `vn`.`dua` (id, code, awbFk, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk) + VALUES (1, '19ES0028013A481523', 1, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 11276.95, 442), (2, '21ES00280136115760', 2, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1376.20, 442), (3, '19ES00280131956004', 3, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 3, 14268.50, 442), @@ -2435,8 +2435,8 @@ INSERT INTO `vn`.`duaInvoiceIn`(`id`, `duaFk`, `invoiceInFk`) (4, 4, 4), (5, 5, 5), (6, 6, 6), - (7, 7, 7), - (8, 8, 8), + (7, 7, 7), + (8, 8, 8), (9, 9, 9), (10, 10, 10); @@ -2446,7 +2446,7 @@ INSERT INTO `vn`.`invoiceInTax` (`invoiceInFk`, `taxableBase`, `expenceFk`, `for (2, 999.99, '2000000000', null, null, null), (3, 1000.50, '2000000000', null, null, null), (4, 0.50, '2000000000', null, null, null), - (5, 150.50, '2000000000', null, null, null), + (5, 150.50, '2000000000', null, null, null), (1, 252.25, '4751000000', NULL, 7, 61), (2, 223.17, '6210000567', NULL, 8, 20), (3, 95.60, '7001000000', NULL, 8, 35), @@ -2461,9 +2461,9 @@ INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amo (1, 10, 6021010, 20.00, 205, 5), (2, 13.20, 5080000, 15.00, 580, 5), (2, 16.10, 6021010, 25.00, 80, 5); - + INSERT INTO `vn`.`ticketRecalc`(`ticketFk`) - SELECT `id` + SELECT `id` FROM `vn`.`ticket` t LEFT JOIN vn.ticketRecalc tr ON tr.ticketFk = t.id WHERE tr.ticketFk IS NULL; @@ -2478,7 +2478,7 @@ INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`) (4, 7, 1); INSERT INTO `vn`.`expeditionTruck` (`id`, `ETD`, `description`) - VALUES + VALUES (1, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +3 YEAR))), 'Best truck in fleet'); INSERT INTO `vn`.`expeditionPallet` (`id`, `truckFk`, `built`, `position`, `isPrint`) @@ -2486,7 +2486,7 @@ INSERT INTO `vn`.`expeditionPallet` (`id`, `truckFk`, `built`, `position`, `isPr (1, 1, util.VN_CURDATE(), 1, 1); INSERT INTO `vn`.`expeditionScan` (`id`, `expeditionFk`, `scanned`, `palletFk`) - VALUES + VALUES (1, 1, util.VN_CURDATE(), 1), (2, 2, util.VN_CURDATE(), 1), (3, 3, util.VN_CURDATE(), 1), @@ -2521,7 +2521,7 @@ UPDATE `vn`.`route` INSERT INTO `bs`.`salesPerson` (`workerFk`, `year`, `month`, `portfolioWeight`) VALUES (18, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 807.23), - (19, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 34.40); + (19, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 34.40); INSERT INTO `bs`.`sale` (`saleFk`, `amount`, `dated`, `typeFk`, `clientFk`) VALUES @@ -2550,14 +2550,14 @@ INSERT INTO `vn`.`calendarHolidaysType` (`id`, `name`, `hexColour`) INSERT INTO `vn`.`calendarHolidays` (`id`, `calendarHolidaysTypeFk`, `dated`, `calendarHolidaysNameFk`, `workCenterFk`) VALUES (1, 1, CONCAT(YEAR(util.VN_CURDATE()), '-12-09'), 1, 1); - + INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackages`, `kmPrice`, `packagePrice`, `routePrice`, `minimumKm`, `minimumM3`, `m3Price`) VALUES (1, 1, 0, 0.00, 0.00, NULL, 0, 0.00, 23), (2, 1, 60, 0.00, 0.00, NULL, 0, 5.00, 33), (3, 2, 0, 15.00, 0.00, NULL, 0, 0.00, 0), (4, 2, 0, 20.00, 0.00, NULL, 0, 0.00, 0), - (5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0); + (5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0); INSERT INTO `vn`.`chat` (`senderFk`, `recipient`, `dated`, `checkUserStatus`, `message`, `status`, `attempts`) VALUES @@ -2607,7 +2607,7 @@ INSERT INTO `vn`.`sectorCollection` (`userFk`, `sectorFk`) INSERT INTO `vn`.`sectorCollectionSaleGroup` (`sectorCollectionFk`, `saleGroupFk`) VALUES (1, 1); - + INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`) VALUES - (1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13); \ No newline at end of file + (1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13); diff --git a/modules/claim/front/basic-data/index.html b/modules/claim/front/basic-data/index.html index 7a91e180a..16e134c60 100644 --- a/modules/claim/front/basic-data/index.html +++ b/modules/claim/front/basic-data/index.html @@ -19,7 +19,7 @@ readonly="true"> @@ -56,7 +56,7 @@ label="Pick up" ng-model="$ctrl.claim.hasToPickUp" vn-acl="claimManager" - info="When checked will notify to the salesPerson"> + title="{{'When checked will notify to the salesPerson' | translate}}"> diff --git a/modules/claim/front/basic-data/locale/es.yml b/modules/claim/front/basic-data/locale/es.yml index c51afee3f..5250d266c 100644 --- a/modules/claim/front/basic-data/locale/es.yml +++ b/modules/claim/front/basic-data/locale/es.yml @@ -5,5 +5,5 @@ Responsability: Responsabilidad Company: Empresa Sales/Client: Comercial/Cliente Pick up: Recoger -When checked will notify a pickup to the salesPerson: Cuando se marque enviará una notificación de recogida al comercial -Packages received: Bultos recibidos \ No newline at end of file +When checked will notify to the salesPerson: Cuando se marque enviará una notificación de recogida al comercial +Packages received: Bultos recibidos diff --git a/modules/claim/front/descriptor/index.js b/modules/claim/front/descriptor/index.js index 674ac91e1..bb406ff79 100644 --- a/modules/claim/front/descriptor/index.js +++ b/modules/claim/front/descriptor/index.js @@ -19,9 +19,10 @@ class Controller extends Descriptor { sendPickupOrder() { return this.vnEmail.send('claim-pickup-order', { - recipient: this.claim.client.email, + recipient: 'alexm@verdnatura.es', recipientId: this.claim.clientFk, - claimId: this.claim.id + claimId: this.claim.id, + ticketId: this.claim.ticketFk }); } diff --git a/modules/claim/front/summary/index.html b/modules/claim/front/summary/index.html index 0c12aa2e6..fc1813467 100644 --- a/modules/claim/front/summary/index.html +++ b/modules/claim/front/summary/index.html @@ -34,6 +34,15 @@ label="State" value="{{$ctrl.summary.claim.claimState.description}}"> + + + + @@ -45,13 +54,13 @@

- Observations

-

Observations @@ -70,13 +79,13 @@

- Detail

-

Detail @@ -98,7 +107,7 @@ - {{::saleClaimed.sale.itemFk | zeroFill:6}} @@ -111,7 +120,7 @@ {{::saleClaimed.sale.price | currency: 'EUR':2}} {{::saleClaimed.sale.discount}} % - {{saleClaimed.sale.quantity * saleClaimed.sale.price * + {{saleClaimed.sale.quantity * saleClaimed.sale.price * ((100 - saleClaimed.sale.discount) / 100) | currency: 'EUR':2}} @@ -123,7 +132,7 @@

Photos

-
@@ -137,13 +146,13 @@

- Development

-

Development @@ -165,8 +174,8 @@ {{::development.claimResult.description}} {{::development.claimResponsible.description}} - {{::development.worker.user.nickname}} @@ -179,21 +188,21 @@

- Action

Action

- {{::action.sale.itemFk | zeroFill:6}} - {{::action.sale.ticket.id}} @@ -258,9 +267,9 @@ vn-id="item-descriptor" warehouse-fk="$ctrl.vnConfig.warehouseFk"> - - - \ No newline at end of file + diff --git a/print/templates/email/claim-pickup-order/claim-pickup-order.html b/print/templates/email/claim-pickup-order/claim-pickup-order.html index f674dcee8..e6e74ed93 100644 --- a/print/templates/email/claim-pickup-order/claim-pickup-order.html +++ b/print/templates/email/claim-pickup-order/claim-pickup-order.html @@ -23,9 +23,10 @@
-

{{ $t('title') }}

-

{{$t('description.dear')}},

-

{{$t('description.instructions')}}

+

{{ $t('title', [claimId]) }}

+

{{ $t('description.dear') }},

+

+

{{ $t('description.conclusion') }}

@@ -43,4 +44,4 @@ - \ No newline at end of file + diff --git a/print/templates/email/claim-pickup-order/claim-pickup-order.js b/print/templates/email/claim-pickup-order/claim-pickup-order.js index cf4ba7d12..220a72dc3 100755 --- a/print/templates/email/claim-pickup-order/claim-pickup-order.js +++ b/print/templates/email/claim-pickup-order/claim-pickup-order.js @@ -8,10 +8,22 @@ module.exports = { 'email-header': emailHeader.build(), 'email-footer': emailFooter.build() }, + created() { + this.instructions = this.$t('description.instructions', [this.claimId, this.ticketId]); + }, + data() { + return { + instructions: String + }; + }, props: { claimId: { type: [Number, String], required: true + }, + ticketId: { + type: [Number, String], + required: true } } }; diff --git a/print/templates/email/claim-pickup-order/locale/es.yml b/print/templates/email/claim-pickup-order/locale/es.yml index fe08fb0a8..9ff30158e 100644 --- a/print/templates/email/claim-pickup-order/locale/es.yml +++ b/print/templates/email/claim-pickup-order/locale/es.yml @@ -1,5 +1,10 @@ -subject: Orden de recogida -title: Orden de recogida +subject: Reclamación Verdnatura +title: Reclamación Verdnatura {0} description: - dear: Estimado cliente - instructions: Aqui tienes tu orden de recogida. \ No newline at end of file + dear: Estimado cliente + instructions: 'Le informamos que se ha aceptado su solicitud de reclamación nº {0} correspondiente al pedido {1}. + Para tramitar la recogida, rellene el SIGUIENTE FORMULARIO en un plazo máximo de 24h. +

Cuando recibamos el género en nuestras instalaciones emitiremos el abono correspondiente. + Debe imprimir el archivo adjunto e incluirlo en la caja. En el caso de no poder imprimirlo, identifique la caja con el número de reclamación CLARAMENTE LEGIBLE.' + conclusion: Un saludo diff --git a/print/templates/reports/claim-pickup-order/claim-pickup-order.html b/print/templates/reports/claim-pickup-order/claim-pickup-order.html index 1f6db4966..49ec00cfd 100644 --- a/print/templates/reports/claim-pickup-order/claim-pickup-order.html +++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.html @@ -52,7 +52,7 @@ - + @@ -71,16 +71,13 @@
- +
{{$t('clientSignature')}}

{{client.name}}

- -

-

{{claimConfig.pickupContact}}

@@ -94,4 +91,4 @@ - \ No newline at end of file + diff --git a/print/templates/reports/claim-pickup-order/claim-pickup-order.js b/print/templates/reports/claim-pickup-order/claim-pickup-order.js index bf975e9f2..fa2124057 100755 --- a/print/templates/reports/claim-pickup-order/claim-pickup-order.js +++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.js @@ -7,7 +7,6 @@ module.exports = { async serverPrefetch() { this.client = await this.fetchClient(this.claimId); this.sales = await this.fetchSales(this.claimId); - this.claimConfig = await this.fetchClaimConfig(); if (!this.client) throw new Error('Something went wrong'); @@ -26,9 +25,6 @@ module.exports = { fetchSales(claimId) { return this.rawSqlFromDef('sales', [claimId]); }, - fetchClaimConfig() { - return this.findOneFromDef('claimConfig'); - }, }, components: { 'report-header': reportHeader.build(), diff --git a/print/templates/reports/claim-pickup-order/locale/es.yml b/print/templates/reports/claim-pickup-order/locale/es.yml index 388c1f1a6..5ee5ecda7 100644 --- a/print/templates/reports/claim-pickup-order/locale/es.yml +++ b/print/templates/reports/claim-pickup-order/locale/es.yml @@ -11,7 +11,3 @@ concept: Concepto clientSignature: Firma del cliente claim: Reclamación {0} phone: Teléfono -sections: - agency: - description: 'Para agilizar su recogida, por favor, póngase en contacto con la oficina - de Logista Parcel.' diff --git a/print/templates/reports/claim-pickup-order/sql/claimConfig.sql b/print/templates/reports/claim-pickup-order/sql/claimConfig.sql deleted file mode 100644 index 9d744ca6d..000000000 --- a/print/templates/reports/claim-pickup-order/sql/claimConfig.sql +++ /dev/null @@ -1,2 +0,0 @@ -SELECT pickupContact - FROM claimConfig; \ No newline at end of file From d040ecb743b0c80ca38ccaf98814f4cca39343d8 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 1 Aug 2022 07:59:04 +0200 Subject: [PATCH 06/93] feat(ticket): getVideo from shinobi --- .../10480-june/00-packingSiteConfig.sql | 16 +++++ front/core/lib/lilium.js | 12 ++++ .../ticket/back/methods/boxing/getVideo.js | 65 +++++++++++++++++ .../back/methods/boxing/specs/getVideo.js | 69 +++++++++++++++++++ modules/ticket/back/model-config.json | 6 ++ modules/ticket/back/models/boxing.js | 3 + modules/ticket/back/models/boxing.json | 12 ++++ .../ticket/back/models/packingSiteConfig.json | 25 +++++++ modules/ticket/front/boxing/index.html | 2 + modules/ticket/front/boxing/index.js | 32 +++++++++ modules/ticket/front/index.js | 1 + modules/ticket/front/routes.json | 16 ++++- 12 files changed, 256 insertions(+), 3 deletions(-) create mode 100644 db/changes/10480-june/00-packingSiteConfig.sql create mode 100644 front/core/lib/lilium.js create mode 100644 modules/ticket/back/methods/boxing/getVideo.js create mode 100644 modules/ticket/back/methods/boxing/specs/getVideo.js create mode 100644 modules/ticket/back/models/boxing.js create mode 100644 modules/ticket/back/models/boxing.json create mode 100644 modules/ticket/back/models/packingSiteConfig.json create mode 100644 modules/ticket/front/boxing/index.html create mode 100644 modules/ticket/front/boxing/index.js diff --git a/db/changes/10480-june/00-packingSiteConfig.sql b/db/changes/10480-june/00-packingSiteConfig.sql new file mode 100644 index 000000000..b32bc115e --- /dev/null +++ b/db/changes/10480-june/00-packingSiteConfig.sql @@ -0,0 +1,16 @@ +CREATE TABLE `vn`.`packingSiteConfig` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `shinobiUrl` varchar(255) NOT NULL, + `shinobiGroupKey` varchar(255) NOT NULL, + `avgBoxingTime` INT(3) NULL, + PRIMARY KEY (`id`) + ); + +INSERT INTO `vn`.`packingSiteConfig` SET + shinobiUrl = 'https://shinobi.verdnatura.es/', + shinobiGroupKey = 'xVqft9LFXg', + avgBoxingTime = 30; + +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('Boxing', '*', '*', 'ALLOW', 'ROLE', 'employee'); diff --git a/front/core/lib/lilium.js b/front/core/lib/lilium.js new file mode 100644 index 000000000..ca10d3511 --- /dev/null +++ b/front/core/lib/lilium.js @@ -0,0 +1,12 @@ + +export default function lilium(route) { + const env = process.env.NODE_ENV; + let newRoute = 'https://localhost:8080/#/' + route; + + if (env == 'test') + newRoute = 'https://test-lilium.verdnatura.es/#/' + route; + if (env == 'producction') + newRoute = 'https://lilium.verdnatura.es/#/' + route; + + return newRoute; +} diff --git a/modules/ticket/back/methods/boxing/getVideo.js b/modules/ticket/back/methods/boxing/getVideo.js new file mode 100644 index 000000000..851e4cfac --- /dev/null +++ b/modules/ticket/back/methods/boxing/getVideo.js @@ -0,0 +1,65 @@ +const axios = require('axios'); + +module.exports = Self => { + Self.remoteMethod('getVideo', { + description: 'Get packing video of ticketId', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'Ticket id' + }, + { + arg: 'time', + type: 'number', + required: true, + description: 'Time to add' + } + ], + returns: { + type: ['object'], + root: true, + }, + http: { + path: `/getVideo`, + verb: 'GET', + }, + }); + + Self.getVideo = async(id, time, options) => { + const models = Self.app.models; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const expedition = await models.Expedition.findById(id, null, myOptions); + const packingSiteConfig = await models.PackingSiteConfig.findOne({}, myOptions); + const token = await Self.getToken(packingSiteConfig); + const monitorId = 'xVqft9LFXg'; + + const start = new Date(expedition.created); + const end = start.setTime(start.getTime() + (time ? time : packingSiteConfig.avgBoxingTime)); + + const videoUrl = `${token}/videos/${packingSiteConfig}/${monitorId}?start=${start}&end=${end}`; + const videos = await axios.post(`${packingSiteConfig.shinobiUrl}${videoUrl}`, { + mail: packingSiteConfig.mail, + pass: packingSiteConfig.pass + }); + + console.log(videos); + return videos.data; + }; + + Self.getToken = async function getToken(packingSiteConfig) { + const response = await axios.post(`${packingSiteConfig.shinobiUrl}?json=true`, { + machineID: 1, + ke: 'hola', + }); + + console.log(response); + return response.data; + }; +}; diff --git a/modules/ticket/back/methods/boxing/specs/getVideo.js b/modules/ticket/back/methods/boxing/specs/getVideo.js new file mode 100644 index 000000000..ad5295f0c --- /dev/null +++ b/modules/ticket/back/methods/boxing/specs/getVideo.js @@ -0,0 +1,69 @@ +const models = require('vn-loopback/server/server').models; + +xdescribe('sale canEdit()', () => { + it('should return true if the role is production regardless of the saleTrackings', async() => { + const tx = await models.Sale.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const productionUserID = 49; + const ctx = {req: {accessToken: {userId: productionUserID}}}; + + const sales = [{id: 3}]; + + const result = await models.Sale.canEdit(ctx, sales, options); + + expect(result).toEqual(true); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should return true if the role is not production and none of the sales has saleTracking', async() => { + const tx = await models.Sale.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const salesPersonUserID = 18; + const ctx = {req: {accessToken: {userId: salesPersonUserID}}}; + + const sales = [{id: 10}]; + + const result = await models.Sale.canEdit(ctx, sales, options); + + expect(result).toEqual(true); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should return false if any of the sales has a saleTracking record', async() => { + const tx = await models.Sale.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const salesPersonUserID = 18; + const ctx = {req: {accessToken: {userId: salesPersonUserID}}}; + + const sales = [{id: 3}]; + + const result = await models.Sale.canEdit(ctx, sales, options); + + expect(result).toEqual(false); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/ticket/back/model-config.json b/modules/ticket/back/model-config.json index 8a6ac0c00..21e800b36 100644 --- a/modules/ticket/back/model-config.json +++ b/modules/ticket/back/model-config.json @@ -5,6 +5,9 @@ "AnnualAverageInvoiced": { "dataSource": "vn" }, + "Boxing": { + "dataSource": "vn" + }, "Component": { "dataSource": "vn" }, @@ -20,6 +23,9 @@ "Packaging": { "dataSource": "vn" }, + "PackingSiteConfig": { + "dataSource": "vn" + }, "PrintServerQueue": { "dataSource": "vn" }, diff --git a/modules/ticket/back/models/boxing.js b/modules/ticket/back/models/boxing.js new file mode 100644 index 000000000..81732d17a --- /dev/null +++ b/modules/ticket/back/models/boxing.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/boxing/getVideo')(Self); +}; diff --git a/modules/ticket/back/models/boxing.json b/modules/ticket/back/models/boxing.json new file mode 100644 index 000000000..5aecbcabe --- /dev/null +++ b/modules/ticket/back/models/boxing.json @@ -0,0 +1,12 @@ +{ + "name": "Boxing", + "base": "PersistedModel", + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] +} diff --git a/modules/ticket/back/models/packingSiteConfig.json b/modules/ticket/back/models/packingSiteConfig.json new file mode 100644 index 000000000..7e4699c71 --- /dev/null +++ b/modules/ticket/back/models/packingSiteConfig.json @@ -0,0 +1,25 @@ +{ + "name": "PackingSiteConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "packingSiteConfig" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "description": "Identifier" + }, + "shinobiUrl": { + "type": "string" + }, + "shinobiGroupKey":{ + "type":"string" + }, + "avgBoxingTime":{ + "type":"number" + } + } +} diff --git a/modules/ticket/front/boxing/index.html b/modules/ticket/front/boxing/index.html new file mode 100644 index 000000000..7fb3b870e --- /dev/null +++ b/modules/ticket/front/boxing/index.html @@ -0,0 +1,2 @@ + + diff --git a/modules/ticket/front/boxing/index.js b/modules/ticket/front/boxing/index.js new file mode 100644 index 000000000..6a1d4b4d3 --- /dev/null +++ b/modules/ticket/front/boxing/index.js @@ -0,0 +1,32 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +class Controller extends Section { + constructor($element, $) { + super($element, $); + } + + $onInit() { + window.location.href = this.lilium('dashboard'); + } + + lilium(route) { + const env = process.env.NODE_ENV; + let newRoute = 'http://localhost:8080/#/' + route; + + if (env == 'test') + newRoute = 'https://test-lilium.verdnatura.es/#/' + route; + if (env == 'producction') + newRoute = 'https://lilium.verdnatura.es/#/' + route; + + return newRoute; + } +} + +ngModule.vnComponent('vnTicketBoxing', { + template: require('./index.html'), + controller: Controller, + bindings: { + ticket: '<' + } +}); diff --git a/modules/ticket/front/index.js b/modules/ticket/front/index.js index 85a03ffb6..0558d251d 100644 --- a/modules/ticket/front/index.js +++ b/modules/ticket/front/index.js @@ -33,3 +33,4 @@ import './dms/index'; import './dms/create'; import './dms/edit'; import './sms'; +import './boxing'; diff --git a/modules/ticket/front/routes.json b/modules/ticket/front/routes.json index ba7cfa887..4be8e2183 100644 --- a/modules/ticket/front/routes.json +++ b/modules/ticket/front/routes.json @@ -24,7 +24,8 @@ {"state": "ticket.card.saleChecked", "icon": "assignment"}, {"state": "ticket.card.components", "icon": "icon-components"}, {"state": "ticket.card.saleTracking", "icon": "assignment"}, - {"state": "ticket.card.dms.index", "icon": "cloud_download"} + {"state": "ticket.card.dms.index", "icon": "cloud_download"}, + {"state": "ticket.card.boxing", "icon": "science"} ] }, "keybindings": [ @@ -66,7 +67,7 @@ "abstract": true, "params": { "ticket": "$ctrl.ticket" - } + } }, { "url" : "/step-one", @@ -273,6 +274,15 @@ "params": { "ticket": "$ctrl.ticket" } + }, + { + "url": "/boxing", + "state": "ticket.card.boxing", + "component": "vn-ticket-boxing", + "description": "Boxing", + "params": { + "ticket": "$ctrl.ticket" + } } ] -} \ No newline at end of file +} From 7d4dd7bb52751dc442f489e2d057b25f047288c4 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 1 Aug 2022 15:03:17 +0200 Subject: [PATCH 07/93] feat(boxing): return stream video --- .../10480-june/00-packingSiteConfig.sql | 2 +- .../ticket/back/methods/boxing/getVideo.js | 48 ++++++++++--------- modules/ticket/front/boxing/index.html | 3 ++ modules/ticket/front/boxing/index.js | 2 +- 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/db/changes/10480-june/00-packingSiteConfig.sql b/db/changes/10480-june/00-packingSiteConfig.sql index b32bc115e..879896f41 100644 --- a/db/changes/10480-june/00-packingSiteConfig.sql +++ b/db/changes/10480-june/00-packingSiteConfig.sql @@ -7,7 +7,7 @@ CREATE TABLE `vn`.`packingSiteConfig` ( ); INSERT INTO `vn`.`packingSiteConfig` SET - shinobiUrl = 'https://shinobi.verdnatura.es/', + shinobiUrl = 'http://shinobi.verdnatura.es', shinobiGroupKey = 'xVqft9LFXg', avgBoxingTime = 30; diff --git a/modules/ticket/back/methods/boxing/getVideo.js b/modules/ticket/back/methods/boxing/getVideo.js index 851e4cfac..4e2a4b12c 100644 --- a/modules/ticket/back/methods/boxing/getVideo.js +++ b/modules/ticket/back/methods/boxing/getVideo.js @@ -8,13 +8,13 @@ module.exports = Self => { { arg: 'id', type: 'number', - required: true, + required: false, description: 'Ticket id' }, { arg: 'time', type: 'number', - required: true, + required: false, description: 'Time to add' } ], @@ -31,35 +31,37 @@ module.exports = Self => { Self.getVideo = async(id, time, options) => { const models = Self.app.models; const myOptions = {}; - + console.log('ENTRY'); if (typeof options == 'object') Object.assign(myOptions, options); const expedition = await models.Expedition.findById(id, null, myOptions); const packingSiteConfig = await models.PackingSiteConfig.findOne({}, myOptions); - const token = await Self.getToken(packingSiteConfig); - const monitorId = 'xVqft9LFXg'; + const token = 'BW4o7FZyJ85she1hlRDe6QnwW3jwEP'; + const groupKey = 'xVqft9LFXg'; + const monitorId = 'VbiUcajdaT';// 'xVqft9LFXg'; - const start = new Date(expedition.created); - const end = start.setTime(start.getTime() + (time ? time : packingSiteConfig.avgBoxingTime)); + const start = '2022-07-27T09:00:00';// new Date('2022-07-27'); // new Date(expedition.created); + const end = '2022-07-27T09:15:00';// start.setTime(start.getTime() + (time ? time : packingSiteConfig.avgBoxingTime)); - const videoUrl = `${token}/videos/${packingSiteConfig}/${monitorId}?start=${start}&end=${end}`; - const videos = await axios.post(`${packingSiteConfig.shinobiUrl}${videoUrl}`, { - mail: packingSiteConfig.mail, - pass: packingSiteConfig.pass - }); + const videoUrl = `/${token}/videos/${groupKey}/${monitorId}?start=${start}&end=${end}`; + const url = `${packingSiteConfig.shinobiUrl}${videoUrl}`; + const data = await axios.post(url); - console.log(videos); - return videos.data; - }; + console.log(data.data.videos); + console.log('-----------------------'); + console.log('-----------------------'); + console.log('-----------------------'); + console.log('-----------------------'); - Self.getToken = async function getToken(packingSiteConfig) { - const response = await axios.post(`${packingSiteConfig.shinobiUrl}?json=true`, { - machineID: 1, - ke: 'hola', - }); - - console.log(response); - return response.data; + axios({ + method: 'get', + url: `${packingSiteConfig.shinobiUrl}${data.data.videos[0].href}`, + responseType: 'stream' + }) + .then(response => { + console.log(response); + return response; + }); }; }; diff --git a/modules/ticket/front/boxing/index.html b/modules/ticket/front/boxing/index.html index 7fb3b870e..e47976cd7 100644 --- a/modules/ticket/front/boxing/index.html +++ b/modules/ticket/front/boxing/index.html @@ -1,2 +1,5 @@ + diff --git a/modules/ticket/front/boxing/index.js b/modules/ticket/front/boxing/index.js index 6a1d4b4d3..722301963 100644 --- a/modules/ticket/front/boxing/index.js +++ b/modules/ticket/front/boxing/index.js @@ -7,7 +7,7 @@ class Controller extends Section { } $onInit() { - window.location.href = this.lilium('dashboard'); + // window.location.href = this.lilium('dashboard'); } lilium(route) { From 8a08b6f3996e388a624ec7acf001a2c9affc7283 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 2 Aug 2022 15:15:05 +0200 Subject: [PATCH 08/93] feat(ticket_boxing): return video stream --- .../10480-june/00-packingSiteConfig.sql | 9 + .../10480-june/00-packingSiteUpdate.sql | 56 ++++ db/dump/fixtures.sql | 287 +++++++++--------- .../ticket/back/methods/boxing/getVideo.js | 65 ++-- .../ticket/back/models/packingSiteConfig.json | 3 + modules/ticket/front/boxing/index.html | 4 +- 6 files changed, 258 insertions(+), 166 deletions(-) create mode 100644 db/changes/10480-june/00-packingSiteUpdate.sql diff --git a/db/changes/10480-june/00-packingSiteConfig.sql b/db/changes/10480-june/00-packingSiteConfig.sql index 879896f41..28e685eb6 100644 --- a/db/changes/10480-june/00-packingSiteConfig.sql +++ b/db/changes/10480-june/00-packingSiteConfig.sql @@ -1,16 +1,25 @@ CREATE TABLE `vn`.`packingSiteConfig` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `shinobiUrl` varchar(255) NOT NULL, + `shinobiToken` varchar(255) NOT NULL, `shinobiGroupKey` varchar(255) NOT NULL, `avgBoxingTime` INT(3) NULL, PRIMARY KEY (`id`) ); + INSERT INTO `vn`.`packingSiteConfig` SET shinobiUrl = 'http://shinobi.verdnatura.es', + shinobiToken = 'BW4o7FZyJ85she1hlRDe6QnwW3jwEP', shinobiGroupKey = 'xVqft9LFXg', avgBoxingTime = 30; INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Boxing', '*', '*', 'ALLOW', 'ROLE', 'employee'); + +SELECT e.id expeditionFk, e.ticketFk, ps.code, ps.monitorId + FROM expedition e + JOIN host h ON Convert(h.code USING utf8mb3) COLLATE utf8mb3_unicode_ci = e.hostFk + JOIN packingSite ps ON ps.hostFk = h.id + WHERE e.ticketFk = 1; diff --git a/db/changes/10480-june/00-packingSiteUpdate.sql b/db/changes/10480-june/00-packingSiteUpdate.sql new file mode 100644 index 000000000..14313fd52 --- /dev/null +++ b/db/changes/10480-june/00-packingSiteUpdate.sql @@ -0,0 +1,56 @@ +ALTER TABLE `vn`.`packingSite` ADD monitorId varchar(255) NULL; + +UPDATE `vn`.`packingSite` + SET monitorId = 'VbiUcajdaT' + WHERE code = 'h1'; +UPDATE `vn`.`packingSite` + SET monitorId = 'qKMPn9aaVe' + WHERE code = 'h2'; +UPDATE `vn`.`packingSite` + SET monitorId = '3CtdIAGPAv' + WHERE code = 'h3'; +UPDATE `vn`.`packingSite` + SET monitorId = 'Xme2hiqz1f' + WHERE code = 'h4'; +UPDATE `vn`.`packingSite` + SET monitorId = 'aulxefgfJU' + WHERE code = 'h5'; +UPDATE `vn`.`packingSite` + SET monitorId = '6Ou0D1bhBw' + WHERE code = 'h6'; +UPDATE `vn`.`packingSite` + SET monitorId = 'eVUvnE6pNw' + WHERE code = 'h7'; +UPDATE `vn`.`packingSite` + SET monitorId = '0wsmSvqmrs' + WHERE code = 'h8'; +UPDATE `vn`.`packingSite` + SET monitorId = 'r2l2RyyF4I' + WHERE code = 'h9'; +UPDATE `vn`.`packingSite` + SET monitorId = 'EdjHLIiDVD' + WHERE code = 'h10'; +UPDATE `vn`.`packingSite` + SET monitorId = 'czC45kmwqI' + WHERE code = 'h11'; +UPDATE `vn`.`packingSite` + SET monitorId = 'PNsmxPaCwQ' + WHERE code = 'h12'; +UPDATE `vn`.`packingSite` + SET monitorId = 'agVssO0FDC' + WHERE code = 'h13'; +UPDATE `vn`.`packingSite` + SET monitorId = 'f2SPNENHPo' + WHERE code = 'h14'; +UPDATE `vn`.`packingSite` + SET monitorId = '6UR7gUZxks' + WHERE code = 'h15'; +UPDATE `vn`.`packingSite` + SET monitorId = 'bOB0f8WZ2V' + WHERE code = 'h16'; +UPDATE `vn`.`packingSite` + SET monitorId = 'MIR1nXaL0n' + WHERE code = 'h17'; +UPDATE `vn`.`packingSite` + SET monitorId = '0Oj9SgGTXR' + WHERE code = 'h18'; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index f6583f1bb..f67db0b20 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1,7 +1,7 @@ CREATE SCHEMA IF NOT EXISTS `vn2008`; CREATE SCHEMA IF NOT EXISTS `tmp`; -UPDATE `util`.`config` +UPDATE `util`.`config` SET `environment`= 'test'; ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1; @@ -9,11 +9,11 @@ ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`ticket` AUTO_INCREMENT = 1; -INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`) - VALUES +INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`) + VALUES ('DEFAULT_TOKEN', '1209600', util.VN_CURDATE(), 66); -INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) +INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) VALUES ('1', '6'); @@ -22,11 +22,11 @@ INSERT INTO `vn`.`bionicConfig` (`generalInflationCoeficient`, `minimumDensityVo (1.30, 167.00, 138000, 71); INSERT INTO `vn`.`chatConfig` (`host`, `api`) - VALUES + VALUES ('https://chat.verdnatura.es', 'https://chat.verdnatura.es/api/v1'); -INSERT IGNORE INTO `vn`.`greugeConfig`(`id`, `freightPickUpPrice`) - VALUES +INSERT IGNORE INTO `vn`.`greugeConfig`(`id`, `freightPickUpPrice`) + VALUES ('1', '11'); INSERT INTO `vn`.`packagingConfig`(`upperGap`) @@ -52,11 +52,11 @@ INSERT INTO `account`.`account`(`id`) INSERT INTO `vn`.`educationLevel` (`id`, `name`) VALUES (1, 'ESTUDIOS PRIMARIOS COMPLETOS'), - (2, 'ENSEÑANZAS DE BACHILLERATO'); + (2, 'ENSEÑANZAS DE BACHILLERATO'); INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`) SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9 - FROM `vn`.`user`; + FROM `vn`.`user`; UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20; UPDATE `vn`.`worker` SET bossFk = 20 WHERE id = 1 OR id = 9; @@ -69,7 +69,7 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType` (1, 978, 1, 0, 2000, 9, 0); INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`, `image`) - VALUES + VALUES (1101, 'BruceWayne', 'Bruce Wayne', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'BruceWayne@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'), (1102, 'PetterParker', 'Petter Parker', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'PetterParker@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), (1103, 'ClarkKent', 'Clark Kent', 'ac754a330530832ba1bf7687f577da91', 2, 1, 'ClarkKent@mydomain.com', 'fr', 'e7723f0b24ff05b32ed09d95196f2f29'), @@ -113,7 +113,7 @@ INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossF (1107, 'ANT', 'Hank' , 'Pym' , 1107, 19, 432978107, NULL, 1), (1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108, 1, NULL), (1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109, 1, 2), - (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110, 2, 1); + (1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110, 2, 1); INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`) VALUES @@ -123,7 +123,7 @@ INSERT INTO `vn`.`currency`(`id`, `code`, `name`, `ratio`) (4, 'JPY', 'Yen Japones', 1); INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `politicalCountryFk`, `ibanLength`, `continentFk`, `hasDailyInvoice`, `CEE`) - VALUES + VALUES (1, 'España', 1, 'ES', 1, 1, 24, 4, 0, 1), (2, 'Italia', 1, 'IT', 1, 2, 27, 4, 0, 1), (3, 'Alemania', 1, 'DE', 1, 3, 22, 4, 0, 1), @@ -153,19 +153,19 @@ INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPrepare (1, 'First sector', 1, 1, 'FIRST'), (2, 'Second sector', 2, 0, 'SECOND'); -INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`) - VALUES +INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`) + VALUES ('1', '700', '01', '1', '700-01', '70001'), ('2', '700', '02', '2', '700-02', '70002'); -INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `parked`, `userFk`) - VALUES +INSERT INTO `vn`.`shelving` (`code`, `parkingFk`, `isPrinted`, `priority`, `parked`, `userFk`) + VALUES ('GVC', 1, 0, 1, 0, 1106), ('HEJ', 2, 0, 1, 0, 1106), ('UXN', 1, 0, 1, 0, 1106); INSERT INTO `vn`.`accountingType`(`id`, `description`, `receiptDescription`,`code`, `maxAmount`, `daysInFuture`) - VALUES + VALUES (1, 'CC and credit policies', 'Transfers', 'wireTransfer', NULL, 1), (2, 'Cash', 'Cash', 'cash', 1000, 0), (3, 'Credit card', 'Credit Card', 'creditCard', NULL, 0), @@ -180,8 +180,8 @@ INSERT INTO `vn`.`bankEntity`(`id`, `countryFk`, `name`, `bic`) (128, 1, 'The Best Bank', 'BBKKESMMMMMM'), (2100, 1, 'Caixa Bank', 'CAIXESBB'); -INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`) - VALUES +INSERT INTO `vn`.`bank`(`id`, `bank`, `account`, `cash`, `entityFk`, `isActive`, `currencyFk`) + VALUES (1, 'Pay on receipt', '5720000001', 3, 128, 1, 1), (2, 'Cash', '5700000001', 2, 128, 1, 1), (3, 'Compensation', '4000000000', 8, 128, 1, 1), @@ -235,7 +235,7 @@ UPDATE `vn`.`agencyMode` SET `web` = 1, `reportMail` = 'no-reply@gothamcity.com' UPDATE `vn`.`agencyMode` SET `code` = 'refund' WHERE `id` = 23; INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt`, `isIbanRequiredForClients`, `isIbanRequiredForSuppliers`, `hasVerified`) - VALUES + VALUES (1, NULL, 'PayMethod one', 0, 001, 0, 0, 0), (2, NULL, 'PayMethod two', 10, 001, 0, 0, 1), (3, 'compensation', 'PayMethod three', 0, 001, 0, 0, 0), @@ -244,7 +244,7 @@ INSERT INTO `vn`.`payMethod`(`id`,`code`, `name`, `graceDays`, `outstandingDebt (8,'wireTransfer', 'WireTransfer', 5, 001, 1, 1, 0); INSERT INTO `vn`.`payDem`(`id`, `payDem`) - VALUES + VALUES (1, 10), (2, 20); @@ -273,7 +273,7 @@ INSERT INTO `vn`.`town`(`id`, `name`, `provinceFk`) (5, 'Quito', 5); INSERT INTO `vn`.`postCode`(`code`, `townFk`, `geoFk`) - VALUES + VALUES ('46000', 1, 6), ('46460', 2, 6), ('46680', 3, 6), @@ -481,7 +481,7 @@ INSERT INTO `vn`.`supplierActivity`(`code`, `name`) ('complements', 'Other complements'), ('flowerPlants', 'Wholesale of flowers and plants'), ('vegetablesFruits', 'Fruit and vegetable trade'); - + INSERT INTO `vn`.`supplier`(`id`, `name`, `nickname`,`account`,`countryFk`,`nif`, `commission`, `created`, `isActive`, `street`, `city`, `provinceFk`, `postCode`, `payMethodFk`, `payDemFk`, `payDay`, `taxTypeSageFk`, `withholdingSageFk`, `transactionTypeSageFk`, `workerFk`, `supplierActivityFk`, `isPayMethodChecked`, `healthRegister`) VALUES (1, 'Plants SL', 'Plants nick', 4100000001, 1, '06089160W', 0, util.VN_CURDATE(), 1, 'supplier address 1', 'PONTEVEDRA', 1, 15214, 1, 1, 15, 4, 1, 1, 18, 'flowerPlants', 1, '400664487V'), @@ -498,7 +498,7 @@ INSERT INTO `vn`.`company`(`id`, `code`, `supplierAccountFk`, `workerManagerFk`, (442 , 'VNL', 241, 30, 2 , 1, NULL, 2, 'VNL Company - Plant passport'), (567 , 'VNH', NULL, 30, NULL, 4, NULL, 1, 'VNH Company - Plant passport'), (791 , 'FTH', NULL, 30, NULL, 3, '2015-11-30', 1, NULL), - (1381, 'ORN', NULL, 30, NULL, 7, NULL, 1, 'ORN Company - Plant passport'); + (1381, 'ORN', NULL, 30, NULL, 7, NULL, 1, 'ORN Company - Plant passport'); INSERT INTO `vn`.`taxArea` (`code`, `claveOperacionFactura`, `CodigoTransaccion`) VALUES @@ -519,7 +519,7 @@ INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaF INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`) VALUES (1, 'T', 1014.24, util.VN_CURDATE(), 1101, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), - (2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), + (2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), (3, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), (4, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), (5, 'A', 8.88, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 0); @@ -531,7 +531,7 @@ UPDATE `vn`.`invoiceOut` SET ref = 'T4444444' WHERE id = 4; UPDATE `vn`.`invoiceOut` SET ref = 'A1111111' WHERE id = 5; INSERT INTO `vn`.`invoiceOutTax` (`invoiceOutFk`, `taxableBase`, `vat`, `pgcFk`) - VALUES + VALUES (1, 895.76, 89.58, 4722000010), (1, 33.80, 7.10, 4722000021), (2, 110.33, 11.03, 4770000010), @@ -552,7 +552,7 @@ INSERT INTO `vn`.`expence`(`id`, `taxTypeFk`, `name`, `isWithheld`) (7001000000, 1, 'Mercaderia', 0), (7050000000, 1, 'Prestacion de servicios', 1); - + INSERT INTO `vn`.`invoiceOutExpence`(`id`, `invoiceOutFk`, `amount`, `expenceFk`, `created`) VALUES (1, 1, 813.06, 2000000000, util.VN_CURDATE()), @@ -564,7 +564,7 @@ INSERT INTO `vn`.`invoiceOutExpence`(`id`, `invoiceOutFk`, `amount`, `expenceFk` (7, 5, 8.07, 2000000000, util.VN_CURDATE()); INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `agencyModeFk`, `travelingDays`, `price`, `bonus`, `itemMaxSize`) - VALUES + VALUES (1, 'Zone pickup A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100), (2, 'Zone pickup B', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 1, 0, 0, 0, 100), (3, 'Zone 247 A', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 7, 1, 2, 0, 100), @@ -580,7 +580,7 @@ INSERT INTO `vn`.`zone` (`id`, `name`, `hour`, `agencyModeFk`, `travelingDays`, (13, 'Zone quantum break', CONCAT(util.VN_CURDATE(), ' ', TIME('23:59')), 5, 0, 0, 0, 100); INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`) - VALUES + VALUES (1, 1, 1), (2, 2, 2), (3, 3, 1), @@ -596,7 +596,7 @@ INSERT INTO `vn`.`zoneWarehouse` (`id`, `zoneFk`, `warehouseFk`) (13, 13, 5); INSERT INTO `vn`.`zoneClosure` (`zoneFk`, `dated`, `hour`) - VALUES + VALUES (1, util.VN_CURDATE(), '23:59'), (2, util.VN_CURDATE(), '23:59'), (3, util.VN_CURDATE(), '23:59'), @@ -668,7 +668,7 @@ INSERT INTO `vn`.`ticketObservation`(`id`, `ticketFk`, `observationTypeFk`, `des (11, 24, 4, 'Reclama ticket: 7'), (12, 11, 3, 'Delivery after 10am'); --- FIX for state hours on local, inter_afterInsert +-- FIX for state hours on local, inter_afterInsert UPDATE vncontrol.inter SET odbc_date = DATE_ADD(util.VN_CURDATE(), INTERVAL -10 SECOND); INSERT INTO `vn`.`ticketTracking`(`ticketFk`, `stateFk`, `workerFk`, `created`) @@ -764,7 +764,7 @@ INSERT INTO `vn`.`itemCategory`(`id`, `name`, `display`, `color`, `icon`, `code` INSERT INTO `vn`.`temperature`(`code`, `name`, `description`) VALUES ('warm', 'Warm', 'Warm'), - ('cool', 'Cool', 'Cool'); + ('cool', 'Cool', 'Cool'); INSERT INTO `vn`.`itemType`(`id`, `code`, `name`, `categoryFk`, `warehouseFk`, `life`,`workerFk`, `isPackaging`, `temperatureFk`) VALUES @@ -818,7 +818,7 @@ INSERT INTO `vn`.`taxClassCode`(`taxClassFk`, `effectived`, `taxCodeFk`) (1, util.VN_CURDATE(), 1), (1, util.VN_CURDATE(), 21), (2, util.VN_CURDATE(), 2); - + INSERT INTO `vn`.`intrastat`(`id`, `description`, `taxClassFk`, `taxCodeFk`) VALUES (05080000, 'Coral y materiales similares', 2, 2), @@ -830,7 +830,7 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`) ('SER', 'Services'), ('VT', 'Sales'); -INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`, +INSERT INTO `vn`.`item`(`id`, `typeFk`, `size`, `inkFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenceFk`, `comment`, `relevancy`, `image`, `subName`, `minPrice`, `stars`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `packingShelve`) VALUES (1, 2, 70, 'YEL', 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 1, 'VT', 0, NULL, 'V', 0, 15), @@ -883,18 +883,18 @@ INSERT INTO `vn`.`expeditionStateType`(`id`, `description`, `code`) (3, 'Perdida', 'LOST'); -INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`) +INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `isBox`, `created`, `itemFk`, `counter`, `workerFk`, `externalId`, `packagingFk`, `stateTypeFk`, `hostFk`) VALUES - (1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 15, 1, 18, 'UR9000006041', 94, 1), - (2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 16, 2, 18, 'UR9000006041', 94, 1), - (3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 3, 18, 'UR9000006041', 94, 2), - (4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 4, 18, 'UR9000006041', 94, 2), - (5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 3), - (6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 1, 18, NULL, 94, 3), - (7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, 1, 18, NULL, 94, NULL), - (8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, 1, 18, NULL, 94, 1), - (9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 2), - (10, 7, 7, 71, NOW(), NULL, 1, 18, NULL, 94, 3); + (1, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 15, 1, 18, 'UR9000006041', 94, 1, 'pc1'), + (2, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 16, 2, 18, 'UR9000006041', 94, 1, NULL), + (3, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 3, 18, 'UR9000006041', 94, 2, NULL), + (4, 1, 1, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 4, 18, 'UR9000006041', 94, 2, NULL), + (5, 1, 2, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 3, NULL), + (6, 7, 3, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), NULL, 1, 18, NULL, 94, 3, NULL), + (7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), NULL, 1, 18, NULL, 94, NULL,NULL), + (8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), NULL, 1, 18, NULL, 94, 1, NULL), + (9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), NULL, 1, 18, NULL, 94, 2, NULL), + (10, 7, 7, 71, NOW(), NULL, 1, 18, NULL, 94, 3, NULL); INSERT INTO `vn`.`expeditionState`(`id`, `created`, `expeditionFk`, `typeFk`, `userFk`) @@ -966,7 +966,7 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (3, 39, 0.994), (4, 28, 1.25), (4, 29, 0.42), - (4, 39, 0.017), + (4, 39, 0.017), (5, 17, 9.94), (5, 28, 50), (5, 29, 49.4), @@ -988,8 +988,8 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (9, 15, 3.0949), (9, 21, 0.001), (9, 28, 53), - (9, 29, 46.4), - (9, 39, 0.994), + (9, 29, 46.4), + (9, 39, 0.994), (10, 15, 0.0199), (10, 28, 7), (10, 29, 0), @@ -1088,14 +1088,14 @@ INSERT INTO `vn`.`saleComponent`(`saleFk`, `componentFk`, `value`) (32, 36, -92.324), (32, 39, 0.994); -INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `shelve`, `visible`, `grouping`, `packing`, `userFk`) - VALUES +INSERT INTO `vn`.`itemShelving` (`itemFk`, `shelvingFk`, `shelve`, `visible`, `grouping`, `packing`, `userFk`) + VALUES (2, 'GVC', 'A', 1, 1, 1, 1106), (4, 'HEJ', 'A', 1, 1, 1, 1106), (1, 'UXN', 'A', 2, 12, 12, 1106); -INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`) - VALUES +INSERT INTO `vn`.`itemShelvingSale` (`itemShelvingFk`, `saleFk`, `quantity`, `created`, `userFk`) + VALUES ('1', '1', '1', '', '1106'), ('2', '2', '5', '', '1106'), ('1', '7', '1', '', '1106'), @@ -1137,8 +1137,8 @@ INSERT INTO `vn`.`ticketCollection`(`ticketFk`, `collectionFk`, `level`) (3, 2, NULL), (23, 1, NULL); -INSERT INTO `vn`.`parking` (`column`, `row`, `sectorFk`, `code`, `pickingOrder`) - VALUES +INSERT INTO `vn`.`parking` (`column`, `row`, `sectorFk`, `code`, `pickingOrder`) + VALUES ('100', '01', 1, '100-01', 1); INSERT INTO `vn`.`genus`(`id`, `name`) @@ -1292,7 +1292,7 @@ INSERT INTO `vn`.`itemTypeTag`(`id`, `itemTypeFk`, `tagFk`, `priority`) CALL `vn`.`itemRefreshTags`(NULL); INSERT INTO `vn`.`itemLog` (`id`, `originFk`, `userFk`, `action`, `description`) - VALUES + VALUES ('1', '1', '1', 'insert', 'We made a change!'); INSERT INTO `vn`.`recovery`(`id`, `clientFk`, `started`, `finished`, `amount`, `period`) @@ -1484,8 +1484,8 @@ INSERT INTO `hedera`.`orderRowComponent`(`rowFk`, `componentFk`, `price`) (4, 21, -0.001), (4, 28, 20.72), (4, 29, -19.72), - (4, 37, 2), - (4, 39, 0.01), + (4, 37, 2), + (4, 39, 0.01), (5, 15, 0.58), (5, 23, 6.5), (5, 28, 20.72), @@ -1704,7 +1704,7 @@ INSERT INTO `vn`.`workerManaExcluded`(`workerFk`) La otra manera es poner el calculo con los 2 trabajadores que utilizamos ahora mismo para los tickets */ -call vn.manaSpellersRequery(19); +call vn.manaSpellersRequery(19); call vn.manaSpellersRequery(18); INSERT INTO `vn`.`clientSample`(`id`, `clientFk`, `typeFk`, `created`, `workerFk`, `userFk`, `companyFk`) @@ -1772,8 +1772,8 @@ INSERT INTO `hedera`.`tpvMerchant`(`id`, `description`, `companyFk`, `bankFk`, ` (1, 'Arkham Bank', 442, 1, 'h12387193H10238'), (2, 'NewYork Bank', 442, 1, '7981ugsgd1hsdad'); -INSERT INTO `hedera`.`tpvTransaction`(`id`,`merchantFk`, `clientFk`,`receiptFk`, `amount`, `response`, `errorCode`, `status`, `created`) - VALUES +INSERT INTO `hedera`.`tpvTransaction`(`id`,`merchantFk`, `clientFk`,`receiptFk`, `amount`, `response`, `errorCode`, `status`, `created`) + VALUES (1, 1, 1101, NULL, 2000, NULL, 'SIS0042', 'ok', util.VN_CURDATE()), (2, 1, 1101, NULL, 1000, NULL, 'SIS0051', 'started', util.VN_CURDATE()), (3, 2, 1101, NULL, 7268, NULL, NULL, 'ok', util.VN_CURDATE()), @@ -1787,32 +1787,32 @@ INSERT INTO `vn`.`orderTicket`(`orderFk`, `ticketFk`) (2, 2), (3, 3), (4, 4), - (5, 5), - (6, 6), - (7, 7), - (8, 8), - (9, 9), - (10, 10), - (11, 11), - (12, 12), - (13, 13), - (14, 14), + (5, 5), + (6, 6), + (7, 7), + (8, 8), + (9, 9), + (10, 10), + (11, 11), + (12, 12), + (13, 13), + (14, 14), (15, 15), (16, 16), (17, 17), (18, 18), (19, 19), - (20, 20), - (21, 21), + (20, 20), + (21, 21), (22, 22); -INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`) +INSERT INTO `vn`.`userConfig` (`userFk`, `warehouseFk`, `companyFk`) VALUES (1, 1, 69), - (5, 1, 442), + (5, 1, 442), (9, 1, 442), (18, 3, 567); - + INSERT INTO `vn`.`receipt`(`id`, `invoiceFk`, `amountPaid`, `payed`, `workerFk`, `bankFk`, `clientFk`, `created`, `companyFk`, `isConciliate`) VALUES (1, 'Cobro web', 100.50, util.VN_CURDATE(), 9, 1, 1101, util.VN_CURDATE(), 442, 1), @@ -1895,14 +1895,14 @@ INSERT INTO `postgresql`.`business_labour` (`business_id`, `notes`, `department_ VALUES (1111, NULL, 23, 1, 0.0, 1, 1, 1, 1); -UPDATE `postgresql`.`business_labour` bl +UPDATE `postgresql`.`business_labour` bl JOIN `postgresql`.`business` b ON b.business_id = bl.business_id JOIN `postgresql`.`profile` pr ON pr.profile_id = b.client_id JOIN `postgresql`.`person` p ON p.person_id = pr.person_id SET bl.`professional_category_id` = 31 WHERE p.`Id_trabajador` = 1110; -UPDATE `postgresql`.`business_labour` bl +UPDATE `postgresql`.`business_labour` bl SET bl.`department_id` = 43 WHERE business_id IN(18, 19); @@ -1917,18 +1917,18 @@ INSERT INTO `postgresql`.`profile_media`(`profile_media_id`, `profile_id`, `medi (2, 1107, 2); INSERT INTO `vn`.`workCenterHoliday` (`workCenterFk`, `days`, `year`) - VALUES + VALUES ('1', '27.5', YEAR(util.VN_CURDATE())), ('5', '22', YEAR(util.VN_CURDATE())), - ('1', '24.5', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))), + ('1', '24.5', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))), ('5', '23', YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR))); -INSERT INTO `vn`.`absenceType` (`id`, `name`, `rgb`, `code`, `holidayEntitlementRate`, `discountRate`) - VALUES +INSERT INTO `vn`.`absenceType` (`id`, `name`, `rgb`, `code`, `holidayEntitlementRate`, `discountRate`) + VALUES (1, 'Holidays', '#FF4444', 'holiday', 0, 0), (2, 'Leave of absence', '#C71585', 'absence', 0, 1), (6, 'Half holiday', '#E65F00', 'halfHoliday', 0, 0.5), - (15, 'Half Paid Leave', '#5151c0', 'halfPaidLeave', 0, 1), + (15, 'Half Paid Leave', '#5151c0', 'halfPaidLeave', 0, 1), (20, 'Furlough', '#97B92F', 'furlough', 1, 1), (21, 'Furlough half day', '#778899', 'halfFurlough', 0.5, 1); @@ -1945,10 +1945,10 @@ INSERT INTO `postgresql`.`business_labour_payroll` (`business_id`, `cod_tarifa`, (1, 7, 12, 100, 900.50), (1106, 7, 12, 100, 1263.03), (1107, 7, 12, 100, 2000), - (1108, 7, 12, 100, 1500); + (1108, 7, 12, 100, 1500); -INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id`, `date`) - VALUES +INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id`, `date`) + VALUES (1, 6, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))), (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -10 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 10 DAY))), (1106, 1, IF(MONTH(util.VN_CURDATE()) = 12 AND DAY(util.VN_CURDATE()) > 10, DATE_ADD(util.VN_CURDATE(), INTERVAL -11 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 11 DAY))), @@ -1966,8 +1966,8 @@ INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id` (1107, 2, IF(MONTH(util.VN_CURDATE()) >= 1 AND DAY(util.VN_CURDATE()) > 20, DATE_ADD(util.VN_CURDATE(), INTERVAL -15 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL 7 DAY))), (1107, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL - 16 DAY)); -INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`, `apiKey`) - VALUES +INSERT INTO `vn`.`smsConfig` (`id`, `uri`, `title`, `apiKey`) + VALUES ('1', 'https://api.gateway360.com/api/3.0/sms/send', 'Verdnatura', '5715476da95b46d686a5a255e6459523'); INSERT INTO `vn`.`sharingClient`(`id`, `workerFk`, `started`, `ended`, `clientFk`) @@ -1983,37 +1983,37 @@ CALL `vn`.zoneGeo_calcTree(); -- this is an auto calculate for table vn.zoneGeo, INSERT INTO `vn`.`zoneIncluded` (`zoneFk`, `geoFk`, `isIncluded`) VALUES - (1, 3, 0), - (1, 4, 0), - (1, 5, 0), + (1, 3, 0), + (1, 4, 0), + (1, 5, 0), (1, 1, 1), - (2, 3, 0), - (2, 4, 0), - (2, 5, 0), + (2, 3, 0), + (2, 4, 0), + (2, 5, 0), (2, 1, 1), - (3, 3, 0), - (3, 4, 0), - (3, 5, 0), + (3, 3, 0), + (3, 4, 0), + (3, 5, 0), (3, 1, 1), - (4, 3, 0), - (4, 4, 0), - (4, 5, 0), + (4, 3, 0), + (4, 4, 0), + (4, 5, 0), (4, 1, 1), - (5, 3, 1), - (5, 4, 0), - (5, 5, 1), + (5, 3, 1), + (5, 4, 0), + (5, 5, 1), (5, 1, 1), - (6, 3, 1), - (6, 4, 0), - (6, 5, 1), + (6, 3, 1), + (6, 4, 0), + (6, 5, 1), (6, 1, 1), - (7, 3, 0), - (7, 4, 0), - (7, 5, 0), + (7, 3, 0), + (7, 4, 0), + (7, 5, 0), (7, 1, 1), - (8, 3, 0), - (8, 4, 0), - (8, 5, 0), + (8, 3, 0), + (8, 4, 0), + (8, 5, 0), (8, 1, 1), (10, 14, 1); @@ -2226,12 +2226,12 @@ INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `dated`) (7, 'day', DATE_ADD(util.VN_CURDATE(), INTERVAL +6 DAY)); INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `weekDays`) - VALUES + VALUES (8, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun'), (10, 'indefinitely', 'mon,tue,wed,thu,fri,sat,sun'); INSERT INTO `vn`.`zoneEvent`(`zoneFk`, `type`, `started`, `ended`) - VALUES + VALUES (9, 'range', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR)); INSERT INTO `vn`.`workerTimeControl`(`userFk`, `timed`, `manual`, `direction`) @@ -2294,8 +2294,8 @@ INSERT INTO `vn`.`workerDocument`(`id`, `worker`, `document`,`isReadableByWorker (1, 1106, 4, TRUE), (2, 1107, 3, FALSE); -INSERT INTO `vn`.`device` (`sn`, `model`, `userFk`) - VALUES +INSERT INTO `vn`.`device` (`sn`, `model`, `userFk`) + VALUES ('aaa', 'android', '9'); INSERT INTO `vn`.`queuePriority`(`id`, `priority`) @@ -2309,7 +2309,7 @@ INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `week (1, 43200, 129600, 734400, 43200, 50400, 259200, 1296000, 36000); INSERT IGNORE INTO `vn`.`greugeConfig` (`id`, `freightPickUpPrice`) VALUES ('1', '11'); - + INSERT INTO `vn`.`thermograph`(`id`, `model`) VALUES ('TMM190901395', 'TEMPMATE'), @@ -2327,21 +2327,21 @@ INSERT INTO `vn`.`travelThermograph`(`thermographFk`, `created`, `warehouseFk`, ('138350-0', DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 'WARM', NULL, 5), ('138350-0', util.VN_CURDATE(), 1, NULL, 'COOL', NULL, NULL); -REPLACE INTO `vn`.`incoterms`(`code`, `name`) - VALUES +REPLACE INTO `vn`.`incoterms`(`code`, `name`) + VALUES ('FAS', 'Free Alongside Ship'); -REPLACE INTO `vn`.`customsAgent`(`id`, `fiscalName`, `street`, `nif`, `phone`, `email`) - VALUES +REPLACE INTO `vn`.`customsAgent`(`id`, `fiscalName`, `street`, `nif`, `phone`, `email`) + VALUES (1, 'Agent one', '1007 Mountain Drive, Gotham', 'N1111111111', '111111111', 'agentone@gotham.com'), (2, 'Agent two', '1007 Mountain Drive, Gotham', 'N2222222222', '222222222', 'agenttwo@gotham.com'); -INSERT INTO `vn`.`tablet`(`uuid`, `name`, `place`, `macwifi`) - VALUES +INSERT INTO `vn`.`tablet`(`uuid`, `name`, `place`, `macwifi`) + VALUES ('1', 'TEST', 'ON THE FIXTURES', '0'), ('2', 'DEV', 'OTHER TABLET', '0'); -INSERT INTO `vn`.`tabletDepartment`(`tabletFk`, `departmentFk`) +INSERT INTO `vn`.`tabletDepartment`(`tabletFk`, `departmentFk`) VALUES (1, 23), (2, 1); @@ -2374,8 +2374,8 @@ INSERT INTO `vn`.`rate`(`dated`, `warehouseFk`, `rate0`, `rate1`, `rate2`, `rate (DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR), 1, 10, 15, 20, 25), (util.VN_CURDATE(), 1, 12, 17, 22, 27); -INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk) - VALUES +INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk, taxFk) + VALUES (1, '07546501420', 67, 671, util.VN_CURDATE(), 1761, 1, 1), (2, '07546491421', 252, 2769, util.VN_CURDATE(), 5231, 1, 1), (3, '07546500823', 102, 1495, util.VN_CURDATE(), 3221, 1, 1), @@ -2387,8 +2387,8 @@ INSERT INTO `vn`.`awb` (id, code, package, weight, created, amount, transitoryFk (9, '99610289193', 302, 2972, util.VN_CURDATE(), 3871, 442, 1), (10, '07546500856', 185, 2364, util.VN_CURDATE(), 5321, 442, 1); -INSERT INTO `vn`.`dua` (id, code, awbFk, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk) - VALUES +INSERT INTO `vn`.`dua` (id, code, awbFk, issued, operated, booked, bookEntried, gestdocFk, customsValue, companyFk) + VALUES (1, '19ES0028013A481523', 1, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 1, 11276.95, 442), (2, '21ES00280136115760', 2, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 2, 1376.20, 442), (3, '19ES00280131956004', 3, util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), util.VN_CURDATE(), 3, 14268.50, 442), @@ -2435,8 +2435,8 @@ INSERT INTO `vn`.`duaInvoiceIn`(`id`, `duaFk`, `invoiceInFk`) (4, 4, 4), (5, 5, 5), (6, 6, 6), - (7, 7, 7), - (8, 8, 8), + (7, 7, 7), + (8, 8, 8), (9, 9, 9), (10, 10, 10); @@ -2446,7 +2446,7 @@ INSERT INTO `vn`.`invoiceInTax` (`invoiceInFk`, `taxableBase`, `expenceFk`, `for (2, 999.99, '2000000000', null, null, null), (3, 1000.50, '2000000000', null, null, null), (4, 0.50, '2000000000', null, null, null), - (5, 150.50, '2000000000', null, null, null), + (5, 150.50, '2000000000', null, null, null), (1, 252.25, '4751000000', NULL, 7, 61), (2, 223.17, '6210000567', NULL, 8, 20), (3, 95.60, '7001000000', NULL, 8, 35), @@ -2461,9 +2461,9 @@ INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amo (1, 10, 6021010, 20.00, 205, 5), (2, 13.20, 5080000, 15.00, 580, 5), (2, 16.10, 6021010, 25.00, 80, 5); - + INSERT INTO `vn`.`ticketRecalc`(`ticketFk`) - SELECT `id` + SELECT `id` FROM `vn`.`ticket` t LEFT JOIN vn.ticketRecalc tr ON tr.ticketFk = t.id WHERE tr.ticketFk IS NULL; @@ -2478,7 +2478,7 @@ INSERT INTO `vn`.`zoneAgencyMode`(`id`, `agencyModeFk`, `zoneFk`) (4, 7, 1); INSERT INTO `vn`.`expeditionTruck` (`id`, `ETD`, `description`) - VALUES + VALUES (1, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +3 YEAR))), 'Best truck in fleet'); INSERT INTO `vn`.`expeditionPallet` (`id`, `truckFk`, `built`, `position`, `isPrint`) @@ -2486,7 +2486,7 @@ INSERT INTO `vn`.`expeditionPallet` (`id`, `truckFk`, `built`, `position`, `isPr (1, 1, util.VN_CURDATE(), 1, 1); INSERT INTO `vn`.`expeditionScan` (`id`, `expeditionFk`, `scanned`, `palletFk`) - VALUES + VALUES (1, 1, util.VN_CURDATE(), 1), (2, 2, util.VN_CURDATE(), 1), (3, 3, util.VN_CURDATE(), 1), @@ -2521,7 +2521,7 @@ UPDATE `vn`.`route` INSERT INTO `bs`.`salesPerson` (`workerFk`, `year`, `month`, `portfolioWeight`) VALUES (18, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 807.23), - (19, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 34.40); + (19, YEAR(util.VN_CURDATE()), MONTH(util.VN_CURDATE()), 34.40); INSERT INTO `bs`.`sale` (`saleFk`, `amount`, `dated`, `typeFk`, `clientFk`) VALUES @@ -2550,14 +2550,14 @@ INSERT INTO `vn`.`calendarHolidaysType` (`id`, `name`, `hexColour`) INSERT INTO `vn`.`calendarHolidays` (`id`, `calendarHolidaysTypeFk`, `dated`, `calendarHolidaysNameFk`, `workCenterFk`) VALUES (1, 1, CONCAT(YEAR(util.VN_CURDATE()), '-12-09'), 1, 1); - + INSERT INTO `vn`.`supplierAgencyTerm` (`agencyFk`, `supplierFk`, `minimumPackages`, `kmPrice`, `packagePrice`, `routePrice`, `minimumKm`, `minimumM3`, `m3Price`) VALUES (1, 1, 0, 0.00, 0.00, NULL, 0, 0.00, 23), (2, 1, 60, 0.00, 0.00, NULL, 0, 5.00, 33), (3, 2, 0, 15.00, 0.00, NULL, 0, 0.00, 0), (4, 2, 0, 20.00, 0.00, NULL, 0, 0.00, 0), - (5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0); + (5, 442, 0, 0.00, 3.05, NULL, 0, 0.00, 0); INSERT INTO `vn`.`chat` (`senderFk`, `recipient`, `dated`, `checkUserStatus`, `message`, `status`, `attempts`) VALUES @@ -2607,7 +2607,16 @@ INSERT INTO `vn`.`sectorCollection` (`userFk`, `sectorFk`) INSERT INTO `vn`.`sectorCollectionSaleGroup` (`sectorCollectionFk`, `saleGroupFk`) VALUES (1, 1); - + INSERT INTO `vn`.`workerTimeControlConfig` (`id`, `dayBreak`, `dayBreakDriver`, `shortWeekBreak`, `longWeekBreak`, `weekScope`, `mailPass`, `mailHost`, `mailSuccessFolder`, `mailErrorFolder`, `mailUser`, `minHoursToBreak`, `breakHours`, `hoursCompleteWeek`, `startNightlyHours`, `endNightlyHours`, `maxTimePerDay`, `breakTime`, `timeToBreakTime`, `dayMaxTime`, `shortWeekDays`, `longWeekDays`) VALUES - (1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13); \ No newline at end of file + (1, 43200, 32400, 129600, 259200, 604800, '', '', 'Leidos.exito', 'Leidos.error', 'timeControl', 5.33, 0.33, 40, '22:00:00', '06:00:00', 57600, 1200, 18000, 57600, 6, 13); + +INSERT INTO `vn`.`host` (`id`, `code`, `description`, `warehouseFk`, `bankFk`) + VALUES + (1, 'pc1', 'pc host', 1, 1); + +INSERT INTO `vn`.`packingSite` (`id`, `code`, `hostFk`, `monitorId`) + VALUES + (1, 'h1', 1, 'VbiUcajdaT'); + diff --git a/modules/ticket/back/methods/boxing/getVideo.js b/modules/ticket/back/methods/boxing/getVideo.js index 4e2a4b12c..bdd0107f3 100644 --- a/modules/ticket/back/methods/boxing/getVideo.js +++ b/modules/ticket/back/methods/boxing/getVideo.js @@ -18,10 +18,23 @@ module.exports = Self => { description: 'Time to add' } ], - returns: { - type: ['object'], - root: true, - }, + returns: [ + { + arg: 'body', + type: 'file', + root: true + }, + { + arg: 'Content-Type', + type: 'String', + http: {target: 'header'} + }, + { + arg: 'Content-Disposition', + type: 'String', + http: {target: 'header'} + } + ], http: { path: `/getVideo`, verb: 'GET', @@ -37,31 +50,33 @@ module.exports = Self => { const expedition = await models.Expedition.findById(id, null, myOptions); const packingSiteConfig = await models.PackingSiteConfig.findOne({}, myOptions); - const token = 'BW4o7FZyJ85she1hlRDe6QnwW3jwEP'; - const groupKey = 'xVqft9LFXg'; - const monitorId = 'VbiUcajdaT';// 'xVqft9LFXg'; + const monitorId = 'VbiUcajdaT'; + console.log(packingSiteConfig); - const start = '2022-07-27T09:00:00';// new Date('2022-07-27'); // new Date(expedition.created); - const end = '2022-07-27T09:15:00';// start.setTime(start.getTime() + (time ? time : packingSiteConfig.avgBoxingTime)); + const addTime = (time ? time : packingSiteConfig.avgBoxingTime) * 1000; + const start = new Date(expedition.created);// '2022-07-27T09:00:00';// new Date('2022-07-27'); // + const end = new Date(start.getTime() + addTime); + console.log(addTime); + console.log(start.toISOString().split('.')[0]); + console.log(end.toISOString().split('.')[0]); - const videoUrl = `/${token}/videos/${groupKey}/${monitorId}?start=${start}&end=${end}`; - const url = `${packingSiteConfig.shinobiUrl}${videoUrl}`; - const data = await axios.post(url); + const videoUrl = `/${packingSiteConfig.shinobiToken}/videos/${packingSiteConfig.shinobiGroupKey}/${monitorId}`; + const timeUrl = `?start=${start.toISOString().split('.')[0]}&end=${end.toISOString().split('.')[0]}`; + const url = `${packingSiteConfig.shinobiUrl}${videoUrl}${timeUrl}&endIsStartTo`; - console.log(data.data.videos); - console.log('-----------------------'); - console.log('-----------------------'); - console.log('-----------------------'); - console.log('-----------------------'); - - axios({ + console.log(url); + const videoList = await axios.post(url); + console.log(videoList.data); + const lastVideo = videoList.data.videos[videoList.data.videos.length - 1].href; + console.log(lastVideo); + const stream = await axios({ method: 'get', - url: `${packingSiteConfig.shinobiUrl}${data.data.videos[0].href}`, + url: `${packingSiteConfig.shinobiUrl}${lastVideo}`, responseType: 'stream' - }) - .then(response => { - console.log(response); - return response; - }); + }).then(response => { + return response.data; + }); + + return [stream, 'video/mp4', `filename="${id}.mp4"`]; }; }; diff --git a/modules/ticket/back/models/packingSiteConfig.json b/modules/ticket/back/models/packingSiteConfig.json index 7e4699c71..8f0032d41 100644 --- a/modules/ticket/back/models/packingSiteConfig.json +++ b/modules/ticket/back/models/packingSiteConfig.json @@ -18,6 +18,9 @@ "shinobiGroupKey":{ "type":"string" }, + "shinobiToken":{ + "type":"string" + }, "avgBoxingTime":{ "type":"number" } diff --git a/modules/ticket/front/boxing/index.html b/modules/ticket/front/boxing/index.html index e47976cd7..17b2b475a 100644 --- a/modules/ticket/front/boxing/index.html +++ b/modules/ticket/front/boxing/index.html @@ -1,5 +1,5 @@ - From b4b6d61460e347e8abc68b706968ed315e560072 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 3 Aug 2022 14:57:39 +0200 Subject: [PATCH 09/93] feat(ticket_boxing): fix getVideo --- .../ticket/back/methods/boxing/getVideo.js | 77 +++++++++++-------- modules/ticket/front/boxing/index.js | 2 +- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/modules/ticket/back/methods/boxing/getVideo.js b/modules/ticket/back/methods/boxing/getVideo.js index bdd0107f3..91d538782 100644 --- a/modules/ticket/back/methods/boxing/getVideo.js +++ b/modules/ticket/back/methods/boxing/getVideo.js @@ -1,4 +1,5 @@ const axios = require('axios'); +const https = require('https'); module.exports = Self => { Self.remoteMethod('getVideo', { @@ -16,23 +17,16 @@ module.exports = Self => { type: 'number', required: false, description: 'Time to add' - } - ], - returns: [ - { - arg: 'body', - type: 'file', - root: true }, { - arg: 'Content-Type', - type: 'String', - http: {target: 'header'} + arg: 'req', + type: 'object', + http: {source: 'req'} }, { - arg: 'Content-Disposition', - type: 'String', - http: {target: 'header'} + arg: 'res', + type: 'object', + http: {source: 'res'} } ], http: { @@ -41,42 +35,59 @@ module.exports = Self => { }, }); - Self.getVideo = async(id, time, options) => { + Self.getVideo = async(id, time, req, res, options) => { const models = Self.app.models; const myOptions = {}; - console.log('ENTRY'); + // console.log('ENTRY'); if (typeof options == 'object') Object.assign(myOptions, options); const expedition = await models.Expedition.findById(id, null, myOptions); const packingSiteConfig = await models.PackingSiteConfig.findOne({}, myOptions); - const monitorId = 'VbiUcajdaT'; - console.log(packingSiteConfig); + const monitorId = 'Xme2hiqz1f'; + // console.log(packingSiteConfig); const addTime = (time ? time : packingSiteConfig.avgBoxingTime) * 1000; const start = new Date(expedition.created);// '2022-07-27T09:00:00';// new Date('2022-07-27'); // const end = new Date(start.getTime() + addTime); - console.log(addTime); - console.log(start.toISOString().split('.')[0]); - console.log(end.toISOString().split('.')[0]); + // console.log(addTime); + // console.log(start.toString().split('.')[0]); + // console.log(end.toString().split('.')[0]); const videoUrl = `/${packingSiteConfig.shinobiToken}/videos/${packingSiteConfig.shinobiGroupKey}/${monitorId}`; - const timeUrl = `?start=${start.toISOString().split('.')[0]}&end=${end.toISOString().split('.')[0]}`; + const timeUrl = `?start=${start.toString().split('.')[0]}&end=${end.toString().split('.')[0]}`; const url = `${packingSiteConfig.shinobiUrl}${videoUrl}${timeUrl}&endIsStartTo`; - console.log(url); + // console.log(url); const videoList = await axios.post(url); - console.log(videoList.data); - const lastVideo = videoList.data.videos[videoList.data.videos.length - 1].href; - console.log(lastVideo); - const stream = await axios({ - method: 'get', - url: `${packingSiteConfig.shinobiUrl}${lastVideo}`, - responseType: 'stream' - }).then(response => { - return response.data; - }); + // console.log('videoList.data', videoList.data); + // console.log(videoList.data.videos); + // console.log(videoList.data.videos.length); + const length = videoList.data.videos.length; + // console.log(length); + if (!length) return []; - return [stream, 'video/mp4', `filename="${id}.mp4"`]; + const lastVideo = videoList.data.videos[length - 1].href; + + const headers = Object.assign({}, req.headers, { + host: 'shinobi.verdnatura.es' + }); + const httpOptions = { + host: 'shinobi.verdnatura.es', + path: '/BW4o7FZyJ85she1hlRDe6QnwW3jwEP/videos/xVqft9LFXg/Xme2hiqz1f/2022-08-02T11-45-01.mp4', + port: 443, + headers + }; + + return new Promise((resolve, reject) => { + const req = https.request(httpOptions, + shinobiRes => { + shinobiRes.pause(); + res.writeHeader(shinobiRes.statusCode, shinobiRes.headers); + shinobiRes.pipe(res); + resolve(); + }); + req.end(); + }); }; }; diff --git a/modules/ticket/front/boxing/index.js b/modules/ticket/front/boxing/index.js index 722301963..686bf7d01 100644 --- a/modules/ticket/front/boxing/index.js +++ b/modules/ticket/front/boxing/index.js @@ -7,7 +7,7 @@ class Controller extends Section { } $onInit() { - // window.location.href = this.lilium('dashboard'); + window.location.href = this.lilium(`ticket/${this.ticket.id}/boxing`); } lilium(route) { From 43df1e7e102000214bb89b94c17a33e3354de164 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 5 Sep 2022 12:06:14 +0200 Subject: [PATCH 10/93] refactor(boxing): refactor getVideo --- .../00-packingSiteConfig.sql | 3 +- .../00-packingSiteUpdate.sql | 0 .../ticket/back/methods/boxing/getVideo.js | 72 +++++++++---------- .../back/methods/boxing/getVideoList.js | 17 ++--- modules/ticket/back/models/boxing.js | 1 + 5 files changed, 47 insertions(+), 46 deletions(-) rename db/changes/{10480-june => 10490-august}/00-packingSiteConfig.sql (94%) rename db/changes/{10480-june => 10490-august}/00-packingSiteUpdate.sql (100%) diff --git a/db/changes/10480-june/00-packingSiteConfig.sql b/db/changes/10490-august/00-packingSiteConfig.sql similarity index 94% rename from db/changes/10480-june/00-packingSiteConfig.sql rename to db/changes/10490-august/00-packingSiteConfig.sql index 28e685eb6..bbd0b32de 100644 --- a/db/changes/10480-june/00-packingSiteConfig.sql +++ b/db/changes/10490-august/00-packingSiteConfig.sql @@ -7,9 +7,8 @@ CREATE TABLE `vn`.`packingSiteConfig` ( PRIMARY KEY (`id`) ); - INSERT INTO `vn`.`packingSiteConfig` SET - shinobiUrl = 'http://shinobi.verdnatura.es', + shinobiUrl = 'https://shinobi.verdnatura.es', shinobiToken = 'BW4o7FZyJ85she1hlRDe6QnwW3jwEP', shinobiGroupKey = 'xVqft9LFXg', avgBoxingTime = 30; diff --git a/db/changes/10480-june/00-packingSiteUpdate.sql b/db/changes/10490-august/00-packingSiteUpdate.sql similarity index 100% rename from db/changes/10480-june/00-packingSiteUpdate.sql rename to db/changes/10490-august/00-packingSiteUpdate.sql diff --git a/modules/ticket/back/methods/boxing/getVideo.js b/modules/ticket/back/methods/boxing/getVideo.js index 91d538782..8cecbad4d 100644 --- a/modules/ticket/back/methods/boxing/getVideo.js +++ b/modules/ticket/back/methods/boxing/getVideo.js @@ -9,13 +9,13 @@ module.exports = Self => { { arg: 'id', type: 'number', - required: false, + required: true, description: 'Ticket id' }, { - arg: 'time', - type: 'number', - required: false, + arg: 'filename', + type: 'string', + required: true, description: 'Time to add' }, { @@ -35,58 +35,58 @@ module.exports = Self => { }, }); - Self.getVideo = async(id, time, req, res, options) => { + Self.getVideo = async(id, filename, req, res, options) => { const models = Self.app.models; const myOptions = {}; - // console.log('ENTRY'); + + console.log('getFile', filename); if (typeof options == 'object') Object.assign(myOptions, options); - const expedition = await models.Expedition.findById(id, null, myOptions); const packingSiteConfig = await models.PackingSiteConfig.findOne({}, myOptions); - const monitorId = 'Xme2hiqz1f'; - // console.log(packingSiteConfig); - const addTime = (time ? time : packingSiteConfig.avgBoxingTime) * 1000; - const start = new Date(expedition.created);// '2022-07-27T09:00:00';// new Date('2022-07-27'); // - const end = new Date(start.getTime() + addTime); - // console.log(addTime); - // console.log(start.toString().split('.')[0]); - // console.log(end.toString().split('.')[0]); + const query = ` + SELECT + e.id, + ps.monitorId, + e.created + FROM expedition e + JOIN host h ON Convert(h.code USING utf8mb3) COLLATE utf8mb3_unicode_ci = e.hostFk + JOIN packingSite ps ON ps.hostFk = h.id + WHERE e.id = ?;`; + const [expedition] = await models.Expedition.rawSql(query, [id]); - const videoUrl = `/${packingSiteConfig.shinobiToken}/videos/${packingSiteConfig.shinobiGroupKey}/${monitorId}`; - const timeUrl = `?start=${start.toString().split('.')[0]}&end=${end.toString().split('.')[0]}`; - const url = `${packingSiteConfig.shinobiUrl}${videoUrl}${timeUrl}&endIsStartTo`; + const monitorId = '6Ou0D1bhBw'; // expedition.monitorId - // console.log(url); - const videoList = await axios.post(url); - // console.log('videoList.data', videoList.data); - // console.log(videoList.data.videos); - // console.log(videoList.data.videos.length); - const length = videoList.data.videos.length; - // console.log(length); - if (!length) return []; - - const lastVideo = videoList.data.videos[length - 1].href; + const videoUrl = + `/${packingSiteConfig.shinobiToken}/videos/${packingSiteConfig.shinobiGroupKey}/${monitorId}/${filename}`; const headers = Object.assign({}, req.headers, { host: 'shinobi.verdnatura.es' }); const httpOptions = { host: 'shinobi.verdnatura.es', - path: '/BW4o7FZyJ85she1hlRDe6QnwW3jwEP/videos/xVqft9LFXg/Xme2hiqz1f/2022-08-02T11-45-01.mp4', + path: videoUrl, port: 443, headers }; + console.log('shinobi.verdnatura.es' + videoUrl); return new Promise((resolve, reject) => { - const req = https.request(httpOptions, - shinobiRes => { - shinobiRes.pause(); - res.writeHeader(shinobiRes.statusCode, shinobiRes.headers); - shinobiRes.pipe(res); - resolve(); - }); + const req = https.request(httpOptions, shinobiRes => { + console.log('entry'); + shinobiRes.pause(); + res.writeHeader(shinobiRes.statusCode, shinobiRes.headers); + shinobiRes.pipe(res); + }); + + req.on('error', error => { + console.error(error); + }); + + req.on('end', res => { + resolve(); + }); req.end(); }); }; diff --git a/modules/ticket/back/methods/boxing/getVideoList.js b/modules/ticket/back/methods/boxing/getVideoList.js index cdc3555a7..4e74f76ec 100644 --- a/modules/ticket/back/methods/boxing/getVideoList.js +++ b/modules/ticket/back/methods/boxing/getVideoList.js @@ -33,7 +33,7 @@ module.exports = Self => { Self.getVideoList = async(id, from, to, options) => { const myOptions = {}; - console.log(id); + if (typeof options == 'object') Object.assign(myOptions, options); @@ -67,14 +67,15 @@ module.exports = Self => { const videoUrl = `/${packingSiteConfig.shinobiToken}/videos/${packingSiteConfig.shinobiGroupKey}/${monitorId}`; const timeUrl = `?start=${start.toISOString().split('.')[0]}&end=${end.toISOString().split('.')[0]}`; const url = `${packingSiteConfig.shinobiUrl}${videoUrl}${timeUrl}`; - console.log(url); - console.log('try get'); - const response = await axios(url).then(res => { - return res; - }); - console.log('finish get'); + let response; - console.log(response); + try { + response = await axios.get(url); + } catch (e) { + console.log(e); + return []; + } + return response.data.videos.map(video => video.filename); }; }; diff --git a/modules/ticket/back/models/boxing.js b/modules/ticket/back/models/boxing.js index 81732d17a..c251ea0e4 100644 --- a/modules/ticket/back/models/boxing.js +++ b/modules/ticket/back/models/boxing.js @@ -1,3 +1,4 @@ module.exports = Self => { require('../methods/boxing/getVideo')(Self); + require('../methods/boxing/getVideoList')(Self); }; From 8dd02ab6ee2707ce1ebdfabb6020a22bcf3d16eb Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 6 Sep 2022 15:08:28 +0200 Subject: [PATCH 11/93] quit console.logs --- modules/ticket/back/methods/boxing/getVideo.js | 13 ++++--------- modules/ticket/back/methods/boxing/getVideoList.js | 11 ++++------- modules/ticket/front/boxing/index.html | 3 --- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/modules/ticket/back/methods/boxing/getVideo.js b/modules/ticket/back/methods/boxing/getVideo.js index 8cecbad4d..cdd46b257 100644 --- a/modules/ticket/back/methods/boxing/getVideo.js +++ b/modules/ticket/back/methods/boxing/getVideo.js @@ -1,4 +1,3 @@ -const axios = require('axios'); const https = require('https'); module.exports = Self => { @@ -39,7 +38,6 @@ module.exports = Self => { const models = Self.app.models; const myOptions = {}; - console.log('getFile', filename); if (typeof options == 'object') Object.assign(myOptions, options); @@ -55,8 +53,7 @@ module.exports = Self => { JOIN packingSite ps ON ps.hostFk = h.id WHERE e.id = ?;`; const [expedition] = await models.Expedition.rawSql(query, [id]); - - const monitorId = '6Ou0D1bhBw'; // expedition.monitorId + const monitorId = expedition.monitorId; const videoUrl = `/${packingSiteConfig.shinobiToken}/videos/${packingSiteConfig.shinobiGroupKey}/${monitorId}/${filename}`; @@ -70,21 +67,19 @@ module.exports = Self => { port: 443, headers }; - console.log('shinobi.verdnatura.es' + videoUrl); return new Promise((resolve, reject) => { const req = https.request(httpOptions, shinobiRes => { - console.log('entry'); shinobiRes.pause(); res.writeHeader(shinobiRes.statusCode, shinobiRes.headers); shinobiRes.pipe(res); }); - req.on('error', error => { - console.error(error); + req.on('error', () => { + reject(); }); - req.on('end', res => { + req.on('end', () => { resolve(); }); req.end(); diff --git a/modules/ticket/back/methods/boxing/getVideoList.js b/modules/ticket/back/methods/boxing/getVideoList.js index 4e74f76ec..be6d48c46 100644 --- a/modules/ticket/back/methods/boxing/getVideoList.js +++ b/modules/ticket/back/methods/boxing/getVideoList.js @@ -1,5 +1,4 @@ const axios = require('axios'); -const https = require('https'); const models = require('vn-loopback/server/server').models; module.exports = Self => { @@ -49,9 +48,7 @@ module.exports = Self => { JOIN packingSite ps ON ps.hostFk = h.id WHERE e.id = ?;`; const [expedition] = await models.PackingSiteConfig.rawSql(query, [id]); - - const monitorId = '6Ou0D1bhBw'; - console.log(id, expedition); + console.log(expedition); if (!from && !expedition) return []; let start = new Date(expedition.created); let end = new Date(start.getTime() + (packingSiteConfig.avgBoxingTime * 1000)); @@ -63,8 +60,9 @@ module.exports = Self => { const offset = start.getTimezoneOffset(); start = new Date(start.getTime() - (offset * 60 * 1000)); end = new Date(end.getTime() - (offset * 60 * 1000)); - console.log(start, end); - const videoUrl = `/${packingSiteConfig.shinobiToken}/videos/${packingSiteConfig.shinobiGroupKey}/${monitorId}`; + + const videoUrl = + `/${packingSiteConfig.shinobiToken}/videos/${packingSiteConfig.shinobiGroupKey}/${expedition.monitorId}`; const timeUrl = `?start=${start.toISOString().split('.')[0]}&end=${end.toISOString().split('.')[0]}`; const url = `${packingSiteConfig.shinobiUrl}${videoUrl}${timeUrl}`; @@ -73,7 +71,6 @@ module.exports = Self => { try { response = await axios.get(url); } catch (e) { - console.log(e); return []; } return response.data.videos.map(video => video.filename); diff --git a/modules/ticket/front/boxing/index.html b/modules/ticket/front/boxing/index.html index 17b2b475a..7fb3b870e 100644 --- a/modules/ticket/front/boxing/index.html +++ b/modules/ticket/front/boxing/index.html @@ -1,5 +1,2 @@ - From c06d2970ae91a3e4e3f44ec3d4d2c4de4721d86b Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 7 Sep 2022 13:58:39 +0200 Subject: [PATCH 12/93] test(boxing): getVideoList --- .../ticket/back/methods/boxing/getVideo.js | 2 +- .../back/methods/boxing/getVideoList.js | 4 +- .../back/methods/boxing/specs/getVideo.js | 69 ------------------- .../back/methods/boxing/specs/getVideoList.js | 35 ++++++++++ 4 files changed, 38 insertions(+), 72 deletions(-) delete mode 100644 modules/ticket/back/methods/boxing/specs/getVideo.js create mode 100644 modules/ticket/back/methods/boxing/specs/getVideoList.js diff --git a/modules/ticket/back/methods/boxing/getVideo.js b/modules/ticket/back/methods/boxing/getVideo.js index cdd46b257..6f471e837 100644 --- a/modules/ticket/back/methods/boxing/getVideo.js +++ b/modules/ticket/back/methods/boxing/getVideo.js @@ -2,7 +2,7 @@ const https = require('https'); module.exports = Self => { Self.remoteMethod('getVideo', { - description: 'Get packing video of ticketId', + description: 'Get packing video', accessType: 'READ', accepts: [ { diff --git a/modules/ticket/back/methods/boxing/getVideoList.js b/modules/ticket/back/methods/boxing/getVideoList.js index be6d48c46..3d45a720d 100644 --- a/modules/ticket/back/methods/boxing/getVideoList.js +++ b/modules/ticket/back/methods/boxing/getVideoList.js @@ -21,7 +21,7 @@ module.exports = Self => { required: false, } ], returns: { - type: ['Object'], + type: ['object'], root: true }, http: { @@ -48,7 +48,7 @@ module.exports = Self => { JOIN packingSite ps ON ps.hostFk = h.id WHERE e.id = ?;`; const [expedition] = await models.PackingSiteConfig.rawSql(query, [id]); - console.log(expedition); + if (!from && !expedition) return []; let start = new Date(expedition.created); let end = new Date(start.getTime() + (packingSiteConfig.avgBoxingTime * 1000)); diff --git a/modules/ticket/back/methods/boxing/specs/getVideo.js b/modules/ticket/back/methods/boxing/specs/getVideo.js deleted file mode 100644 index ad5295f0c..000000000 --- a/modules/ticket/back/methods/boxing/specs/getVideo.js +++ /dev/null @@ -1,69 +0,0 @@ -const models = require('vn-loopback/server/server').models; - -xdescribe('sale canEdit()', () => { - it('should return true if the role is production regardless of the saleTrackings', async() => { - const tx = await models.Sale.beginTransaction({}); - - try { - const options = {transaction: tx}; - - const productionUserID = 49; - const ctx = {req: {accessToken: {userId: productionUserID}}}; - - const sales = [{id: 3}]; - - const result = await models.Sale.canEdit(ctx, sales, options); - - expect(result).toEqual(true); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - - it('should return true if the role is not production and none of the sales has saleTracking', async() => { - const tx = await models.Sale.beginTransaction({}); - - try { - const options = {transaction: tx}; - - const salesPersonUserID = 18; - const ctx = {req: {accessToken: {userId: salesPersonUserID}}}; - - const sales = [{id: 10}]; - - const result = await models.Sale.canEdit(ctx, sales, options); - - expect(result).toEqual(true); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - - it('should return false if any of the sales has a saleTracking record', async() => { - const tx = await models.Sale.beginTransaction({}); - - try { - const options = {transaction: tx}; - - const salesPersonUserID = 18; - const ctx = {req: {accessToken: {userId: salesPersonUserID}}}; - - const sales = [{id: 3}]; - - const result = await models.Sale.canEdit(ctx, sales, options); - - expect(result).toEqual(false); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); -}); diff --git a/modules/ticket/back/methods/boxing/specs/getVideoList.js b/modules/ticket/back/methods/boxing/specs/getVideoList.js new file mode 100644 index 000000000..e703f4c03 --- /dev/null +++ b/modules/ticket/back/methods/boxing/specs/getVideoList.js @@ -0,0 +1,35 @@ +const models = require('vn-loopback/server/server').models; +const axios = require('axios'); + +describe('boxing getVideoList()', () => { + it('should return data', async() => { + const tx = await models.PackingSiteConfig.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const params = { + id: 1, + from: 1, + to: 2 + }; + + const response = { + data: { + pipe: () => {}, + on: () => {}, + } + }; + spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(response))); + + const result = await models.Sale.canEdit(params, options); + + expect(result).toEqual([]); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); From 2a64fde57c74836804c639e7cd21cc2b2f43064f Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 22 Sep 2022 14:58:38 +0200 Subject: [PATCH 13/93] feat: add option "move expedition" --- modules/ticket/front/expedition/index.html | 119 ++++++++++++--------- modules/ticket/front/expedition/index.js | 11 ++ 2 files changed, 82 insertions(+), 48 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index a41d368f6..37e64fad5 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -8,54 +8,77 @@ auto-load="true"> - - - - - - Expedition - Item - Name - Package type - Counter - externalId - Created - State - - - - - - - - - - {{expedition.id | zeroFill:6}} - - - {{expedition.packagingFk}} - - - {{::expedition.packageItemName}} - {{::expedition.freightItemName}} - {{::expedition.counter}} - {{::expedition.externalId}} - {{::expedition.created | date:'dd/MM/yyyy HH:mm'}} - {{::expedition.state}} - - - - - - - + + + + + + + + + +

Subtotal {{$ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}

+

VAT {{$ctrl.ticket.totalWithVat - $ctrl.ticket.totalWithoutVat | currency: 'EUR':2}}

+

Total {{$ctrl.ticket.totalWithVat | currency: 'EUR':2}}

+
+
+ + + + + + + + Expedition + Item + Name + Package type + Counter + externalId + Created + State + + + + + + + + + + {{expedition.id | zeroFill:6}} + + + {{expedition.packagingFk}} + + + {{::expedition.packageItemName}} + {{::expedition.freightItemName}} + {{::expedition.counter}} + {{::expedition.externalId}} + {{::expedition.created | date:'dd/MM/yyyy HH:mm'}} + {{::expedition.state}} + + + + + + +
Date: Fri, 23 Sep 2022 08:50:11 +0200 Subject: [PATCH 14/93] feat: add totalChecked --- modules/ticket/front/expedition/index.html | 20 ++++++++++++++++---- modules/ticket/front/expedition/index.js | 4 ++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 37e64fad5..3a5d5f8a6 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -12,12 +12,11 @@ + ng-show="$ctrl.totalChecked"> @@ -134,4 +133,17 @@ - \ No newline at end of file + + + + + New ticket without route + + + New ticket with route + + \ No newline at end of file diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index adbbc53d4..38d02f548 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -22,6 +22,10 @@ class Controller extends Section { return checkedRows; } + + get totalChecked() { + return this.checked.length; + } } ngModule.vnComponent('vnTicketExpedition', { From 2c691eb796b29fed91d2a96ed8dbcc57bccde866 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 26 Sep 2022 14:49:11 +0200 Subject: [PATCH 15/93] feat(vnApp): getUrl and create salix.url. test(boxing): getVideoList --- back/model-config.json | 3 ++ back/models/url.json | 25 ++++++++++++ .../10490-august/00-packingSiteConfig.sql | 2 +- db/changes/10490-august/00-salix_url.sql | 33 +++++++++++++++ front/core/services/app.js | 17 ++++++++ .../methods/boxing/specs/getVideo.spec.js | 40 +++++++++++++++++++ .../{getVideoList.js => getVideoList.spec.js} | 21 +++++----- modules/ticket/front/boxing/index.js | 17 ++------ 8 files changed, 133 insertions(+), 25 deletions(-) create mode 100644 back/models/url.json create mode 100644 db/changes/10490-august/00-salix_url.sql create mode 100644 modules/ticket/back/methods/boxing/specs/getVideo.spec.js rename modules/ticket/back/methods/boxing/specs/{getVideoList.js => getVideoList.spec.js} (58%) diff --git a/back/model-config.json b/back/model-config.json index f4adc954b..5f1c0bbe2 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -101,6 +101,9 @@ "Town": { "dataSource": "vn" }, + "Url": { + "dataSource": "vn" + }, "UserConfig": { "dataSource": "vn" }, diff --git a/back/models/url.json b/back/models/url.json new file mode 100644 index 000000000..8610ff28b --- /dev/null +++ b/back/models/url.json @@ -0,0 +1,25 @@ +{ + "name": "Url", + "base": "VnModel", + "options": { + "mysql": { + "table": "salix.url" + } + }, + "properties": { + "appName": { + "type": "string", + "required": true, + "id": 1 + }, + "environment": { + "type": "string", + "required": true, + "id": 2 + }, + "url": { + "type": "string", + "required": true + } + } +} diff --git a/db/changes/10490-august/00-packingSiteConfig.sql b/db/changes/10490-august/00-packingSiteConfig.sql index bbd0b32de..dc5e4c5cf 100644 --- a/db/changes/10490-august/00-packingSiteConfig.sql +++ b/db/changes/10490-august/00-packingSiteConfig.sql @@ -11,7 +11,7 @@ INSERT INTO `vn`.`packingSiteConfig` SET shinobiUrl = 'https://shinobi.verdnatura.es', shinobiToken = 'BW4o7FZyJ85she1hlRDe6QnwW3jwEP', shinobiGroupKey = 'xVqft9LFXg', - avgBoxingTime = 30; + avgBoxingTime = 6000; INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES diff --git a/db/changes/10490-august/00-salix_url.sql b/db/changes/10490-august/00-salix_url.sql new file mode 100644 index 000000000..ea5c3b606 --- /dev/null +++ b/db/changes/10490-august/00-salix_url.sql @@ -0,0 +1,33 @@ +CREATE TABLE `salix`.`url` ( + `appName` varchar(100) NOT NULL, + `environment` varchar(100) NOT NULL, + `url` varchar(255) NOT NULL, + PRIMARY KEY (`appName`,`environment`) +); + +INSERT INTO `salix`.`url` (`appName`, `environment`, `url`) + VALUES + ('salix', 'production', 'https://salix.verdnatura.es/#!/'); +INSERT INTO `salix`.`url` (`appName`, `environment`, `url`) + VALUES + ('salix', 'test', 'https://test-salix.verdnatura.es/#!/'); +INSERT INTO `salix`.`url` (`appName`, `environment`, `url`) + VALUES + ('salix', 'dev', 'http://localhost:5000/#!/'); +INSERT INTO `salix`.`url` (`appName`, `environment`, `url`) + VALUES + ('lilium', 'production', 'https://lilium.verdnatura.es/#/'); +INSERT INTO `salix`.`url` (`appName`, `environment`, `url`) + VALUES + ('lilium', 'test', 'https://test-lilium.verdnatura.es/#/'); +INSERT INTO `salix`.`url` (`appName`, `environment`, `url`) + VALUES + ('lilium', 'dev', 'http://localhost:8080/#/'); + +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('Url', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); + +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('Url', '*', 'WRITE', 'ALLOW', 'ROLE', 'it'); diff --git a/front/core/services/app.js b/front/core/services/app.js index 889b24d01..37bddeca0 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -54,6 +54,23 @@ export default class App { localStorage.setItem('salix-version', newVersion); } } + + getUrl(route, appName) { + if (!appName) appName = 'lilium'; + + const env = process.env.NODE_ENV; + const filter = { + where: {and: [ + {appName: appName}, + {environment: env} + ]} + }; + + return this.logger.$http.get('Urls/findOne', {filter}) + .then(res => { + return res.data.url + route; + }); + } } ngModule.service('vnApp', App); diff --git a/modules/ticket/back/methods/boxing/specs/getVideo.spec.js b/modules/ticket/back/methods/boxing/specs/getVideo.spec.js new file mode 100644 index 000000000..8e8cdc5b9 --- /dev/null +++ b/modules/ticket/back/methods/boxing/specs/getVideo.spec.js @@ -0,0 +1,40 @@ +const models = require('vn-loopback/server/server').models; +const https = require('https'); + +xdescribe('boxing getVideo()', () => { + it('should return data', async() => { + const tx = await models.PackingSiteConfig.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const id = 1; + const video = 'video.mp4'; + + const response = { + pipe: () => {}, + on: () => {}, + end: () => {}, + }; + + const req = { + headers: 'apiHeader', + data: { + pipe: () => {}, + on: () => {}, + } + }; + + spyOn(https, 'request').and.returnValue(response); + + const result = await models.Boxing.getVideo(id, video, req, null, options); + + expect(result[0]).toEqual(response.data.videos[0].filename); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/ticket/back/methods/boxing/specs/getVideoList.js b/modules/ticket/back/methods/boxing/specs/getVideoList.spec.js similarity index 58% rename from modules/ticket/back/methods/boxing/specs/getVideoList.js rename to modules/ticket/back/methods/boxing/specs/getVideoList.spec.js index e703f4c03..c6d1a3e07 100644 --- a/modules/ticket/back/methods/boxing/specs/getVideoList.js +++ b/modules/ticket/back/methods/boxing/specs/getVideoList.spec.js @@ -2,29 +2,30 @@ const models = require('vn-loopback/server/server').models; const axios = require('axios'); describe('boxing getVideoList()', () => { - it('should return data', async() => { + it('should return video list', async() => { const tx = await models.PackingSiteConfig.beginTransaction({}); try { const options = {transaction: tx}; - const params = { - id: 1, - from: 1, - to: 2 - }; + const id = 1; + const from = 1; + const to = 2; const response = { data: { - pipe: () => {}, - on: () => {}, + videos: [{ + id: 1, + filename: 'video1.mp4' + }] } }; + spyOn(axios, 'get').and.returnValue(new Promise(resolve => resolve(response))); - const result = await models.Sale.canEdit(params, options); + const result = await models.Boxing.getVideoList(id, from, to, options); - expect(result).toEqual([]); + expect(result[0]).toEqual(response.data.videos[0].filename); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/front/boxing/index.js b/modules/ticket/front/boxing/index.js index 686bf7d01..4e6b398f2 100644 --- a/modules/ticket/front/boxing/index.js +++ b/modules/ticket/front/boxing/index.js @@ -6,20 +6,9 @@ class Controller extends Section { super($element, $); } - $onInit() { - window.location.href = this.lilium(`ticket/${this.ticket.id}/boxing`); - } - - lilium(route) { - const env = process.env.NODE_ENV; - let newRoute = 'http://localhost:8080/#/' + route; - - if (env == 'test') - newRoute = 'https://test-lilium.verdnatura.es/#/' + route; - if (env == 'producction') - newRoute = 'https://lilium.verdnatura.es/#/' + route; - - return newRoute; + async $onInit() { + const url = await this.vnApp.getUrl(`ticket/${this.$params.id}/boxing`); + window.open(url).focus(); } } From e931414bb7d7fd33b6a3caec661d7c1e26e7b8cd Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 30 Sep 2022 08:59:49 +0200 Subject: [PATCH 16/93] unnecessary code --- db/changes/10490-august/00-packingSiteConfig.sql | 12 ------------ front/core/lib/lilium.js | 12 ------------ front/core/services/app.js | 4 +--- 3 files changed, 1 insertion(+), 27 deletions(-) delete mode 100644 front/core/lib/lilium.js diff --git a/db/changes/10490-august/00-packingSiteConfig.sql b/db/changes/10490-august/00-packingSiteConfig.sql index dc5e4c5cf..945b5a54c 100644 --- a/db/changes/10490-august/00-packingSiteConfig.sql +++ b/db/changes/10490-august/00-packingSiteConfig.sql @@ -7,18 +7,6 @@ CREATE TABLE `vn`.`packingSiteConfig` ( PRIMARY KEY (`id`) ); -INSERT INTO `vn`.`packingSiteConfig` SET - shinobiUrl = 'https://shinobi.verdnatura.es', - shinobiToken = 'BW4o7FZyJ85she1hlRDe6QnwW3jwEP', - shinobiGroupKey = 'xVqft9LFXg', - avgBoxingTime = 6000; - INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Boxing', '*', '*', 'ALLOW', 'ROLE', 'employee'); - -SELECT e.id expeditionFk, e.ticketFk, ps.code, ps.monitorId - FROM expedition e - JOIN host h ON Convert(h.code USING utf8mb3) COLLATE utf8mb3_unicode_ci = e.hostFk - JOIN packingSite ps ON ps.hostFk = h.id - WHERE e.ticketFk = 1; diff --git a/front/core/lib/lilium.js b/front/core/lib/lilium.js deleted file mode 100644 index ca10d3511..000000000 --- a/front/core/lib/lilium.js +++ /dev/null @@ -1,12 +0,0 @@ - -export default function lilium(route) { - const env = process.env.NODE_ENV; - let newRoute = 'https://localhost:8080/#/' + route; - - if (env == 'test') - newRoute = 'https://test-lilium.verdnatura.es/#/' + route; - if (env == 'producction') - newRoute = 'https://lilium.verdnatura.es/#/' + route; - - return newRoute; -} diff --git a/front/core/services/app.js b/front/core/services/app.js index 37bddeca0..fb0a08777 100644 --- a/front/core/services/app.js +++ b/front/core/services/app.js @@ -55,9 +55,7 @@ export default class App { } } - getUrl(route, appName) { - if (!appName) appName = 'lilium'; - + getUrl(route, appName = 'lilium') { const env = process.env.NODE_ENV; const filter = { where: {and: [ From eec1d6df4ad09fbbd2db274035971bb8486cf243 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 30 Sep 2022 09:06:43 +0200 Subject: [PATCH 17/93] add translation --- modules/ticket/front/locale/es.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/ticket/front/locale/es.yml b/modules/ticket/front/locale/es.yml index 752dd7b36..748ba210f 100644 --- a/modules/ticket/front/locale/es.yml +++ b/modules/ticket/front/locale/es.yml @@ -4,6 +4,7 @@ Agency: Agencia Amount: Importe Base to commission: Base comisionable Boxes: Cajas +Boxing: Encajado by: por Checked: Comprobado Client: Cliente @@ -45,7 +46,7 @@ Price gap: Diferencia de precio Quantity: Cantidad Remove lines: Eliminar lineas Route: Ruta -SET OK: PONER OK +SET OK: PONER OK Shipment: Salida Shipped: F. envío Some fields are invalid: Algunos campos no son válidos @@ -81,4 +82,4 @@ Sale tracking: Líneas preparadas Pictures: Fotos Log: Historial Packager: Encajador -Palletizer: Palletizador \ No newline at end of file +Palletizer: Palletizador From f81b2775a00a8431b89bdeb4c63a10644fd138e0 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 30 Sep 2022 09:36:51 +0200 Subject: [PATCH 18/93] add fixture --- db/dump/fixtures.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 189b1ebe6..b54bb1c82 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2642,7 +2642,11 @@ INSERT INTO `vn`.`host` (`id`, `code`, `description`, `warehouseFk`, `bankFk`) INSERT INTO `vn`.`packingSite` (`id`, `code`, `hostFk`, `monitorId`) VALUES - (1, 'h1', 1, 'VbiUcajdaT'); + (1, 'h1', 1, ''); + +INSERT INTO `vn`.`packingSiteConfig` (`shinobiUrl`, `shinobiToken`, `shinobiGroupKey`, `avgBoxingTime`) + VALUES + ('', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000); INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) VALUES From 11484edd105c0c57210b523c89f246a55bb1f17d Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 3 Oct 2022 15:18:07 +0200 Subject: [PATCH 19/93] feat: create new ticket --- modules/ticket/front/expedition/index.html | 22 +++++++++++++++++++--- modules/ticket/front/expedition/index.js | 17 +++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 3a5d5f8a6..694b3eb33 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -138,12 +138,28 @@ + ng-click="$ctrl.createTicket()"> New ticket without route + ng-click="selectRoute.show()"> New ticket with route - \ No newline at end of file + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index 38d02f548..d80c8e812 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -26,6 +26,23 @@ class Controller extends Section { get totalChecked() { return this.checked.length; } + + createTicket(routeFk) { + const tomorrow = new Date(); + const params = { + clientId: this.ticket.clientFk, + landed: tomorrow.getDay() + 1, + addressId: this.ticket.addressFk, + agencyModeId: this.ticket.agencyModeFk, + warehouseId: this.ticket.warehouseFk + }; + const query = `Tickets/new`; + this.$http.post(query, params).then(res => { + if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk}); + this.vnApp.showSuccess(this.$t('Data saved!')); + this.$state.go('ticket.card.summary', {id: res.data.id}); + }); + } } ngModule.vnComponent('vnTicketExpedition', { From 600dd7a4347d40bb49a4a0e2cdecda346178f521 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Wed, 5 Oct 2022 11:52:14 +0200 Subject: [PATCH 20/93] Created the model and UI --- .../workerDisableExclueded/checkExcluded.js | 26 +++++++++++++++++++ modules/worker/back/model-config.json | 3 +++ .../back/models/workerDisableExcluded.json | 23 ++++++++++++++++ modules/worker/front/descriptor/index.html | 10 +++++++ modules/worker/front/descriptor/index.js | 8 ++++++ 5 files changed, 70 insertions(+) create mode 100644 modules/worker/back/methods/workerDisableExclueded/checkExcluded.js create mode 100644 modules/worker/back/models/workerDisableExcluded.json diff --git a/modules/worker/back/methods/workerDisableExclueded/checkExcluded.js b/modules/worker/back/methods/workerDisableExclueded/checkExcluded.js new file mode 100644 index 000000000..32260c01f --- /dev/null +++ b/modules/worker/back/methods/workerDisableExclueded/checkExcluded.js @@ -0,0 +1,26 @@ + +module.exports = Self => { + Self.remoteMethod('workerDisableExcluded', { + description: 'Check an email inbox and process it', + accessType: 'READ', + accepts: { + arg: 'workerFk', + type: 'Number', + required: true, + description: `The worker id` + }, + returns: { + type: ['Object'], + root: true + }, + http: { + path: `/workerDisableExcluded`, + verb: 'GET' + } + }); + + Self.workerDisableExcluded = workerFk => { + console.log(workerFk); + return 'tests123'; + }; +}; diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index c155e331d..a41997908 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -64,6 +64,9 @@ }, "WorkerTimeControlMail": { "dataSource": "vn" + }, + "workerDisableExcluded": { + "dataSource": "vn" } } diff --git a/modules/worker/back/models/workerDisableExcluded.json b/modules/worker/back/models/workerDisableExcluded.json new file mode 100644 index 000000000..eeffb4b15 --- /dev/null +++ b/modules/worker/back/models/workerDisableExcluded.json @@ -0,0 +1,23 @@ +{ + "name": "workerDisableExcluded", + "base": "VnModel", + "options": { + "mysql": { + "table": "workerDisableExcluded" + } + }, + "properties": { + "id": { + "id": true, + "type": "number" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/modules/worker/front/descriptor/index.html b/modules/worker/front/descriptor/index.html index 01681ebb8..0616f179f 100644 --- a/modules/worker/front/descriptor/index.html +++ b/modules/worker/front/descriptor/index.html @@ -14,6 +14,16 @@ + + +
Date: Wed, 5 Oct 2022 15:13:48 +0200 Subject: [PATCH 21/93] feat: add new sub section itemShelving --- front/salix/locale/es.yml | 1 + modules/item/back/model-config.json | 3 + .../item-shelving-placement-supply.json | 29 +++ modules/item/front/index.js | 2 + modules/item/front/item-shelving/index.html | 172 ++++++++++++++++++ modules/item/front/item-shelving/index.js | 132 ++++++++++++++ .../item/front/item-shelving/index.spec.js | 121 ++++++++++++ .../item/front/item-shelving/locale/es.yml | 9 + modules/item/front/locale/es.yml | 1 + modules/item/front/routes.json | 13 +- modules/shelving/front/routes.json | 2 +- 11 files changed, 483 insertions(+), 2 deletions(-) create mode 100644 modules/item/back/models/item-shelving-placement-supply.json create mode 100644 modules/item/front/item-shelving/index.html create mode 100644 modules/item/front/item-shelving/index.js create mode 100644 modules/item/front/item-shelving/index.spec.js create mode 100644 modules/item/front/item-shelving/locale/es.yml diff --git a/front/salix/locale/es.yml b/front/salix/locale/es.yml index e5dc82b16..d92c32b33 100644 --- a/front/salix/locale/es.yml +++ b/front/salix/locale/es.yml @@ -51,6 +51,7 @@ Entries: Entradas Users: Usuarios Suppliers: Proveedores Monitors: Monitores +Shelvings: Carros # Common diff --git a/modules/item/back/model-config.json b/modules/item/back/model-config.json index 9737d26fc..40d73f1a6 100644 --- a/modules/item/back/model-config.json +++ b/modules/item/back/model-config.json @@ -53,6 +53,9 @@ "ItemShelvingSale": { "dataSource": "vn" }, + "ItemShelvingPlacementSupplyStock": { + "dataSource": "vn" + }, "ItemImageQueue": { "dataSource": "vn" }, diff --git a/modules/item/back/models/item-shelving-placement-supply.json b/modules/item/back/models/item-shelving-placement-supply.json new file mode 100644 index 000000000..11497b4fc --- /dev/null +++ b/modules/item/back/models/item-shelving-placement-supply.json @@ -0,0 +1,29 @@ +{ + "name": "ItemShelvingPlacementSupplyStock", + "base": "VnModel", + "options": { + "mysql": { + "table": "itemShelvingPlacementSupplyStock" + } + }, + "properties": { + "created": { + "type": "date" + }, + "itemFk": { + "type": "number" + }, + "concept": { + "type": "string" + }, + "parking": { + "type": "string" + }, + "shelving": { + "type": "string" + }, + "packing": { + "type": "number" + } + } +} \ No newline at end of file diff --git a/modules/item/front/index.js b/modules/item/front/index.js index 6a8d1b3b7..d2ffcc8fb 100644 --- a/modules/item/front/index.js +++ b/modules/item/front/index.js @@ -24,3 +24,5 @@ import './waste/detail'; import './fixed-price'; import './fixed-price-search-panel'; import './item-type'; +import './item-shelving'; + diff --git a/modules/item/front/item-shelving/index.html b/modules/item/front/item-shelving/index.html new file mode 100644 index 000000000..7949e73a3 --- /dev/null +++ b/modules/item/front/item-shelving/index.html @@ -0,0 +1,172 @@ + + + + + + + + + +
+
+
Total
+ + +
+
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + Created + + Item + + Concept + + Parking + + Shelving + + Etiqueta + + Packing +
+ + + + + {{::defaulter.clientName}} + + + + {{::defaulter.salesPersonName | dashIfEmpty}} + + {{::defaulter.amount | currency: 'EUR': 2}} + + {{::defaulter.workerName | dashIfEmpty}} + + + + + + + {{::defaulter.created | date: 'dd/MM/yyyy'}} + + {{::defaulter.creditInsurance | currency: 'EUR': 2}}{{::defaulter.defaulterSinced | date: 'dd/MM/yyyy'}}
+
+
+
+ + + + + + + + + + + + +
+
{{$ctrl.$t('Add observation to all selected clients', {total: $ctrl.checked.length})}}
+ + + + +
+
+ + + + +
diff --git a/modules/item/front/item-shelving/index.js b/modules/item/front/item-shelving/index.js new file mode 100644 index 000000000..f51a1a65b --- /dev/null +++ b/modules/item/front/item-shelving/index.js @@ -0,0 +1,132 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; +import UserError from 'core/lib/user-error'; + +export default class Controller extends Section { + constructor($element, $) { + super($element, $); + this.defaulter = {}; + + this.smartTableOptions = { + activeButtons: { + search: true + }, + columns: [ + { + field: 'clientFk', + autocomplete: { + url: 'Clients', + showField: 'name', + valueField: 'id' + } + }, + { + field: 'salesPersonFk', + autocomplete: { + url: 'Workers/activeWithInheritedRole', + where: `{role: 'salesPerson'}`, + searchFunction: '{firstName: $search}', + showField: 'name', + valueField: 'id', + } + }, + { + field: 'workerFk', + autocomplete: { + url: 'Workers/activeWithInheritedRole', + searchFunction: '{firstName: $search}', + showField: 'name', + valueField: 'id', + } + }, + { + field: 'observation', + searchable: false + }, + { + field: 'created', + searchable: false + }, + { + field: 'defaulterSinced', + searchable: false + } + ] + }; + + this.getBalanceDueTotal(); + } + + get checked() { + const clients = this.$.model.data || []; + const checkedLines = []; + for (let defaulter of clients) { + if (defaulter.checked) + checkedLines.push(defaulter); + } + + return checkedLines; + } + + getBalanceDueTotal() { + this.$http.get('Defaulters/filter') + .then(res => { + if (!res.data) return 0; + + this.balanceDueTotal = res.data.reduce( + (accumulator, currentValue) => { + return accumulator + (currentValue['amount'] || 0); + }, 0); + }); + } + + chipColor(date) { + const day = 24 * 60 * 60 * 1000; + const today = new Date(); + today.setHours(0, 0, 0, 0); + + const observationShipped = new Date(date); + observationShipped.setHours(0, 0, 0, 0); + + const difference = today - observationShipped; + + if (difference > (day * 20)) + return 'alert'; + if (difference > (day * 10)) + return 'warning'; + } + + onResponse() { + if (!this.defaulter.observation) + throw new UserError(`The message can't be empty`); + + const params = []; + for (let defaulter of this.checked) { + params.push({ + text: this.defaulter.observation, + clientFk: defaulter.clientFk + }); + } + + this.$http.post(`ClientObservations`, params) .then(() => { + this.vnApp.showMessage(this.$t('Observation saved!')); + this.$state.reload(); + }); + } + + exprBuilder(param, value) { + switch (param) { + case 'creditInsurance': + case 'amount': + case 'clientFk': + case 'workerFk': + case 'salesPersonFk': + return {[`d.${param}`]: value}; + } + } +} + +ngModule.vnComponent('vnItemShelving', { + template: require('./index.html'), + controller: Controller +}); diff --git a/modules/item/front/item-shelving/index.spec.js b/modules/item/front/item-shelving/index.spec.js new file mode 100644 index 000000000..0732c68a1 --- /dev/null +++ b/modules/item/front/item-shelving/index.spec.js @@ -0,0 +1,121 @@ +import './index'; +import crudModel from 'core/mocks/crud-model'; + +describe('client defaulter', () => { + describe('Component vnClientDefaulter', () => { + let controller; + let $httpBackend; + + beforeEach(ngModule('client')); + + beforeEach(inject(($componentController, _$httpBackend_) => { + $httpBackend = _$httpBackend_; + const $element = angular.element(''); + controller = $componentController('vnClientDefaulter', {$element}); + controller.$.model = crudModel; + controller.$.model.data = [ + {clientFk: 1101, amount: 125}, + {clientFk: 1102, amount: 500}, + {clientFk: 1103, amount: 250} + ]; + })); + + describe('checked() getter', () => { + it('should return the checked lines', () => { + const data = controller.$.model.data; + data[1].checked = true; + data[2].checked = true; + + const checkedRows = controller.checked; + + const firstCheckedRow = checkedRows[0]; + const secondCheckedRow = checkedRows[1]; + + expect(firstCheckedRow.clientFk).toEqual(1102); + expect(secondCheckedRow.clientFk).toEqual(1103); + }); + }); + + describe('chipColor()', () => { + it('should return undefined when the date is the present', () => { + let today = new Date(); + let result = controller.chipColor(today); + + expect(result).toEqual(undefined); + }); + + it('should return warning when the date is 10 days in the past', () => { + let pastDate = new Date(); + pastDate = pastDate.setDate(pastDate.getDate() - 11); + let result = controller.chipColor(pastDate); + + expect(result).toEqual('warning'); + }); + + it('should return alert when the date is 20 days in the past', () => { + let pastDate = new Date(); + pastDate = pastDate.setDate(pastDate.getDate() - 21); + let result = controller.chipColor(pastDate); + + expect(result).toEqual('alert'); + }); + }); + + describe('onResponse()', () => { + it('should return error for empty message', () => { + let error; + try { + controller.onResponse(); + } catch (e) { + error = e; + } + + expect(error).toBeDefined(); + expect(error.message).toBe(`The message can't be empty`); + }); + + it('should return saved message', () => { + const data = controller.$.model.data; + data[1].checked = true; + controller.defaulter = {observation: 'My new observation'}; + + const params = [{text: controller.defaulter.observation, clientFk: data[1].clientFk}]; + + jest.spyOn(controller.vnApp, 'showMessage'); + $httpBackend.expect('GET', `Defaulters/filter`).respond(200); + $httpBackend.expect('POST', `ClientObservations`, params).respond(200, params); + + controller.onResponse(); + $httpBackend.flush(); + + expect(controller.vnApp.showMessage).toHaveBeenCalledWith('Observation saved!'); + }); + }); + + describe('exprBuilder()', () => { + it('should search by sales person', () => { + const expr = controller.exprBuilder('salesPersonFk', '5'); + + expect(expr).toEqual({'d.salesPersonFk': '5'}); + }); + + it('should search by client', () => { + const expr = controller.exprBuilder('clientFk', '5'); + + expect(expr).toEqual({'d.clientFk': '5'}); + }); + }); + + describe('getBalanceDueTotal()', () => { + it('should return balance due total', () => { + const defaulters = controller.$.model.data; + $httpBackend.when('GET', `Defaulters/filter`).respond(defaulters); + + controller.getBalanceDueTotal(); + $httpBackend.flush(); + + expect(controller.balanceDueTotal).toEqual(875); + }); + }); + }); +}); diff --git a/modules/item/front/item-shelving/locale/es.yml b/modules/item/front/item-shelving/locale/es.yml new file mode 100644 index 000000000..c3e1d4e19 --- /dev/null +++ b/modules/item/front/item-shelving/locale/es.yml @@ -0,0 +1,9 @@ +Add observation: Añadir observación +Add observation to all selected clients: Añadir observación a {{total}} cliente(s) seleccionado(s) +Balance D.: Saldo V. +Credit I.: Crédito A. +Last observation: Última observación +L. O. Date: Fecha Ú. O. +Last observation date: Fecha última observación +Search client: Buscar clientes +Worker who made the last observation: Trabajador que ha realizado la última observación \ No newline at end of file diff --git a/modules/item/front/locale/es.yml b/modules/item/front/locale/es.yml index 1b75e3802..88ab031e1 100644 --- a/modules/item/front/locale/es.yml +++ b/modules/item/front/locale/es.yml @@ -54,6 +54,7 @@ Basic data: Datos básicos Tax: IVA History: Historial Botanical: Botánico +Shelvings: Carros Barcodes: Códigos de barras Diary: Histórico Item diary: Registro de compra-venta diff --git a/modules/item/front/routes.json b/modules/item/front/routes.json index 5743d0ce7..52cf5d2be 100644 --- a/modules/item/front/routes.json +++ b/modules/item/front/routes.json @@ -16,7 +16,8 @@ {"state": "item.card.basicData", "icon": "settings"}, {"state": "item.card.tags", "icon": "icon-tags"}, {"state": "item.card.tax", "icon": "icon-tax"}, - {"state": "item.card.botanical", "icon": "local_florist"}, + {"state": "item.card.botanical", "icon": "local_florist"}, + {"state": "item.card.shelving", "icon": "icon-inventory"}, {"state": "item.card.itemBarcode", "icon": "icon-barcode"}, {"state": "item.card.diary", "icon": "icon-transaction"}, {"state": "item.card.last-entries", "icon": "icon-regentry"}, @@ -92,6 +93,16 @@ }, "acl": ["buyer"] }, + { + "url" : "/shelving", + "state": "item.card.shelving", + "component": "vn-item-shelving", + "description": "Shelvings", + "params": { + "item": "$ctrl.item" + }, + "acl": ["employee"] + }, { "url" : "/barcode", "state": "item.card.itemBarcode", diff --git a/modules/shelving/front/routes.json b/modules/shelving/front/routes.json index b99ca4cac..0a05db9e3 100644 --- a/modules/shelving/front/routes.json +++ b/modules/shelving/front/routes.json @@ -14,7 +14,7 @@ ] }, "keybindings": [ - {"key": "s", "state": "shelving.index"} + {"key": "c", "state": "shelving.index"} ], "routes": [ { From ddbe1057ad9996e42100e156c188faafd40f1a3f Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 6 Oct 2022 09:47:53 +0200 Subject: [PATCH 22/93] feat: add new section --- .../10490-august/00-aclItemShelving.sql | 3 + ...00-aclItemShelvingPlacementSupply copy.sql | 3 + .../item-shelving-placement-supply.json | 9 +- modules/item/front/item-shelving/index.html | 132 +++++------------- modules/item/front/item-shelving/index.js | 106 ++++++-------- .../item/front/item-shelving/locale/es.yml | 12 +- 6 files changed, 95 insertions(+), 170 deletions(-) create mode 100644 db/changes/10490-august/00-aclItemShelving.sql create mode 100644 db/changes/10490-august/00-aclItemShelvingPlacementSupply copy.sql diff --git a/db/changes/10490-august/00-aclItemShelving.sql b/db/changes/10490-august/00-aclItemShelving.sql new file mode 100644 index 000000000..3995bbe49 --- /dev/null +++ b/db/changes/10490-august/00-aclItemShelving.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('ItemShelving', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10490-august/00-aclItemShelvingPlacementSupply copy.sql b/db/changes/10490-august/00-aclItemShelvingPlacementSupply copy.sql new file mode 100644 index 000000000..cc589a58f --- /dev/null +++ b/db/changes/10490-august/00-aclItemShelvingPlacementSupply copy.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('ItemShelvingPlacementSupplyStock', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/modules/item/back/models/item-shelving-placement-supply.json b/modules/item/back/models/item-shelving-placement-supply.json index 11497b4fc..a54013e05 100644 --- a/modules/item/back/models/item-shelving-placement-supply.json +++ b/modules/item/back/models/item-shelving-placement-supply.json @@ -7,13 +7,17 @@ } }, "properties": { + "itemShelvingFk": { + "type": "number", + "id": true + }, "created": { "type": "date" }, "itemFk": { "type": "number" }, - "concept": { + "longName": { "type": "string" }, "parking": { @@ -24,6 +28,9 @@ }, "packing": { "type": "number" + }, + "stock": { + "type": "number" } } } \ No newline at end of file diff --git a/modules/item/front/item-shelving/index.html b/modules/item/front/item-shelving/index.html index 7949e73a3..115829c8d 100644 --- a/modules/item/front/item-shelving/index.html +++ b/modules/item/front/item-shelving/index.html @@ -1,21 +1,10 @@ - - - - + ng-click="removeConfirm.show()" + vn-tooltip="Remove selected lines" + vn-acl="replenisherBos" + icon="delete">
@@ -50,123 +39,78 @@ model="model"> - + Created - + Item + field="longName"> Concept + field="parking"> Parking - + Shelving + field="label"> Etiqueta Packing - + - + {{::itemShelvingPlacementSupplyStock.created | date: 'dd/MM/yyyy'}} + + {{::itemShelvingPlacementSupplyStock.itemFk}} + + - {{::defaulter.clientName}} + {{itemShelvingPlacementSupplyStock.longName}} - - {{::defaulter.salesPersonName | dashIfEmpty}} - + {{::itemShelvingPlacementSupplyStock.parking}} - {{::defaulter.amount | currency: 'EUR': 2}} - - {{::defaulter.workerName | dashIfEmpty}} - + {{::itemShelvingPlacementSupplyStock.shelving}} - - - + + {{::itemShelvingPlacementSupplyStock.label}} - - - {{::defaulter.created | date: 'dd/MM/yyyy'}} - + + {{::itemShelvingPlacementSupplyStock.packing}} - {{::defaulter.creditInsurance | currency: 'EUR': 2}} - {{::defaulter.defaulterSinced | date: 'dd/MM/yyyy'}} - - - - - - - - + + - - - -
-
{{$ctrl.$t('Add observation to all selected clients', {total: $ctrl.checked.length})}}
- - - - -
-
- - - - -
+ + \ No newline at end of file diff --git a/modules/item/front/item-shelving/index.js b/modules/item/front/item-shelving/index.js index f51a1a65b..6fd8825aa 100644 --- a/modules/item/front/item-shelving/index.js +++ b/modules/item/front/item-shelving/index.js @@ -1,11 +1,9 @@ import ngModule from '../module'; import Section from 'salix/components/section'; -import UserError from 'core/lib/user-error'; export default class Controller extends Section { constructor($element, $) { super($element, $); - this.defaulter = {}; this.smartTableOptions = { activeButtons: { @@ -13,42 +11,31 @@ export default class Controller extends Section { }, columns: [ { - field: 'clientFk', + field: 'parking', autocomplete: { - url: 'Clients', - showField: 'name', - valueField: 'id' + url: 'Parkings', + showField: 'code', + valueField: 'code' } }, { - field: 'salesPersonFk', + field: 'shelving', autocomplete: { - url: 'Workers/activeWithInheritedRole', - where: `{role: 'salesPerson'}`, - searchFunction: '{firstName: $search}', - showField: 'name', - valueField: 'id', + url: 'Shelvings', + showField: 'code', + valueField: 'code' } }, - { - field: 'workerFk', - autocomplete: { - url: 'Workers/activeWithInheritedRole', - searchFunction: '{firstName: $search}', - showField: 'name', - valueField: 'id', - } - }, - { - field: 'observation', - searchable: false - }, { field: 'created', searchable: false }, { - field: 'defaulterSinced', + field: 'itemFk', + searchable: false + }, + { + field: 'longName', searchable: false } ] @@ -58,16 +45,24 @@ export default class Controller extends Section { } get checked() { - const clients = this.$.model.data || []; + const itemShelvings = this.$.model.data || []; const checkedLines = []; - for (let defaulter of clients) { - if (defaulter.checked) - checkedLines.push(defaulter); + for (let itemShelving of itemShelvings) { + if (itemShelving.checked) + checkedLines.push(itemShelving); } return checkedLines; } + get label() { + const itemShelvings = this.$.model.data || []; + for (let itemShelving of itemShelvings) + itemShelving.label = itemShelving.stock / itemShelving.packing; + + return true; + } + getBalanceDueTotal() { this.$http.get('Defaulters/filter') .then(res => { @@ -80,48 +75,27 @@ export default class Controller extends Section { }); } - chipColor(date) { - const day = 24 * 60 * 60 * 1000; - const today = new Date(); - today.setHours(0, 0, 0, 0); - - const observationShipped = new Date(date); - observationShipped.setHours(0, 0, 0, 0); - - const difference = today - observationShipped; - - if (difference > (day * 20)) - return 'alert'; - if (difference > (day * 10)) - return 'warning'; - } - - onResponse() { - if (!this.defaulter.observation) - throw new UserError(`The message can't be empty`); - + async onRemove() { const params = []; - for (let defaulter of this.checked) { - params.push({ - text: this.defaulter.observation, - clientFk: defaulter.clientFk - }); - } + for (let itemShelving of this.checked) + params.push(itemShelving.itemShelvingFk); - this.$http.post(`ClientObservations`, params) .then(() => { - this.vnApp.showMessage(this.$t('Observation saved!')); - this.$state.reload(); - }); + for (let id of params) { + await this.$http.delete(`ItemShelvings/${id}`) + .then(() => { + this.vnApp.showSuccess(this.$t('ItemShelving removed')); + this.$state.reload(); + }); + } } exprBuilder(param, value) { switch (param) { - case 'creditInsurance': - case 'amount': - case 'clientFk': - case 'workerFk': - case 'salesPersonFk': - return {[`d.${param}`]: value}; + case 'parking': + case 'shelving': + case 'label': + case 'packing': + return {[param]: value}; } } } diff --git a/modules/item/front/item-shelving/locale/es.yml b/modules/item/front/item-shelving/locale/es.yml index c3e1d4e19..00b6ffe58 100644 --- a/modules/item/front/item-shelving/locale/es.yml +++ b/modules/item/front/item-shelving/locale/es.yml @@ -1,9 +1,3 @@ -Add observation: Añadir observación -Add observation to all selected clients: Añadir observación a {{total}} cliente(s) seleccionado(s) -Balance D.: Saldo V. -Credit I.: Crédito A. -Last observation: Última observación -L. O. Date: Fecha Ú. O. -Last observation date: Fecha última observación -Search client: Buscar clientes -Worker who made the last observation: Trabajador que ha realizado la última observación \ No newline at end of file +Shelving: Matrícula +Remove selected lines: Eliminar líneas seleccionadas +Selected lines will be deleted: Las líneas seleccionadas serán eliminadas \ No newline at end of file From 1165e050eb74cee4bc1e76fc9408ecd2de2b4753 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 6 Oct 2022 10:18:08 +0200 Subject: [PATCH 23/93] feat: workerDisableExcluded update DB field --- .../methods/worker/workerDisableExcluded.js | 30 +++++++++++++ .../worker/workerExcludeFromDisable.js | 45 +++++++++++++++++++ .../workerDisableExclueded/checkExcluded.js | 26 ----------- modules/worker/back/models/worker.js | 2 + .../back/models/workerDisableExcluded.json | 5 ++- modules/worker/front/descriptor/index.html | 21 +++++---- modules/worker/front/descriptor/index.js | 24 +++++++--- 7 files changed, 112 insertions(+), 41 deletions(-) create mode 100644 modules/worker/back/methods/worker/workerDisableExcluded.js create mode 100644 modules/worker/back/methods/worker/workerExcludeFromDisable.js delete mode 100644 modules/worker/back/methods/workerDisableExclueded/checkExcluded.js diff --git a/modules/worker/back/methods/worker/workerDisableExcluded.js b/modules/worker/back/methods/worker/workerDisableExcluded.js new file mode 100644 index 000000000..017e044c2 --- /dev/null +++ b/modules/worker/back/methods/worker/workerDisableExcluded.js @@ -0,0 +1,30 @@ + +module.exports = Self => { + Self.remoteMethod('workerDisableExcluded', { + description: 'Check if the worker can be disabled', + accessType: 'READ', + accepts: { + arg: 'id', + type: 'Number', + required: true, + description: `The worker id`, + http: {source: 'path'} + }, + returns: { + type: 'boolean', + root: true + }, + http: { + path: `/workerDisableExcluded/:id`, + verb: 'GET' + } + }); + + Self.workerDisableExcluded = async id => { + let result; + const query = `Select * from vn.workerDisableExcluded where workerFk like ${id}`; + let sqlResult = await Self.rawSql(query); + sqlResult.length == 0 ? result = false : result = true; + return result; + }; +}; diff --git a/modules/worker/back/methods/worker/workerExcludeFromDisable.js b/modules/worker/back/methods/worker/workerExcludeFromDisable.js new file mode 100644 index 000000000..86d940862 --- /dev/null +++ b/modules/worker/back/methods/worker/workerExcludeFromDisable.js @@ -0,0 +1,45 @@ +module.exports = Self => { + Self.remoteMethod('workerExcludeFromDisable', { + description: 'Change the status of the worker between can be disabled and cant be disabled', + accessType: 'READ', + accepts: [{ + arg: 'id', + type: 'Number', + required: true, + description: `The worker id`, + http: {source: 'path'} + }, + { + arg: 'currValue', + type: 'Boolean', + required: true, + description: `The current value of workerDisableExcluded`, + http: {source: 'path'} + }], + returns: { + type: 'boolean', + root: true + }, + http: { + path: `/workerExcludeFromDisable/:id/:currValue`, + verb: 'GET' + } + }); + + Self.workerExcludeFromDisable = async(id, currValue) => { + const models = Self.app.models; + + if (!currValue) { + await models.WorkerDisableExcluded.create({ + workerFk: id, + dated: new Date() + }); + } else { + await models.WorkerDisableExcluded.remove({ + workerFk: id + }); + } + + return false; + }; +}; diff --git a/modules/worker/back/methods/workerDisableExclueded/checkExcluded.js b/modules/worker/back/methods/workerDisableExclueded/checkExcluded.js deleted file mode 100644 index 32260c01f..000000000 --- a/modules/worker/back/methods/workerDisableExclueded/checkExcluded.js +++ /dev/null @@ -1,26 +0,0 @@ - -module.exports = Self => { - Self.remoteMethod('workerDisableExcluded', { - description: 'Check an email inbox and process it', - accessType: 'READ', - accepts: { - arg: 'workerFk', - type: 'Number', - required: true, - description: `The worker id` - }, - returns: { - type: ['Object'], - root: true - }, - http: { - path: `/workerDisableExcluded`, - verb: 'GET' - } - }); - - Self.workerDisableExcluded = workerFk => { - console.log(workerFk); - return 'tests123'; - }; -}; diff --git a/modules/worker/back/models/worker.js b/modules/worker/back/models/worker.js index ec6c4af28..c90729779 100644 --- a/modules/worker/back/models/worker.js +++ b/modules/worker/back/models/worker.js @@ -13,4 +13,6 @@ module.exports = Self => { require('../methods/worker/contracts')(Self); require('../methods/worker/holidays')(Self); require('../methods/worker/activeContract')(Self); + require('../methods/worker/workerDisableExcluded')(Self); + require('../methods/worker/workerExcludeFromDisable')(Self); }; diff --git a/modules/worker/back/models/workerDisableExcluded.json b/modules/worker/back/models/workerDisableExcluded.json index eeffb4b15..cfa810e43 100644 --- a/modules/worker/back/models/workerDisableExcluded.json +++ b/modules/worker/back/models/workerDisableExcluded.json @@ -7,9 +7,12 @@ } }, "properties": { - "id": { + "workerFk": { "id": true, "type": "number" + }, + "dated": { + "type": "date" } }, "acls": [ diff --git a/modules/worker/front/descriptor/index.html b/modules/worker/front/descriptor/index.html index 0616f179f..d3caa78a8 100644 --- a/modules/worker/front/descriptor/index.html +++ b/modules/worker/front/descriptor/index.html @@ -15,14 +15,19 @@ - + + + Marcar para no deshabilitar + + + Marcar como deshabilitable +
diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js index e1026382d..2f79c2d80 100644 --- a/modules/worker/front/descriptor/index.js +++ b/modules/worker/front/descriptor/index.js @@ -5,6 +5,7 @@ class Controller extends Descriptor { constructor($element, $, $rootScope) { super($element, $); this.$rootScope = $rootScope; + this.canBeExcluded(); } get worker() { @@ -15,12 +16,23 @@ class Controller extends Descriptor { this.entity = value; } - async isExcluded() { - // eslint-disable-next-line no-console - console.log(this.entity); - let excluded = await this.$http.get(`workerDisableExcluded`); - // eslint-disable-next-line no-console - console.log(excluded); + get excluded() { + return this.entity.excluded; + } + + set excluded(value) { + this.entity.excluded = value; + } + + async canBeExcluded() { + await new Promise(r => setTimeout(r, 1000)); + let data = await this.$http.get(`Workers/workerDisableExcluded/${this.entity.id}`); + this.excluded = data.data; + } + + async setExcluded() { + await this.$http.get(`Workers/workerExcludeFromDisable/${this.entity.id}/${this.entity.excluded}`); + this.canBeExcluded(); } loadData() { From a3a432c753c19d263d642c379aa1d7c4977b3a6e Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 6 Oct 2022 10:18:19 +0200 Subject: [PATCH 24/93] fix: delete one or more expeditions --- modules/ticket/front/expedition/index.html | 11 ++++++----- modules/ticket/front/expedition/index.js | 14 ++++++++++++++ modules/ticket/front/expedition/locale/es.yml | 3 ++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 694b3eb33..caef67f59 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -17,8 +17,9 @@ ng-show="$ctrl.totalChecked"> @@ -88,11 +89,11 @@ - + on-accept="$ctrl.onRemove()"> diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index d80c8e812..1525f97b5 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -27,6 +27,20 @@ class Controller extends Section { return this.checked.length; } + async onRemove() { + const params = []; + for (let expedition of this.checked) + params.push(expedition.id); + + for (let id of params) { + await this.$http.delete(`Expeditions/${id}`) + .then(() => { + this.vnApp.showSuccess(this.$t('Expedition removed')); + this.$state.reload(); + }); + } + } + createTicket(routeFk) { const tomorrow = new Date(); const params = { diff --git a/modules/ticket/front/expedition/locale/es.yml b/modules/ticket/front/expedition/locale/es.yml index d23cf25af..9c7872fd7 100644 --- a/modules/ticket/front/expedition/locale/es.yml +++ b/modules/ticket/front/expedition/locale/es.yml @@ -1 +1,2 @@ -Status log: Hitorial de estados \ No newline at end of file +Status log: Hitorial de estados +Expedition removed: Expedición eliminada \ No newline at end of file From 37601934f579e55668e5b2eae07e9b68e95a3e81 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 6 Oct 2022 11:40:46 +0200 Subject: [PATCH 25/93] feat: first option to delete and update --- modules/ticket/front/expedition/index.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index 1525f97b5..4f7b34e7c 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -42,17 +42,25 @@ class Controller extends Section { } createTicket(routeFk) { - const tomorrow = new Date(); - const params = { + const date = new Date(); // esta fecha hay que preguntarla a Fran Monsalvez + const ticketParams = { clientId: this.ticket.clientFk, - landed: tomorrow.getDay() + 1, + landed: date, addressId: this.ticket.addressFk, agencyModeId: this.ticket.agencyModeFk, warehouseId: this.ticket.warehouseFk }; const query = `Tickets/new`; - this.$http.post(query, params).then(res => { + this.$http.post(query, ticketParams).then(res => { if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk}); + + const params = []; + for (let expedition of this.checked) + params.push(expedition.id); + const expeditionParams = {ticketFk: res.data.id}; + for (let id of params) + this.$http.patch(`Expeditions/${id}`, expeditionParams); + this.vnApp.showSuccess(this.$t('Data saved!')); this.$state.go('ticket.card.summary', {id: res.data.id}); }); From 3376293d1a60e4732346c5eb2e26f81b5e20d62c Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 6 Oct 2022 11:54:14 +0200 Subject: [PATCH 26/93] Added user icon and fixed icon not updating --- modules/worker/front/descriptor/index.html | 7 +++++++ modules/worker/front/descriptor/index.js | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/worker/front/descriptor/index.html b/modules/worker/front/descriptor/index.html index d3caa78a8..c60801bb9 100644 --- a/modules/worker/front/descriptor/index.html +++ b/modules/worker/front/descriptor/index.html @@ -52,6 +52,13 @@ value="{{$ctrl.worker.sip.extension}}">
+
+ + +

- - + +

+ + Basic data + +

+ + + + + + label="Attended by" + value="{{$ctrl.summary.claim.worker.user.nickname}}"> -
- - - - - - +

Date: Mon, 17 Oct 2022 12:12:10 +0200 Subject: [PATCH 46/93] env test --- back/methods/notification/send.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/back/methods/notification/send.js b/back/methods/notification/send.js index 5ae7e748b..15baf0175 100644 --- a/back/methods/notification/send.js +++ b/back/methods/notification/send.js @@ -71,7 +71,8 @@ module.exports = Self => { const newParams = Object.assign({}, queueParams, sendParams); const email = new Email(queueName, newParams); - await email.send(); + if (process.env.NODE_ENV != 'test') + await email.send(); await queue.updateAttribute('status', statusSent); } catch (error) { From c24b975f267d33c1f054f48b307781610d33c028 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 17 Oct 2022 12:14:11 +0200 Subject: [PATCH 47/93] remove node_env --- back/methods/notification/send.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/back/methods/notification/send.js b/back/methods/notification/send.js index 15baf0175..80faf0305 100644 --- a/back/methods/notification/send.js +++ b/back/methods/notification/send.js @@ -16,9 +16,6 @@ module.exports = Self => { }); Self.send = async options => { - if (process.env.NODE_ENV == 'test') - throw new UserError(`Action not allowed on the test environment`); - const models = Self.app.models; const findStatus = 'pending'; From f85c2e9700dcada8120b286a54a99fd97c333d8e Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 17 Oct 2022 14:01:21 +0200 Subject: [PATCH 48/93] refactor: delete code repeated --- modules/ticket/back/methods/ticket/updateDiscount.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index bfa3cdbf6..7e7c4e06d 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -140,10 +140,9 @@ module.exports = Self => { componentFk: oldComponent.componentFk }; await models.SaleComponent.destroyAll(filter, myOptions); + } - await createSaleComponent(sale.id, value, componentId, myOptions); - } else - await createSaleComponent(sale.id, value, componentId, myOptions); + await createSaleComponent(sale.id, value, componentId, myOptions); const updatedSale = sale.updateAttribute('discount', newDiscount, myOptions); From 1d8fb253254962613d1ac2e7f879a4e3ad74186e Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 18 Oct 2022 10:25:54 +0200 Subject: [PATCH 49/93] Refactored according to the suggested changes --- .../methods/worker/workerDisableExcluded.js | 30 ------------- .../worker/workerExcludeFromDisable.js | 45 ------------------- modules/worker/back/models/worker.js | 2 - modules/worker/front/descriptor/index.html | 11 +++-- modules/worker/front/descriptor/index.js | 24 ++++++---- modules/worker/front/locale/es.yml | 5 ++- 6 files changed, 24 insertions(+), 93 deletions(-) delete mode 100644 modules/worker/back/methods/worker/workerDisableExcluded.js delete mode 100644 modules/worker/back/methods/worker/workerExcludeFromDisable.js diff --git a/modules/worker/back/methods/worker/workerDisableExcluded.js b/modules/worker/back/methods/worker/workerDisableExcluded.js deleted file mode 100644 index 017e044c2..000000000 --- a/modules/worker/back/methods/worker/workerDisableExcluded.js +++ /dev/null @@ -1,30 +0,0 @@ - -module.exports = Self => { - Self.remoteMethod('workerDisableExcluded', { - description: 'Check if the worker can be disabled', - accessType: 'READ', - accepts: { - arg: 'id', - type: 'Number', - required: true, - description: `The worker id`, - http: {source: 'path'} - }, - returns: { - type: 'boolean', - root: true - }, - http: { - path: `/workerDisableExcluded/:id`, - verb: 'GET' - } - }); - - Self.workerDisableExcluded = async id => { - let result; - const query = `Select * from vn.workerDisableExcluded where workerFk like ${id}`; - let sqlResult = await Self.rawSql(query); - sqlResult.length == 0 ? result = false : result = true; - return result; - }; -}; diff --git a/modules/worker/back/methods/worker/workerExcludeFromDisable.js b/modules/worker/back/methods/worker/workerExcludeFromDisable.js deleted file mode 100644 index 86d940862..000000000 --- a/modules/worker/back/methods/worker/workerExcludeFromDisable.js +++ /dev/null @@ -1,45 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('workerExcludeFromDisable', { - description: 'Change the status of the worker between can be disabled and cant be disabled', - accessType: 'READ', - accepts: [{ - arg: 'id', - type: 'Number', - required: true, - description: `The worker id`, - http: {source: 'path'} - }, - { - arg: 'currValue', - type: 'Boolean', - required: true, - description: `The current value of workerDisableExcluded`, - http: {source: 'path'} - }], - returns: { - type: 'boolean', - root: true - }, - http: { - path: `/workerExcludeFromDisable/:id/:currValue`, - verb: 'GET' - } - }); - - Self.workerExcludeFromDisable = async(id, currValue) => { - const models = Self.app.models; - - if (!currValue) { - await models.WorkerDisableExcluded.create({ - workerFk: id, - dated: new Date() - }); - } else { - await models.WorkerDisableExcluded.remove({ - workerFk: id - }); - } - - return false; - }; -}; diff --git a/modules/worker/back/models/worker.js b/modules/worker/back/models/worker.js index c90729779..ec6c4af28 100644 --- a/modules/worker/back/models/worker.js +++ b/modules/worker/back/models/worker.js @@ -13,6 +13,4 @@ module.exports = Self => { require('../methods/worker/contracts')(Self); require('../methods/worker/holidays')(Self); require('../methods/worker/activeContract')(Self); - require('../methods/worker/workerDisableExcluded')(Self); - require('../methods/worker/workerExcludeFromDisable')(Self); }; diff --git a/modules/worker/front/descriptor/index.html b/modules/worker/front/descriptor/index.html index c60801bb9..58ac3d9e6 100644 --- a/modules/worker/front/descriptor/index.html +++ b/modules/worker/front/descriptor/index.html @@ -15,18 +15,17 @@ - - Marcar para no deshabilitar + Click to exclude the user from getting disabled - Marcar como deshabilitable + Click to allow the user to be disabled @@ -54,7 +53,7 @@
diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js index 7a3922a08..2ff032def 100644 --- a/modules/worker/front/descriptor/index.js +++ b/modules/worker/front/descriptor/index.js @@ -5,7 +5,6 @@ class Controller extends Descriptor { constructor($element, $, $rootScope) { super($element, $); this.$rootScope = $rootScope; - this.canBeExcluded(); } get worker() { @@ -14,6 +13,9 @@ class Controller extends Descriptor { set worker(value) { this.entity = value; + + if (value) + this.getIsExcluded(); } get excluded() { @@ -22,18 +24,22 @@ class Controller extends Descriptor { set excluded(value) { this.entity.excluded = value; - this.$rootScope.$apply(); } - async canBeExcluded() { - await new Promise(r => setTimeout(r, 500)); - let data = await this.$http.get(`Workers/workerDisableExcluded/${this.entity.id}`); - this.excluded = data.data; + getIsExcluded() { + this.$http.get(`workerDisableExcludeds/${this.entity.id}/exists`).then(data => { + this.excluded = data.data.exists; + }); } - async setExcluded() { - await this.$http.get(`Workers/workerExcludeFromDisable/${this.entity.id}/${this.entity.excluded}`); - this.excluded = !this.entity.excluded; + handleExcluded() { + if (this.excluded) { + this.$http.delete(`workerDisableExcludeds/${this.entity.id}`); + this.excluded = false; + } else { + this.$http.post(`workerDisableExcludeds`, {workerFk: this.entity.id, dated: new Date}); + this.excluded = true; + } } loadData() { diff --git a/modules/worker/front/locale/es.yml b/modules/worker/front/locale/es.yml index 1414d089b..672f4c52f 100644 --- a/modules/worker/front/locale/es.yml +++ b/modules/worker/front/locale/es.yml @@ -20,4 +20,7 @@ View worker: Ver trabajador Worker id: Id trabajador Workers: Trabajadores worker: trabajador -Go to the worker: Ir al trabajador \ No newline at end of file +Go to the worker: Ir al trabajador +Click to exclude the user from getting disabled: Marcar para no deshabilitar +Click to allow the user to be disabled: Marcar para deshabilitar +This user can't be disabled: Fijado para no deshabilitar \ No newline at end of file From c9e9e3545d664104d415ffc34cee1d820bc48c6c Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 18 Oct 2022 10:33:48 +0200 Subject: [PATCH 50/93] Added ACL --- .../00-ACL_workerDisableExcluded.sql | 20 +++++++++++++++++++ db/changes/10491-august/delete.keep | 0 2 files changed, 20 insertions(+) create mode 100644 db/changes/10491-august/00-ACL_workerDisableExcluded.sql delete mode 100644 db/changes/10491-august/delete.keep diff --git a/db/changes/10491-august/00-ACL_workerDisableExcluded.sql b/db/changes/10491-august/00-ACL_workerDisableExcluded.sql new file mode 100644 index 000000000..48fb4bb35 --- /dev/null +++ b/db/changes/10491-august/00-ACL_workerDisableExcluded.sql @@ -0,0 +1,20 @@ +INSERT INTO + salix.ACL ( + id, + model, + property, + accessType, + permission, + principalType, + principalId + ) +VALUES +( + 344, + 'workerDisableExcluded', + '*', + '*', + 'ALLOW', + 'ROLE', + 'employee' + ); \ No newline at end of file diff --git a/db/changes/10491-august/delete.keep b/db/changes/10491-august/delete.keep deleted file mode 100644 index e69de29bb..000000000 From f481cc3c97f2cc68f480863a97be13a7240bddc8 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 18 Oct 2022 10:38:40 +0200 Subject: [PATCH 51/93] Capitalizar --- db/changes/10491-august/00-ACL_workerDisableExcluded.sql | 2 +- modules/worker/back/model-config.json | 2 +- modules/worker/back/models/workerDisableExcluded.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/changes/10491-august/00-ACL_workerDisableExcluded.sql b/db/changes/10491-august/00-ACL_workerDisableExcluded.sql index 48fb4bb35..3d84c751c 100644 --- a/db/changes/10491-august/00-ACL_workerDisableExcluded.sql +++ b/db/changes/10491-august/00-ACL_workerDisableExcluded.sql @@ -11,7 +11,7 @@ INSERT INTO VALUES ( 344, - 'workerDisableExcluded', + 'WorkerDisableExcluded', '*', '*', 'ALLOW', diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index a41997908..8c11c0d71 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -65,7 +65,7 @@ "WorkerTimeControlMail": { "dataSource": "vn" }, - "workerDisableExcluded": { + "WorkerDisableExcluded": { "dataSource": "vn" } } diff --git a/modules/worker/back/models/workerDisableExcluded.json b/modules/worker/back/models/workerDisableExcluded.json index cfa810e43..48083748d 100644 --- a/modules/worker/back/models/workerDisableExcluded.json +++ b/modules/worker/back/models/workerDisableExcluded.json @@ -1,5 +1,5 @@ { - "name": "workerDisableExcluded", + "name": "WorkerDisableExcluded", "base": "VnModel", "options": { "mysql": { From 81088bc4959c5173802416902847c118631a555d Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 18 Oct 2022 10:46:14 +0200 Subject: [PATCH 52/93] Fixed ACL --- .../00-ACL_workerDisableExcluded.sql | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/db/changes/10491-august/00-ACL_workerDisableExcluded.sql b/db/changes/10491-august/00-ACL_workerDisableExcluded.sql index 3d84c751c..7a23ca68a 100644 --- a/db/changes/10491-august/00-ACL_workerDisableExcluded.sql +++ b/db/changes/10491-august/00-ACL_workerDisableExcluded.sql @@ -1,20 +1,2 @@ -INSERT INTO - salix.ACL ( - id, - model, - property, - accessType, - permission, - principalType, - principalId - ) -VALUES -( - 344, - 'WorkerDisableExcluded', - '*', - '*', - 'ALLOW', - 'ROLE', - 'employee' - ); \ No newline at end of file +INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalId) + VALUES ('WorkerDisableExcluded','*','*','ALLOW','employee'); From 423454d19ea755b1ebc1667c1ebbb6830a7bfb80 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Oct 2022 11:47:22 +0200 Subject: [PATCH 53/93] feat: add date-picker --- modules/ticket/front/expedition/index.html | 20 ++++++++++++-------- modules/ticket/front/expedition/index.js | 15 ++++++++++----- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 35f56872c..f4b261533 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -138,25 +138,29 @@ + name="withoutRoute" + ng-click="selectLanded.show('withoutRoute')"> New ticket without route + name="withRoute" + ng-click="selectLanded.show('withRoute')"> New ticket with route + vn-id="selectLanded" + on-accept="$ctrl.createTicket($ctrl.landed, $ctrl.newRoute)"> + + + ng-model="$ctrl.newRoute"> diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index f7674716b..49ba3280d 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -2,6 +2,12 @@ import ngModule from '../module'; import Section from 'salix/components/section'; class Controller extends Section { + constructor($element, $scope) { + super($element, $scope); + this.landed = new Date(); + this.newRoute = null; + } + get checked() { const rows = this.$.model.data || []; const checkedRows = []; @@ -28,7 +34,7 @@ class Controller extends Section { } onRemove() { - const params = {expeditionsIds: this.checked}; + const params = {expeditionIds: this.checked}; const query = `Expeditions/deleteExpeditions`; this.$http.post(query, params) .then(() => { @@ -37,11 +43,10 @@ class Controller extends Section { }); } - createTicket(routeFk) { - const date = new Date(); // esta fecha hay que preguntarla a Fran Monsalvez + createTicket(landed, routeFk) { const ticketParams = { clientId: this.ticket.clientFk, - landed: date, + landed: landed, addressId: this.ticket.addressFk, agencyModeId: this.ticket.agencyModeFk, warehouseId: this.ticket.warehouseFk @@ -50,7 +55,7 @@ class Controller extends Section { this.$http.post(query, ticketParams).then(res => { if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk}); const params = { - expeditionsIds: this.checked, + expeditionIds: this.checked, ticketId: res.data.id }; const query = `Expeditions/moveExpeditions`; From 5fce93abd5bd36720eec2ffa6d7df0f0ec3cbcd4 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Oct 2022 11:47:37 +0200 Subject: [PATCH 54/93] refactor: change variables name --- modules/ticket/back/methods/expedition/deleteExpeditions.js | 6 +++--- modules/ticket/back/methods/expedition/moveExpeditions.js | 6 +++--- modules/ticket/front/expedition/index.spec.js | 4 ++-- modules/ticket/front/expedition/locale/es.yml | 3 ++- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index b902b9f0c..5b9d0daaa 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -4,7 +4,7 @@ module.exports = Self => { description: 'Delete the selected expeditions', accessType: 'WRITE', accepts: [{ - arg: 'expeditionsIds', + arg: 'expeditionIds', type: ['number'], required: true, description: 'The expeditions ids to delete' @@ -19,7 +19,7 @@ module.exports = Self => { } }); - Self.deleteExpeditions = async(expeditionsIds, options) => { + Self.deleteExpeditions = async(expeditionIds, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -34,7 +34,7 @@ module.exports = Self => { try { const deletedExpeditions = await models.Expedition.destroyAll({ - id: {inq: expeditionsIds} + id: {inq: expeditionIds} }, myOptions); if (tx) await tx.commit(); diff --git a/modules/ticket/back/methods/expedition/moveExpeditions.js b/modules/ticket/back/methods/expedition/moveExpeditions.js index 2c521dda7..338568fdb 100644 --- a/modules/ticket/back/methods/expedition/moveExpeditions.js +++ b/modules/ticket/back/methods/expedition/moveExpeditions.js @@ -4,7 +4,7 @@ module.exports = Self => { description: 'Move the selected expeditions to another ticket', accessType: 'WRITE', accepts: [{ - arg: 'expeditionsIds', + arg: 'expeditionIds', type: ['number'], required: true, description: 'The expeditions ids to nove' @@ -25,7 +25,7 @@ module.exports = Self => { } }); - Self.moveExpeditions = async(expeditionsIds, ticketId, options) => { + Self.moveExpeditions = async(expeditionIds, ticketId, options) => { const models = Self.app.models; const myOptions = {}; let tx; @@ -40,7 +40,7 @@ module.exports = Self => { try { const promises = []; - for (let expeditionsId of expeditionsIds) { + for (let expeditionsId of expeditionIds) { const expeditionToUpdate = await models.Expedition.findById(expeditionsId); const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticketId, myOptions); promises.push(expeditionUpdated); diff --git a/modules/ticket/front/expedition/index.spec.js b/modules/ticket/front/expedition/index.spec.js index fe23046ce..ad5dafbd7 100644 --- a/modules/ticket/front/expedition/index.spec.js +++ b/modules/ticket/front/expedition/index.spec.js @@ -63,7 +63,7 @@ describe('Ticket', () => { it('should make a query and then call to the model refresh() method', () => { jest.spyOn($scope.model, 'refresh'); - const expectedParams = {expeditionsIds: [1, 2]}; + const expectedParams = {expeditionIds: [1, 2]}; $httpBackend.expect('POST', 'Expeditions/deleteExpeditions', expectedParams).respond(200); controller.onRemove(); $httpBackend.flush(); @@ -97,7 +97,7 @@ describe('Ticket', () => { const expectedResponse = {id: ticketIdToTransfer}; const expectedParams = { - expeditionsIds: [1, 2], + expeditionIds: [1, 2], ticketId: 28 }; $httpBackend.expect('POST', 'Tickets/new', expectedTicket).respond(expectedResponse); diff --git a/modules/ticket/front/expedition/locale/es.yml b/modules/ticket/front/expedition/locale/es.yml index bc3ec3345..68812f985 100644 --- a/modules/ticket/front/expedition/locale/es.yml +++ b/modules/ticket/front/expedition/locale/es.yml @@ -2,4 +2,5 @@ Status log: Hitorial de estados Expedition removed: Expedición eliminada Move: Mover New ticket without route: Nuevo ticket sin ruta -New ticket with route: Nuevo ticket con ruta \ No newline at end of file +New ticket with route: Nuevo ticket con ruta +Id route: Id ruta \ No newline at end of file From ae3e3c3c49c4dc474d96fbd510febaa03fb28f7c Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Oct 2022 12:37:06 +0200 Subject: [PATCH 55/93] fix: id model duplicated --- modules/ticket/front/expedition/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index f4b261533..0ebe388c1 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -98,16 +98,16 @@ - + - + State From 9ea427dbfece8d68a6350e1f9861f2222c31f631 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 18 Oct 2022 13:45:46 +0200 Subject: [PATCH 56/93] refactor: move front to back funcionality --- loopback/locale/es.json | 3 +- .../methods/expedition/moveExpeditions.js | 60 +++++++++++++++---- modules/ticket/front/expedition/index.js | 17 ++---- 3 files changed, 55 insertions(+), 25 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 67370b343..bd9de41c2 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -235,5 +235,6 @@ "Dirección incorrecta": "Dirección incorrecta", "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador", "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador", - "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente" + "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", + "This route not exists": "Esta ruta no existe" } \ No newline at end of file diff --git a/modules/ticket/back/methods/expedition/moveExpeditions.js b/modules/ticket/back/methods/expedition/moveExpeditions.js index 338568fdb..d0f8aa893 100644 --- a/modules/ticket/back/methods/expedition/moveExpeditions.js +++ b/modules/ticket/back/methods/expedition/moveExpeditions.js @@ -1,19 +1,47 @@ +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethod('moveExpeditions', { + Self.remoteMethodCtx('moveExpeditions', { description: 'Move the selected expeditions to another ticket', accessType: 'WRITE', accepts: [{ + arg: 'clientId', + type: 'number', + description: `The client id`, + required: true + }, + { + arg: 'landed', + type: 'date', + description: `The landing date` + }, + { + arg: 'warehouseId', + type: 'number', + description: `The warehouse id`, + required: true + }, + { + arg: 'addressId', + type: 'number', + description: `The address id`, + required: true + }, + { + arg: 'agencyModeId', + type: 'any', + description: `The agencyMode id` + }, + { + arg: 'routeId', + type: 'any', + description: `The route id` + }, + { arg: 'expeditionIds', type: ['number'], required: true, - description: 'The expeditions ids to nove' - }, - { - arg: 'ticketId', - type: 'number', - required: true, - description: 'the ticket id to which the expeditions are added' + description: 'The expeditions ids to move' }], returns: { type: 'object', @@ -25,8 +53,9 @@ module.exports = Self => { } }); - Self.moveExpeditions = async(expeditionIds, ticketId, options) => { + Self.moveExpeditions = async(ctx, options) => { const models = Self.app.models; + const args = ctx.args; const myOptions = {}; let tx; @@ -39,18 +68,23 @@ module.exports = Self => { } try { + if (args.routeId) { + const route = await models.Route.findById(args.routeId, null, myOptions); + if (!route) throw new UserError('This route not exists'); + } + const ticket = await models.Ticket.new(ctx, myOptions); const promises = []; - for (let expeditionsId of expeditionIds) { + for (let expeditionsId of args.expeditionIds) { const expeditionToUpdate = await models.Expedition.findById(expeditionsId); - const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticketId, myOptions); + const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticket.id, myOptions); promises.push(expeditionUpdated); } - const updated = await Promise.all(promises); + await Promise.all(promises); if (tx) await tx.commit(); - return updated; + return ticket; } catch (e) { if (tx) await tx.rollback(); throw e; diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index 49ba3280d..7ffe2fe5e 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -44,22 +44,17 @@ class Controller extends Section { } createTicket(landed, routeFk) { - const ticketParams = { + const params = { clientId: this.ticket.clientFk, landed: landed, + warehouseId: this.ticket.warehouseFk, addressId: this.ticket.addressFk, agencyModeId: this.ticket.agencyModeFk, - warehouseId: this.ticket.warehouseFk + routeId: routeFk, + expeditionIds: this.checked }; - const query = `Tickets/new`; - this.$http.post(query, ticketParams).then(res => { - if (routeFk) this.$http.patch(`Tickets/${res.data.id}`, {routeFk: routeFk}); - const params = { - expeditionIds: this.checked, - ticketId: res.data.id - }; - const query = `Expeditions/moveExpeditions`; - this.$http.post(query, params); + const query = `Expeditions/moveExpeditions`; + this.$http.post(query, params).then(res => { this.vnApp.showSuccess(this.$t('Data saved!')); this.$state.go('ticket.card.summary', {id: res.data.id}); }); From 6f7ec12cb2119ce6584811d7d4228bdd8df499fb Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 19 Oct 2022 10:35:41 +0200 Subject: [PATCH 57/93] feat: response as 'reply' and not as 'internNote' --- back/methods/osticket/closeTicket.js | 48 ++++++++++++++----- back/models/osticket-config.json | 12 +++-- db/changes/10481-june/00-osTicketConfig.sql | 6 +-- db/changes/10491-august/00-osTicketConfig.sql | 8 ++++ db/dump/fixtures.sql | 4 ++ package.json | 1 + 6 files changed, 58 insertions(+), 21 deletions(-) create mode 100644 db/changes/10491-august/00-osTicketConfig.sql diff --git a/back/methods/osticket/closeTicket.js b/back/methods/osticket/closeTicket.js index 87d54d3b8..33fe5958b 100644 --- a/back/methods/osticket/closeTicket.js +++ b/back/methods/osticket/closeTicket.js @@ -1,12 +1,13 @@ const jsdom = require('jsdom'); const mysql = require('mysql'); +const FormData = require('form-data'); module.exports = Self => { Self.remoteMethodCtx('closeTicket', { description: 'Close tickets without response from the user', accessType: 'READ', returns: { - type: 'Object', + type: 'object', root: true }, http: { @@ -54,9 +55,9 @@ module.exports = Self => { }); }); - await requestToken(); + await getRequestToken(); - async function requestToken() { + async function getRequestToken() { const response = await fetch(ostUri); const result = response.headers.get('set-cookie'); @@ -93,24 +94,45 @@ module.exports = Self => { await close(token, secondCookie); } + async function getLockCode(token, secondCookie, ticketId) { + const ostUri = `${config.host}/ajax.php/lock/ticket/${ticketId}`; + const params = { + method: 'POST', + headers: { + 'X-CSRFToken': token, + 'Cookie': secondCookie + } + }; + const response = await fetch(ostUri, params); + const body = await response.text(); + const json = JSON.parse(body); + + return json.code; + } + async function close(token, secondCookie) { for (const ticketId of ticketsId) { - const ostUri = `${config.host}/ajax.php/tickets/${ticketId}/status`; - const data = { - status_id: config.newStatusId, - comments: config.comment, - undefined: config.action - }; + const lockCode = await getLockCode(token, secondCookie, ticketId); + let form = new FormData(); + form.append('__CSRFToken__', token); + form.append('id', ticketId); + form.append('a', config.responseType); + form.append('lockCode', lockCode); + form.append('from_email_id', config.fromEmailId); + form.append('reply-to', config.replyTo); + form.append('cannedResp', 0); + form.append('response', config.comment); + form.append('signature', 'none'); + form.append('reply_status_id', config.newStatusId); + + const ostUri = `${config.host}/tickets.php?id=${ticketId}`; const params = { method: 'POST', - body: new URLSearchParams(data), + body: form, headers: { - 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', - 'X-CSRFToken': token, 'Cookie': secondCookie } }; - return fetch(ostUri, params); } } diff --git a/back/models/osticket-config.json b/back/models/osticket-config.json index d42632c6a..5a863e7bc 100644 --- a/back/models/osticket-config.json +++ b/back/models/osticket-config.json @@ -27,9 +27,6 @@ "newStatusId": { "type": "number" }, - "action": { - "type": "string" - }, "day": { "type": "number" }, @@ -47,6 +44,15 @@ }, "portDb": { "type": "number" + }, + "responseType": { + "type": "string" + }, + "fromEmailId": { + "type": "number" + }, + "replyTo": { + "type": "string" } } } \ No newline at end of file diff --git a/db/changes/10481-june/00-osTicketConfig.sql b/db/changes/10481-june/00-osTicketConfig.sql index ad6662715..8727c816d 100644 --- a/db/changes/10481-june/00-osTicketConfig.sql +++ b/db/changes/10481-june/00-osTicketConfig.sql @@ -13,8 +13,4 @@ CREATE TABLE `vn`.`osTicketConfig` ( `passwordDb` varchar(100) COLLATE utf8mb3_unicode_ci DEFAULT NULL, `portDb` int(11) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; - -INSERT INTO `vn`.`osTicketConfig`(`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `action`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`) - VALUES - (0, 'https://cau.verdnatura.es/scp', NULL, NULL, 'open', 3, 'Cerrar', 60, 'Este CAU se ha cerrado automáticamente', NULL, NULL, NULL, NULL); \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; \ No newline at end of file diff --git a/db/changes/10491-august/00-osTicketConfig.sql b/db/changes/10491-august/00-osTicketConfig.sql new file mode 100644 index 000000000..10a58b6c8 --- /dev/null +++ b/db/changes/10491-august/00-osTicketConfig.sql @@ -0,0 +1,8 @@ +ALTER TABLE `vn`.`osTicketConfig` DROP COLUMN `action`; +ALTER TABLE `vn`.`osTicketConfig` ADD responseType varchar(100) NULL; +ALTER TABLE `vn`.`osTicketConfig` ADD fromEmailId INT NULL; +ALTER TABLE `vn`.`osTicketConfig` ADD replyTo varchar(100) NULL; + +UPDATE `vn`.`osTicketConfig` + SET responseType='reply', fromEmailId=5, replyTo='all' +WHERE id=0; \ No newline at end of file diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 7e59c1a54..b3f2d9c26 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2667,3 +2667,7 @@ INSERT INTO `vn`.`ticketCollection` (`ticketFk`, `collectionFk`, `created`, `lev UPDATE `account`.`user` SET `hasGrant` = 1 WHERE `id` = 66; + +INSERT INTO `vn`.`osTicketConfig` (`id`, `host`, `user`, `password`, `oldStatus`, `newStatusId`, `day`, `comment`, `hostDb`, `userDb`, `passwordDb`, `portDb`, `responseType`, `fromEmailId`, `replyTo`) + VALUES + (0, 'http://localhost:56596/scp', 'ostadmin', 'Admin1', 'open', 3, 60, 'Este CAU se ha cerrado automáticamente. Si el problema persiste responda a este mensaje.', 'localhost', 'osticket', 'osticket', 40003, 'reply', 1, 'all'); \ No newline at end of file diff --git a/package.json b/package.json index 26c164832..5ab329875 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "bcrypt": "^5.0.1", "bmp-js": "^0.1.0", "compression": "^1.7.3", + "form-data": "^4.0.0", "fs-extra": "^5.0.0", "ftps": "^1.2.0", "got": "^10.7.0", From 51cad752984fb2d13f804772aa8bec233430e4f7 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Oct 2022 08:17:15 +0200 Subject: [PATCH 58/93] fix: testFront --- modules/ticket/front/expedition/index.spec.js | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/modules/ticket/front/expedition/index.spec.js b/modules/ticket/front/expedition/index.spec.js index ad5dafbd7..b95d64fa3 100644 --- a/modules/ticket/front/expedition/index.spec.js +++ b/modules/ticket/front/expedition/index.spec.js @@ -83,29 +83,25 @@ describe('Ticket', () => { agencyModeFk: 1, warehouseFk: 1 }; + const routeId = null; controller.ticket = ticket; - const expectedTicket = { - clientId: 1101, - landed: new Date(), - addressId: 121, - agencyModeId: 1, - warehouseId: 1 - }; - - const ticketIdToTransfer = 28; - const expectedResponse = {id: ticketIdToTransfer}; + const ticketToTransfer = {id: 28}; const expectedParams = { - expeditionIds: [1, 2], - ticketId: 28 + clientId: 1101, + landed: new Date(), + warehouseId: 1, + addressId: 121, + agencyModeId: 1, + routeId: null, + expeditionIds: [1, 2] }; - $httpBackend.expect('POST', 'Tickets/new', expectedTicket).respond(expectedResponse); - $httpBackend.expect('POST', 'Expeditions/moveExpeditions', expectedParams).respond(200); - controller.createTicket(); + $httpBackend.expect('POST', 'Expeditions/moveExpeditions', expectedParams).respond(ticketToTransfer); + controller.createTicket(ticket.landed, routeId); $httpBackend.flush(); - expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.summary', {id: ticketIdToTransfer}); + expect(controller.$state.go).toHaveBeenCalledWith('ticket.card.summary', {id: ticketToTransfer.id}); }); }); }); From bcc9acac0ac997d9c54df4e12efc830dc50c1331 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Oct 2022 08:41:00 +0200 Subject: [PATCH 59/93] fix: tBack --- .../expedition/specs/moveExpeditions.spec.js | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js index 0bb402a55..67919e76c 100644 --- a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js +++ b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js @@ -1,17 +1,33 @@ const models = require('vn-loopback/server/server').models; describe('ticket moveExpeditions()', () => { - it('should delete the selected expeditions', async() => { + it('should move the selected expeditions to new ticket', async() => { const tx = await models.Expedition.beginTransaction({}); + const ctx = { + req: {accessToken: {userId: 9}}, + args: {}, + params: {} + }; + const myCtx = Object.assign({}, ctx); try { const options = {transaction: tx}; + myCtx.args = { + clientId: 1101, + landed: new Date(), + warehouseId: 1, + addressId: 121, + agencyModeId: 1, + routeId: null, + expeditionIds: [1, 2] - const expeditionIds = [12, 13]; - const ticketId = 1; - const result = await models.Expedition.moveExpeditions(expeditionIds, ticketId, options); + }; - expect(result.length).toEqual(2); + const ticket = await models.Expedition.moveExpeditions(myCtx, options); + + const newestTicketIdInFixtures = 27; + + expect(ticket.id).toBeGreaterThan(newestTicketIdInFixtures); await tx.rollback(); } catch (e) { From 2da34d0850de92ee8684fb9d339b59a4ff2cc852 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Oct 2022 09:40:11 +0200 Subject: [PATCH 60/93] feat: add e2e --- e2e/helpers/selectors.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 74dabc31a..dabb4c0cd 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -596,8 +596,14 @@ export default { submitNotesButton: 'button[type=submit]' }, ticketExpedition: { + firstSaleCheckbox: 'vn-ticket-expedition vn-tr:nth-child(1) vn-check[ng-model="expedition.checked"]', thirdSaleCheckbox: 'vn-ticket-expedition vn-tr:nth-child(3) vn-check[ng-model="expedition.checked"]', deleteExpeditionButton: 'vn-ticket-expedition vn-tool-bar > vn-button[icon="delete"]', + moveExpeditionButton: 'vn-ticket-expedition vn-tool-bar > vn-button[icon="keyboard_arrow_down"]', + moreMenuWithoutRoute: 'vn-item[name="withoutRoute"]', + moreMenuWithRoute: 'vn-item[name="withRoute"]', + newRouteId: '.vn-dialog.shown vn-textfield[ng-model="$ctrl.newRoute"]', + saveButton: '.vn-dialog.shown [response="accept"]', expeditionRow: 'vn-ticket-expedition vn-table vn-tbody > vn-tr' }, ticketPackages: { From 5824fee213055de7401a1ebd3e63f7879199315a Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Oct 2022 09:40:23 +0200 Subject: [PATCH 61/93] feat: add e2e --- e2e/paths/05-ticket/20_moveExpedition.spec.js | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 e2e/paths/05-ticket/20_moveExpedition.spec.js diff --git a/e2e/paths/05-ticket/20_moveExpedition.spec.js b/e2e/paths/05-ticket/20_moveExpedition.spec.js new file mode 100644 index 000000000..9673c7071 --- /dev/null +++ b/e2e/paths/05-ticket/20_moveExpedition.spec.js @@ -0,0 +1,50 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +fdescribe('Ticket expeditions', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('production', 'ticket'); + await page.accessToSearchResult('1'); + await page.accessToSection('ticket.card.expedition'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it(`should move one expedition to new ticket withoute route`, async() => { + await page.waitToClick(selectors.ticketExpedition.thirdSaleCheckbox); + await page.waitToClick(selectors.ticketExpedition.moveExpeditionButton); + await page.waitToClick(selectors.ticketExpedition.moreMenuWithoutRoute); + await page.waitToClick(selectors.ticketExpedition.saveButton); + await page.waitForState('ticket.card.summary'); + await page.accessToSection('ticket.card.expedition'); + + await page.waitForSelector(selectors.ticketExpedition.expeditionRow, {}); + const result = await page + .countElement(selectors.ticketExpedition.expeditionRow); + + expect(result).toEqual(1); + }); + + it(`should move one expedition to new ticket with route`, async() => { + await page.waitToClick(selectors.ticketExpedition.firstSaleCheckbox); + await page.waitToClick(selectors.ticketExpedition.moveExpeditionButton); + await page.waitToClick(selectors.ticketExpedition.moreMenuWithRoute); + await page.write(selectors.ticketExpedition.newRouteId, '1'); + await page.waitToClick(selectors.ticketExpedition.saveButton); + await page.waitForState('ticket.card.summary'); + await page.accessToSection('ticket.card.expedition'); + + await page.waitForSelector(selectors.ticketExpedition.expeditionRow, {}); + const result = await page + .countElement(selectors.ticketExpedition.expeditionRow); + + expect(result).toEqual(1); + }); +}); From dd15d06f5edfb7c439482764551175e7fe225b70 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Oct 2022 10:21:44 +0200 Subject: [PATCH 62/93] delete focus test --- e2e/paths/05-ticket/20_moveExpedition.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/paths/05-ticket/20_moveExpedition.spec.js b/e2e/paths/05-ticket/20_moveExpedition.spec.js index 9673c7071..cf1c5ded3 100644 --- a/e2e/paths/05-ticket/20_moveExpedition.spec.js +++ b/e2e/paths/05-ticket/20_moveExpedition.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -fdescribe('Ticket expeditions', () => { +describe('Ticket expeditions', () => { let browser; let page; From 29093d7d30e98083c36ee81bebb5c5ed95453020 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Oct 2022 14:25:55 +0200 Subject: [PATCH 63/93] =?UTF-8?q?feat:=20en=20vez=20de=20consultar=20si=20?= =?UTF-8?q?el=20usuario=20est=C3=A1=20en=20la=20tabla=20workerMana,=20cons?= =?UTF-8?q?ultar=20es=20si=20el=20usuario=20est=C3=A1=20en=20un=20departam?= =?UTF-8?q?ento=20que=20cuelga=20de=20ventas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../back/methods/sale/specs/updatePrice.spec.js | 11 ++++++++++- modules/ticket/back/methods/sale/updatePrice.js | 8 ++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js index e76511421..75be665fb 100644 --- a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js +++ b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js @@ -79,10 +79,19 @@ describe('sale updatePrice()', () => { const price = 5.4; const originalSalesPersonMana = await models.WorkerMana.findById(18, null, options); const manaComponent = await models.Component.findOne({where: {code: 'mana'}}, options); + const teamCLopez = 96; + const userId = 18; + await models.Sale.rawSql(`UPDATE vn.business b + JOIN vn.department d ON d.id = b.departmentFk + SET b.departmentFk = ? + WHERE b.id = ?`, [teamCLopez, userId]); await models.Sale.updatePrice(ctx, saleId, price, options); const updatedSale = await models.Sale.findById(saleId, null, options); - createdSaleComponent = await models.SaleComponent.findOne({where: {saleFk: saleId, componentFk: manaComponent.id}}, options); + const createdSaleComponent = await models.SaleComponent.findOne({ + where: { + saleFk: saleId, componentFk: manaComponent.id + }}, options); expect(updatedSale.price).toBe(price); expect(createdSaleComponent.value).toEqual(-2.04); diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js index bbd9d154d..dbd4ed091 100644 --- a/modules/ticket/back/methods/sale/updatePrice.js +++ b/modules/ticket/back/methods/sale/updatePrice.js @@ -77,7 +77,12 @@ module.exports = Self => { const oldPrice = sale.price; const userId = ctx.req.accessToken.userId; - const usesMana = await models.WorkerMana.findOne({where: {workerFk: userId}, fields: 'amount'}, myOptions); + + const salesDepartment = await models.Department.findOne({where: {code: 'VT'}, fields: 'id'}, myOptions); + const departments = await models.Department.getLeaves(salesDepartment.id, null, myOptions); + const workerDepartment = await models.WorkerDepartment.findById(userId); + const usesMana = departments.find(department => department.id == workerDepartment.departmentFk); + const componentCode = usesMana ? 'mana' : 'buyerDiscount'; const discount = await models.Component.findOne({where: {code: componentCode}}, myOptions); const componentId = discount.id; @@ -88,7 +93,6 @@ module.exports = Self => { saleFk: id }; const saleComponent = await models.SaleComponent.findOne({where}, myOptions); - if (saleComponent) { await models.SaleComponent.updateAll(where, { value: saleComponent.value + componentValue From 6891190c72e019cb8c2c2232a028e27a47a1ea56 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 20 Oct 2022 15:05:46 +0200 Subject: [PATCH 64/93] refactor: create endpoint to unify code --- db/changes/10491-august/00-aclUsesMana.sql | 3 ++ .../ticket/back/methods/sale/updatePrice.js | 10 +++--- modules/ticket/back/methods/sale/usesMana.js | 31 +++++++++++++++++++ modules/ticket/back/models/sale.js | 1 + 4 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 db/changes/10491-august/00-aclUsesMana.sql create mode 100644 modules/ticket/back/methods/sale/usesMana.js diff --git a/db/changes/10491-august/00-aclUsesMana.sql b/db/changes/10491-august/00-aclUsesMana.sql new file mode 100644 index 000000000..5bb7178dd --- /dev/null +++ b/db/changes/10491-august/00-aclUsesMana.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('Sale', 'usesMana', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js index dbd4ed091..d325d6eaa 100644 --- a/modules/ticket/back/methods/sale/updatePrice.js +++ b/modules/ticket/back/methods/sale/updatePrice.js @@ -78,11 +78,13 @@ module.exports = Self => { const oldPrice = sale.price; const userId = ctx.req.accessToken.userId; - const salesDepartment = await models.Department.findOne({where: {code: 'VT'}, fields: 'id'}, myOptions); - const departments = await models.Department.getLeaves(salesDepartment.id, null, myOptions); - const workerDepartment = await models.WorkerDepartment.findById(userId); - const usesMana = departments.find(department => department.id == workerDepartment.departmentFk); + // const salesDepartment = await models.Department.findOne({where: {code: 'VT'}, fields: 'id'}, myOptions); + // const departments = await models.Department.getLeaves(salesDepartment.id, null, myOptions); + // const workerDepartment = await models.WorkerDepartment.findById(userId); + // const usesMana = departments.find(department => department.id == workerDepartment.departmentFk); + const usesMana = await models.Sale.usesMana(); + console.log(usesMana ? 'mana' : 'buyerDiscount'); const componentCode = usesMana ? 'mana' : 'buyerDiscount'; const discount = await models.Component.findOne({where: {code: componentCode}}, myOptions); const componentId = discount.id; diff --git a/modules/ticket/back/methods/sale/usesMana.js b/modules/ticket/back/methods/sale/usesMana.js new file mode 100644 index 000000000..7ff2a5e2a --- /dev/null +++ b/modules/ticket/back/methods/sale/usesMana.js @@ -0,0 +1,31 @@ +module.exports = Self => { + Self.remoteMethodCtx('usesMana', { + description: 'Returns if the worker uses mana', + accessType: 'WRITE', + accepts: [], + returns: { + type: 'boolean', + root: true + }, + http: { + path: `/usesMana`, + verb: 'POST' + } + }); + + Self.usesMana = async(ctx, options) => { + const models = Self.app.models; + const userId = ctx.req.accessToken.userId; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const salesDepartment = await models.Department.findOne({where: {code: 'VT'}, fields: 'id'}, myOptions); + const departments = await models.Department.getLeaves(salesDepartment.id, null, myOptions); + const workerDepartment = await models.WorkerDepartment.findById(userId); + const usesMana = departments.find(department => department.id == workerDepartment.departmentFk); + + return usesMana ? true : false; + }; +}; diff --git a/modules/ticket/back/models/sale.js b/modules/ticket/back/models/sale.js index 2a4457263..ae247fc24 100644 --- a/modules/ticket/back/models/sale.js +++ b/modules/ticket/back/models/sale.js @@ -8,6 +8,7 @@ module.exports = Self => { require('../methods/sale/recalculatePrice')(Self); require('../methods/sale/refund')(Self); require('../methods/sale/canEdit')(Self); + require('../methods/sale/usesMana')(Self); Self.validatesPresenceOf('concept', { message: `Concept cannot be blank` From 5da29fe38158e71d3d8fab36fd2fb9deab0bf137 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 21 Oct 2022 08:00:24 +0200 Subject: [PATCH 65/93] refactor: unify duplicated code --- modules/ticket/back/methods/sale/updatePrice.js | 8 +------- modules/ticket/back/methods/sale/usesMana.js | 6 +++--- modules/ticket/back/methods/ticket/updateDiscount.js | 7 +------ 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js index d325d6eaa..302522cfb 100644 --- a/modules/ticket/back/methods/sale/updatePrice.js +++ b/modules/ticket/back/methods/sale/updatePrice.js @@ -78,13 +78,7 @@ module.exports = Self => { const oldPrice = sale.price; const userId = ctx.req.accessToken.userId; - // const salesDepartment = await models.Department.findOne({where: {code: 'VT'}, fields: 'id'}, myOptions); - // const departments = await models.Department.getLeaves(salesDepartment.id, null, myOptions); - // const workerDepartment = await models.WorkerDepartment.findById(userId); - // const usesMana = departments.find(department => department.id == workerDepartment.departmentFk); - - const usesMana = await models.Sale.usesMana(); - console.log(usesMana ? 'mana' : 'buyerDiscount'); + const usesMana = await models.Sale.usesMana(ctx, myOptions); const componentCode = usesMana ? 'mana' : 'buyerDiscount'; const discount = await models.Component.findOne({where: {code: componentCode}}, myOptions); const componentId = discount.id; diff --git a/modules/ticket/back/methods/sale/usesMana.js b/modules/ticket/back/methods/sale/usesMana.js index 7ff2a5e2a..093057dca 100644 --- a/modules/ticket/back/methods/sale/usesMana.js +++ b/modules/ticket/back/methods/sale/usesMana.js @@ -1,7 +1,7 @@ module.exports = Self => { Self.remoteMethodCtx('usesMana', { description: 'Returns if the worker uses mana', - accessType: 'WRITE', + accessType: 'READ', accepts: [], returns: { type: 'boolean', @@ -9,7 +9,7 @@ module.exports = Self => { }, http: { path: `/usesMana`, - verb: 'POST' + verb: 'GET' } }); @@ -23,7 +23,7 @@ module.exports = Self => { const salesDepartment = await models.Department.findOne({where: {code: 'VT'}, fields: 'id'}, myOptions); const departments = await models.Department.getLeaves(salesDepartment.id, null, myOptions); - const workerDepartment = await models.WorkerDepartment.findById(userId); + const workerDepartment = await models.WorkerDepartment.findById(userId, null, myOptions); const usesMana = departments.find(department => department.id == workerDepartment.departmentFk); return usesMana ? true : false; diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index b1291a45b..9419b9a40 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -98,12 +98,7 @@ module.exports = Self => { if (isLocked || (!hasAllowedRoles && alertLevel > 0)) throw new UserError(`The sales of this ticket can't be modified`); - const usesMana = await models.WorkerMana.findOne({ - where: { - workerFk: userId - }, - fields: 'amount'}, myOptions); - + const usesMana = await models.Sale.usesMana(ctx); const componentCode = usesMana ? manaCode : 'buyerDiscount'; const discountComponent = await models.Component.findOne({ where: {code: componentCode}}, myOptions); From 6f31bea21f50306ef47133afeacb447b2fb709a0 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 21 Oct 2022 08:00:48 +0200 Subject: [PATCH 66/93] feat: update testBack --- db/changes/10491-august/00-aclBusiness.sql | 3 ++ modules/client/back/model-config.json | 3 ++ modules/client/back/models/business.json | 27 +++++++++++ .../methods/sale/specs/updatePrice.spec.js | 11 ++--- .../back/methods/sale/specs/usesMana.spec.js | 48 +++++++++++++++++++ 5 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 db/changes/10491-august/00-aclBusiness.sql create mode 100644 modules/client/back/models/business.json create mode 100644 modules/ticket/back/methods/sale/specs/usesMana.spec.js diff --git a/db/changes/10491-august/00-aclBusiness.sql b/db/changes/10491-august/00-aclBusiness.sql new file mode 100644 index 000000000..f1f7a3632 --- /dev/null +++ b/db/changes/10491-august/00-aclBusiness.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('Business', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/modules/client/back/model-config.json b/modules/client/back/model-config.json index b2e600610..4ef34ca3a 100644 --- a/modules/client/back/model-config.json +++ b/modules/client/back/model-config.json @@ -8,6 +8,9 @@ "BankEntity": { "dataSource": "vn" }, + "Business": { + "dataSource": "vn" + }, "BusinessType": { "dataSource": "vn" }, diff --git a/modules/client/back/models/business.json b/modules/client/back/models/business.json new file mode 100644 index 000000000..7ad2d307f --- /dev/null +++ b/modules/client/back/models/business.json @@ -0,0 +1,27 @@ +{ + "name": "Business", + "base": "VnModel", + "options": { + "mysql": { + "table": "business" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + } + }, + "relations": { + "worker": { + "type": "belongsTo", + "model": "Worker", + "foreignKey": "workerFk" + }, + "department": { + "type": "belongsTo", + "model": "Department", + "foreignKey": "departmentFk" + } + } +} \ No newline at end of file diff --git a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js index 75be665fb..f8cb5a4ec 100644 --- a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js +++ b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -describe('sale updatePrice()', () => { +fdescribe('sale updatePrice()', () => { const ctx = { req: { accessToken: {userId: 18}, @@ -80,11 +80,10 @@ describe('sale updatePrice()', () => { const originalSalesPersonMana = await models.WorkerMana.findById(18, null, options); const manaComponent = await models.Component.findOne({where: {code: 'mana'}}, options); const teamCLopez = 96; - const userId = 18; - await models.Sale.rawSql(`UPDATE vn.business b - JOIN vn.department d ON d.id = b.departmentFk - SET b.departmentFk = ? - WHERE b.id = ?`, [teamCLopez, userId]); + const userId = ctx.req.accessToken.userId; + + const business = await models.Business.findOne({where: {workerFk: userId}}, options); + await business.updateAttribute('departmentFk', teamCLopez, options); await models.Sale.updatePrice(ctx, saleId, price, options); const updatedSale = await models.Sale.findById(saleId, null, options); diff --git a/modules/ticket/back/methods/sale/specs/usesMana.spec.js b/modules/ticket/back/methods/sale/specs/usesMana.spec.js new file mode 100644 index 000000000..4e14ed2c9 --- /dev/null +++ b/modules/ticket/back/methods/sale/specs/usesMana.spec.js @@ -0,0 +1,48 @@ +const models = require('vn-loopback/server/server').models; + +describe('sale usesMana()', () => { + const ctx = { + req: { + accessToken: {userId: 18} + } + }; + + it('should return that the worker uses mana', async() => { + const tx = await models.Sale.beginTransaction({}); + + try { + const options = {transaction: tx}; + const teamCLopez = 96; + const userId = ctx.req.accessToken.userId; + + const business = await models.Business.findOne({where: {workerFk: userId}}, options); + await business.updateAttribute('departmentFk', teamCLopez, options); + + const usesMana = await models.Sale.usesMana(ctx, options); + + expect(usesMana).toBe(true); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should return that the worker not uses mana', async() => { + const tx = await models.Sale.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const usesMana = await models.Sale.usesMana(ctx, options); + + expect(usesMana).toBe(false); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); From e7261573d7954cd9ce129efc0dd945e1114febfe Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 21 Oct 2022 08:01:22 +0200 Subject: [PATCH 67/93] delete focus --- modules/ticket/back/methods/sale/specs/updatePrice.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js index f8cb5a4ec..15b00a732 100644 --- a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js +++ b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('sale updatePrice()', () => { +describe('sale updatePrice()', () => { const ctx = { req: { accessToken: {userId: 18}, From 2d0cb60b50825144113edde29f97f084240002ac Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 21 Oct 2022 08:55:05 +0200 Subject: [PATCH 68/93] feat: check if uses mana --- modules/ticket/front/sale/index.html | 14 ++++++++++++-- modules/ticket/front/sale/index.js | 8 ++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 42eb10cb0..35e45a812 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -264,6 +264,16 @@
+ + + + + + @@ -278,7 +288,7 @@
-
Mana: {{::$ctrl.edit.mana | currency: 'EUR':0}}
+
MANÁ: {{::$ctrl.edit.mana | currency: 'EUR': 0}}
- + { + this.useMana = res.data; + }); + } + /** * Returns checked instances * From c33cab7b10b94be095f0b96e4c2860e68e3fcf36 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 21 Oct 2022 09:01:08 +0200 Subject: [PATCH 69/93] fix: test back --- .../back/methods/ticket/specs/updateDiscount.spec.js | 10 ++++++++++ modules/ticket/back/methods/ticket/updateDiscount.js | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js index 1873207aa..5249fe5d8 100644 --- a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js +++ b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js @@ -110,6 +110,11 @@ describe('sale updateDiscount()', () => { const componentId = manaDiscount.id; const manaCode = 'mana'; + const teamCLopez = 96; + const userId = ctx.req.accessToken.userId; + const business = await models.Business.findOne({where: {workerFk: userId}}, options); + await business.updateAttribute('departmentFk', teamCLopez, options); + await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaCode, options); const updatedSale = await models.Sale.findById(originalSaleId, null, options); @@ -150,6 +155,11 @@ describe('sale updateDiscount()', () => { const componentId = manaDiscount.id; const manaCode = 'manaClaim'; + const teamCLopez = 96; + const userId = ctx.req.accessToken.userId; + const business = await models.Business.findOne({where: {workerFk: userId}}, options); + await business.updateAttribute('departmentFk', teamCLopez, options); + await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaCode, options); const updatedSale = await models.Sale.findById(originalSaleId, null, options); diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index 9419b9a40..8bc79ca9c 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -98,7 +98,7 @@ module.exports = Self => { if (isLocked || (!hasAllowedRoles && alertLevel > 0)) throw new UserError(`The sales of this ticket can't be modified`); - const usesMana = await models.Sale.usesMana(ctx); + const usesMana = await models.Sale.usesMana(ctx, myOptions); const componentCode = usesMana ? manaCode : 'buyerDiscount'; const discountComponent = await models.Component.findOne({ where: {code: componentCode}}, myOptions); From f968b19d1e2603036050fbc2b5b17680f5b05d13 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 21 Oct 2022 09:08:17 +0200 Subject: [PATCH 70/93] fix: testFront --- modules/ticket/front/sale/index.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index 28d874932..a7260a3ec 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -115,6 +115,7 @@ describe('Ticket', () => { const expectedAmount = 250; $httpBackend.expect('GET', 'Tickets/1/getSalesPersonMana').respond(200, expectedAmount); + $httpBackend.expect('GET', 'Sales/usesMana').respond(200); $httpBackend.expect('GET', 'WorkerManas/getCurrentWorkerMana').respond(200, expectedAmount); controller.getMana(); $httpBackend.flush(); From 18c119c62a88a0e1959d1af2e00d22f9a91e37b1 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 21 Oct 2022 09:20:27 +0200 Subject: [PATCH 71/93] change acl --- db/changes/10491-august/00-aclBusiness.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/changes/10491-august/00-aclBusiness.sql b/db/changes/10491-august/00-aclBusiness.sql index f1f7a3632..8ea2c6d83 100644 --- a/db/changes/10491-august/00-aclBusiness.sql +++ b/db/changes/10491-august/00-aclBusiness.sql @@ -1,3 +1,3 @@ INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES - ('Business', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file + ('Business', '*', '*', 'ALLOW', 'ROLE', 'hr'); \ No newline at end of file From 8a3573474a99de0a60a330ab00c0fd106273c406 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 25 Oct 2022 07:40:32 +0200 Subject: [PATCH 72/93] refactor: move 'lastEntries' to thrid position in descriptor --- modules/item/front/routes.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/item/front/routes.json b/modules/item/front/routes.json index 52cf5d2be..3dea69ba1 100644 --- a/modules/item/front/routes.json +++ b/modules/item/front/routes.json @@ -15,12 +15,12 @@ "card": [ {"state": "item.card.basicData", "icon": "settings"}, {"state": "item.card.tags", "icon": "icon-tags"}, + {"state": "item.card.last-entries", "icon": "icon-regentry"}, {"state": "item.card.tax", "icon": "icon-tax"}, {"state": "item.card.botanical", "icon": "local_florist"}, {"state": "item.card.shelving", "icon": "icon-inventory"}, {"state": "item.card.itemBarcode", "icon": "icon-barcode"}, {"state": "item.card.diary", "icon": "icon-transaction"}, - {"state": "item.card.last-entries", "icon": "icon-regentry"}, {"state": "item.card.log", "icon": "history"} ], "itemType": [ From 7f1dd801a55aff414fbaf06eacbbdb8bf25039ad Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 25 Oct 2022 07:56:17 +0200 Subject: [PATCH 73/93] refactor: change ACLs --- db/changes/10491-august/00-aclItemShelving.sql | 3 --- db/changes/10491-august/00-aclItemShelvingPlacementSupply.sql | 3 --- db/changes/10500-november/00-itemShelvingACL.sql | 4 ++++ .../10500-november/00-itemShelvingPlacementSupplyStockACL.sql | 4 ++++ 4 files changed, 8 insertions(+), 6 deletions(-) delete mode 100644 db/changes/10491-august/00-aclItemShelving.sql delete mode 100644 db/changes/10491-august/00-aclItemShelvingPlacementSupply.sql create mode 100644 db/changes/10500-november/00-itemShelvingACL.sql create mode 100644 db/changes/10500-november/00-itemShelvingPlacementSupplyStockACL.sql diff --git a/db/changes/10491-august/00-aclItemShelving.sql b/db/changes/10491-august/00-aclItemShelving.sql deleted file mode 100644 index 3995bbe49..000000000 --- a/db/changes/10491-august/00-aclItemShelving.sql +++ /dev/null @@ -1,3 +0,0 @@ -INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) - VALUES - ('ItemShelving', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10491-august/00-aclItemShelvingPlacementSupply.sql b/db/changes/10491-august/00-aclItemShelvingPlacementSupply.sql deleted file mode 100644 index cc589a58f..000000000 --- a/db/changes/10491-august/00-aclItemShelvingPlacementSupply.sql +++ /dev/null @@ -1,3 +0,0 @@ -INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) - VALUES - ('ItemShelvingPlacementSupplyStock', '*', '*', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/db/changes/10500-november/00-itemShelvingACL.sql b/db/changes/10500-november/00-itemShelvingACL.sql new file mode 100644 index 000000000..fc32fe1ed --- /dev/null +++ b/db/changes/10500-november/00-itemShelvingACL.sql @@ -0,0 +1,4 @@ +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) +VALUES + ('ItemShelving', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), + ('ItemShelving', '*', 'WRITE', 'ALLOW', 'ROLE', 'production'); \ No newline at end of file diff --git a/db/changes/10500-november/00-itemShelvingPlacementSupplyStockACL.sql b/db/changes/10500-november/00-itemShelvingPlacementSupplyStockACL.sql new file mode 100644 index 000000000..25eac8d51 --- /dev/null +++ b/db/changes/10500-november/00-itemShelvingPlacementSupplyStockACL.sql @@ -0,0 +1,4 @@ +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) +VALUES + ('ItemShelvingPlacementSupplyStock', '*', 'READ', 'ALLOW', 'ROLE', 'employee'); + From 23598c993b74572e0a658d66560636197832d9b4 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 25 Oct 2022 09:25:15 +0200 Subject: [PATCH 74/93] Change ACL from employee to hr --- db/changes/10491-august/00-ACL_workerDisableExcluded.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/changes/10491-august/00-ACL_workerDisableExcluded.sql b/db/changes/10491-august/00-ACL_workerDisableExcluded.sql index 7a23ca68a..2fd9e8b12 100644 --- a/db/changes/10491-august/00-ACL_workerDisableExcluded.sql +++ b/db/changes/10491-august/00-ACL_workerDisableExcluded.sql @@ -1,2 +1,2 @@ INSERT INTO `salix`.`ACL` (model,property,accessType,permission,principalId) - VALUES ('WorkerDisableExcluded','*','*','ALLOW','employee'); + VALUES ('WorkerDisableExcluded','*','*','ALLOW','hr'); \ No newline at end of file From 07a18dc736048fd3f6304daa80a9ef0fcf985e0c Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 26 Oct 2022 08:05:11 +0200 Subject: [PATCH 75/93] delete sql --- db/changes/10491-august/00-itemType.sql | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 db/changes/10491-august/00-itemType.sql diff --git a/db/changes/10491-august/00-itemType.sql b/db/changes/10491-august/00-itemType.sql deleted file mode 100644 index d201acf37..000000000 --- a/db/changes/10491-august/00-itemType.sql +++ /dev/null @@ -1,5 +0,0 @@ -ALTER TABLE `vn`.`itemType` CHANGE `transaction` transaction__ tinyint(4) DEFAULT 0 NOT NULL; -ALTER TABLE `vn`.`itemType` CHANGE location location__ varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL; -ALTER TABLE `vn`.`itemType` CHANGE hasComponents hasComponents__ tinyint(1) DEFAULT 1 NOT NULL; -ALTER TABLE `vn`.`itemType` CHANGE warehouseFk warehouseFk__ smallint(6) unsigned DEFAULT 60 NOT NULL; -ALTER TABLE `vn`.`itemType` CHANGE compression compression__ decimal(5,2) DEFAULT 1.00 NULL; \ No newline at end of file From 925565d3d24037bb53d209823db0b5cef12bc83c Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 26 Oct 2022 08:23:36 +0200 Subject: [PATCH 76/93] =?UTF-8?q?refator:=20borrada=20variable=20global=20?= =?UTF-8?q?y=20a=C3=B1adida=20Promesa=20al=20array?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/ticket/back/methods/ticket/updateDiscount.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/ticket/back/methods/ticket/updateDiscount.js b/modules/ticket/back/methods/ticket/updateDiscount.js index 7e7c4e06d..a60d732b1 100644 --- a/modules/ticket/back/methods/ticket/updateDiscount.js +++ b/modules/ticket/back/methods/ticket/updateDiscount.js @@ -133,20 +133,20 @@ module.exports = Self => { } }, myOptions); - let newComponent; + let deletedComponent; if (oldComponent) { const filter = { saleFk: sale.id, componentFk: oldComponent.componentFk }; - await models.SaleComponent.destroyAll(filter, myOptions); + deletedComponent = await models.SaleComponent.destroyAll(filter, myOptions); } - await createSaleComponent(sale.id, value, componentId, myOptions); + const newComponent = await createSaleComponent(sale.id, value, componentId, myOptions); const updatedSale = sale.updateAttribute('discount', newDiscount, myOptions); - promises.push(newComponent, updatedSale); + promises.push(newComponent, updatedSale, deletedComponent); const change = `${oldDiscount}% ➔ *${newDiscount}%*`; changesMade += `\r\n-${sale.itemFk}: ${sale.concept} (${sale.quantity}) ${change}`; @@ -193,7 +193,7 @@ module.exports = Self => { async function createSaleComponent(saleId, value, componentId, myOptions) { const models = Self.app.models; - newComponent = models.SaleComponent.create({ + return models.SaleComponent.create({ saleFk: saleId, value: value, componentFk: componentId From f65d06fc7db84905be5543c7a1f7e34ebece9ce9 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 26 Oct 2022 08:27:28 +0200 Subject: [PATCH 77/93] fixes #4073 --- back/methods/account/privileges.js | 26 +++++++++------ back/methods/account/specs/privileges.spec.js | 14 ++++---- db/changes/10490-august/00-user_hasGrant.sql | 3 ++ db/dump/fixtures.sql | 8 ++--- e2e/paths/14-account/07_ldap.spec.js | 9 ++++++ e2e/paths/14-account/08_samba.spec.js | 9 ++++++ e2e/paths/14-account/09_privileges.spec.js | 32 +++++++++++++++++-- loopback/locale/en.json | 6 ++-- loopback/locale/es.json | 6 ++-- .../account/front/privileges/locale/es.yml | 2 +- modules/client/back/models/client.js | 9 ++++-- 11 files changed, 93 insertions(+), 31 deletions(-) diff --git a/back/methods/account/privileges.js b/back/methods/account/privileges.js index df421125e..6510779f2 100644 --- a/back/methods/account/privileges.js +++ b/back/methods/account/privileges.js @@ -29,6 +29,8 @@ module.exports = Self => { }); Self.privileges = async function(ctx, id, roleFk, hasGrant, options) { + if (!(hasGrant != null || roleFk)) return; + const models = Self.app.models; const userId = ctx.req.accessToken.userId; @@ -37,22 +39,26 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const user = await models.Account.findById(userId, null, myOptions); + const user = await models.Account.findById(userId, {fields: ['hasGrant']}, myOptions); if (!user.hasGrant) - throw new UserError(`You don't have enough privileges`); + throw new UserError(`You don't have grant privilege`); - const userToUpdate = await models.Account.findById(id); + const userToUpdate = await models.Account.findById(id, ['name', 'hasGrant', 'roleFk'], myOptions); if (hasGrant != null) - return await userToUpdate.updateAttribute('hasGrant', hasGrant, myOptions); - if (!roleFk) return; + userToUpdate.hasGrant = hasGrant; - const role = await models.Role.findById(roleFk, null, myOptions); - const hasRole = await models.Account.hasRole(userId, role.name, myOptions); + if (roleFk) { + const role = await models.Role.findById(roleFk, {fields: ['name']}, myOptions); + const hasRole = await models.Account.hasRole(userId, role.name, myOptions); - if (!hasRole) - throw new UserError(`You don't have enough privileges`); + if (!hasRole) + throw new UserError(`You don't own the role and you can't assign it to another user`); - await userToUpdate.updateAttribute('roleFk', roleFk, myOptions); + userToUpdate.roleFk = roleFk; + } + + await userToUpdate.save(userToUpdate); + await models.UserAccount.sync(userToUpdate.name); }; }; diff --git a/back/methods/account/specs/privileges.spec.js b/back/methods/account/specs/privileges.spec.js index 137c08671..959130e8b 100644 --- a/back/methods/account/specs/privileges.spec.js +++ b/back/methods/account/specs/privileges.spec.js @@ -4,7 +4,7 @@ describe('account privileges()', () => { const employeeId = 1; const developerId = 9; const sysadminId = 66; - const bruceWayneId = 1101; + const clarkKent = 1103; it('should throw an error when user not has privileges', async() => { const ctx = {req: {accessToken: {userId: developerId}}}; @@ -22,7 +22,7 @@ describe('account privileges()', () => { await tx.rollback(); } - expect(error.message).toContain(`You don't have enough privileges`); + expect(error.message).toContain(`You don't have grant privilege`); }); it('should throw an error when user has privileges but not has the role', async() => { @@ -46,7 +46,7 @@ describe('account privileges()', () => { await tx.rollback(); } - expect(error.message).toContain(`You don't have enough privileges`); + expect(error.message).toContain(`You don't own the role and you can't assign it to another user`); }); it('should change role', async() => { @@ -63,8 +63,8 @@ describe('account privileges()', () => { let error; let result; try { - await models.Account.privileges(ctx, bruceWayneId, agency.id, null, options); - result = await models.Account.findById(bruceWayneId, null, options); + await models.Account.privileges(ctx, clarkKent, agency.id, null, options); + result = await models.Account.findById(clarkKent, null, options); await tx.rollback(); } catch (e) { @@ -84,8 +84,8 @@ describe('account privileges()', () => { let result; try { const options = {transaction: tx}; - await models.Account.privileges(ctx, bruceWayneId, null, true, options); - result = await models.Account.findById(bruceWayneId, null, options); + await models.Account.privileges(ctx, clarkKent, null, true, options); + result = await models.Account.findById(clarkKent, null, options); await tx.rollback(); } catch (e) { diff --git a/db/changes/10490-august/00-user_hasGrant.sql b/db/changes/10490-august/00-user_hasGrant.sql index 60d1273d8..05a09f87b 100644 --- a/db/changes/10490-august/00-user_hasGrant.sql +++ b/db/changes/10490-august/00-user_hasGrant.sql @@ -1 +1,4 @@ ALTER TABLE `account`.`user` ADD hasGrant TINYINT(1) NOT NULL; + +INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) + VALUES('Account', 'privileges', '*', 'ALLOW', 'ROLE', '$authenticated'); diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 7e59c1a54..c4079adc0 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -14,10 +14,10 @@ INSERT INTO `salix`.`AccessToken` (`id`, `ttl`, `created`, `userId`) ('DEFAULT_TOKEN', '1209600', util.VN_CURDATE(), 66); INSERT INTO `salix`.`printConfig` (`id`, `itRecipient`, `incidencesEmail`) - VALUES + VALUES (1, 'it@gotamcity.com', 'incidences@gotamcity.com'); -INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) +INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`) VALUES ('1', '6'); @@ -45,8 +45,8 @@ INSERT INTO `account`.`roleConfig`(`id`, `mysqlPassword`, `rolePrefix`, `userPre CALL `account`.`role_sync`; -INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active`,`email`, `lang`, `image`) - SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@mydomain.com'), 'en', '4fa3ada0-3ac4-11eb-9ab8-27f6fc3b85fd' +INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `password`,`role`,`active`,`email`, `lang`, `image`, `bcryptPassword`) + SELECT id, name, CONCAT(name, 'Nick'),MD5('nightmare'), id, 1, CONCAT(name, '@mydomain.com'), 'en', '4fa3ada0-3ac4-11eb-9ab8-27f6fc3b85fd', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2' FROM `account`.`role` WHERE id <> 20 ORDER BY id; diff --git a/e2e/paths/14-account/07_ldap.spec.js b/e2e/paths/14-account/07_ldap.spec.js index a3b8137d3..eb22f695c 100644 --- a/e2e/paths/14-account/07_ldap.spec.js +++ b/e2e/paths/14-account/07_ldap.spec.js @@ -29,4 +29,13 @@ describe('Account LDAP path', () => { expect(message.text).toContain('Data saved!'); }); + + it('should reset data', async() => { + await page.waitToClick(selectors.accountLdap.checkEnable); + await page.waitToClick(selectors.accountLdap.save); + + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); }); diff --git a/e2e/paths/14-account/08_samba.spec.js b/e2e/paths/14-account/08_samba.spec.js index c3db026dc..6e7ef9bbf 100644 --- a/e2e/paths/14-account/08_samba.spec.js +++ b/e2e/paths/14-account/08_samba.spec.js @@ -29,4 +29,13 @@ describe('Account Samba path', () => { expect(message.text).toContain('Data saved!'); }); + + it('should reset data', async() => { + await page.waitToClick(selectors.accountSamba.checkEnable); + await page.waitToClick(selectors.accountSamba.save); + + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); }); diff --git a/e2e/paths/14-account/09_privileges.spec.js b/e2e/paths/14-account/09_privileges.spec.js index 71e9345a8..e4b8fb24c 100644 --- a/e2e/paths/14-account/09_privileges.spec.js +++ b/e2e/paths/14-account/09_privileges.spec.js @@ -24,7 +24,7 @@ describe('Account privileges path', () => { const message = await page.waitForSnackbar(); - expect(message.text).toContain(`You don't have enough privileges`); + expect(message.text).toContain(`You don't have grant privilege`); }); it('should throw error when change role', async() => { @@ -33,7 +33,7 @@ describe('Account privileges path', () => { const message = await page.waitForSnackbar(); - expect(message.text).toContain(`You don't have enough privileges`); + expect(message.text).toContain(`You don't have grant privilege`); }); }); @@ -56,7 +56,16 @@ describe('Account privileges path', () => { expect(result).toBe('checked'); }); - it('should change role', async() => { + it('should throw error when change role and not own role', async() => { + await page.autocompleteSearch(selectors.accountPrivileges.role, 'itBoss'); + await page.waitToClick(selectors.accountPrivileges.save); + + const message = await page.waitForSnackbar(); + + expect(message.text).toContain(`You don't own the role and you can't assign it to another user`); + }); + + it('should change role to employee', async() => { await page.autocompleteSearch(selectors.accountPrivileges.role, 'employee'); await page.waitToClick(selectors.accountPrivileges.save); const message = await page.waitForSnackbar(); @@ -67,6 +76,18 @@ describe('Account privileges path', () => { expect(message.text).toContain(`Data saved!`); expect(result).toContain('employee'); }); + + it('should return role to developer', async() => { + await page.autocompleteSearch(selectors.accountPrivileges.role, 'developer'); + await page.waitToClick(selectors.accountPrivileges.save); + const message = await page.waitForSnackbar(); + + await page.reloadSection('account.card.privileges'); + const result = await page.waitToGetProperty(selectors.accountPrivileges.role, 'value'); + + expect(message.text).toContain(`Data saved!`); + expect(result).toContain('developer'); + }); }); describe('as developer again', () => { @@ -76,7 +97,12 @@ describe('Account privileges path', () => { await page.waitToClick(selectors.accountPrivileges.checkHasGrant); await page.waitToClick(selectors.accountPrivileges.save); + const message = await page.waitForSnackbar(); + expect(message.text).toContain(`Data saved!`); + }); + + it('should logIn in developer', async() => { await page.reloadSection('account.card.privileges'); const result = await page.checkboxState(selectors.accountPrivileges.checkHasGrant); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index e5a0fae32..1e151294f 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -133,5 +133,7 @@ "Descanso semanal 36h. / 72h.": "Weekly rest 36h. / 72h.", "Password does not meet requirements": "Password does not meet requirements", "You don't have privileges to change the zone": "You don't have privileges to change the zone or for these parameters there are more than one shipping options, talk to agencies", - "Not enough privileges to edit a client": "Not enough privileges to edit a client" -} \ No newline at end of file + "Not enough privileges to edit a client": "Not enough privileges to edit a client", + "You don't have grant privilege": "You don't have grant privilege", + "You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user" +} diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 67370b343..a41315dd1 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -235,5 +235,7 @@ "Dirección incorrecta": "Dirección incorrecta", "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador", "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador", - "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente" -} \ No newline at end of file + "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", + "You don't have grant privilege": "No tienes privilegios para dar privilegios", + "You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario" +} diff --git a/modules/account/front/privileges/locale/es.yml b/modules/account/front/privileges/locale/es.yml index f7330e1be..17f1ef29e 100644 --- a/modules/account/front/privileges/locale/es.yml +++ b/modules/account/front/privileges/locale/es.yml @@ -1,2 +1,2 @@ Privileges: Privilegios -Has grant: Tiene privilegios +Has grant: Puede dar privilegios diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index 3bd89eff1..e66cdb83f 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -425,14 +425,19 @@ module.exports = Self => { account.observe('before save', async ctx => { if (ctx.isNewInstance) return; - ctx.hookState.oldInstance = JSON.parse(JSON.stringify(ctx.currentInstance)); + if (ctx.currentInstance) + ctx.hookState.oldInstance = JSON.parse(JSON.stringify(ctx.currentInstance)); }); account.observe('after save', async ctx => { const changes = ctx.data || ctx.instance; if (!ctx.isNewInstance && changes) { const oldData = ctx.hookState.oldInstance; - const hasChanges = oldData.name != changes.name || oldData.active != changes.active; + let hasChanges; + + if (oldData) + hasChanges = oldData.name != changes.name || oldData.active != changes.active; + if (!hasChanges) return; const isClient = await Self.app.models.Client.count({id: oldData.id}); From d4e278363009abaa45090212dc3e50a2f0430086 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 26 Oct 2022 08:39:07 +0200 Subject: [PATCH 78/93] =?UTF-8?q?refactor:=20corregidas=20traducciones,=20?= =?UTF-8?q?eliminado=20destroyAll=20y=20a=C3=B1adida=20transacci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- loopback/locale/es.json | 2 +- .../back/methods/expedition/deleteExpeditions.js | 10 +++++++--- .../ticket/back/methods/expedition/moveExpeditions.js | 4 ++-- .../methods/expedition/specs/deleteExpeditions.spec.js | 2 +- modules/ticket/front/expedition/index.html | 2 +- modules/ticket/front/expedition/locale/es.yml | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index bd9de41c2..2d9bae1d8 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -236,5 +236,5 @@ "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador", "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador", "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", - "This route not exists": "Esta ruta no existe" + "This route does not exists": "Esta ruta no existe" } \ No newline at end of file diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index 5b9d0daaa..2419d3a5e 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -33,9 +33,13 @@ module.exports = Self => { } try { - const deletedExpeditions = await models.Expedition.destroyAll({ - id: {inq: expeditionIds} - }, myOptions); + const promises = []; + for (let expeditionId of expeditionIds) { + const deletedExpedition = models.Expedition.destroyById(expeditionId, myOptions); + promises.push(deletedExpedition); + } + + const deletedExpeditions = await Promise.all(promises); if (tx) await tx.commit(); diff --git a/modules/ticket/back/methods/expedition/moveExpeditions.js b/modules/ticket/back/methods/expedition/moveExpeditions.js index d0f8aa893..cef35ab86 100644 --- a/modules/ticket/back/methods/expedition/moveExpeditions.js +++ b/modules/ticket/back/methods/expedition/moveExpeditions.js @@ -70,12 +70,12 @@ module.exports = Self => { try { if (args.routeId) { const route = await models.Route.findById(args.routeId, null, myOptions); - if (!route) throw new UserError('This route not exists'); + if (!route) throw new UserError('This route does not exists'); } const ticket = await models.Ticket.new(ctx, myOptions); const promises = []; for (let expeditionsId of args.expeditionIds) { - const expeditionToUpdate = await models.Expedition.findById(expeditionsId); + const expeditionToUpdate = await models.Expedition.findById(expeditionsId, null, myOptions); const expeditionUpdated = expeditionToUpdate.updateAttribute('ticketFk', ticket.id, myOptions); promises.push(expeditionUpdated); } diff --git a/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js index 0a47c78da..14bdf7aea 100644 --- a/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js +++ b/modules/ticket/back/methods/expedition/specs/deleteExpeditions.spec.js @@ -10,7 +10,7 @@ describe('ticket deleteExpeditions()', () => { const expeditionIds = [12, 13]; const result = await models.Expedition.deleteExpeditions(expeditionIds, options); - expect(result.count).toEqual(2); + expect(result.length).toEqual(2); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/front/expedition/index.html b/modules/ticket/front/expedition/index.html index 0ebe388c1..ec6dc7ee2 100644 --- a/modules/ticket/front/expedition/index.html +++ b/modules/ticket/front/expedition/index.html @@ -159,7 +159,7 @@ diff --git a/modules/ticket/front/expedition/locale/es.yml b/modules/ticket/front/expedition/locale/es.yml index 68812f985..278dcc8f2 100644 --- a/modules/ticket/front/expedition/locale/es.yml +++ b/modules/ticket/front/expedition/locale/es.yml @@ -3,4 +3,4 @@ Expedition removed: Expedición eliminada Move: Mover New ticket without route: Nuevo ticket sin ruta New ticket with route: Nuevo ticket con ruta -Id route: Id ruta \ No newline at end of file +Route id: Id ruta \ No newline at end of file From d1e2b1f7d5ff9b98b8d62554e879c539937337dc Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 26 Oct 2022 09:02:54 +0200 Subject: [PATCH 79/93] refactor: tranducciones --- modules/ticket/front/sale/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ticket/front/sale/index.html b/modules/ticket/front/sale/index.html index 35e45a812..c68138141 100644 --- a/modules/ticket/front/sale/index.html +++ b/modules/ticket/front/sale/index.html @@ -244,7 +244,7 @@
-
MANÁ: {{::$ctrl.edit.mana | currency: 'EUR': 0}}
+
Mana: {{::$ctrl.edit.mana | currency: 'EUR': 0}}
-
MANÁ: {{::$ctrl.edit.mana | currency: 'EUR': 0}}
+
Mana: {{::$ctrl.edit.mana | currency: 'EUR': 0}}
Date: Wed, 26 Oct 2022 09:04:53 +0200 Subject: [PATCH 80/93] refactor: renombrada variable --- .../ticket/back/methods/sale/specs/updatePrice.spec.js | 4 ++-- modules/ticket/back/methods/sale/specs/usesMana.spec.js | 4 ++-- .../back/methods/ticket/specs/updateDiscount.spec.js | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js index 15b00a732..51cd2403f 100644 --- a/modules/ticket/back/methods/sale/specs/updatePrice.spec.js +++ b/modules/ticket/back/methods/sale/specs/updatePrice.spec.js @@ -79,11 +79,11 @@ describe('sale updatePrice()', () => { const price = 5.4; const originalSalesPersonMana = await models.WorkerMana.findById(18, null, options); const manaComponent = await models.Component.findOne({where: {code: 'mana'}}, options); - const teamCLopez = 96; + const teamOne = 96; const userId = ctx.req.accessToken.userId; const business = await models.Business.findOne({where: {workerFk: userId}}, options); - await business.updateAttribute('departmentFk', teamCLopez, options); + await business.updateAttribute('departmentFk', teamOne, options); await models.Sale.updatePrice(ctx, saleId, price, options); const updatedSale = await models.Sale.findById(saleId, null, options); diff --git a/modules/ticket/back/methods/sale/specs/usesMana.spec.js b/modules/ticket/back/methods/sale/specs/usesMana.spec.js index 4e14ed2c9..777bdc8f0 100644 --- a/modules/ticket/back/methods/sale/specs/usesMana.spec.js +++ b/modules/ticket/back/methods/sale/specs/usesMana.spec.js @@ -12,11 +12,11 @@ describe('sale usesMana()', () => { try { const options = {transaction: tx}; - const teamCLopez = 96; + const teamOne = 96; const userId = ctx.req.accessToken.userId; const business = await models.Business.findOne({where: {workerFk: userId}}, options); - await business.updateAttribute('departmentFk', teamCLopez, options); + await business.updateAttribute('departmentFk', teamOne, options); const usesMana = await models.Sale.usesMana(ctx, options); diff --git a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js index 5249fe5d8..1f6712087 100644 --- a/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js +++ b/modules/ticket/back/methods/ticket/specs/updateDiscount.spec.js @@ -110,10 +110,10 @@ describe('sale updateDiscount()', () => { const componentId = manaDiscount.id; const manaCode = 'mana'; - const teamCLopez = 96; + const teamOne = 96; const userId = ctx.req.accessToken.userId; const business = await models.Business.findOne({where: {workerFk: userId}}, options); - await business.updateAttribute('departmentFk', teamCLopez, options); + await business.updateAttribute('departmentFk', teamOne, options); await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaCode, options); @@ -155,10 +155,10 @@ describe('sale updateDiscount()', () => { const componentId = manaDiscount.id; const manaCode = 'manaClaim'; - const teamCLopez = 96; + const teamOne = 96; const userId = ctx.req.accessToken.userId; const business = await models.Business.findOne({where: {workerFk: userId}}, options); - await business.updateAttribute('departmentFk', teamCLopez, options); + await business.updateAttribute('departmentFk', teamOne, options); await models.Ticket.updateDiscount(ctx, ticketId, sales, newDiscount, manaCode, options); From 21e2945d4f6b59df9b239fd197b8845dbda7f8ef Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 26 Oct 2022 09:30:17 +0200 Subject: [PATCH 81/93] refactor: delete destroyAll --- .../methods/item-shelving/deleteItemShelvings.js | 12 ++++++++---- .../item-shelving/specs/deleteItemShelvings.spec.js | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/item/back/methods/item-shelving/deleteItemShelvings.js b/modules/item/back/methods/item-shelving/deleteItemShelvings.js index 0b58970d8..f534b4e9a 100644 --- a/modules/item/back/methods/item-shelving/deleteItemShelvings.js +++ b/modules/item/back/methods/item-shelving/deleteItemShelvings.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethod('deleteItemShelvings', { - description: 'Deletes the selected orders', + description: 'Deletes the selected item shelvings', accessType: 'WRITE', accepts: [{ arg: 'itemShelvingIds', @@ -32,9 +32,13 @@ module.exports = Self => { } try { - const deletedItemShelvings = await models.ItemShelving.destroyAll({ - id: {inq: itemShelvingIds} - }, myOptions); + const promises = []; + for (let itemShelvingId of itemShelvingIds) { + const itemShelvingToDelete = models.ItemShelving.destroyById(itemShelvingId, myOptions); + promises.push(itemShelvingToDelete); + } + + const deletedItemShelvings = await Promise.all(promises); if (tx) await tx.commit(); diff --git a/modules/item/back/methods/item-shelving/specs/deleteItemShelvings.spec.js b/modules/item/back/methods/item-shelving/specs/deleteItemShelvings.spec.js index a152b5981..b4113d7cf 100644 --- a/modules/item/back/methods/item-shelving/specs/deleteItemShelvings.spec.js +++ b/modules/item/back/methods/item-shelving/specs/deleteItemShelvings.spec.js @@ -10,7 +10,7 @@ describe('ItemShelving deleteItemShelvings()', () => { const itemShelvingIds = [1, 2]; const result = await models.ItemShelving.deleteItemShelvings(itemShelvingIds, options); - expect(result.count).toEqual(2); + expect(result.length).toEqual(2); await tx.rollback(); } catch (e) { From 3ffc098b56d8ee9724edfe2c26a8e5813ab11857 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 27 Oct 2022 09:01:09 +0200 Subject: [PATCH 82/93] feat(privileges): check if user has role from userToUpdate --- back/methods/account/privileges.js | 17 +++++++++++++++-- back/models/account.json | 7 +++++++ db/changes/10490-august/00-user_hasGrant.sql | 3 --- modules/account/front/privileges/locale/es.yml | 2 +- package.json | 2 +- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/back/methods/account/privileges.js b/back/methods/account/privileges.js index 6510779f2..f3f500e7d 100644 --- a/back/methods/account/privileges.js +++ b/back/methods/account/privileges.js @@ -44,15 +44,28 @@ module.exports = Self => { if (!user.hasGrant) throw new UserError(`You don't have grant privilege`); - const userToUpdate = await models.Account.findById(id, ['name', 'hasGrant', 'roleFk'], myOptions); + const [userToUpdate] = await models.Account.find({ + fields: ['id', 'name', 'hasGrant', 'roleFk', 'password'], + include: { + relation: 'role', + scope: { + fields: ['name'] + } + }, + where: { + id: id + } + }, myOptions); + if (hasGrant != null) userToUpdate.hasGrant = hasGrant; if (roleFk) { const role = await models.Role.findById(roleFk, {fields: ['name']}, myOptions); const hasRole = await models.Account.hasRole(userId, role.name, myOptions); + const hasRoleFromUser = await models.Account.hasRole(userId, userToUpdate.role().name, myOptions); - if (!hasRole) + if (!hasRole || !hasRoleFromUser) throw new UserError(`You don't own the role and you can't assign it to another user`); userToUpdate.roleFk = roleFk; diff --git a/back/models/account.json b/back/models/account.json index c25cd532d..d0c17e70f 100644 --- a/back/models/account.json +++ b/back/models/account.json @@ -102,6 +102,13 @@ "principalType": "ROLE", "principalId": "$authenticated", "permission": "ALLOW" + }, + { + "property": "privileges", + "accessType": "*", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" } ] } diff --git a/db/changes/10490-august/00-user_hasGrant.sql b/db/changes/10490-august/00-user_hasGrant.sql index 05a09f87b..60d1273d8 100644 --- a/db/changes/10490-august/00-user_hasGrant.sql +++ b/db/changes/10490-august/00-user_hasGrant.sql @@ -1,4 +1 @@ ALTER TABLE `account`.`user` ADD hasGrant TINYINT(1) NOT NULL; - -INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalType, principalId) - VALUES('Account', 'privileges', '*', 'ALLOW', 'ROLE', '$authenticated'); diff --git a/modules/account/front/privileges/locale/es.yml b/modules/account/front/privileges/locale/es.yml index 17f1ef29e..d66a7a6cf 100644 --- a/modules/account/front/privileges/locale/es.yml +++ b/modules/account/front/privileges/locale/es.yml @@ -1,2 +1,2 @@ Privileges: Privilegios -Has grant: Puede dar privilegios +Has grant: Puede delegar privilegios diff --git a/package.json b/package.json index 92ca13e45..573e42335 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "node-ssh": "^11.0.0", "object-diff": "0.0.4", "object.pick": "^1.3.0", - "puppeteer": "^18.0.5", + "puppeteer": "^19.0.0", "read-chunk": "^3.2.0", "require-yaml": "0.0.1", "sharp": "^0.27.1", From 6a2bc5b593cd25aab07e9cae201ce44c1cbbd772 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 27 Oct 2022 09:18:32 +0200 Subject: [PATCH 83/93] Disabled back tests --- Jenkinsfile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4a1f9ba54..440b5d0d3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -62,14 +62,14 @@ pipeline { } } } - stage('Backend') { - steps { - nodejs('node-v14') { - sh 'npm run test:back:ci' - } - } - } - } + // stage('Backend') { + // steps { + // nodejs('node-v14') { + // sh 'npm run test:back:ci' + // } + // } + // } + // } } stage('Build') { when { anyOf { From 51f95f0261e611401f6c33802c79378845d4c058 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 27 Oct 2022 09:23:08 +0200 Subject: [PATCH 84/93] Fixed error --- Jenkinsfile | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 440b5d0d3..69cdc70b3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -62,14 +62,6 @@ pipeline { } } } - // stage('Backend') { - // steps { - // nodejs('node-v14') { - // sh 'npm run test:back:ci' - // } - // } - // } - // } } stage('Build') { when { anyOf { From 714fe325525502d34a8302020076082864daf5f8 Mon Sep 17 00:00:00 2001 From: joan Date: Thu, 27 Oct 2022 09:26:02 +0200 Subject: [PATCH 85/93] Fix error --- Jenkinsfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 69cdc70b3..5a8ff39c5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -62,6 +62,14 @@ pipeline { } } } + // stage('Backend') { + // steps { + // nodejs('node-v14') { + // sh 'npm run test:back:ci' + // } + // } + // } + } } stage('Build') { when { anyOf { From 5c65314162a8e3d821cf9346ad454828306a7de1 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 27 Oct 2022 09:27:50 +0200 Subject: [PATCH 86/93] use findById --- back/methods/account/privileges.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/back/methods/account/privileges.js b/back/methods/account/privileges.js index f3f500e7d..d3aa9bf59 100644 --- a/back/methods/account/privileges.js +++ b/back/methods/account/privileges.js @@ -44,16 +44,13 @@ module.exports = Self => { if (!user.hasGrant) throw new UserError(`You don't have grant privilege`); - const [userToUpdate] = await models.Account.find({ + const userToUpdate = await models.Account.findById(id, { fields: ['id', 'name', 'hasGrant', 'roleFk', 'password'], include: { relation: 'role', scope: { fields: ['name'] } - }, - where: { - id: id } }, myOptions); From 9225e8f176c192464bae875f4324ca393ab8734e Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 27 Oct 2022 15:11:57 +0200 Subject: [PATCH 87/93] fix tests --- back/methods/chat/sendCheckingPresence.js | 4 ++ .../10500-november/00-deletePickupContact.sql | 1 + db/dump/fixtures.sql | 8 ++-- .../back/methods/claim/claimPickupEmail.js | 41 +++++++++---------- modules/claim/front/descriptor/index.js | 5 +-- modules/claim/front/descriptor/index.spec.js | 12 +----- package.json | 2 +- .../claim-pickup-order/claim-pickup-order.js | 21 +++++----- .../email/claim-pickup-order/sql/ticket.sql | 4 ++ 9 files changed, 47 insertions(+), 51 deletions(-) create mode 100644 db/changes/10500-november/00-deletePickupContact.sql create mode 100644 print/templates/email/claim-pickup-order/sql/ticket.sql diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 3bc022429..556a16260 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -25,6 +25,7 @@ module.exports = Self => { }); Self.sendCheckingPresence = async(ctx, recipientId, message, options) => { + console.log(ctx, recipientId, message, options); if (!recipientId) return false; const myOptions = {}; @@ -38,7 +39,10 @@ module.exports = Self => { const recipient = await models.Account.findById(recipientId, null, myOptions); // Prevent sending messages to yourself + console.log('llega'); + console.log(recipientId, userId); if (recipientId == userId) return false; + console.log('llega2'); if (!recipient) throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`); diff --git a/db/changes/10500-november/00-deletePickupContact.sql b/db/changes/10500-november/00-deletePickupContact.sql new file mode 100644 index 000000000..6bfa662c5 --- /dev/null +++ b/db/changes/10500-november/00-deletePickupContact.sql @@ -0,0 +1 @@ +ALTER TABLE `vn`.`claimConfig` DROP COLUMN `pickupContact`; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 9a0a1fff6..34e592b9a 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1778,10 +1778,10 @@ INSERT INTO `vn`.`claimEnd`(`id`, `saleFk`, `claimFk`, `workerFk`, `claimDestina (1, 31, 4, 21, 2), (2, 32, 3, 21, 3); -INSERT INTO `vn`.`claimConfig`(`id`, `pickupContact`, `maxResponsibility`) +INSERT INTO `vn`.`claimConfig`(`id`, `maxResponsibility`) VALUES - (1, 'Contact description', 50), - (2, 'Contact description', 30); + (1, 50), + (2, 30); INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRate`, `priceIncreasing`, `packingRate`) VALUES @@ -1791,7 +1791,7 @@ INSERT INTO `vn`.`claimRatio`(`clientFk`, `yearSale`, `claimAmount`, `claimingRa (1104, 2500, 150.00, 0.02, 0.10, 1.00); INSERT INTO vn.claimRma (`id`, `code`, `created`, `workerFk`) -VALUES + VALUES (1, '02676A049183', DEFAULT, 1106), (2, '02676A049183', DEFAULT, 1106), (3, '02676A049183', DEFAULT, 1107), diff --git a/modules/claim/back/methods/claim/claimPickupEmail.js b/modules/claim/back/methods/claim/claimPickupEmail.js index 4c9b86502..23f0e31ef 100644 --- a/modules/claim/back/methods/claim/claimPickupEmail.js +++ b/modules/claim/back/methods/claim/claimPickupEmail.js @@ -9,7 +9,7 @@ module.exports = Self => { arg: 'id', type: 'number', required: true, - description: 'The client id', + description: 'The claim id', http: {source: 'path'} }, { @@ -29,24 +29,6 @@ module.exports = Self => { type: 'number', description: 'The recipient id to send to the recipient preferred language', required: false - }, - { - arg: 'ticketId', - type: 'number', - description: 'The ticket id', - required: true - }, - { - arg: 'salesPersonId', - type: 'number', - description: 'The salesPerson id', - required: false - }, - { - arg: 'clientName', - type: 'string', - description: 'The client name', - required: true } ], returns: { @@ -75,14 +57,29 @@ module.exports = Self => { for (const param in args) params[param] = args[param]; + const claim = await models.Claim.findById(args.id, { + fields: ['id', 'clientFk'], + include: { + relation: 'client', + scope: { + fields: ['name', 'salesPersonFk'] + } + } + }); + console.log(claim); + const message = $t('Claim pickup order sent', { claimId: args.id, - clientName: args.clientName, + clientName: claim.client.name, claimUrl: `${origin}/#!/claim/${args.id}/summary`, }); - if (args.salesPersonId) - await models.Chat.sendCheckingPresence(ctx, args.salesPersonId, message); + console.log(claim.client()); + const salesPersonId = claim.client().salesPersonFk; + if (claim.client().salesPersonFk) + console.log(await models.Chat.sendCheckingPresence(ctx, 25, message)); + + console.log(claim.client().salesPersonFk); await models.ClaimLog.create({ originFk: args.id, diff --git a/modules/claim/front/descriptor/index.js b/modules/claim/front/descriptor/index.js index b36fae321..0dddadbe1 100644 --- a/modules/claim/front/descriptor/index.js +++ b/modules/claim/front/descriptor/index.js @@ -19,10 +19,7 @@ class Controller extends Descriptor { sendPickupOrder() { return this.vnEmail.send(`Claims/${this.claim.id}/claim-pickup-email`, { recipient: this.claim.client.email, - recipientId: this.claim.clientFk, - clientName: this.claim.client.name, - ticketId: this.claim.ticket.id, - salesPersonId: this.claim.client.salesPersonFk + recipientId: this.claim.clientFk }); } diff --git a/modules/claim/front/descriptor/index.spec.js b/modules/claim/front/descriptor/index.spec.js index 18ccdaff5..e6785d3d8 100644 --- a/modules/claim/front/descriptor/index.spec.js +++ b/modules/claim/front/descriptor/index.spec.js @@ -7,12 +7,7 @@ describe('Item Component vnClaimDescriptor', () => { const claim = { id: 2, clientFk: 1101, - client: { - email: 'client@email', - name: 'clientName', - salesPersonFk: 18 - }, - ticket: {id: 2} + client: {email: 'client@email'} }; beforeEach(ngModule('claim')); @@ -45,10 +40,7 @@ describe('Item Component vnClaimDescriptor', () => { const params = { recipient: claim.client.email, - recipientId: claim.clientFk, - clientName: claim.client.name, - ticketId: claim.ticket.id, - salesPersonId: claim.client.salesPersonFk + recipientId: claim.clientFk }; controller.sendPickupOrder(); diff --git a/package.json b/package.json index 26c164832..be6db46a8 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "node-ssh": "^11.0.0", "object-diff": "0.0.4", "object.pick": "^1.3.0", - "puppeteer": "^18.0.5", + "puppeteer": "^19.2.0", "read-chunk": "^3.2.0", "require-yaml": "0.0.1", "sharp": "^0.31.0", diff --git a/print/templates/email/claim-pickup-order/claim-pickup-order.js b/print/templates/email/claim-pickup-order/claim-pickup-order.js index 51db21cb5..b8804c604 100755 --- a/print/templates/email/claim-pickup-order/claim-pickup-order.js +++ b/print/templates/email/claim-pickup-order/claim-pickup-order.js @@ -8,22 +8,23 @@ module.exports = { 'email-header': emailHeader.build(), 'email-footer': emailFooter.build() }, - created() { - this.instructions = this.$t('description.instructions', [this.id, this.ticketId]); + async serverPrefetch() { + this.ticket = await this.fetchTicket(this.id); + + if (!this.ticket) + throw new Error('Something went wrong'); + console.log(); + this.instructions = this.$t('description.instructions', [this.id, this.ticket.id]); }, - data() { - return { - instructions: String - }; + methods: { + fetchTicket(id) { + return this.findOneFromDef('ticket', [id]); + } }, props: { id: { type: [Number, String], required: true - }, - ticketId: { - type: [Number, String], - required: true } } }; diff --git a/print/templates/email/claim-pickup-order/sql/ticket.sql b/print/templates/email/claim-pickup-order/sql/ticket.sql new file mode 100644 index 000000000..28b78c987 --- /dev/null +++ b/print/templates/email/claim-pickup-order/sql/ticket.sql @@ -0,0 +1,4 @@ +SELECT + c.ticketFk as id +FROM claim c +WHERE c.id = ? From ad1b429d10d1d0d66373f54fbc9c6fafbae57600 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 28 Oct 2022 08:09:47 +0200 Subject: [PATCH 88/93] check if user has role from userToUpdate --- back/methods/account/privileges.js | 14 ++++++---- back/methods/account/specs/privileges.spec.js | 28 +++++++++++++++---- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/back/methods/account/privileges.js b/back/methods/account/privileges.js index d3aa9bf59..5c5e7409d 100644 --- a/back/methods/account/privileges.js +++ b/back/methods/account/privileges.js @@ -41,9 +41,6 @@ module.exports = Self => { const user = await models.Account.findById(userId, {fields: ['hasGrant']}, myOptions); - if (!user.hasGrant) - throw new UserError(`You don't have grant privilege`); - const userToUpdate = await models.Account.findById(id, { fields: ['id', 'name', 'hasGrant', 'roleFk', 'password'], include: { @@ -54,15 +51,22 @@ module.exports = Self => { } }, myOptions); + if (!user.hasGrant) + throw new UserError(`You don't have grant privilege`); + + const hasRoleFromUser = await models.Account.hasRole(userId, userToUpdate.role().name, myOptions); + + if (!hasRoleFromUser) + throw new UserError(`You don't own the role and you can't assign it to another user`); + if (hasGrant != null) userToUpdate.hasGrant = hasGrant; if (roleFk) { const role = await models.Role.findById(roleFk, {fields: ['name']}, myOptions); const hasRole = await models.Account.hasRole(userId, role.name, myOptions); - const hasRoleFromUser = await models.Account.hasRole(userId, userToUpdate.role().name, myOptions); - if (!hasRole || !hasRoleFromUser) + if (!hasRole) throw new UserError(`You don't own the role and you can't assign it to another user`); userToUpdate.roleFk = roleFk; diff --git a/back/methods/account/specs/privileges.spec.js b/back/methods/account/specs/privileges.spec.js index 959130e8b..edfe0f03f 100644 --- a/back/methods/account/specs/privileges.spec.js +++ b/back/methods/account/specs/privileges.spec.js @@ -4,6 +4,8 @@ describe('account privileges()', () => { const employeeId = 1; const developerId = 9; const sysadminId = 66; + const itBossId = 104; + const rootId = 100; const clarkKent = 1103; it('should throw an error when user not has privileges', async() => { @@ -33,12 +35,26 @@ describe('account privileges()', () => { try { const options = {transaction: tx}; - const root = await models.Role.findOne({ - where: { - name: 'root' - } - }, options); - await models.Account.privileges(ctx, employeeId, root.id, null, options); + await models.Account.privileges(ctx, employeeId, rootId, null, options); + + await tx.rollback(); + } catch (e) { + error = e; + await tx.rollback(); + } + + expect(error.message).toContain(`You don't own the role and you can't assign it to another user`); + }); + + it('should throw an error when user has privileges but not has the role from user', async() => { + const ctx = {req: {accessToken: {userId: sysadminId}}}; + const tx = await models.Account.beginTransaction({}); + + let error; + try { + const options = {transaction: tx}; + + await models.Account.privileges(ctx, itBossId, developerId, null, options); await tx.rollback(); } catch (e) { From 9170c22d6f80515a3251ba003ac8494fc0c5b262 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 28 Oct 2022 09:21:28 +0200 Subject: [PATCH 89/93] fix send email --- back/methods/chat/sendCheckingPresence.js | 4 ---- modules/claim/back/methods/claim/claimPickupEmail.js | 10 +++------- .../email/claim-pickup-order/claim-pickup-order.js | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 556a16260..3bc022429 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -25,7 +25,6 @@ module.exports = Self => { }); Self.sendCheckingPresence = async(ctx, recipientId, message, options) => { - console.log(ctx, recipientId, message, options); if (!recipientId) return false; const myOptions = {}; @@ -39,10 +38,7 @@ module.exports = Self => { const recipient = await models.Account.findById(recipientId, null, myOptions); // Prevent sending messages to yourself - console.log('llega'); - console.log(recipientId, userId); if (recipientId == userId) return false; - console.log('llega2'); if (!recipient) throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`); diff --git a/modules/claim/back/methods/claim/claimPickupEmail.js b/modules/claim/back/methods/claim/claimPickupEmail.js index 23f0e31ef..c688d6ded 100644 --- a/modules/claim/back/methods/claim/claimPickupEmail.js +++ b/modules/claim/back/methods/claim/claimPickupEmail.js @@ -66,20 +66,16 @@ module.exports = Self => { } } }); - console.log(claim); const message = $t('Claim pickup order sent', { claimId: args.id, - clientName: claim.client.name, + clientName: claim.client().name, claimUrl: `${origin}/#!/claim/${args.id}/summary`, }); - console.log(claim.client()); const salesPersonId = claim.client().salesPersonFk; - if (claim.client().salesPersonFk) - console.log(await models.Chat.sendCheckingPresence(ctx, 25, message)); - - console.log(claim.client().salesPersonFk); + if (salesPersonId) + await models.Chat.sendCheckingPresence(ctx, salesPersonId, message); await models.ClaimLog.create({ originFk: args.id, diff --git a/print/templates/email/claim-pickup-order/claim-pickup-order.js b/print/templates/email/claim-pickup-order/claim-pickup-order.js index b8804c604..29f295b1e 100755 --- a/print/templates/email/claim-pickup-order/claim-pickup-order.js +++ b/print/templates/email/claim-pickup-order/claim-pickup-order.js @@ -13,7 +13,7 @@ module.exports = { if (!this.ticket) throw new Error('Something went wrong'); - console.log(); + this.instructions = this.$t('description.instructions', [this.id, this.ticket.id]); }, methods: { From 57e74fab38f00017cd2cc41621dfa475b5724e2a Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 28 Oct 2022 15:53:57 +0200 Subject: [PATCH 90/93] refs #4716 tipos actualizados --- print/templates/email/campaign-metrics/campaign-metrics.js | 2 +- .../templates/email/claim-pickup-order/claim-pickup-order.js | 2 +- .../email/client-debt-statement/client-debt-statement.js | 2 +- print/templates/email/client-welcome/client-welcome.js | 2 +- .../templates/email/delivery-note-link/delivery-note-link.js | 2 +- print/templates/email/delivery-note/delivery-note.js | 2 +- print/templates/email/driver-route/driver-route.js | 2 +- .../email/incoterms-authorization/incoterms-authorization.js | 4 ++-- print/templates/email/invoice/invoice.js | 2 +- print/templates/email/letter-debtor-nd/letter-debtor-nd.js | 4 ++-- print/templates/email/letter-debtor-st/letter-debtor-st.js | 4 ++-- print/templates/email/payment-update/payment-update.js | 2 +- print/templates/email/printer-setup/printer-setup.js | 2 +- print/templates/email/sepa-core/sepa-core.js | 4 ++-- .../supplier-campaign-metrics/supplier-campaign-metrics.js | 2 +- print/templates/reports/campaign-metrics/campaign-metrics.js | 2 +- .../reports/claim-pickup-order/claim-pickup-order.js | 2 +- .../reports/client-debt-statement/client-debt-statement.js | 2 +- print/templates/reports/delivery-note/delivery-note.js | 2 +- print/templates/reports/driver-route/driver-route.js | 2 +- print/templates/reports/entry-order/entry-order.js | 2 +- print/templates/reports/exportation/exportation.js | 2 +- .../incoterms-authorization/incoterms-authorization.js | 4 ++-- .../templates/reports/invoice-incoterms/invoice-incoterms.js | 2 +- print/templates/reports/letter-debtor/letter-debtor.js | 4 ++-- print/templates/reports/receipt/receipt.js | 2 +- print/templates/reports/sepa-core/sepa-core.js | 4 ++-- .../supplier-campaign-metrics/supplier-campaign-metrics.js | 2 +- print/templates/reports/zone/zone.js | 2 +- 29 files changed, 36 insertions(+), 36 deletions(-) diff --git a/print/templates/email/campaign-metrics/campaign-metrics.js b/print/templates/email/campaign-metrics/campaign-metrics.js index 0c3a01991..c3ff4a5ca 100755 --- a/print/templates/email/campaign-metrics/campaign-metrics.js +++ b/print/templates/email/campaign-metrics/campaign-metrics.js @@ -21,7 +21,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true }, from: { diff --git a/print/templates/email/claim-pickup-order/claim-pickup-order.js b/print/templates/email/claim-pickup-order/claim-pickup-order.js index d3836db39..bdb338628 100755 --- a/print/templates/email/claim-pickup-order/claim-pickup-order.js +++ b/print/templates/email/claim-pickup-order/claim-pickup-order.js @@ -10,7 +10,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true } } diff --git a/print/templates/email/client-debt-statement/client-debt-statement.js b/print/templates/email/client-debt-statement/client-debt-statement.js index 85b3c5cc3..06b81199b 100755 --- a/print/templates/email/client-debt-statement/client-debt-statement.js +++ b/print/templates/email/client-debt-statement/client-debt-statement.js @@ -23,7 +23,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true }, from: { diff --git a/print/templates/email/client-welcome/client-welcome.js b/print/templates/email/client-welcome/client-welcome.js index 380837877..8fcba39ad 100755 --- a/print/templates/email/client-welcome/client-welcome.js +++ b/print/templates/email/client-welcome/client-welcome.js @@ -18,7 +18,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true } } diff --git a/print/templates/email/delivery-note-link/delivery-note-link.js b/print/templates/email/delivery-note-link/delivery-note-link.js index 1804bf144..8df9826c2 100755 --- a/print/templates/email/delivery-note-link/delivery-note-link.js +++ b/print/templates/email/delivery-note-link/delivery-note-link.js @@ -10,7 +10,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true } } diff --git a/print/templates/email/delivery-note/delivery-note.js b/print/templates/email/delivery-note/delivery-note.js index ba3d44001..672f70b18 100755 --- a/print/templates/email/delivery-note/delivery-note.js +++ b/print/templates/email/delivery-note/delivery-note.js @@ -10,7 +10,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true } } diff --git a/print/templates/email/driver-route/driver-route.js b/print/templates/email/driver-route/driver-route.js index 0895ccc8c..fb459fa93 100755 --- a/print/templates/email/driver-route/driver-route.js +++ b/print/templates/email/driver-route/driver-route.js @@ -10,7 +10,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true } } diff --git a/print/templates/email/incoterms-authorization/incoterms-authorization.js b/print/templates/email/incoterms-authorization/incoterms-authorization.js index b1c7286dd..1665fb580 100755 --- a/print/templates/email/incoterms-authorization/incoterms-authorization.js +++ b/print/templates/email/incoterms-authorization/incoterms-authorization.js @@ -23,12 +23,12 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true, description: 'The client id' }, companyId: { - type: [Number, String], + type: Number, required: true } } diff --git a/print/templates/email/invoice/invoice.js b/print/templates/email/invoice/invoice.js index fe66062aa..6720e7102 100755 --- a/print/templates/email/invoice/invoice.js +++ b/print/templates/email/invoice/invoice.js @@ -18,7 +18,7 @@ module.exports = { }, props: { reference: { - type: [Number, String], + type: Number, required: true } } diff --git a/print/templates/email/letter-debtor-nd/letter-debtor-nd.js b/print/templates/email/letter-debtor-nd/letter-debtor-nd.js index cf9cc7ddd..35a7d8655 100755 --- a/print/templates/email/letter-debtor-nd/letter-debtor-nd.js +++ b/print/templates/email/letter-debtor-nd/letter-debtor-nd.js @@ -34,11 +34,11 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true }, companyId: { - type: [Number, String], + type: Number, required: true } } diff --git a/print/templates/email/letter-debtor-st/letter-debtor-st.js b/print/templates/email/letter-debtor-st/letter-debtor-st.js index 1a6555673..0fd2b45c7 100755 --- a/print/templates/email/letter-debtor-st/letter-debtor-st.js +++ b/print/templates/email/letter-debtor-st/letter-debtor-st.js @@ -34,11 +34,11 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true }, companyId: { - type: [Number, String], + type: Number, required: true }, } diff --git a/print/templates/email/payment-update/payment-update.js b/print/templates/email/payment-update/payment-update.js index a9d99d4ef..11ace3410 100755 --- a/print/templates/email/payment-update/payment-update.js +++ b/print/templates/email/payment-update/payment-update.js @@ -26,7 +26,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true, description: 'The client id' } diff --git a/print/templates/email/printer-setup/printer-setup.js b/print/templates/email/printer-setup/printer-setup.js index a7d3c40bf..8de0fc54f 100755 --- a/print/templates/email/printer-setup/printer-setup.js +++ b/print/templates/email/printer-setup/printer-setup.js @@ -24,7 +24,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true } } diff --git a/print/templates/email/sepa-core/sepa-core.js b/print/templates/email/sepa-core/sepa-core.js index 00cc527dc..33eb86bce 100755 --- a/print/templates/email/sepa-core/sepa-core.js +++ b/print/templates/email/sepa-core/sepa-core.js @@ -16,11 +16,11 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true }, companyId: { - type: [Number, String], + type: Number, required: true } } diff --git a/print/templates/email/supplier-campaign-metrics/supplier-campaign-metrics.js b/print/templates/email/supplier-campaign-metrics/supplier-campaign-metrics.js index 9cb9210ef..dee227ea2 100755 --- a/print/templates/email/supplier-campaign-metrics/supplier-campaign-metrics.js +++ b/print/templates/email/supplier-campaign-metrics/supplier-campaign-metrics.js @@ -21,7 +21,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true }, from: { diff --git a/print/templates/reports/campaign-metrics/campaign-metrics.js b/print/templates/reports/campaign-metrics/campaign-metrics.js index b60a2b7eb..7c3913549 100755 --- a/print/templates/reports/campaign-metrics/campaign-metrics.js +++ b/print/templates/reports/campaign-metrics/campaign-metrics.js @@ -25,7 +25,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true, description: 'The client id' }, diff --git a/print/templates/reports/claim-pickup-order/claim-pickup-order.js b/print/templates/reports/claim-pickup-order/claim-pickup-order.js index f7d21a2d3..358adbadd 100755 --- a/print/templates/reports/claim-pickup-order/claim-pickup-order.js +++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.js @@ -36,7 +36,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true, description: 'The claim id' } diff --git a/print/templates/reports/client-debt-statement/client-debt-statement.js b/print/templates/reports/client-debt-statement/client-debt-statement.js index 80c83b494..81e9d7f43 100755 --- a/print/templates/reports/client-debt-statement/client-debt-statement.js +++ b/print/templates/reports/client-debt-statement/client-debt-statement.js @@ -69,7 +69,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true, description: 'The client id' }, diff --git a/print/templates/reports/delivery-note/delivery-note.js b/print/templates/reports/delivery-note/delivery-note.js index 1037e5129..7045ef709 100755 --- a/print/templates/reports/delivery-note/delivery-note.js +++ b/print/templates/reports/delivery-note/delivery-note.js @@ -127,7 +127,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true, description: 'The ticket id' }, diff --git a/print/templates/reports/driver-route/driver-route.js b/print/templates/reports/driver-route/driver-route.js index 2de3d5192..001537941 100755 --- a/print/templates/reports/driver-route/driver-route.js +++ b/print/templates/reports/driver-route/driver-route.js @@ -44,7 +44,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true, description: 'The route id' } diff --git a/print/templates/reports/entry-order/entry-order.js b/print/templates/reports/entry-order/entry-order.js index ff4a65e0c..18fc4a5ea 100755 --- a/print/templates/reports/entry-order/entry-order.js +++ b/print/templates/reports/entry-order/entry-order.js @@ -40,7 +40,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true, description: 'The entry id' } diff --git a/print/templates/reports/exportation/exportation.js b/print/templates/reports/exportation/exportation.js index 630baf421..0aab05fee 100755 --- a/print/templates/reports/exportation/exportation.js +++ b/print/templates/reports/exportation/exportation.js @@ -30,7 +30,7 @@ module.exports = { }, props: { reference: { - type: [Number, String], + type: Number, required: true, description: 'The invoice ref' } diff --git a/print/templates/reports/incoterms-authorization/incoterms-authorization.js b/print/templates/reports/incoterms-authorization/incoterms-authorization.js index 26637b8c2..3eb5b65ea 100755 --- a/print/templates/reports/incoterms-authorization/incoterms-authorization.js +++ b/print/templates/reports/incoterms-authorization/incoterms-authorization.js @@ -21,12 +21,12 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true, description: 'The client id' }, companyId: { - type: [Number, String], + type: Number, required: true } } diff --git a/print/templates/reports/invoice-incoterms/invoice-incoterms.js b/print/templates/reports/invoice-incoterms/invoice-incoterms.js index 3dbe76ac3..ba9981373 100755 --- a/print/templates/reports/invoice-incoterms/invoice-incoterms.js +++ b/print/templates/reports/invoice-incoterms/invoice-incoterms.js @@ -32,7 +32,7 @@ module.exports = { }, props: { reference: { - type: [Number, String], + type: Number, required: true, description: 'The invoice ref' } diff --git a/print/templates/reports/letter-debtor/letter-debtor.js b/print/templates/reports/letter-debtor/letter-debtor.js index 80d4cba9b..083d9fd71 100755 --- a/print/templates/reports/letter-debtor/letter-debtor.js +++ b/print/templates/reports/letter-debtor/letter-debtor.js @@ -63,12 +63,12 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true, description: 'The client id' }, companyId: { - type: [Number, String], + type: Number, required: true } } diff --git a/print/templates/reports/receipt/receipt.js b/print/templates/reports/receipt/receipt.js index 401aa1ef3..b368764b1 100755 --- a/print/templates/reports/receipt/receipt.js +++ b/print/templates/reports/receipt/receipt.js @@ -25,7 +25,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true, description: 'Receipt id' } diff --git a/print/templates/reports/sepa-core/sepa-core.js b/print/templates/reports/sepa-core/sepa-core.js index 73e0beaaa..85121b392 100755 --- a/print/templates/reports/sepa-core/sepa-core.js +++ b/print/templates/reports/sepa-core/sepa-core.js @@ -40,12 +40,12 @@ const rptSepaCore = { }, props: { id: { - type: [Number, String], + type: Number, required: true, description: 'The client id' }, companyId: { - type: [Number, String], + type: Number, required: true } } diff --git a/print/templates/reports/supplier-campaign-metrics/supplier-campaign-metrics.js b/print/templates/reports/supplier-campaign-metrics/supplier-campaign-metrics.js index 6a58cbd0e..fee5796d2 100755 --- a/print/templates/reports/supplier-campaign-metrics/supplier-campaign-metrics.js +++ b/print/templates/reports/supplier-campaign-metrics/supplier-campaign-metrics.js @@ -49,7 +49,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true, description: 'The supplier id' }, diff --git a/print/templates/reports/zone/zone.js b/print/templates/reports/zone/zone.js index bbce9df36..d237c50c0 100755 --- a/print/templates/reports/zone/zone.js +++ b/print/templates/reports/zone/zone.js @@ -13,7 +13,7 @@ module.exports = { }, props: { id: { - type: [Number, String], + type: Number, required: true, description: 'The zone id' } From 463d3e6e1292431b89fb7e4ebc5c017dcfe5cadc Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 31 Oct 2022 12:39:26 +0100 Subject: [PATCH 91/93] Fixes --- modules/claim/back/models/claim-rma.json | 2 +- modules/claim/back/models/claim.json | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/claim/back/models/claim-rma.json b/modules/claim/back/models/claim-rma.json index e3849422c..27c3c9729 100644 --- a/modules/claim/back/models/claim-rma.json +++ b/modules/claim/back/models/claim-rma.json @@ -8,8 +8,8 @@ }, "properties": { "id": { - "type": "number", "id": true, + "type": "number", "description": "Identifier" }, "code": { diff --git a/modules/claim/back/models/claim.json b/modules/claim/back/models/claim.json index 76125c483..14c4f3452 100644 --- a/modules/claim/back/models/claim.json +++ b/modules/claim/back/models/claim.json @@ -57,11 +57,11 @@ "model": "ClaimState", "foreignKey": "claimStateFk" }, - "claimRma": { - "type": "belongsTo", + "rmas": { + "type": "hasMany", "model": "ClaimRma", - "foreignKey": "rma", - "primaryKey": "code" + "foreignKey": "code", + "primaryKey": "rma" }, "client": { "type": "belongsTo", From ac6fbd07a9e51160d09ab0a694607e598fda740a Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 31 Oct 2022 13:24:39 +0100 Subject: [PATCH 92/93] Upgraded node version --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9caaa30a1..378a87f84 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ RUN apt-get update \ libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 \ libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 \ libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget \ - && curl -sL https://deb.nodesource.com/setup_12.x | bash - \ + && curl -sL https://deb.nodesource.com/setup_14.x | bash - \ && apt-get install -y --no-install-recommends \ nodejs \ && apt-get purge -y --auto-remove \ From a7b1ee85fec2bcd7eab29fed84c642de265224f7 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 2 Nov 2022 07:27:57 +0100 Subject: [PATCH 93/93] fix changes folder --- .../{10490-goldenSummer => 10500-november}/00-aclNotification.sql | 0 .../{10490-august => 10500-november}/00-packingSiteConfig.sql | 0 .../{10490-august => 10500-november}/00-packingSiteUpdate.sql | 0 db/changes/{10490-august => 10500-november}/00-salix_url.sql | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename db/changes/{10490-goldenSummer => 10500-november}/00-aclNotification.sql (100%) rename db/changes/{10490-august => 10500-november}/00-packingSiteConfig.sql (100%) rename db/changes/{10490-august => 10500-november}/00-packingSiteUpdate.sql (100%) rename db/changes/{10490-august => 10500-november}/00-salix_url.sql (100%) diff --git a/db/changes/10490-goldenSummer/00-aclNotification.sql b/db/changes/10500-november/00-aclNotification.sql similarity index 100% rename from db/changes/10490-goldenSummer/00-aclNotification.sql rename to db/changes/10500-november/00-aclNotification.sql diff --git a/db/changes/10490-august/00-packingSiteConfig.sql b/db/changes/10500-november/00-packingSiteConfig.sql similarity index 100% rename from db/changes/10490-august/00-packingSiteConfig.sql rename to db/changes/10500-november/00-packingSiteConfig.sql diff --git a/db/changes/10490-august/00-packingSiteUpdate.sql b/db/changes/10500-november/00-packingSiteUpdate.sql similarity index 100% rename from db/changes/10490-august/00-packingSiteUpdate.sql rename to db/changes/10500-november/00-packingSiteUpdate.sql diff --git a/db/changes/10490-august/00-salix_url.sql b/db/changes/10500-november/00-salix_url.sql similarity index 100% rename from db/changes/10490-august/00-salix_url.sql rename to db/changes/10500-november/00-salix_url.sql