From dfdf3d68bffb6ef991d85f0985c74b1a0315b696 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 24 Nov 2022 09:36:05 +0100 Subject: [PATCH 01/94] changes needed for the worker Notification manager to work --- .../methods/notification/deleteSubcription.js | 56 +++++++++++++++++++ back/models/notificationAcl.json | 10 ++++ back/models/notificationSubscription.js | 3 + back/models/notificationSubscription.json | 1 - 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 back/methods/notification/deleteSubcription.js create mode 100644 back/models/notificationSubscription.js diff --git a/back/methods/notification/deleteSubcription.js b/back/methods/notification/deleteSubcription.js new file mode 100644 index 000000000..9095613fe --- /dev/null +++ b/back/methods/notification/deleteSubcription.js @@ -0,0 +1,56 @@ +module.exports = Self => { + Self.remoteMethod('deleteSubscription', { + description: 'delete a notification subscription', + accessType: 'WRITE', + accepts: [ + { + arg: 'notificationId', + type: 'string', + required: true + }, + { + arg: 'userId', + type: 'string', + required: true + } + ], + returns: { + type: 'object', + root: true + }, + http: { + path: `/deleteSubscription`, + verb: 'POST' + } + }); + + Self.deleteSubscription = async(notificationId, userId, options) => { + const myOptions = {}; + let tx; + + if (typeof options == 'object') + + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + + myOptions.transaction = tx; + } + + try { + const query = `DELETE FROM util.notificationSubscription + WHERE notificationFk = ? AND userFk = ?`; + + await Self.rawSql(query, [notificationId, userId], myOptions); + + if (tx) await tx.commit(); + + return {success: true}; + } catch (error) { + if (tx) await tx.rollback(); + + throw error; + } + }; +}; diff --git a/back/models/notificationAcl.json b/back/models/notificationAcl.json index e3e97f52d..a20187961 100644 --- a/back/models/notificationAcl.json +++ b/back/models/notificationAcl.json @@ -6,6 +6,16 @@ "table": "util.notificationAcl" } }, + "properties":{ + "notificationFk": { + "id": true, + "type": "number" + }, + "roleFk":{ + "id": true, + "type": "number" + } + }, "relations": { "notification": { "type": "belongsTo", diff --git a/back/models/notificationSubscription.js b/back/models/notificationSubscription.js new file mode 100644 index 000000000..ce5d89e8b --- /dev/null +++ b/back/models/notificationSubscription.js @@ -0,0 +1,3 @@ +module.exports = Self => { + require('../methods/notification/deleteSubcription')(Self); +}; diff --git a/back/models/notificationSubscription.json b/back/models/notificationSubscription.json index 43fa6db27..11dbde6fb 100644 --- a/back/models/notificationSubscription.json +++ b/back/models/notificationSubscription.json @@ -9,7 +9,6 @@ "properties": { "notificationFk": { "type": "number", - "id": true, "description": "Identifier" }, "userFk": { From 3e08650b6f7f1210f6905861818673dd3df402a3 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Fri, 25 Nov 2022 07:06:04 +0100 Subject: [PATCH 02/94] acls for the notifications --- db/changes/10503-november/00-acl-notifications.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/changes/10503-november/00-acl-notifications.sql diff --git a/db/changes/10503-november/00-acl-notifications.sql b/db/changes/10503-november/00-acl-notifications.sql new file mode 100644 index 000000000..b2377393b --- /dev/null +++ b/db/changes/10503-november/00-acl-notifications.sql @@ -0,0 +1,3 @@ +INSERT INTO salix.ACL (model,property,accessType,principalId) + VALUES ('NotificationSubscription','*','*','employee'), + VALUES ('NotificationAcl','*','*','employee'); \ No newline at end of file From 074763f633bd54113d9220a2a708c9074958668b Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Fri, 25 Nov 2022 11:47:23 +0100 Subject: [PATCH 03/94] rename files --- .../{00-acl-notifications.sql => 00-acl_notifications.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/changes/10503-november/{00-acl-notifications.sql => 00-acl_notifications.sql} (100%) diff --git a/db/changes/10503-november/00-acl-notifications.sql b/db/changes/10503-november/00-acl_notifications.sql similarity index 100% rename from db/changes/10503-november/00-acl-notifications.sql rename to db/changes/10503-november/00-acl_notifications.sql From aee7cd113ef7c6355ca51fffae9721a42ff92a04 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Mon, 28 Nov 2022 09:33:14 +0100 Subject: [PATCH 04/94] add template strings to sql --- db/changes/10503-november/00-acl_notifications.sql | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/db/changes/10503-november/00-acl_notifications.sql b/db/changes/10503-november/00-acl_notifications.sql index b2377393b..ee2e2e345 100644 --- a/db/changes/10503-november/00-acl_notifications.sql +++ b/db/changes/10503-november/00-acl_notifications.sql @@ -1,3 +1,4 @@ -INSERT INTO salix.ACL (model,property,accessType,principalId) - VALUES ('NotificationSubscription','*','*','employee'), - VALUES ('NotificationAcl','*','*','employee'); \ No newline at end of file +INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`principalId`) + VALUES + ('NotificationSubscription','*','*','employee'), + ('NotificationAcl','*','*','employee'); \ No newline at end of file From ada3e6f175da8e0564866a9b3608a39fa385cb8f Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 27 Dec 2022 10:10:37 +0100 Subject: [PATCH 05/94] update sql folder --- db/changes/224903/00-acl_notifications.sql | 4 ---- db/changes/230201/00-acl_notifications.sql | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) delete mode 100644 db/changes/224903/00-acl_notifications.sql create mode 100644 db/changes/230201/00-acl_notifications.sql diff --git a/db/changes/224903/00-acl_notifications.sql b/db/changes/224903/00-acl_notifications.sql deleted file mode 100644 index ee2e2e345..000000000 --- a/db/changes/224903/00-acl_notifications.sql +++ /dev/null @@ -1,4 +0,0 @@ -INSERT INTO `salix`.`ACL` (`model`,`property`,`accessType`,`principalId`) - VALUES - ('NotificationSubscription','*','*','employee'), - ('NotificationAcl','*','*','employee'); \ No newline at end of file diff --git a/db/changes/230201/00-acl_notifications.sql b/db/changes/230201/00-acl_notifications.sql new file mode 100644 index 000000000..ef710aca6 --- /dev/null +++ b/db/changes/230201/00-acl_notifications.sql @@ -0,0 +1,3 @@ + VALUES + ('NotificationSubscription','*','*','employee'), + ('NotificationAcl','*','*','employee'); \ No newline at end of file From 5eda1388efdbe94854308d31a6798982df6a4fc7 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 27 Dec 2022 10:26:56 +0100 Subject: [PATCH 06/94] refs #4927 unique key added --- CHANGELOG.md | 4 ++-- db/changes/230201/.gitkeep | 0 db/changes/230201/00-SupplierUniqueKey.sql | 1 + modules/supplier/back/models/supplier.js | 4 ---- 4 files changed, 3 insertions(+), 6 deletions(-) delete mode 100644 db/changes/230201/.gitkeep create mode 100644 db/changes/230201/00-SupplierUniqueKey.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 95b3028de..906dd002c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- +- ### Changed -- \ No newline at end of file +- Se permite añadir Proveedores con la misma razón social pero con países distintos diff --git a/db/changes/230201/.gitkeep b/db/changes/230201/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/db/changes/230201/00-SupplierUniqueKey.sql b/db/changes/230201/00-SupplierUniqueKey.sql new file mode 100644 index 000000000..9c0d4a192 --- /dev/null +++ b/db/changes/230201/00-SupplierUniqueKey.sql @@ -0,0 +1 @@ +ALTER TABLE `vn`.`supplier` ADD UNIQUE (name, countryFk); diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index 44549c65c..64c585b6a 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -16,10 +16,6 @@ module.exports = Self => { message: 'The social name cannot be empty' }); - Self.validatesUniquenessOf('name', { - message: 'The supplier name must be unique' - }); - if (this.city) { Self.validatesPresenceOf('city', { message: 'City cannot be empty' From 3ca1d1f4ee6e7b4853d4c8c04df17017f6e79ded Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 27 Dec 2022 10:29:15 +0100 Subject: [PATCH 07/94] remove error in fixtures --- db/dump/fixtures.sql | 4 ---- 1 file changed, 4 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 762e5411a..ff87b4bd0 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1954,10 +1954,6 @@ INSERT INTO `vn`.`workerBusinessType` (`id`, `name`, `isFullTime`, `isPermanent` (100, 'INDEFINIDO A TIEMPO COMPLETO', 1, 1, 1), (109, 'CONVERSION DE TEMPORAL EN INDEFINIDO T.COMPLETO', 1, 1, 1); -INSERT INTO `vn`.`businessCategory` (`id`, `description`, `rate`) - VALUES - (1, 'basic employee', 1); - UPDATE `vn`.`business` b SET `rate` = 7, `workerBusinessCategoryFk` = 1, From ea7f4b7c02172517a94f4077febf5d635409f846 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 27 Dec 2022 10:34:12 +0100 Subject: [PATCH 08/94] remove broken fixture --- db/dump/fixtures.sql | 4 ---- 1 file changed, 4 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index ff87b4bd0..b2501c6db 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2746,10 +2746,6 @@ INSERT INTO `vn`.`mdbApp` (`app`, `baselineBranchFk`, `userFk`, `locked`) VALUES ('foo', 'master', NULL, NULL), ('bar', 'test', 9, util.VN_NOW()); -INSERT INTO `vn`.`ticketLog` (`id`, `originFk`, `userFk`, `action`, `changedModel`, `oldInstance`, `newInstance`, `changedModelId`) - VALUES - (1, 1, 9, 'insert', 'Ticket', '{}', '{"clientFk":1, "nickname": "Bat cave"}', 1); - INSERT INTO `salix`.`url` (`appName`, `environment`, `url`) VALUES From ee0cd2174f78a5e4207c2026bf0218f282d9b3ae Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 27 Dec 2022 14:32:19 +0100 Subject: [PATCH 09/94] requested changes refs #4797 @2h --- .../methods/notification/deleteSubcription.js | 56 --------------- back/models/notificationSubscription.js | 72 ++++++++++++++++++- back/models/notificationSubscription.json | 1 + db/changes/230201/00-acl_notifications.sql | 14 +++- 4 files changed, 83 insertions(+), 60 deletions(-) delete mode 100644 back/methods/notification/deleteSubcription.js diff --git a/back/methods/notification/deleteSubcription.js b/back/methods/notification/deleteSubcription.js deleted file mode 100644 index 9095613fe..000000000 --- a/back/methods/notification/deleteSubcription.js +++ /dev/null @@ -1,56 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('deleteSubscription', { - description: 'delete a notification subscription', - accessType: 'WRITE', - accepts: [ - { - arg: 'notificationId', - type: 'string', - required: true - }, - { - arg: 'userId', - type: 'string', - required: true - } - ], - returns: { - type: 'object', - root: true - }, - http: { - path: `/deleteSubscription`, - verb: 'POST' - } - }); - - Self.deleteSubscription = async(notificationId, userId, options) => { - const myOptions = {}; - let tx; - - if (typeof options == 'object') - - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - - myOptions.transaction = tx; - } - - try { - const query = `DELETE FROM util.notificationSubscription - WHERE notificationFk = ? AND userFk = ?`; - - await Self.rawSql(query, [notificationId, userId], myOptions); - - if (tx) await tx.commit(); - - return {success: true}; - } catch (error) { - if (tx) await tx.rollback(); - - throw error; - } - }; -}; diff --git a/back/models/notificationSubscription.js b/back/models/notificationSubscription.js index ce5d89e8b..83f52047b 100644 --- a/back/models/notificationSubscription.js +++ b/back/models/notificationSubscription.js @@ -1,3 +1,73 @@ +const UserError = require('vn-loopback/util/user-error'); + module.exports = Self => { - require('../methods/notification/deleteSubcription')(Self); + Self.observe('before save', async function(ctx) { + let models = Self.app.models; + let userId = ctx.options.accessToken.userId; + let modifiedUser = await models.Worker.findOne({ + fields: ['id', 'bossFk'], + where: { + id: ctx.instance.userFk + } + }); + + if (userId == modifiedUser.id || userId == modifiedUser.bossFk) + return; + else + throw new UserError('You dont have permission to modify this user'); + }); + + Self.remoteMethod('deleteNotification', { + description: 'Gets the current user data', + accepts: [ + { + arg: 'ctx', + type: 'object', + http: {source: 'context'} + }, + { + arg: 'userId', + type: 'string' + }, + { + arg: 'notificationId', + type: 'number' + }, + { + arg: 'authorId', + type: 'number' + } + ], + returns: { + type: 'object', + root: true + }, + http: { + verb: 'POST', + path: '/deleteNotification' + } + }); + + Self.deleteNotification = async function(ctx) { + let models = Self.app.models; + let user = await ctx.args.authorId; + let notificationId = await ctx.args.notificationId; + let userId = await ctx.args.userId; + let modifiedUser = await models.Worker.findOne({ + fields: ['id', 'bossFk'], + where: { + id: ctx.args.userId + } + }); + + if (user == modifiedUser.id || modifiedUser.bossFk == user) { + const query = `DELETE FROM util.notificationSubscription + WHERE notificationFk = ? AND userFk = ?`; + + await Self.rawSql(query, [notificationId, userId]); + + return; + } else + throw new UserError('You dont have permission to modify this user'); + }; }; diff --git a/back/models/notificationSubscription.json b/back/models/notificationSubscription.json index 11dbde6fb..43fa6db27 100644 --- a/back/models/notificationSubscription.json +++ b/back/models/notificationSubscription.json @@ -9,6 +9,7 @@ "properties": { "notificationFk": { "type": "number", + "id": true, "description": "Identifier" }, "userFk": { diff --git a/db/changes/230201/00-acl_notifications.sql b/db/changes/230201/00-acl_notifications.sql index ef710aca6..c206dd27f 100644 --- a/db/changes/230201/00-acl_notifications.sql +++ b/db/changes/230201/00-acl_notifications.sql @@ -1,3 +1,11 @@ - VALUES - ('NotificationSubscription','*','*','employee'), - ('NotificationAcl','*','*','employee'); \ No newline at end of file +INSERT INTO + `salix`.`ACL` ( + `model`, + `property`, + `accessType`, + `permission`, + `principalId` + ) +VALUES + ('NotificationSubscription', '*', '*', 'employee'), + ('NotificationAcl', '*', '*', 'employee'); \ No newline at end of file From 0a602892e6f32326bd1b6ee477e69db59b55a55f Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 27 Dec 2022 14:59:23 +0100 Subject: [PATCH 10/94] changed let to const and removed duplicate code --- back/models/notificationSubscription.js | 36 ++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/back/models/notificationSubscription.js b/back/models/notificationSubscription.js index 83f52047b..811914634 100644 --- a/back/models/notificationSubscription.js +++ b/back/models/notificationSubscription.js @@ -2,14 +2,10 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.observe('before save', async function(ctx) { - let models = Self.app.models; - let userId = ctx.options.accessToken.userId; - let modifiedUser = await models.Worker.findOne({ - fields: ['id', 'bossFk'], - where: { - id: ctx.instance.userFk - } - }); + const models = Self.app.models; + const userId = ctx.options.accessToken.userId; + const user = await ctx.instance.userFk; + const modifiedUser = await getUserToModify(user, models); if (userId == modifiedUser.id || userId == modifiedUser.bossFk) return; @@ -49,16 +45,11 @@ module.exports = Self => { }); Self.deleteNotification = async function(ctx) { - let models = Self.app.models; - let user = await ctx.args.authorId; - let notificationId = await ctx.args.notificationId; - let userId = await ctx.args.userId; - let modifiedUser = await models.Worker.findOne({ - fields: ['id', 'bossFk'], - where: { - id: ctx.args.userId - } - }); + const models = Self.app.models; + const user = await ctx.args.authorId; + const notificationId = await ctx.args.notificationId; + const userId = await ctx.args.userId; + const modifiedUser = await getUserToModify(userId, models); if (user == modifiedUser.id || modifiedUser.bossFk == user) { const query = `DELETE FROM util.notificationSubscription @@ -70,4 +61,13 @@ module.exports = Self => { } else throw new UserError('You dont have permission to modify this user'); }; + + async function getUserToModify(user, models) { + return await models.Worker.findOne({ + fields: ['id', 'bossFk'], + where: { + id: user + } + }); + } }; From 3792a80ad53259be8c9035eeab044511d0bfd605 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 29 Dec 2022 14:24:32 +0100 Subject: [PATCH 11/94] =?UTF-8?q?refs=20#4925=20feat:=20a=C3=B1adido=20bac?= =?UTF-8?q?k=20para=20editar=20tags?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/changes/230201/00-ACL_tag_update.sql | 3 + .../core/components/crud-model/crud-model.js | 47 +++++----- modules/item/back/methods/tag/onSubmit.js | 94 +++++++++++++++++++ modules/item/back/models/item-tag.js | 4 +- modules/item/back/models/tag.js | 1 + modules/item/front/tags/index.html | 9 +- modules/item/front/tags/index.js | 11 ++- 7 files changed, 137 insertions(+), 32 deletions(-) create mode 100644 db/changes/230201/00-ACL_tag_update.sql create mode 100644 modules/item/back/methods/tag/onSubmit.js diff --git a/db/changes/230201/00-ACL_tag_update.sql b/db/changes/230201/00-ACL_tag_update.sql new file mode 100644 index 000000000..3c103e990 --- /dev/null +++ b/db/changes/230201/00-ACL_tag_update.sql @@ -0,0 +1,3 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) + VALUES + ('Tag', 'onSubmit', 'WRITE', 'ALLOW', 'ROLE', 'employee'); diff --git a/front/core/components/crud-model/crud-model.js b/front/core/components/crud-model/crud-model.js index 16b837d6a..10414daa3 100644 --- a/front/core/components/crud-model/crud-model.js +++ b/front/core/components/crud-model/crud-model.js @@ -147,28 +147,17 @@ export default class CrudModel extends ModelProxy { this.moreRows = null; } - /** - * Saves current changes on the server. - * - * @return {Promise} The save request promise - */ - save() { - if (!this.isChanged) - return this.$q.resolve(); + getChanges() { + if (!this.isChanged) return null; - let deletes = []; - let updates = []; - let creates = []; - let orgDeletes = []; - let orgUpdates = []; - let orgCreates = []; + const deletes = []; + const updates = []; + const creates = []; - let pk = this.primaryKey; + const pk = this.primaryKey; - for (let row of this.removed) { + for (let row of this.removed) deletes.push(row.$orgRow[pk]); - orgDeletes.push(row); - } for (let row of this.data) { if (row.$isNew) { @@ -178,7 +167,6 @@ export default class CrudModel extends ModelProxy { data[prop] = row[prop]; } creates.push(row); - orgCreates.push(row); } else if (row.$oldData) { let data = {}; for (let prop in row.$oldData) @@ -187,7 +175,6 @@ export default class CrudModel extends ModelProxy { data, where: {[pk]: row.$orgRow[pk]} }); - orgUpdates.push(row); } } @@ -198,8 +185,20 @@ export default class CrudModel extends ModelProxy { changes[prop] = undefined; } - if (!changes) - return this.$q.resolve(); + return changes; + } + + /** + * Saves current changes on the server. + * + * @return {Promise} The save request promise + */ + save() { + const pk = this.primaryKey; + const changes = this.getChanges(); + if (!changes) return this.$q.resolve(); + + const creates = changes.creates; let url = this.saveUrl ? this.saveUrl : `${this._url}/crud`; return this.$http.post(url, changes) @@ -207,8 +206,8 @@ export default class CrudModel extends ModelProxy { const created = res.data; // Apply new data to created instances - for (let i = 0; i < orgCreates.length; i++) { - const row = orgCreates[i]; + for (let i = 0; i < creates.length; i++) { + const row = creates[i]; row[pk] = created[i][pk]; for (let prop in row) { diff --git a/modules/item/back/methods/tag/onSubmit.js b/modules/item/back/methods/tag/onSubmit.js new file mode 100644 index 000000000..1bd33d3d4 --- /dev/null +++ b/modules/item/back/methods/tag/onSubmit.js @@ -0,0 +1,94 @@ + +module.exports = function(Self) { + Self.remoteMethodCtx('onSubmit', { + description: 'Creates client address updating default address', + accessType: 'WRITE', + accepts: [ + { + arg: 'creates', + type: ['object'], + description: 'The itemTags records to create' + }, { + arg: 'deletes', + type: ['number'], + description: 'The itemTags ids to delete' + }, { + arg: 'updates', + type: ['object'], + description: 'The itemTags records to update' + }, { + arg: 'maxPriority', + type: 'number', + description: 'The maxPriority value' + } + ], + returns: { + root: true, + type: 'object' + }, + http: { + verb: 'PATCH', + path: '/onSubmit' + } + }); + + Self.onSubmit = async(ctx, options) => { + const models = Self.app.models; + const args = ctx.args; + let tx; + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + try { + const promises = []; + + if (args.deletes) { + for (const itemTagId of args.deletes) { + const itemTagDeleted = await models.ItemTag.destroyById(itemTagId, myOptions); + promises.push(itemTagDeleted); + } + } + + if (args.updates) { + console.log('args.updates', args.updates); + for (const row of args.updates) { + if (row.data.priority) { + const itemTag = await models.ItemTag.findById(row.where.id, null, myOptions); + const itemTagUpdatedPriority = await itemTag.updateAttributes({ + priority: row.data.priority + args.maxPriority + }, myOptions); + promises.push(itemTagUpdatedPriority); + } + } + for (const row of args.updates) { + const itemTag = await models.ItemTag.findById(row.where.id, null, myOptions); + const itemTagUpdated = await itemTag.updateAttributes(row.data, myOptions); + promises.push(itemTagUpdated); + } + } + + if (args.creates) { + for (const itemTag of args.creates) { + const newItemTag = await models.ItemTag.create(itemTag, myOptions); + promises.push(newItemTag); + } + } + + const resolvedPromises = await Promise.all(promises); + + if (tx) await tx.commit(); + + return resolvedPromises; + } catch (e) { + if (tx) await tx.rollback(); + throw e; + } + }; +}; diff --git a/modules/item/back/models/item-tag.js b/modules/item/back/models/item-tag.js index 5b7163913..4fd44270a 100644 --- a/modules/item/back/models/item-tag.js +++ b/modules/item/back/models/item-tag.js @@ -4,8 +4,8 @@ module.exports = Self => { require('../methods/item-tag/filterItemTags')(Self); Self.rewriteDbError(function(err) { - if (err.code === 'ER_DUP_ENTRY') - return new UserError(`The tag or priority can't be repeated for an item`); + // if (err.code === 'ER_DUP_ENTRY') + // return new UserError(`The tag or priority can't be repeated for an item`); if (err.code === 'ER_BAD_NULL_ERROR') return new UserError(`Tag value cannot be blank`); return err; diff --git a/modules/item/back/models/tag.js b/modules/item/back/models/tag.js index 43fbc0db3..92760e34f 100644 --- a/modules/item/back/models/tag.js +++ b/modules/item/back/models/tag.js @@ -1,3 +1,4 @@ module.exports = Self => { require('../methods/tag/filterValue')(Self); + require('../methods/tag/onSubmit')(Self); }; diff --git a/modules/item/front/tags/index.html b/modules/item/front/tags/index.html index c040b9984..471a53634 100644 --- a/modules/item/front/tags/index.html +++ b/modules/item/front/tags/index.html @@ -19,7 +19,7 @@ data="tags" auto-load="true"> -
+ - - + -
\ No newline at end of file + diff --git a/modules/item/front/tags/index.js b/modules/item/front/tags/index.js index 3b3cd58ef..b5c1fa7f9 100644 --- a/modules/item/front/tags/index.js +++ b/modules/item/front/tags/index.js @@ -29,8 +29,15 @@ class Controller extends Section { } onSubmit() { - this.$.watcher.check(); - this.$.model.save().then(() => { + const changes = this.$.model.getChanges(); + console.log(changes); + const data = { + creates: changes.creates, + deletes: changes.deletes, + updates: changes.updates, + maxPriority: this.getHighestPriority() + }; + this.$http.patch(`Tags/onSubmit`, data).then(() => { this.$.watcher.notifySaved(); this.$.watcher.updateOriginalData(); this.card.reload(); From a55d00765581e2dd0b686c2dfdf533116b8bd420 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 3 Jan 2023 08:12:46 +0100 Subject: [PATCH 12/94] requested changes --- back/models/notificationSubscription.js | 20 +++++++------------- db/changes/230201/00-acl_notifications.sql | 15 ++++----------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/back/models/notificationSubscription.js b/back/models/notificationSubscription.js index 811914634..26fcc04df 100644 --- a/back/models/notificationSubscription.js +++ b/back/models/notificationSubscription.js @@ -14,7 +14,7 @@ module.exports = Self => { }); Self.remoteMethod('deleteNotification', { - description: 'Gets the current user data', + description: 'Deletes a notification subscription', accepts: [ { arg: 'ctx', @@ -22,15 +22,11 @@ module.exports = Self => { http: {source: 'context'} }, { - arg: 'userId', + arg: 'userFk', type: 'string' }, { - arg: 'notificationId', - type: 'number' - }, - { - arg: 'authorId', + arg: 'notificationFk', type: 'number' } ], @@ -44,18 +40,16 @@ module.exports = Self => { } }); - Self.deleteNotification = async function(ctx) { + Self.deleteNotification = async function(ctx, userFk, notificationFk) { const models = Self.app.models; - const user = await ctx.args.authorId; - const notificationId = await ctx.args.notificationId; - const userId = await ctx.args.userId; - const modifiedUser = await getUserToModify(userId, models); + const user = ctx.req.accessToken.userId; + const modifiedUser = await getUserToModify(userFk, models); if (user == modifiedUser.id || modifiedUser.bossFk == user) { const query = `DELETE FROM util.notificationSubscription WHERE notificationFk = ? AND userFk = ?`; - await Self.rawSql(query, [notificationId, userId]); + await Self.rawSql(query, [notificationFk, userFk]); return; } else diff --git a/db/changes/230201/00-acl_notifications.sql b/db/changes/230201/00-acl_notifications.sql index c206dd27f..4b86e2cd0 100644 --- a/db/changes/230201/00-acl_notifications.sql +++ b/db/changes/230201/00-acl_notifications.sql @@ -1,11 +1,4 @@ -INSERT INTO - `salix`.`ACL` ( - `model`, - `property`, - `accessType`, - `permission`, - `principalId` - ) -VALUES - ('NotificationSubscription', '*', '*', 'employee'), - ('NotificationAcl', '*', '*', 'employee'); \ No newline at end of file +INSERT INTO `salix`.`ACL` (model,property,accessType,principalId) + VALUES ('NotificationSubscription','*','*','employee'); +INSERT INTO `salix`.`ACL` (model,property,accessType,principalId) + VALUES ('NotificationAcl','*','*','employee'); From 22d0da273e3e027b0d59c5195de013d698af19a9 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 3 Jan 2023 13:21:51 +0100 Subject: [PATCH 13/94] =?UTF-8?q?refs=20#4925=20fix:=20coge=20=C3=BAnicame?= =?UTF-8?q?nte=20los=20=C3=BAltimos=20cambios=20aplicados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/item/front/tags/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/item/front/tags/index.js b/modules/item/front/tags/index.js index b5c1fa7f9..bfa1f3f46 100644 --- a/modules/item/front/tags/index.js +++ b/modules/item/front/tags/index.js @@ -30,7 +30,6 @@ class Controller extends Section { onSubmit() { const changes = this.$.model.getChanges(); - console.log(changes); const data = { creates: changes.creates, deletes: changes.deletes, @@ -38,9 +37,9 @@ class Controller extends Section { maxPriority: this.getHighestPriority() }; this.$http.patch(`Tags/onSubmit`, data).then(() => { + this.$.model.refresh(); this.$.watcher.notifySaved(); this.$.watcher.updateOriginalData(); - this.card.reload(); }); } } From fec965a8ddb79ba35c0d1800e9be2a32531a2a75 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 3 Jan 2023 13:29:27 +0100 Subject: [PATCH 14/94] =?UTF-8?q?refs=204925=20refactor:=20borrados=20cons?= =?UTF-8?q?ole.log=20y=20actualizada=20descripci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/item/back/methods/tag/onSubmit.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/item/back/methods/tag/onSubmit.js b/modules/item/back/methods/tag/onSubmit.js index 1bd33d3d4..b80b80d90 100644 --- a/modules/item/back/methods/tag/onSubmit.js +++ b/modules/item/back/methods/tag/onSubmit.js @@ -1,7 +1,7 @@ module.exports = function(Self) { Self.remoteMethodCtx('onSubmit', { - description: 'Creates client address updating default address', + description: 'Save model changes', accessType: 'WRITE', accepts: [ { @@ -57,7 +57,6 @@ module.exports = function(Self) { } if (args.updates) { - console.log('args.updates', args.updates); for (const row of args.updates) { if (row.data.priority) { const itemTag = await models.ItemTag.findById(row.where.id, null, myOptions); From 21a62a0fab016623b0993be5b7ade9e3cddc8940 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 3 Jan 2023 13:29:44 +0100 Subject: [PATCH 15/94] refactor --- modules/item/back/models/item-tag.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/item/back/models/item-tag.js b/modules/item/back/models/item-tag.js index 4fd44270a..5b7163913 100644 --- a/modules/item/back/models/item-tag.js +++ b/modules/item/back/models/item-tag.js @@ -4,8 +4,8 @@ module.exports = Self => { require('../methods/item-tag/filterItemTags')(Self); Self.rewriteDbError(function(err) { - // if (err.code === 'ER_DUP_ENTRY') - // return new UserError(`The tag or priority can't be repeated for an item`); + if (err.code === 'ER_DUP_ENTRY') + return new UserError(`The tag or priority can't be repeated for an item`); if (err.code === 'ER_BAD_NULL_ERROR') return new UserError(`Tag value cannot be blank`); return err; From 3edc0403ba3a744b11ea2c618227709de72c322b Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 5 Jan 2023 10:35:42 +0100 Subject: [PATCH 16/94] fix --- front/core/components/crud-model/crud-model.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/front/core/components/crud-model/crud-model.js b/front/core/components/crud-model/crud-model.js index 10414daa3..421a79f9b 100644 --- a/front/core/components/crud-model/crud-model.js +++ b/front/core/components/crud-model/crud-model.js @@ -178,7 +178,7 @@ export default class CrudModel extends ModelProxy { } } - let changes = {deletes, updates, creates}; + const changes = {deletes, updates, creates}; for (let prop in changes) { if (changes[prop].length === 0) @@ -198,8 +198,7 @@ export default class CrudModel extends ModelProxy { const changes = this.getChanges(); if (!changes) return this.$q.resolve(); - const creates = changes.creates; - + const creates = changes.creates || []; let url = this.saveUrl ? this.saveUrl : `${this._url}/crud`; return this.$http.post(url, changes) .then(res => { From fd9ca3a4c13d7283dc6be959c9fb1999ee06a700 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 5 Jan 2023 10:35:49 +0100 Subject: [PATCH 17/94] add test --- .../back/methods/tag/specs/onSubmit.spec.js | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 modules/item/back/methods/tag/specs/onSubmit.spec.js diff --git a/modules/item/back/methods/tag/specs/onSubmit.spec.js b/modules/item/back/methods/tag/specs/onSubmit.spec.js new file mode 100644 index 000000000..a8077db67 --- /dev/null +++ b/modules/item/back/methods/tag/specs/onSubmit.spec.js @@ -0,0 +1,100 @@ +const models = require('vn-loopback/server/server').models; + +describe('tag onSubmit()', () => { + it('should delete a tag', async() => { + const tx = await models.Item.beginTransaction({}); + const options = {transaction: tx}; + + try { + const deletes = [40]; + const ctx = { + args: { + deletes: deletes + } + }; + const result = await models.Tag.onSubmit(ctx, options); + + expect(result.length).toEqual(1); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should update a tag', async() => { + const tx = await models.Item.beginTransaction({}); + const options = {transaction: tx}; + + try { + const updates = [{data: {value: 'Container Test'}, where: {id: 36}}]; + const ctx = { + args: { + updates: updates + } + }; + const result = await models.Tag.onSubmit(ctx, options); + + expect(result.length).toEqual(1); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should create a tag', async() => { + const tx = await models.Item.beginTransaction({}); + const options = {transaction: tx}; + + try { + const creates = [{ + 'itemFk': '6', + 'priority': 8, + '$orgIndex': null, + '$oldData': null, + '$isNew': true, + 'tagFk': 3, + 'value': 'madera' + }]; + const ctx = { + args: { + creates: creates + } + }; + const result = await models.Tag.onSubmit(ctx, options); + + expect(result.length).toEqual(1); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should swap priority for two tags', async() => { + const tx = await models.Item.beginTransaction({}); + const options = {transaction: tx}; + + try { + const updates = [ + {data: {priority: 2}, where: {id: 36}}, + {data: {priority: 1}, where: {id: 37}} + ]; + const ctx = { + args: { + updates: updates, + maxPriority: 7, + + } + }; + const result = await models.Tag.onSubmit(ctx, options); + + expect(result.length).toEqual(4); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); From 3abbfc4fa7c9fa3c595caffed38aa5633f1fc096 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 5 Jan 2023 10:35:55 +0100 Subject: [PATCH 18/94] refacotr --- CHANGELOG.md | 1 + modules/item/front/tags/index.html | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d7073dc53..4e45bb760 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - [General] Al utilizar el traductor de Google se descuadraban los iconos +- [Artículos](Etiquetas) Permite intercambiar la relevancia entre dos etiquetas. ### Removed - [Tickets](Control clientes) Eliminada sección diff --git a/modules/item/front/tags/index.html b/modules/item/front/tags/index.html index 471a53634..f9b5370fa 100644 --- a/modules/item/front/tags/index.html +++ b/modules/item/front/tags/index.html @@ -73,10 +73,10 @@ - - + From 24b8b172b9d3f361414798cde012e27d2b8be131 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 5 Jan 2023 14:13:42 +0100 Subject: [PATCH 19/94] use notification id --- back/models/notificationSubscription.js | 44 ++++++++++++----------- back/models/notificationSubscription.json | 11 +++--- db/dump/structure.sql | 3 +- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/back/models/notificationSubscription.js b/back/models/notificationSubscription.js index 26fcc04df..77ef8ffbe 100644 --- a/back/models/notificationSubscription.js +++ b/back/models/notificationSubscription.js @@ -22,13 +22,10 @@ module.exports = Self => { http: {source: 'context'} }, { - arg: 'userFk', - type: 'string' + arg: 'notificationId', + type: 'number', + required: true }, - { - arg: 'notificationFk', - type: 'number' - } ], returns: { type: 'object', @@ -40,28 +37,35 @@ module.exports = Self => { } }); - Self.deleteNotification = async function(ctx, userFk, notificationFk) { + Self.deleteNotification = async function(ctx, notificationId) { const models = Self.app.models; const user = ctx.req.accessToken.userId; - const modifiedUser = await getUserToModify(userFk, models); + const modifiedUser = await getUserToModify(notificationId, models); if (user == modifiedUser.id || modifiedUser.bossFk == user) { - const query = `DELETE FROM util.notificationSubscription - WHERE notificationFk = ? AND userFk = ?`; - - await Self.rawSql(query, [notificationFk, userFk]); - + await models.NotificationSubscription.destroyById(notificationId); return; } else throw new UserError('You dont have permission to modify this user'); }; - async function getUserToModify(user, models) { - return await models.Worker.findOne({ - fields: ['id', 'bossFk'], - where: { - id: user - } - }); + async function getUserToModify(notificationId = null, userFk = null, models) { + if (notificationId != null) { + const subscription = await models.NotificationSubscription.findById(notificationId); + const user = await subscription.userFk; + return await models.Worker.findOne({ + fields: ['id', 'bossFk'], + where: { + id: user + } + }); + } else { + return await models.Worker.findOne({ + fields: ['id', 'bossFk'], + where: { + id: userFk + } + }); + } } }; diff --git a/back/models/notificationSubscription.json b/back/models/notificationSubscription.json index 43fa6db27..a640e0917 100644 --- a/back/models/notificationSubscription.json +++ b/back/models/notificationSubscription.json @@ -7,15 +7,18 @@ } }, "properties": { - "notificationFk": { + "id": { "type": "number", "id": true, - "description": "Identifier" + "description": "Primary key" + }, + "notificationFk": { + "type": "number", + "description": "Foreign key to Notification" }, "userFk": { "type": "number", - "id": true, - "description": "Identifier" + "description": "Foreign key to Account" } }, "relations": { diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 47fdd6d74..510a51d94 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -19726,9 +19726,10 @@ DROP TABLE IF EXISTS `notificationSubscription`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `notificationSubscription` ( + `Id` int(11) NOT NULL AUTO_INCREMENT, `notificationFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, - PRIMARY KEY (`notificationFk`,`userFk`), + PRIMARY KEY (`Id`), KEY `notificationSubscription_ibfk_2` (`userFk`), CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `notification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `notificationSubscription_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE From 3b69d76525b604cd81a72cdaf58d9d88888f83b7 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Mon, 9 Jan 2023 08:43:11 +0100 Subject: [PATCH 20/94] fix error preventing subscriptions --- back/models/notificationSubscription.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/back/models/notificationSubscription.js b/back/models/notificationSubscription.js index 77ef8ffbe..eafa9d51b 100644 --- a/back/models/notificationSubscription.js +++ b/back/models/notificationSubscription.js @@ -5,7 +5,7 @@ module.exports = Self => { const models = Self.app.models; const userId = ctx.options.accessToken.userId; const user = await ctx.instance.userFk; - const modifiedUser = await getUserToModify(user, models); + const modifiedUser = await getUserToModify(null, user, models); if (userId == modifiedUser.id || userId == modifiedUser.bossFk) return; @@ -40,7 +40,7 @@ module.exports = Self => { Self.deleteNotification = async function(ctx, notificationId) { const models = Self.app.models; const user = ctx.req.accessToken.userId; - const modifiedUser = await getUserToModify(notificationId, models); + const modifiedUser = await getUserToModify(notificationId, null, models); if (user == modifiedUser.id || modifiedUser.bossFk == user) { await models.NotificationSubscription.destroyById(notificationId); From e4603a06f2d9e92f95e0198c9918ee6e752167e1 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 12 Jan 2023 08:59:24 +0100 Subject: [PATCH 21/94] refacotor: borrados los await para que devuelva la promesa --- modules/item/back/methods/tag/onSubmit.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/item/back/methods/tag/onSubmit.js b/modules/item/back/methods/tag/onSubmit.js index b80b80d90..aec67e92a 100644 --- a/modules/item/back/methods/tag/onSubmit.js +++ b/modules/item/back/methods/tag/onSubmit.js @@ -51,7 +51,7 @@ module.exports = function(Self) { if (args.deletes) { for (const itemTagId of args.deletes) { - const itemTagDeleted = await models.ItemTag.destroyById(itemTagId, myOptions); + const itemTagDeleted = models.ItemTag.destroyById(itemTagId, myOptions); promises.push(itemTagDeleted); } } @@ -60,7 +60,7 @@ module.exports = function(Self) { for (const row of args.updates) { if (row.data.priority) { const itemTag = await models.ItemTag.findById(row.where.id, null, myOptions); - const itemTagUpdatedPriority = await itemTag.updateAttributes({ + const itemTagUpdatedPriority = itemTag.updateAttributes({ priority: row.data.priority + args.maxPriority }, myOptions); promises.push(itemTagUpdatedPriority); @@ -68,14 +68,14 @@ module.exports = function(Self) { } for (const row of args.updates) { const itemTag = await models.ItemTag.findById(row.where.id, null, myOptions); - const itemTagUpdated = await itemTag.updateAttributes(row.data, myOptions); + const itemTagUpdated = itemTag.updateAttributes(row.data, myOptions); promises.push(itemTagUpdated); } } if (args.creates) { for (const itemTag of args.creates) { - const newItemTag = await models.ItemTag.create(itemTag, myOptions); + const newItemTag = models.ItemTag.create(itemTag, myOptions); promises.push(newItemTag); } } From 41671e8a3a358ea8c3170b8c388c3e4d4640a398 Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 13 Jan 2023 08:38:29 +0100 Subject: [PATCH 22/94] refs #4927 modified hook to check name & country --- loopback/locale/es.json | 5 +++-- modules/supplier/back/models/supplier.js | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index ea83b36c4..f2acea939 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -252,5 +252,6 @@ "Receipt's bank was not found": "No se encontró el banco del recibo", "This receipt was not compensated": "Este recibo no ha sido compensado", "Client's email was not found": "No se encontró el email del cliente", - "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9" -} \ No newline at end of file + "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9", + "A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país." +} diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index 64c585b6a..cba220af8 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -116,13 +116,21 @@ module.exports = Self => { Self.observe('before save', async function(ctx) { const changes = ctx.data || ctx.instance; const orgData = ctx.currentInstance; - - const socialName = changes.name || orgData.name; const hasChanges = orgData && changes; - const socialNameChanged = hasChanges - && orgData.socialName != socialName; - if ((socialNameChanged) && !isAlpha(socialName)) - throw new UserError('The social name has an invalid format'); + if (hasChanges) { + const name = changes.name || orgData.name; + const nameChanged = hasChanges && orgData.name != name; + const countryFk = changes.countryFk || orgData.countryFk; + const countryChanged = hasChanges && orgData.countryFk != countryFk; + + if (nameChanged || countryChanged) { + if (!isAlpha(name)) throw new UserError('The social name has an invalid format'); + + const supplier = await Self.app.models.Supplier.findOne({where: {name, countryFk}, fields: ['id']}); + if (supplier) + throw new UserError('A supplier with the same name already exists. Change the country.'); + } + } }); }; From 6b1a6fe44b2f6ac22015ac4a114dee8b4af4bd8d Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 16 Jan 2023 15:18:00 +0100 Subject: [PATCH 23/94] feat: mock dates front and back --- db/dump/fixtures.sql | 6 +++--- db/dump/mockDate.sql | 15 +++++++-------- front/core/services/date.js | 15 +++++++++++++++ front/core/services/index.js | 1 + front/salix/index.ejs | 2 +- front/salix/services/index.js | 15 +++++++++++++++ jest-front.js | 11 +++++++++++ loopback/server/boot/date.js | 17 +++++++++++++++++ 8 files changed, 70 insertions(+), 12 deletions(-) create mode 100644 front/core/services/date.js create mode 100644 loopback/server/boot/date.js diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index fba094ef4..9d31c9b33 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1910,7 +1910,7 @@ DROP TEMPORARY TABLE IF EXISTS tmp.worker; CREATE TEMPORARY TABLE tmp.worker (PRIMARY KEY (id)) ENGINE = MEMORY - SELECT w.id, w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL +1 YEAR)), '-12-25'), CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk` + SELECT w.id, w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)), '-12-25') as started, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL +1 YEAR)), '-12-25') as ended, CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk` FROM `vn`.`worker` `w`; INSERT INTO `vn`.`business`(`id`, `workerFk`, `companyCodeFk`, `started`, `ended`, `workerBusiness`, `reasonEndFk`, `notes`, `departmentFk`, `workerBusinessProfessionalCategoryFk`, `calendarTypeFk`, `isHourlyLabor`, `workerBusinessAgreementFk`, `workcenterFk`) @@ -1920,7 +1920,7 @@ DROP TEMPORARY TABLE IF EXISTS tmp.worker; CREATE TEMPORARY TABLE tmp.worker (PRIMARY KEY (id)) ENGINE = MEMORY - SELECT '1111' as 'id', w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -2 YEAR)), '-12-25'), CONCAT(YEAR(DATE_ADD(CURDATE(), INTERVAL -1 YEAR)), '-12-24'), CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk` + SELECT '1111' as 'id', w.id as `workerFk`, 'VNL', CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -2 YEAR)), '-12-25') as started, CONCAT(YEAR(DATE_ADD(util.VN_CURDATE(), INTERVAL -1 YEAR)) as ended, '-12-24'), CONCAT('E-46-', RPAD(CONCAT(w.id, 9), 8, w.id)), NULL as `notes`, NULL as `departmentFk`, 23, 1 as `workerBusinessProfessionalCategoryFk`, 1 as `calendarTypeFk`, 1 as `isHourlyLabor`, 1 as `workerBusinessAgreementFk`, 1 as `workcenterFk` FROM `vn`.`worker` `w` WHERE `w`.`id` = 1109; @@ -2629,7 +2629,7 @@ INSERT INTO `vn`.`machineWorker` (`workerFk`, `machineFk`, `inTimed`, `outTimed` INSERT INTO `vn`.`zoneExclusion` (`id`, `zoneFk`, `dated`, `created`, `userFk`) VALUES - (1, 1, DATE_ADD(CURDATE(), INTERVAL (IF(DAYOFWEEK(CURDATE())<=7, 7, 14) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100), + (1, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=7, 7, 14) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100), (2, 1, DATE_ADD(util.VN_CURDATE(), INTERVAL (IF(DAYOFWEEK(util.VN_CURDATE())<=8, 8, 15) - DAYOFWEEK(util.VN_CURDATE())) DAY), util.VN_CURDATE(), 100); INSERT INTO `vn`.`zoneExclusionGeo` (`zoneExclusionFk`, `geoFk`) diff --git a/db/dump/mockDate.sql b/db/dump/mockDate.sql index c63c2d76c..5334bbe81 100644 --- a/db/dump/mockDate.sql +++ b/db/dump/mockDate.sql @@ -3,18 +3,17 @@ USE `util`; DELIMITER ;; DROP FUNCTION IF EXISTS `util`.`mockedDate`; -CREATE FUNCTION `util`.`mockedDate`() +CREATE FUNCTION `util`.`mockedDate`() RETURNS DATETIME DETERMINISTIC BEGIN - RETURN NOW(); - -- '2022-01-19 08:00:00' + RETURN '2022-06-15 11:00:00'; END ;; DELIMITER ; DELIMITER ;; DROP FUNCTION IF EXISTS `util`.`VN_CURDATE`; -CREATE FUNCTION `util`.`VN_CURDATE`() +CREATE FUNCTION `util`.`VN_CURDATE`() RETURNS DATE DETERMINISTIC BEGIN @@ -24,7 +23,7 @@ DELIMITER ; DELIMITER ;; DROP FUNCTION IF EXISTS `util`.`VN_CURTIME`; -CREATE FUNCTION `util`.`VN_CURTIME`() +CREATE FUNCTION `util`.`VN_CURTIME`() RETURNS TIME DETERMINISTIC BEGIN @@ -34,10 +33,10 @@ DELIMITER ; DELIMITER ;; DROP FUNCTION IF EXISTS `util`.`VN_NOW`; -CREATE FUNCTION `util`.`VN_NOW`() +CREATE FUNCTION `util`.`VN_NOW`() RETURNS DATETIME DETERMINISTIC BEGIN - RETURN mockedDate(); + RETURN mockedDate(); END ;; -DELIMITER ; \ No newline at end of file +DELIMITER ; diff --git a/front/core/services/date.js b/front/core/services/date.js new file mode 100644 index 000000000..0d013b9f6 --- /dev/null +++ b/front/core/services/date.js @@ -0,0 +1,15 @@ +Date.vnNew = () => { + return new Date(Date.vnUTC()); +}; + +Date.vnNow = () => { + return new Date(Date.vnUTC()).getTime(); +}; + +Date.vnUTC = () => { + const env = process.env.NODE_ENV; + if (!env || env === 'development') + return new Date(Date.UTC(2022, 5, 15, 11)); + + return new Date(Date.UTC()); +}; diff --git a/front/core/services/index.js b/front/core/services/index.js index ff1d438ed..867a13df0 100644 --- a/front/core/services/index.js +++ b/front/core/services/index.js @@ -10,3 +10,4 @@ import './week-days'; import './report'; import './email'; import './file'; +import './date'; diff --git a/front/salix/index.ejs b/front/salix/index.ejs index 3aed9d9a6..1c13c3541 100644 --- a/front/salix/index.ejs +++ b/front/salix/index.ejs @@ -10,7 +10,7 @@ diff --git a/front/salix/services/index.js b/front/salix/services/index.js index e69de29bb..0fe541d1f 100644 --- a/front/salix/services/index.js +++ b/front/salix/services/index.js @@ -0,0 +1,15 @@ +Date.vnNew = () => { + return new Date(Date.vnUTC()); +}; + +Date.vnNow = () => { + return new Date(Date.vnUTC()).getTime(); +}; + +Date.vnUTC = () => { + const env = process.env.NODE_ENV; + if (!env || env === 'development') + return new Date(Date.UTC(2000, 0, 1, 11)); + + return new Date(Date.UTC()); +}; diff --git a/jest-front.js b/jest-front.js index 6d7532260..45fed2319 100644 --- a/jest-front.js +++ b/jest-front.js @@ -36,6 +36,17 @@ window.ngModule = function(moduleName, ...args) { if (args.length) fns = fns.concat(args); + Date.vnUTC = () => { + return new Date(Date.UTC(2000, 0, 1, 11)); + }; + Date.vnNew = () => { + return new Date(Date.UTC(2000, 0, 1, 11)); + }; + + Date.vnNow = () => { + return new Date(Date.UTC(2000, 0, 1, 11)).getTime(); + }; return angular.mock.module(...fns); }; + diff --git a/loopback/server/boot/date.js b/loopback/server/boot/date.js new file mode 100644 index 000000000..73eebf3be --- /dev/null +++ b/loopback/server/boot/date.js @@ -0,0 +1,17 @@ +module.exports = () => { + Date.vnNew = () => { + return new Date(Date.vnUTC()); + }; + + Date.vnNow = () => { + return new Date(Date.vnUTC()).getTime(); + }; + + Date.vnUTC = () => { + const env = process.env.NODE_ENV; + if (!env || env === 'development') + return new Date(Date.UTC(2022, 5, 15, 11)); + + return new Date(Date.UTC()); + }; +}; From e27a559416941b1bc4ceba942575d87343c161f8 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 16 Jan 2023 15:18:24 +0100 Subject: [PATCH 24/94] refactor: replace all Date --- back/methods/campaign/latest.js | 2 +- back/methods/campaign/spec/latest.spec.js | 4 +- back/methods/campaign/spec/upcoming.spec.js | 2 +- back/methods/campaign/upcoming.js | 2 +- back/methods/chat/getServiceAuth.js | 4 +- back/methods/chat/send.js | 2 +- back/methods/chat/sendCheckingPresence.js | 2 +- back/methods/chat/spec/sendQueued.spec.js | 2 +- back/methods/dms/deleteTrashFiles.js | 2 +- back/methods/dms/saveSign.js | 2 +- back/methods/docuware/upload.js | 2 +- back/methods/edi/updateData.js | 2 +- back/methods/notification/clean.js | 2 +- back/methods/notification/specs/clean.spec.js | 2 +- back/models/image.js | 2 +- db/tests/vn/buyUltimate.spec.js | 2 +- db/tests/vn/buyUltimateFromInterval.spec.js | 2 +- db/tests/vn/ticketCalculateClon.spec.js | 2 +- db/tests/vn/ticketCreateWithUser.spec.js | 2 +- .../vn/timeBusiness_calculateByUser.spec.js | 4 +- .../vn/timeControl_calculateByUser.spec.js | 12 +++--- db/tests/vn/zone_getLanded.spec.js | 4 +- e2e/helpers/extensions.js | 2 +- .../02-client/20_credit_insurance.spec.js | 2 +- e2e/paths/03-worker/04_time_control.spec.js | 6 +-- e2e/paths/03-worker/05_calendar.spec.js | 2 +- e2e/paths/04-item/13_fixedPrice.spec.js | 2 +- .../05-ticket/06_basic_data_steps.spec.js | 4 +- e2e/paths/05-ticket/14_create_ticket.spec.js | 2 +- e2e/paths/08-route/02_basic_data.spec.js | 2 +- e2e/paths/09-invoice-in/03_basic_data.spec.js | 2 +- .../09-invoice-out/02_descriptor.spec.js | 2 +- e2e/paths/10-travel/01_create.spec.js | 2 +- .../10-travel/02_basic_data_and_log.spec.js | 2 +- e2e/paths/10-travel/03_descriptor.spec.js | 2 +- front/core/components/calendar/index.js | 6 +-- front/core/components/calendar/index.spec.js | 4 +- .../core/components/date-picker/index.spec.js | 2 +- front/core/components/input-time/index.js | 2 +- .../core/components/input-time/index.spec.js | 2 +- front/salix/components/upload-photo/index.js | 2 +- .../importToNewRefundTicket.js | 4 +- .../back/methods/claim/createFromSales.js | 2 +- .../back/methods/claim/regularizeClaim.js | 10 ++--- .../claim/specs/createFromSales.spec.js | 4 +- .../methods/claim/specs/updateClaim.spec.js | 2 +- .../claim/specs/updateClaimAction.spec.js | 2 +- .../methods/client/consumptionSendQueued.js | 6 +-- .../back/methods/client/createReceipt.js | 2 +- modules/client/back/methods/client/getCard.js | 2 +- modules/client/back/methods/client/getDebt.js | 2 +- .../back/methods/client/lastActiveTickets.js | 8 ++-- modules/client/back/methods/client/summary.js | 2 +- .../createWithInsurance.spec.js | 2 +- .../client/back/methods/defaulter/filter.js | 6 +-- .../methods/recovery/hasActiveRecovery.js | 2 +- modules/client/back/models/client-sample.js | 2 +- modules/client/front/balance/create/index.js | 2 +- modules/client/front/consumption/index.js | 4 +- .../client/front/consumption/index.spec.js | 4 +- .../front/credit-insurance/create/index.js | 2 +- .../credit-insurance/create/index.spec.js | 2 +- .../front/credit-insurance/index/index.js | 2 +- .../credit-insurance/index/index.spec.js | 6 +-- .../insurance/create/index.js | 2 +- modules/client/front/defaulter/index.js | 2 +- modules/client/front/defaulter/index.spec.js | 6 +-- modules/client/front/greuge/create/index.js | 2 +- .../client/front/notification/index.spec.js | 6 +-- modules/client/front/recovery/create/index.js | 2 +- modules/client/front/recovery/index/index.js | 2 +- modules/client/front/summary/index.js | 2 +- modules/client/front/summary/index.spec.js | 6 +-- modules/client/front/unpaid/index.js | 2 +- modules/client/front/unpaid/index.spec.js | 2 +- .../back/methods/entry/latestBuysFilter.js | 6 +-- .../entry/specs/latestBuysFilter.spec.js | 4 +- .../methods/invoice-in/specs/filter.spec.js | 4 +- .../invoiceIn/front/basic-data/index.spec.js | 2 +- modules/invoiceIn/front/descriptor/index.js | 2 +- modules/invoiceIn/front/dueDay/index.js | 2 +- .../methods/invoiceOut/clientsToInvoice.js | 20 ++++----- .../methods/invoiceOut/createManualInvoice.js | 12 +++--- .../methods/invoiceOut/specs/filter.spec.js | 2 +- .../invoiceOut/specs/invoiceClient.spec.js | 6 +-- .../front/index/global-invoicing/index.js | 2 +- .../index/global-invoicing/index.spec.js | 10 ++--- .../invoiceOut/front/index/manual/index.js | 2 +- .../specs/upsertFixedPrice.spec.js | 2 +- .../item-image-queue/downloadImages.js | 4 +- .../back/methods/item/getVisibleAvailable.js | 2 +- .../item/back/methods/item/getWasteByItem.js | 4 +- .../back/methods/item/getWasteByWorker.js | 2 +- modules/item/back/methods/item/regularize.js | 8 ++-- .../item/specs/getVisibleAvailable.spec.js | 4 +- .../item/specs/lastEntriesFilter.spec.js | 8 ++-- modules/item/front/descriptor/index.js | 2 +- modules/item/front/diary/index.js | 2 +- modules/item/front/fixed-price/index.spec.js | 2 +- modules/item/front/last-entries/index.js | 4 +- .../front/request-search-panel/index.spec.js | 8 ++-- modules/item/front/request/index.js | 8 ++-- modules/item/front/request/index.spec.js | 2 +- modules/mdb/back/methods/mdbApp/lock.js | 2 +- .../methods/sales-monitor/clientsFilter.js | 4 +- .../back/methods/sales-monitor/salesFilter.js | 2 +- .../sales-monitor/specs/clientsFilter.spec.js | 8 ++-- .../sales-monitor/specs/salesFilter.spec.js | 16 +++---- modules/monitor/front/index/clients/index.js | 6 +-- modules/monitor/front/index/orders/index.js | 2 +- .../front/index/search-panel/index.spec.js | 8 ++-- modules/monitor/front/index/tickets/index.js | 4 +- .../monitor/front/index/tickets/index.spec.js | 10 ++--- .../back/methods/order/specs/new.spec.js | 4 +- modules/order/front/basic-data/index.spec.js | 2 +- modules/order/front/index/index.js | 2 +- modules/order/front/index/index.spec.js | 6 +-- .../route/back/methods/agency-term/filter.js | 24 +++++------ .../methods/agency-term/specs/filter.spec.js | 6 +-- .../back/methods/route/specs/clone.spec.js | 2 +- .../back/methods/route/specs/filter.spec.js | 6 +-- .../route/specs/getSuggestedTickets.spec.js | 2 +- .../methods/route/specs/insertTicket.spec.js | 2 +- modules/route/front/index/index.js | 2 +- modules/route/front/index/index.spec.js | 2 +- modules/route/front/main/index.js | 6 +-- modules/route/front/main/index.spec.js | 2 +- .../route/front/search-panel/index.spec.js | 8 ++-- modules/supplier/front/consumption/index.js | 4 +- .../supplier/front/consumption/index.spec.js | 4 +- modules/supplier/front/descriptor/index.js | 2 +- .../expedition/specs/moveExpeditions.spec.js | 2 +- .../methods/sale/getClaimableFromTicket.js | 22 +++++----- modules/ticket/back/methods/sale/refund.js | 2 +- .../ticket-tracking/specs/changeState.spec.js | 2 +- .../back/methods/ticket/canBeInvoiced.js | 2 +- .../ticket/back/methods/ticket/closeAll.js | 10 ++--- modules/ticket/back/methods/ticket/filter.js | 8 ++-- .../ticket/back/methods/ticket/makeInvoice.js | 2 +- modules/ticket/back/methods/ticket/restore.js | 4 +- .../ticket/specs/canBeInvoiced.spec.js | 2 +- .../ticket/specs/componentUpdate.spec.js | 12 +++--- .../back/methods/ticket/specs/filter.spec.js | 8 ++-- .../ticket/specs/getTicketsAdvance.spec.js | 4 +- .../ticket/specs/getTicketsFuture.spec.js | 2 +- .../back/methods/ticket/specs/merge.spec.js | 4 +- .../back/methods/ticket/specs/new.spec.js | 2 +- .../ticket/specs/priceDifference.spec.js | 8 ++-- .../back/methods/ticket/specs/restore.spec.js | 6 +-- modules/ticket/front/advance/index.js | 4 +- modules/ticket/front/advance/index.spec.js | 8 ++-- .../front/basic-data/step-one/index.spec.js | 32 +++++++------- modules/ticket/front/descriptor-menu/index.js | 2 +- .../front/descriptor-menu/index.spec.js | 4 +- modules/ticket/front/expedition/index.js | 2 +- modules/ticket/front/expedition/index.spec.js | 2 +- modules/ticket/front/future/index.js | 4 +- modules/ticket/front/future/index.spec.js | 6 +-- modules/ticket/front/index/index.js | 2 +- modules/ticket/front/index/index.spec.js | 6 +-- modules/ticket/front/main/index.js | 2 +- modules/ticket/front/package/index.js | 2 +- modules/ticket/front/sale/index.js | 2 +- modules/ticket/front/sale/index.spec.js | 6 +-- .../ticket/front/search-panel/index.spec.js | 8 ++-- .../methods/thermograph/createThermograph.js | 2 +- .../back/methods/travel/cloneWithEntries.js | 4 +- .../travel/specs/cloneWithEntries.spec.js | 2 +- .../travel/specs/extraCommunityFilter.spec.js | 4 +- .../back/methods/travel/specs/filter.spec.js | 4 +- modules/travel/front/create/index.spec.js | 4 +- modules/travel/front/extra-community/index.js | 4 +- modules/travel/front/index/index.js | 2 +- modules/travel/front/index/index.spec.js | 6 +-- modules/travel/front/main/index.js | 2 +- modules/travel/front/main/index.spec.js | 2 +- .../travel/front/search-panel/index.spec.js | 8 ++-- .../worker/back/methods/calendar/absences.js | 4 +- .../methods/calendar/specs/absences.spec.js | 12 +++--- .../back/methods/holiday/getByWarehouse.js | 2 +- .../worker-time-control-mail/checkInbox.js | 4 +- .../methods/worker-time-control/sendMail.js | 12 +++--- .../worker-time-control/specs/filter.spec.js | 8 ++-- .../specs/timeEntry.spec.js | 42 +++++++++---------- .../back/methods/worker/activeContract.js | 2 +- .../back/methods/worker/createAbsence.js | 4 +- .../worker/back/methods/worker/holidays.js | 4 +- .../worker/specs/createAbsence.spec.js | 8 ++-- .../worker/specs/deleteAbsence.spec.js | 4 +- .../worker/specs/getWorkedHours.spec.js | 4 +- .../methods/worker/specs/holidays.spec.js | 4 +- .../worker/specs/updateAbsence.spec.js | 2 +- modules/worker/front/calendar/index.js | 6 +-- modules/worker/front/calendar/index.spec.js | 18 ++++---- modules/worker/front/descriptor/index.js | 2 +- modules/worker/front/time-control/index.js | 4 +- .../worker/front/time-control/index.spec.js | 8 ++-- .../specs/getAgenciesWithWarehouse.spec.js | 2 +- .../methods/agency/specs/getLanded.spec.js | 2 +- .../methods/agency/specs/getShipped.spec.js | 4 +- .../methods/agency/specs/landsThatDay.spec.js | 2 +- modules/zone/back/methods/zone/deleteZone.js | 2 +- .../methods/zone/specs/exclusionGeo.spec.js | 2 +- .../zone/specs/getEventsFiltered.spec.js | 6 +-- .../methods/zone/specs/getZoneClosing.spec.js | 2 +- .../zone/specs/includingExpired.spec.js | 2 +- modules/zone/front/calendar/index.js | 2 +- modules/zone/front/calendar/index.spec.js | 24 +++++------ modules/zone/front/create/index.js | 2 +- .../zone/front/delivery-days/index.spec.js | 2 +- modules/zone/front/descriptor/index.js | 2 +- modules/zone/front/events/index.spec.js | 10 ++--- .../buyer-week-waste/buyer-week-waste.js | 2 +- .../email/osticket-report/osticket-report.js | 2 +- .../balance-compensation.js | 2 +- .../claim-pickup-order/claim-pickup-order.js | 2 +- .../client-debt-statement.js | 2 +- .../reports/credit-request/credit-request.js | 2 +- .../expedition-pallet-label.js | 2 +- .../extra-community/extra-community.js | 14 +++---- .../incoterms-authorization.js | 2 +- .../reports/item-label/item-label.js | 2 +- .../reports/letter-debtor/letter-debtor.js | 2 +- .../templates/reports/sepa-core/sepa-core.js | 2 +- 224 files changed, 502 insertions(+), 502 deletions(-) diff --git a/back/methods/campaign/latest.js b/back/methods/campaign/latest.js index a418f1267..56ab81330 100644 --- a/back/methods/campaign/latest.js +++ b/back/methods/campaign/latest.js @@ -22,7 +22,7 @@ module.exports = Self => { Self.latest = async filter => { const conn = Self.dataSource.connector; - const minDate = new Date(); + const minDate = Date.vnNew(); minDate.setFullYear(minDate.getFullYear() - 1); const where = {dated: {gte: minDate}}; diff --git a/back/methods/campaign/spec/latest.spec.js b/back/methods/campaign/spec/latest.spec.js index a71849b59..59e4c1e7a 100644 --- a/back/methods/campaign/spec/latest.spec.js +++ b/back/methods/campaign/spec/latest.spec.js @@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server'); describe('campaign latest()', () => { it('should return the campaigns from the last year', async() => { - const now = new Date(); + const now = Date.vnNew(); const result = await app.models.Campaign.latest(); const randomIndex = Math.floor(Math.random() * result.length); const campaignDated = result[randomIndex].dated; @@ -12,7 +12,7 @@ describe('campaign latest()', () => { }); it('should return the campaigns from the current year', async() => { - const now = new Date(); + const now = Date.vnNew(); const currentYear = now.getFullYear(); const result = await app.models.Campaign.latest({ where: {dated: {like: `%${currentYear}%`}} diff --git a/back/methods/campaign/spec/upcoming.spec.js b/back/methods/campaign/spec/upcoming.spec.js index 14bffe3cf..2aec5117f 100644 --- a/back/methods/campaign/spec/upcoming.spec.js +++ b/back/methods/campaign/spec/upcoming.spec.js @@ -4,7 +4,7 @@ describe('campaign upcoming()', () => { it('should return the upcoming campaign but from the last year', async() => { const response = await app.models.Campaign.upcoming(); const campaignDated = response.dated; - const now = new Date(); + const now = Date.vnNew(); expect(campaignDated).toEqual(jasmine.any(Date)); expect(campaignDated).toBeLessThanOrEqual(now); diff --git a/back/methods/campaign/upcoming.js b/back/methods/campaign/upcoming.js index 2f1a5a377..c98fee6e5 100644 --- a/back/methods/campaign/upcoming.js +++ b/back/methods/campaign/upcoming.js @@ -14,7 +14,7 @@ module.exports = Self => { }); Self.upcoming = async() => { - const minDate = new Date(); + const minDate = Date.vnNew(); minDate.setFullYear(minDate.getFullYear() - 1); return Self.findOne({ diff --git a/back/methods/chat/getServiceAuth.js b/back/methods/chat/getServiceAuth.js index 827092109..ff14e76cb 100644 --- a/back/methods/chat/getServiceAuth.js +++ b/back/methods/chat/getServiceAuth.js @@ -21,7 +21,7 @@ module.exports = Self => { if (!this.login) return; - if (Date.now() > this.login.expires) + if (Date.vnNow() > this.login.expires) this.login = await requestToken(); return this.login; @@ -48,7 +48,7 @@ module.exports = Self => { userId: requestData.userId, token: requestData.authToken }, - expires: Date.now() + (1000 * 60 * tokenLifespan) + expires: Date.vnNow() + (1000 * 60 * tokenLifespan) }; } } diff --git a/back/methods/chat/send.js b/back/methods/chat/send.js index c5c8feead..915120d49 100644 --- a/back/methods/chat/send.js +++ b/back/methods/chat/send.js @@ -33,7 +33,7 @@ module.exports = Self => { await models.Chat.create({ senderFk: sender.id, recipient: to, - dated: new Date(), + dated: Date.vnNew(), checkUserStatus: 0, message: message, status: 0, diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 075591969..883a1b693 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -49,7 +49,7 @@ module.exports = Self => { await models.Chat.create({ senderFk: sender.id, recipient: `@${recipient.name}`, - dated: new Date(), + dated: Date.vnNew(), checkUserStatus: 1, message: message, status: 0, diff --git a/back/methods/chat/spec/sendQueued.spec.js b/back/methods/chat/spec/sendQueued.spec.js index bbf5a73c7..ed791756b 100644 --- a/back/methods/chat/spec/sendQueued.spec.js +++ b/back/methods/chat/spec/sendQueued.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('Chat sendCheckingPresence()', () => { - const today = new Date(); + const today = Date.vnNew(); today.setHours(6, 0); const chatModel = models.Chat; diff --git a/back/methods/dms/deleteTrashFiles.js b/back/methods/dms/deleteTrashFiles.js index f14e65e9f..239d654ef 100644 --- a/back/methods/dms/deleteTrashFiles.js +++ b/back/methods/dms/deleteTrashFiles.js @@ -32,7 +32,7 @@ module.exports = Self => { where: {code: 'trash'} }, myOptions); - const date = new Date(); + const date = Date.vnNew(); date.setMonth(date.getMonth() - 4); const dmsToDelete = await models.Dms.find({ diff --git a/back/methods/dms/saveSign.js b/back/methods/dms/saveSign.js index f668c5ed2..ed462a301 100644 --- a/back/methods/dms/saveSign.js +++ b/back/methods/dms/saveSign.js @@ -163,7 +163,7 @@ module.exports = Self => { fields: ['alertLevel'] }); - signedTime ? signedTime != undefined : signedTime = new Date(); + signedTime ? signedTime != undefined : signedTime = Date.vnNew(); if (alertLevel >= 2) { let dir; diff --git a/back/methods/docuware/upload.js b/back/methods/docuware/upload.js index b5ee3d18f..ea9ee3622 100644 --- a/back/methods/docuware/upload.js +++ b/back/methods/docuware/upload.js @@ -127,7 +127,7 @@ module.exports = Self => { const uploadOptions = { headers: { 'Content-Type': 'multipart/form-data', - 'X-File-ModifiedDate': new Date(), + 'X-File-ModifiedDate': Date.vnNew(), 'Cookie': options.headers.headers.Cookie, ...data.getHeaders() }, diff --git a/back/methods/edi/updateData.js b/back/methods/edi/updateData.js index c5705513f..232695f4e 100644 --- a/back/methods/edi/updateData.js +++ b/back/methods/edi/updateData.js @@ -230,7 +230,7 @@ module.exports = Self => { UPDATE edi.tableConfig SET updated = ? WHERE fileName = ? - `, [new Date(), baseName], options); + `, [Date.vnNew(), baseName], options); } console.log(`Updated table ${toTable}\n`); diff --git a/back/methods/notification/clean.js b/back/methods/notification/clean.js index bdc6737df..8ce32d389 100644 --- a/back/methods/notification/clean.js +++ b/back/methods/notification/clean.js @@ -32,7 +32,7 @@ module.exports = Self => { if (!config.cleanDays) return; - const cleanDate = new Date(); + const cleanDate = Date.vnNew(); cleanDate.setDate(cleanDate.getDate() - config.cleanDays); await models.NotificationQueue.destroyAll({ diff --git a/back/methods/notification/specs/clean.spec.js b/back/methods/notification/specs/clean.spec.js index 4c9dc563d..857886a64 100644 --- a/back/methods/notification/specs/clean.spec.js +++ b/back/methods/notification/specs/clean.spec.js @@ -10,7 +10,7 @@ describe('Notification Clean()', () => { const notification = await models.Notification.findOne({}, options); const notificationConfig = await models.NotificationConfig.findOne({}); - const cleanDate = new Date(); + const cleanDate = Date.vnNew(); cleanDate.setDate(cleanDate.getDate() - (notificationConfig.cleanDays + 1)); let before; diff --git a/back/models/image.js b/back/models/image.js index d736e924f..37f4ec20d 100644 --- a/back/models/image.js +++ b/back/models/image.js @@ -77,7 +77,7 @@ module.exports = Self => { const newImage = await Self.upsertWithWhere(data, { name: fileName, collectionFk: collectionName, - updated: (new Date).getTime() + updated: Date.vnNow() }, myOptions); // Resizes and saves the image diff --git a/db/tests/vn/buyUltimate.spec.js b/db/tests/vn/buyUltimate.spec.js index e0b3fa568..4c98945c1 100644 --- a/db/tests/vn/buyUltimate.spec.js +++ b/db/tests/vn/buyUltimate.spec.js @@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server'); const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; describe('buyUltimate()', () => { - const today = new Date(); + const today = Date.vnNew(); it(`should create buyUltimate temporal table and update it's values`, async() => { let stmts = []; let stmt; diff --git a/db/tests/vn/buyUltimateFromInterval.spec.js b/db/tests/vn/buyUltimateFromInterval.spec.js index b5e6970f7..7a4a79d47 100644 --- a/db/tests/vn/buyUltimateFromInterval.spec.js +++ b/db/tests/vn/buyUltimateFromInterval.spec.js @@ -5,7 +5,7 @@ describe('buyUltimateFromInterval()', () => { let today; let future; beforeAll(() => { - let now = new Date(); + let now = Date.vnNew(); now.setHours(0, 0, 0, 0); today = now; diff --git a/db/tests/vn/ticketCalculateClon.spec.js b/db/tests/vn/ticketCalculateClon.spec.js index 03814682d..a3c790492 100644 --- a/db/tests/vn/ticketCalculateClon.spec.js +++ b/db/tests/vn/ticketCalculateClon.spec.js @@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server'); const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; describe('ticket ticketCalculateClon()', () => { - const today = new Date(); + const today = Date.vnNew(); it('should add the ticket to the order containing the original ticket', async() => { let stmts = []; let stmt; diff --git a/db/tests/vn/ticketCreateWithUser.spec.js b/db/tests/vn/ticketCreateWithUser.spec.js index 1c13be1b3..4aeece564 100644 --- a/db/tests/vn/ticketCreateWithUser.spec.js +++ b/db/tests/vn/ticketCreateWithUser.spec.js @@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server'); const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; describe('ticket ticketCreateWithUser()', () => { - const today = new Date(); + const today = Date.vnNew(); it('should confirm the procedure creates the expected ticket', async() => { let stmts = []; let stmt; diff --git a/db/tests/vn/timeBusiness_calculateByUser.spec.js b/db/tests/vn/timeBusiness_calculateByUser.spec.js index 441f567ac..5fe51d8f8 100644 --- a/db/tests/vn/timeBusiness_calculateByUser.spec.js +++ b/db/tests/vn/timeBusiness_calculateByUser.spec.js @@ -3,9 +3,9 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; describe('timeBusiness_calculateByUser()', () => { it('should return the expected hours for today', async() => { - let start = new Date(); + let start = Date.vnNew(); start.setHours(0, 0, 0, 0); - let end = new Date(); + let end = Date.vnNew(); end.setHours(0, 0, 0, 0); let stmts = []; diff --git a/db/tests/vn/timeControl_calculateByUser.spec.js b/db/tests/vn/timeControl_calculateByUser.spec.js index 2aa16c7a4..73e00ec3a 100644 --- a/db/tests/vn/timeControl_calculateByUser.spec.js +++ b/db/tests/vn/timeControl_calculateByUser.spec.js @@ -3,11 +3,11 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; describe('timeControl_calculateByUser()', () => { it(`should return today's worked hours`, async() => { - let start = new Date(); + let start = Date.vnNew(); start.setHours(0, 0, 0, 0); start.setDate(start.getDate() - 1); - let end = new Date(); + let end = Date.vnNew(); end.setHours(0, 0, 0, 0); end.setDate(end.getDate() + 1); @@ -17,7 +17,7 @@ describe('timeControl_calculateByUser()', () => { stmts.push('START TRANSACTION'); stmts.push(` - DROP TEMPORARY TABLE IF EXISTS + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate, tmp.timeBusinessCalculate `); @@ -48,14 +48,14 @@ describe('timeControl_calculateByUser()', () => { }); it(`should return the worked hours between last sunday and monday`, async() => { - let lastSunday = new Date(); + let lastSunday = Date.vnNew(); let daysSinceSunday = lastSunday.getDay(); if (daysSinceSunday === 0) // this means today is sunday but you need the previous sunday :) daysSinceSunday = 7; lastSunday.setHours(23, 0, 0, 0); lastSunday.setDate(lastSunday.getDate() - daysSinceSunday); - let monday = new Date(); + let monday = Date.vnNew(); let daysSinceMonday = daysSinceSunday - 1; // aiming for monday (today could be monday) monday.setHours(7, 0, 0, 0); monday.setDate(monday.getDate() - daysSinceMonday); @@ -66,7 +66,7 @@ describe('timeControl_calculateByUser()', () => { stmts.push('START TRANSACTION'); stmts.push(` - DROP TEMPORARY TABLE IF EXISTS + DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate, tmp.timeBusinessCalculate `); diff --git a/db/tests/vn/zone_getLanded.spec.js b/db/tests/vn/zone_getLanded.spec.js index 5f82156d3..888d7c132 100644 --- a/db/tests/vn/zone_getLanded.spec.js +++ b/db/tests/vn/zone_getLanded.spec.js @@ -6,7 +6,7 @@ describe('zone zone_getLanded()', () => { let stmts = []; let stmt; stmts.push('START TRANSACTION'); - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); let params = { @@ -40,7 +40,7 @@ describe('zone zone_getLanded()', () => { it(`should return data for a shipped tomorrow`, async() => { let stmts = []; let stmt; - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); stmts.push('START TRANSACTION'); diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 7bf56e2c8..7d80c69ee 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -436,7 +436,7 @@ let actions = { }, pickDate: async function(selector, date) { - date = date || new Date(); + date = date || Date.vnNew(); const timeZoneOffset = date.getTimezoneOffset() * 60000; const localDate = (new Date(date.getTime() - timeZoneOffset)) diff --git a/e2e/paths/02-client/20_credit_insurance.spec.js b/e2e/paths/02-client/20_credit_insurance.spec.js index 904a51145..a4f148b8f 100644 --- a/e2e/paths/02-client/20_credit_insurance.spec.js +++ b/e2e/paths/02-client/20_credit_insurance.spec.js @@ -4,7 +4,7 @@ import getBrowser from '../../helpers/puppeteer'; describe('Client credit insurance path', () => { let browser; let page; - let previousMonth = new Date(); + let previousMonth = Date.vnNew(); previousMonth.setMonth(previousMonth.getMonth() - 1); beforeAll(async() => { diff --git a/e2e/paths/03-worker/04_time_control.spec.js b/e2e/paths/03-worker/04_time_control.spec.js index bba7ced89..651a1d006 100644 --- a/e2e/paths/03-worker/04_time_control.spec.js +++ b/e2e/paths/03-worker/04_time_control.spec.js @@ -22,7 +22,7 @@ describe('Worker time control path', () => { const hankPymId = 1107; it('should go to the next month, go to current month and go 1 month in the past', async() => { - let date = new Date(); + let date = Date.vnNew(); date.setMonth(date.getMonth() + 1); let month = date.toLocaleString('default', {month: 'long'}); @@ -31,7 +31,7 @@ describe('Worker time control path', () => { expect(result).toContain(month); - date = new Date(); + date = Date.vnNew(); month = date.toLocaleString('default', {month: 'long'}); await page.click(selectors.workerTimeControl.previousMonthButton); @@ -39,7 +39,7 @@ describe('Worker time control path', () => { expect(result).toContain(month); - date = new Date(); + date = Date.vnNew(); date.setMonth(date.getMonth() - 1); const timestamp = Math.round(date.getTime() / 1000); month = date.toLocaleString('default', {month: 'long'}); diff --git a/e2e/paths/03-worker/05_calendar.spec.js b/e2e/paths/03-worker/05_calendar.spec.js index c310baf5a..f0af0a053 100644 --- a/e2e/paths/03-worker/05_calendar.spec.js +++ b/e2e/paths/03-worker/05_calendar.spec.js @@ -4,7 +4,7 @@ import getBrowser from '../../helpers/puppeteer'; describe('Worker calendar path', () => { const reasonableTimeBetweenClicks = 300; - const date = new Date(); + const date = Date.vnNew(); const lastYear = (date.getFullYear() - 1).toString(); let browser; diff --git a/e2e/paths/04-item/13_fixedPrice.spec.js b/e2e/paths/04-item/13_fixedPrice.spec.js index fc7aac3d0..3e90f5846 100644 --- a/e2e/paths/04-item/13_fixedPrice.spec.js +++ b/e2e/paths/04-item/13_fixedPrice.spec.js @@ -22,7 +22,7 @@ describe('Item fixed prices path', () => { }); it('should fill the fixed price data', async() => { - const now = new Date(); + const now = Date.vnNew(); await page.autocompleteSearch(selectors.itemFixedPrice.fourthWarehouse, 'Warehouse one'); await page.write(selectors.itemFixedPrice.fourthPPU, '1'); await page.write(selectors.itemFixedPrice.fourthPPP, '1'); diff --git a/e2e/paths/05-ticket/06_basic_data_steps.spec.js b/e2e/paths/05-ticket/06_basic_data_steps.spec.js index fa901e325..55aec45fb 100644 --- a/e2e/paths/05-ticket/06_basic_data_steps.spec.js +++ b/e2e/paths/05-ticket/06_basic_data_steps.spec.js @@ -93,7 +93,7 @@ describe('Ticket Edit basic data path', () => { it(`should split ticket without negatives`, async() => { const newAgency = 'Gotham247'; - const newDate = new Date(); + const newDate = Date.vnNew(); newDate.setDate(newDate.getDate() - 1); await page.accessToSearchResult('14'); @@ -127,7 +127,7 @@ describe('Ticket Edit basic data path', () => { }); it(`should old ticket have old date and agency`, async() => { - const oldDate = new Date(); + const oldDate = Date.vnNew(); const oldAgency = 'Super-Man delivery'; await page.accessToSearchResult('14'); diff --git a/e2e/paths/05-ticket/14_create_ticket.spec.js b/e2e/paths/05-ticket/14_create_ticket.spec.js index 48b4ebdd0..80c288a01 100644 --- a/e2e/paths/05-ticket/14_create_ticket.spec.js +++ b/e2e/paths/05-ticket/14_create_ticket.spec.js @@ -4,7 +4,7 @@ import getBrowser from '../../helpers/puppeteer'; describe('Ticket create path', () => { let browser; let page; - let nextMonth = new Date(); + let nextMonth = Date.vnNew(); nextMonth.setMonth(nextMonth.getMonth() + 1); beforeAll(async() => { diff --git a/e2e/paths/08-route/02_basic_data.spec.js b/e2e/paths/08-route/02_basic_data.spec.js index b1440f2d1..ff8361499 100644 --- a/e2e/paths/08-route/02_basic_data.spec.js +++ b/e2e/paths/08-route/02_basic_data.spec.js @@ -18,7 +18,7 @@ describe('Route basic Data path', () => { }); it('should edit the route basic data', async() => { - const nextMonth = new Date(); + const nextMonth = Date.vnNew(); nextMonth.setMonth(nextMonth.getMonth() + 1); await page.autocompleteSearch(selectors.routeBasicData.worker, 'adminBossNick'); diff --git a/e2e/paths/09-invoice-in/03_basic_data.spec.js b/e2e/paths/09-invoice-in/03_basic_data.spec.js index 0a28ed191..778b5949c 100644 --- a/e2e/paths/09-invoice-in/03_basic_data.spec.js +++ b/e2e/paths/09-invoice-in/03_basic_data.spec.js @@ -19,7 +19,7 @@ describe('InvoiceIn basic data path', () => { }); it(`should edit the invoiceIn basic data`, async() => { - const now = new Date(); + const now = Date.vnNew(); await page.pickDate(selectors.invoiceInBasicData.issued, now); await page.pickDate(selectors.invoiceInBasicData.operated, now); await page.autocompleteSearch(selectors.invoiceInBasicData.supplier, 'Verdnatura'); diff --git a/e2e/paths/09-invoice-out/02_descriptor.spec.js b/e2e/paths/09-invoice-out/02_descriptor.spec.js index 8d403e083..5169345bc 100644 --- a/e2e/paths/09-invoice-out/02_descriptor.spec.js +++ b/e2e/paths/09-invoice-out/02_descriptor.spec.js @@ -100,7 +100,7 @@ describe('InvoiceOut descriptor path', () => { }); it(`should check the invoiceOut booked in the summary data`, async() => { - let today = new Date(); + let today = Date.vnNew(); let day = today.getDate(); if (day < 10) day = `0${day}`; diff --git a/e2e/paths/10-travel/01_create.spec.js b/e2e/paths/10-travel/01_create.spec.js index e5d812ebd..15da42d5d 100644 --- a/e2e/paths/10-travel/01_create.spec.js +++ b/e2e/paths/10-travel/01_create.spec.js @@ -4,7 +4,7 @@ import getBrowser from '../../helpers/puppeteer'; describe('Travel create path', () => { let browser; let page; - const date = new Date(); + const date = Date.vnNew(); const day = 15; date.setDate(day); diff --git a/e2e/paths/10-travel/02_basic_data_and_log.spec.js b/e2e/paths/10-travel/02_basic_data_and_log.spec.js index a231a70b2..341b38f59 100644 --- a/e2e/paths/10-travel/02_basic_data_and_log.spec.js +++ b/e2e/paths/10-travel/02_basic_data_and_log.spec.js @@ -22,7 +22,7 @@ describe('Travel basic data path', () => { }); it('should set a wrong delivery date then receive an error on submit', async() => { - const lastMonth = new Date(); + const lastMonth = Date.vnNew(); lastMonth.setMonth(lastMonth.getMonth() - 1); await page.pickDate(selectors.travelBasicData.deliveryDate, lastMonth); diff --git a/e2e/paths/10-travel/03_descriptor.spec.js b/e2e/paths/10-travel/03_descriptor.spec.js index f459ef043..77b26b676 100644 --- a/e2e/paths/10-travel/03_descriptor.spec.js +++ b/e2e/paths/10-travel/03_descriptor.spec.js @@ -123,7 +123,7 @@ describe('Travel descriptor path', () => { }); it('should update the landed date to a future date to enable cloneWithEntries', async() => { - const nextMonth = new Date(); + const nextMonth = Date.vnNew(); nextMonth.setMonth(nextMonth.getMonth() + 1); await page.pickDate(selectors.travelBasicData.deliveryDate, nextMonth); await page.waitToClick(selectors.travelBasicData.save); diff --git a/front/core/components/calendar/index.js b/front/core/components/calendar/index.js index 85b51fd04..17ccbf041 100644 --- a/front/core/components/calendar/index.js +++ b/front/core/components/calendar/index.js @@ -15,7 +15,7 @@ export default class Calendar extends FormInput { constructor($element, $scope, vnWeekDays, moment) { super($element, $scope); this.weekDays = vnWeekDays.locales; - this.defaultDate = new Date(); + this.defaultDate = Date.vnNew(); this.displayControls = true; this.moment = moment; } @@ -115,8 +115,8 @@ export default class Calendar extends FormInput { let wday = date.getDay(); let month = date.getMonth(); - const currentDay = new Date().getDate(); - const currentMonth = new Date().getMonth(); + const currentDay = Date.vnNew().getDate(); + const currentMonth = Date.vnNew().getMonth(); let classes = { today: day === currentDay && month === currentMonth, diff --git a/front/core/components/calendar/index.spec.js b/front/core/components/calendar/index.spec.js index e3a3b0f87..c4ad6f14b 100644 --- a/front/core/components/calendar/index.spec.js +++ b/front/core/components/calendar/index.spec.js @@ -2,7 +2,7 @@ describe('Component vnCalendar', () => { let controller; let $element; - let date = new Date(); + let date = Date.vnNew(); date.setHours(0, 0, 0, 0); date.setDate(1); @@ -48,7 +48,7 @@ describe('Component vnCalendar', () => { it(`should return the selected element, then emit a 'selection' event`, () => { jest.spyOn(controller, 'emit'); - const day = new Date(); + const day = Date.vnNew(); day.setHours(0, 0, 0, 0); const clickEvent = new Event('click'); diff --git a/front/core/components/date-picker/index.spec.js b/front/core/components/date-picker/index.spec.js index f76396311..13ab1d70a 100644 --- a/front/core/components/date-picker/index.spec.js +++ b/front/core/components/date-picker/index.spec.js @@ -4,7 +4,7 @@ describe('Component vnDatePicker', () => { let $ctrl; let today; - today = new Date(); + today = Date.vnNew(); today.setHours(0, 0, 0, 0); beforeEach(ngModule('vnCore')); diff --git a/front/core/components/input-time/index.js b/front/core/components/input-time/index.js index 0d01fbd32..67fa9d6fd 100644 --- a/front/core/components/input-time/index.js +++ b/front/core/components/input-time/index.js @@ -31,7 +31,7 @@ export default class InputTime extends Field { date = this.modelDate ? new Date(this.modelDate) - : new Date(); + : Date.vnNew(); date.setHours(split[0], split[1], 0, 0); } diff --git a/front/core/components/input-time/index.spec.js b/front/core/components/input-time/index.spec.js index abb684df8..7b4f1c823 100644 --- a/front/core/components/input-time/index.spec.js +++ b/front/core/components/input-time/index.spec.js @@ -20,7 +20,7 @@ describe('Component vnInputTime', () => { describe('field() setter', () => { it(`should display the formated the date`, () => { - let date = new Date(); + let date = Date.vnNew(); $ctrl.field = date; let displayed = $filter('date')(date, 'HH:mm'); diff --git a/front/salix/components/upload-photo/index.js b/front/salix/components/upload-photo/index.js index c47018307..fb115992f 100644 --- a/front/salix/components/upload-photo/index.js +++ b/front/salix/components/upload-photo/index.js @@ -197,7 +197,7 @@ export default class UploadPhoto extends Component { timeout: this.canceler.promise, transformRequest: ([file]) => { const formData = new FormData(); - const now = new Date(); + const now = Date.vnNew(); const timestamp = now.getTime(); const fileName = `${file.name}_${timestamp}`; diff --git a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js index 22a48f83e..f0686ffa6 100644 --- a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js +++ b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.js @@ -95,7 +95,7 @@ module.exports = Self => { }, myOptions); const claim = await models.Claim.findOne(filter, myOptions); - const today = new Date(); + const today = Date.vnNew(); const newRefundTicket = await models.Ticket.create({ clientFk: claim.ticket().clientFk, @@ -172,7 +172,7 @@ module.exports = Self => { async function saveObservation(observation, options) { const query = `INSERT INTO vn.ticketObservation (ticketFk, observationTypeFk, description) VALUES(?, ?, ?) - ON DUPLICATE KEY + ON DUPLICATE KEY UPDATE description = CONCAT(vn.ticketObservation.description, VALUES(description),' ')`; await Self.rawSql(query, [ observation.ticketFk, diff --git a/modules/claim/back/methods/claim/createFromSales.js b/modules/claim/back/methods/claim/createFromSales.js index ba7bda71d..2ce3bc44b 100644 --- a/modules/claim/back/methods/claim/createFromSales.js +++ b/modules/claim/back/methods/claim/createFromSales.js @@ -60,7 +60,7 @@ module.exports = Self => { const landedPlusWeek = new Date(ticket.landed); landedPlusWeek.setDate(landedPlusWeek.getDate() + 7); const hasClaimManagerRole = await models.Account.hasRole(userId, 'claimManager', myOptions); - const isClaimable = landedPlusWeek >= new Date(); + const isClaimable = landedPlusWeek >= Date.vnNew(); if (ticket.isDeleted) throw new UserError(`You can't create a claim for a removed ticket`); diff --git a/modules/claim/back/methods/claim/regularizeClaim.js b/modules/claim/back/methods/claim/regularizeClaim.js index ab8ea58a4..672c94947 100644 --- a/modules/claim/back/methods/claim/regularizeClaim.js +++ b/modules/claim/back/methods/claim/regularizeClaim.js @@ -1,6 +1,6 @@ module.exports = Self => { Self.remoteMethodCtx('regularizeClaim', { - description: `Imports lines from claimBeginning to a new ticket + description: `Imports lines from claimBeginning to a new ticket with specific shipped, landed dates, agency and company`, accessType: 'WRITE', accepts: [{ @@ -135,10 +135,10 @@ module.exports = Self => { } async function getTicketId(params, options) { - const minDate = new Date(); + const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); - const maxDate = new Date(); + const maxDate = Date.vnNew(); maxDate.setHours(23, 59, 59, 59); let ticket = await Self.app.models.Ticket.findOne({ @@ -155,8 +155,8 @@ module.exports = Self => { } async function createTicket(ctx, options) { - ctx.args.shipped = new Date(); - ctx.args.landed = new Date(); + ctx.args.shipped = Date.vnNew(); + ctx.args.landed = Date.vnNew(); ctx.args.agencyModeId = null; ctx.args.routeId = null; diff --git a/modules/claim/back/methods/claim/specs/createFromSales.spec.js b/modules/claim/back/methods/claim/specs/createFromSales.spec.js index 9151c361e..7cf663caf 100644 --- a/modules/claim/back/methods/claim/specs/createFromSales.spec.js +++ b/modules/claim/back/methods/claim/specs/createFromSales.spec.js @@ -54,7 +54,7 @@ describe('Claim createFromSales()', () => { try { const options = {transaction: tx}; - const todayMinusEightDays = new Date(); + const todayMinusEightDays = Date.vnNew(); todayMinusEightDays.setDate(todayMinusEightDays.getDate() - 8); const ticket = await models.Ticket.findById(ticketId, null, options); @@ -85,7 +85,7 @@ describe('Claim createFromSales()', () => { try { const options = {transaction: tx}; - const todayMinusEightDays = new Date(); + const todayMinusEightDays = Date.vnNew(); todayMinusEightDays.setDate(todayMinusEightDays.getDate() - 8); const ticket = await models.Ticket.findById(ticketId, null, options); diff --git a/modules/claim/back/methods/claim/specs/updateClaim.spec.js b/modules/claim/back/methods/claim/specs/updateClaim.spec.js index 8d888eb40..113df35c9 100644 --- a/modules/claim/back/methods/claim/specs/updateClaim.spec.js +++ b/modules/claim/back/methods/claim/specs/updateClaim.spec.js @@ -1,7 +1,7 @@ const app = require('vn-loopback/server/server'); describe('Update Claim', () => { - const newDate = new Date(); + const newDate = Date.vnNew(); const originalData = { ticketFk: 3, clientFk: 1101, diff --git a/modules/claim/back/methods/claim/specs/updateClaimAction.spec.js b/modules/claim/back/methods/claim/specs/updateClaimAction.spec.js index 4cd4ce528..12ab45fac 100644 --- a/modules/claim/back/methods/claim/specs/updateClaimAction.spec.js +++ b/modules/claim/back/methods/claim/specs/updateClaimAction.spec.js @@ -1,7 +1,7 @@ const app = require('vn-loopback/server/server'); describe('Update Claim', () => { - const newDate = new Date(); + const newDate = Date.vnNew(); const original = { ticketFk: 3, clientFk: 1101, diff --git a/modules/client/back/methods/client/consumptionSendQueued.js b/modules/client/back/methods/client/consumptionSendQueued.js index 77e0e34f2..31b54b21d 100644 --- a/modules/client/back/methods/client/consumptionSendQueued.js +++ b/modules/client/back/methods/client/consumptionSendQueued.js @@ -32,7 +32,7 @@ module.exports = Self => { c.id AS clientFk, c.email AS clientEmail, eu.email salesPersonEmail - FROM client c + FROM client c JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk JOIN ticket t ON t.clientFk = c.id JOIN sale s ON s.ticketFk = t.id @@ -61,10 +61,10 @@ module.exports = Self => { SET status = 'printed', printed = ? WHERE id = ?`, - [new Date(), queue.id]); + [Date.vnNew(), queue.id]); } catch (error) { await Self.rawSql(` - UPDATE clientConsumptionQueue + UPDATE clientConsumptionQueue SET status = ? WHERE id = ?`, [error.message, queue.id]); diff --git a/modules/client/back/methods/client/createReceipt.js b/modules/client/back/methods/client/createReceipt.js index a75ee8844..74fe2211e 100644 --- a/modules/client/back/methods/client/createReceipt.js +++ b/modules/client/back/methods/client/createReceipt.js @@ -51,7 +51,7 @@ module.exports = function(Self) { Self.createReceipt = async(ctx, options) => { const models = Self.app.models; const args = ctx.args; - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); let tx; diff --git a/modules/client/back/methods/client/getCard.js b/modules/client/back/methods/client/getCard.js index 21b3140bd..afbe36e49 100644 --- a/modules/client/back/methods/client/getCard.js +++ b/modules/client/back/methods/client/getCard.js @@ -74,7 +74,7 @@ module.exports = function(Self) { ] }, myOptions); - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const query = `SELECT vn.clientGetDebt(?, ?) AS debt`; const data = await Self.rawSql(query, [id, date], myOptions); diff --git a/modules/client/back/methods/client/getDebt.js b/modules/client/back/methods/client/getDebt.js index aafdbfa48..5f8a8c569 100644 --- a/modules/client/back/methods/client/getDebt.js +++ b/modules/client/back/methods/client/getDebt.js @@ -25,7 +25,7 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const query = `SELECT vn.clientGetDebt(?, ?) AS debt`; const [debt] = await Self.rawSql(query, [clientFk, date], myOptions); diff --git a/modules/client/back/methods/client/lastActiveTickets.js b/modules/client/back/methods/client/lastActiveTickets.js index 03616a0e3..d662f75aa 100644 --- a/modules/client/back/methods/client/lastActiveTickets.js +++ b/modules/client/back/methods/client/lastActiveTickets.js @@ -32,14 +32,14 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const ticket = await Self.app.models.Ticket.findById(ticketId, null, myOptions); const query = ` - SELECT + SELECT t.id, t.shipped, - a.name AS agencyName, + a.name AS agencyName, w.name AS warehouseName, ad.nickname AS nickname, ad.city AS city, @@ -52,7 +52,7 @@ module.exports = Self => { JOIN vn.warehouse w ON t.warehouseFk = w.id JOIN vn.address ad ON t.addressFk = ad.id JOIN vn.province pr ON ad.provinceFk = pr.id - WHERE t.shipped >= ? AND t.clientFk = ? AND ts.alertLevel = 0 + WHERE t.shipped >= ? AND t.clientFk = ? AND ts.alertLevel = 0 AND t.id <> ? AND t.warehouseFk = ? ORDER BY t.shipped LIMIT 10`; diff --git a/modules/client/back/methods/client/summary.js b/modules/client/back/methods/client/summary.js index 48cb75f31..caa3d8033 100644 --- a/modules/client/back/methods/client/summary.js +++ b/modules/client/back/methods/client/summary.js @@ -125,7 +125,7 @@ module.exports = Self => { async function getRecoveries(recoveryModel, clientId, options) { const filter = { where: { - and: [{clientFk: clientId}, {or: [{finished: null}, {finished: {gt: Date.now()}}]}] + and: [{clientFk: clientId}, {or: [{finished: null}, {finished: {gt: Date.vnNow()}}]}] }, limit: 1 }; diff --git a/modules/client/back/methods/credit-classification/createWithInsurance.spec.js b/modules/client/back/methods/credit-classification/createWithInsurance.spec.js index 95ff5025f..a5837bb90 100644 --- a/modules/client/back/methods/credit-classification/createWithInsurance.spec.js +++ b/modules/client/back/methods/credit-classification/createWithInsurance.spec.js @@ -23,7 +23,7 @@ describe('Client createWithInsurance', () => { try { const options = {transaction: tx}; - const data = {clientFk: 1101, started: Date.now(), credit: 999, grade: 255}; + const data = {clientFk: 1101, started: Date.vnNow(), credit: 999, grade: 255}; const result = await models.CreditClassification.createWithInsurance(data, options); diff --git a/modules/client/back/methods/defaulter/filter.js b/modules/client/back/methods/defaulter/filter.js index ce1d89818..748581913 100644 --- a/modules/client/back/methods/defaulter/filter.js +++ b/modules/client/back/methods/defaulter/filter.js @@ -51,7 +51,7 @@ module.exports = Self => { const stmts = []; - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const stmt = new ParameterizedSQL( `SELECT * @@ -65,14 +65,14 @@ module.exports = Self => { co.created, co.text observation, uw.id workerFk, - uw.name workerName, + uw.name workerName, c.creditInsurance, d.defaulterSinced FROM vn.defaulter d JOIN vn.client c ON c.id = d.clientFk LEFT JOIN vn.clientObservation co ON co.clientFk = c.id LEFT JOIN account.user u ON u.id = c.salesPersonFk - LEFT JOIN account.user uw ON uw.id = co.workerFk + LEFT JOIN account.user uw ON uw.id = co.workerFk WHERE d.created = ? AND d.amount > 0 diff --git a/modules/client/back/methods/recovery/hasActiveRecovery.js b/modules/client/back/methods/recovery/hasActiveRecovery.js index 6b69d99d7..344b6b6ab 100644 --- a/modules/client/back/methods/recovery/hasActiveRecovery.js +++ b/modules/client/back/methods/recovery/hasActiveRecovery.js @@ -27,7 +27,7 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const query = ` SELECT count(*) AS hasActiveRecovery diff --git a/modules/client/back/models/client-sample.js b/modules/client/back/models/client-sample.js index 787cc2ad8..5e4393042 100644 --- a/modules/client/back/models/client-sample.js +++ b/modules/client/back/models/client-sample.js @@ -41,7 +41,7 @@ module.exports = Self => { // Disable old mandate if (oldMandate) - oldMandate.updateAttribute('finished', new Date()); + oldMandate.updateAttribute('finished', Date.vnNew()); // Create a new mandate await models.Mandate.create({ diff --git a/modules/client/front/balance/create/index.js b/modules/client/front/balance/create/index.js index 35b2e0b38..db973ae45 100644 --- a/modules/client/front/balance/create/index.js +++ b/modules/client/front/balance/create/index.js @@ -68,7 +68,7 @@ class Controller extends Dialog { } this.maxAmount = accountingType && accountingType.maxAmount; - this.receipt.payed = new Date(); + this.receipt.payed = Date.vnNew(); if (accountingType.daysInFuture) this.receipt.payed.setDate(this.receipt.payed.getDate() + accountingType.daysInFuture); } diff --git a/modules/client/front/consumption/index.js b/modules/client/front/consumption/index.js index d9b657318..eb3a10dd6 100644 --- a/modules/client/front/consumption/index.js +++ b/modules/client/front/consumption/index.js @@ -17,11 +17,11 @@ class Controller extends Section { } setDefaultFilter() { - const minDate = new Date(); + const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); minDate.setMonth(minDate.getMonth() - 2); - const maxDate = new Date(); + const maxDate = Date.vnNew(); maxDate.setHours(23, 59, 59, 59); this.filterParams = { diff --git a/modules/client/front/consumption/index.spec.js b/modules/client/front/consumption/index.spec.js index 33cbce58f..f2acddbca 100644 --- a/modules/client/front/consumption/index.spec.js +++ b/modules/client/front/consumption/index.spec.js @@ -26,7 +26,7 @@ describe('Client', () => { it('should call the window.open function', () => { jest.spyOn(window, 'open').mockReturnThis(); - const now = new Date(); + const now = Date.vnNew(); controller.$.model.userParams = { from: now, to: now @@ -49,7 +49,7 @@ describe('Client', () => { describe('sendEmail()', () => { it('should make a GET query sending the report', () => { - const now = new Date(); + const now = Date.vnNew(); controller.$.model.userParams = { from: now, to: now diff --git a/modules/client/front/credit-insurance/create/index.js b/modules/client/front/credit-insurance/create/index.js index 83dc18806..e3138e459 100644 --- a/modules/client/front/credit-insurance/create/index.js +++ b/modules/client/front/credit-insurance/create/index.js @@ -5,7 +5,7 @@ class Controller extends Section { constructor($element, $) { super($element, $); this.creditClassification = { - started: this.$filter('date')(new Date(), 'yyyy-MM-dd HH:mm') + started: this.$filter('date')(Date.vnNew(), 'yyyy-MM-dd HH:mm') }; } diff --git a/modules/client/front/credit-insurance/create/index.spec.js b/modules/client/front/credit-insurance/create/index.spec.js index 36a91ceca..c50afd5cf 100644 --- a/modules/client/front/credit-insurance/create/index.spec.js +++ b/modules/client/front/credit-insurance/create/index.spec.js @@ -24,7 +24,7 @@ describe('Client', () => { describe('onSubmit()', () => { it('should perform a POST query', () => { - let started = new Date(); + let started = Date.vnNew(); controller.creditClassification = { started: started, credit: 300, diff --git a/modules/client/front/credit-insurance/index/index.js b/modules/client/front/credit-insurance/index/index.js index 5f59c918a..b40025c65 100644 --- a/modules/client/front/credit-insurance/index/index.js +++ b/modules/client/front/credit-insurance/index/index.js @@ -52,7 +52,7 @@ class Controller extends Section { } returnDialog() { - let params = {finished: Date.now()}; + let params = {finished: Date.vnNow()}; this.$http.patch(`CreditClassifications/${this.classificationId}`, params).then(() => { this._getClassifications(this.client.id); }); diff --git a/modules/client/front/credit-insurance/index/index.spec.js b/modules/client/front/credit-insurance/index/index.spec.js index 8629db684..af072691a 100644 --- a/modules/client/front/credit-insurance/index/index.spec.js +++ b/modules/client/front/credit-insurance/index/index.spec.js @@ -39,7 +39,7 @@ describe('Client', () => { it(`should return false if finds a classification without due date`, () => { controller.classifications = [ - {finished: Date.now()}, + {finished: Date.vnNow()}, {finished: null} ]; @@ -50,8 +50,8 @@ describe('Client', () => { it(`should return true if all classifications are defined with due date`, () => { controller.classifications = [ - {finished: Date.now()}, - {finished: Date.now()} + {finished: Date.vnNow()}, + {finished: Date.vnNow()} ]; let result = controller.canCreateNew(); diff --git a/modules/client/front/credit-insurance/insurance/create/index.js b/modules/client/front/credit-insurance/insurance/create/index.js index 94de53352..9eae5bfa9 100644 --- a/modules/client/front/credit-insurance/insurance/create/index.js +++ b/modules/client/front/credit-insurance/insurance/create/index.js @@ -5,7 +5,7 @@ class Controller extends Section { constructor($element, $) { super($element, $); this.insurance = { - created: this.$filter('date')(new Date(), 'yyyy-MM-dd HH:mm:ss') + created: this.$filter('date')(Date.vnNew(), 'yyyy-MM-dd HH:mm:ss') }; } diff --git a/modules/client/front/defaulter/index.js b/modules/client/front/defaulter/index.js index 4beadfda6..bfadc5c6a 100644 --- a/modules/client/front/defaulter/index.js +++ b/modules/client/front/defaulter/index.js @@ -82,7 +82,7 @@ export default class Controller extends Section { chipColor(date) { const day = 24 * 60 * 60 * 1000; - const today = new Date(); + const today = Date.vnNew(); today.setHours(0, 0, 0, 0); const observationShipped = new Date(date); diff --git a/modules/client/front/defaulter/index.spec.js b/modules/client/front/defaulter/index.spec.js index 0732c68a1..f92378d08 100644 --- a/modules/client/front/defaulter/index.spec.js +++ b/modules/client/front/defaulter/index.spec.js @@ -38,14 +38,14 @@ describe('client defaulter', () => { describe('chipColor()', () => { it('should return undefined when the date is the present', () => { - let today = new Date(); + let today = Date.vnNew(); 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(); + let pastDate = Date.vnNew(); pastDate = pastDate.setDate(pastDate.getDate() - 11); let result = controller.chipColor(pastDate); @@ -53,7 +53,7 @@ describe('client defaulter', () => { }); it('should return alert when the date is 20 days in the past', () => { - let pastDate = new Date(); + let pastDate = Date.vnNew(); pastDate = pastDate.setDate(pastDate.getDate() - 21); let result = controller.chipColor(pastDate); diff --git a/modules/client/front/greuge/create/index.js b/modules/client/front/greuge/create/index.js index dcc0fa522..147ad9bcb 100644 --- a/modules/client/front/greuge/create/index.js +++ b/modules/client/front/greuge/create/index.js @@ -5,7 +5,7 @@ class Controller extends Section { constructor(...args) { super(...args); this.greuge = { - shipped: new Date(), + shipped: Date.vnNew(), clientFk: this.$params.id }; } diff --git a/modules/client/front/notification/index.spec.js b/modules/client/front/notification/index.spec.js index 4e754f6ad..e1de104be 100644 --- a/modules/client/front/notification/index.spec.js +++ b/modules/client/front/notification/index.spec.js @@ -39,7 +39,7 @@ describe('Client notification', () => { describe('campaignSelection() setter', () => { it('should set the campaign from and to properties', () => { - const dated = new Date(); + const dated = Date.vnNew(); controller.campaignSelection = { dated: dated, scopeDays: 14 @@ -61,8 +61,8 @@ describe('Client notification', () => { controller.$.filters = {hide: () => {}}; controller.campaign = { - from: new Date(), - to: new Date() + from: Date.vnNew(), + to: Date.vnNew() }; const data = controller.$.model.data; diff --git a/modules/client/front/recovery/create/index.js b/modules/client/front/recovery/create/index.js index 4fd05eaa0..1779d647e 100644 --- a/modules/client/front/recovery/create/index.js +++ b/modules/client/front/recovery/create/index.js @@ -5,7 +5,7 @@ class Controller extends Section { constructor($element, $) { super($element, $); this.recovery = { - started: new Date() + started: Date.vnNew() }; } diff --git a/modules/client/front/recovery/index/index.js b/modules/client/front/recovery/index/index.js index d53ded805..e89b6832c 100644 --- a/modules/client/front/recovery/index/index.js +++ b/modules/client/front/recovery/index/index.js @@ -4,7 +4,7 @@ import Section from 'salix/components/section'; class Controller extends Section { setFinished(recovery) { if (!recovery.finished) { - let params = {finished: Date.now()}; + let params = {finished: Date.vnNow()}; this.$http.patch(`Recoveries/${recovery.id}`, params).then( () => this.$.model.refresh() ); diff --git a/modules/client/front/summary/index.js b/modules/client/front/summary/index.js index 1f22612d2..877579e33 100644 --- a/modules/client/front/summary/index.js +++ b/modules/client/front/summary/index.js @@ -100,7 +100,7 @@ class Controller extends Summary { } chipColor(date) { - const today = new Date(); + const today = Date.vnNew(); today.setHours(0, 0, 0, 0); const ticketShipped = new Date(date); diff --git a/modules/client/front/summary/index.spec.js b/modules/client/front/summary/index.spec.js index 0261cef45..a05d48518 100644 --- a/modules/client/front/summary/index.spec.js +++ b/modules/client/front/summary/index.spec.js @@ -76,14 +76,14 @@ describe('Client', () => { describe('chipColor()', () => { it('should return warning when the date is the present', () => { - let today = new Date(); + let today = Date.vnNew(); let result = controller.chipColor(today); expect(result).toEqual('warning'); }); it('should return success when the date is in the future', () => { - let futureDate = new Date(); + let futureDate = Date.vnNew(); futureDate = futureDate.setDate(futureDate.getDate() + 10); let result = controller.chipColor(futureDate); @@ -91,7 +91,7 @@ describe('Client', () => { }); it('should return undefined when the date is in the past', () => { - let pastDate = new Date(); + let pastDate = Date.vnNew(); pastDate = pastDate.setDate(pastDate.getDate() - 10); let result = controller.chipColor(pastDate); diff --git a/modules/client/front/unpaid/index.js b/modules/client/front/unpaid/index.js index a8ff64386..fcf620b54 100644 --- a/modules/client/front/unpaid/index.js +++ b/modules/client/front/unpaid/index.js @@ -4,7 +4,7 @@ import Section from 'salix/components/section'; export default class Controller extends Section { setDefaultDate(hasData) { if (hasData && !this.clientUnpaid.dated) - this.clientUnpaid.dated = new Date(); + this.clientUnpaid.dated = Date.vnNew(); } } diff --git a/modules/client/front/unpaid/index.spec.js b/modules/client/front/unpaid/index.spec.js index bfeb7df19..0f6460a03 100644 --- a/modules/client/front/unpaid/index.spec.js +++ b/modules/client/front/unpaid/index.spec.js @@ -14,7 +14,7 @@ describe('client unpaid', () => { describe('setDefaultDate()', () => { it(`should not set today date if has dated`, () => { const hasData = true; - const yesterday = new Date(); + const yesterday = Date.vnNew(); yesterday.setDate(yesterday.getDate() - 1); controller.clientUnpaid = { diff --git a/modules/entry/back/methods/entry/latestBuysFilter.js b/modules/entry/back/methods/entry/latestBuysFilter.js index b920f4b58..30d47a2a3 100644 --- a/modules/entry/back/methods/entry/latestBuysFilter.js +++ b/modules/entry/back/methods/entry/latestBuysFilter.js @@ -150,10 +150,10 @@ module.exports = Self => { const userConfig = await models.UserConfig.getUserConfig(ctx, myOptions); - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); stmt = new ParameterizedSQL(` - SELECT + SELECT i.image, i.id AS itemFk, i.size, @@ -209,7 +209,7 @@ module.exports = Self => { LEFT JOIN itemType t ON t.id = i.typeFk LEFT JOIN intrastat intr ON intr.id = i.intrastatFk LEFT JOIN origin ori ON ori.id = i.originFk - LEFT JOIN entry e ON e.id = b.entryFk AND e.created >= DATE_SUB(? ,INTERVAL 1 YEAR) + LEFT JOIN entry e ON e.id = b.entryFk AND e.created >= DATE_SUB(? ,INTERVAL 1 YEAR) LEFT JOIN supplier s ON s.id = e.supplierFk` , [userConfig.warehouseFk, date]); diff --git a/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js b/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js index 9b1e60532..0578fcdd4 100644 --- a/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js +++ b/modules/entry/back/methods/entry/specs/latestBuysFilter.spec.js @@ -332,10 +332,10 @@ describe('Entry latests buys filter()', () => { const options = {transaction: tx}; try { - const from = new Date(); + const from = Date.vnNew(); from.setHours(0, 0, 0, 0); - const to = new Date(); + const to = Date.vnNew(); to.setHours(23, 59, 59, 999); const ctx = { diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js index 401b8dab0..adab3cbeb 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js @@ -146,8 +146,8 @@ describe('InvoiceIn filter()', () => { const options = {transaction: tx}; try { - const from = new Date(); - const to = new Date(); + const from = Date.vnNew(); + const to = Date.vnNew(); from.setHours(0, 0, 0, 0); to.setHours(23, 59, 59, 999); to.setDate(to.getDate() + 1); diff --git a/modules/invoiceIn/front/basic-data/index.spec.js b/modules/invoiceIn/front/basic-data/index.spec.js index 09aa08293..98710ac35 100644 --- a/modules/invoiceIn/front/basic-data/index.spec.js +++ b/modules/invoiceIn/front/basic-data/index.spec.js @@ -78,7 +78,7 @@ describe('InvoiceIn', () => { description: 'This is a description', files: [{ lastModified: 1668673957761, - lastModifiedDate: new Date(), + lastModifiedDate: Date.vnNew(), name: 'file-example.png', size: 19653, type: 'image/png', diff --git a/modules/invoiceIn/front/descriptor/index.js b/modules/invoiceIn/front/descriptor/index.js index 4dc89a459..e005211a3 100644 --- a/modules/invoiceIn/front/descriptor/index.js +++ b/modules/invoiceIn/front/descriptor/index.js @@ -75,7 +75,7 @@ class Controller extends Descriptor { filter: { where: { invoiceInFk: id, - dueDated: {gte: new Date()} + dueDated: {gte: Date.vnNew()} } }}) .then(res => { diff --git a/modules/invoiceIn/front/dueDay/index.js b/modules/invoiceIn/front/dueDay/index.js index 3cc1c81e8..ee9b13e5c 100644 --- a/modules/invoiceIn/front/dueDay/index.js +++ b/modules/invoiceIn/front/dueDay/index.js @@ -4,7 +4,7 @@ import Section from 'salix/components/section'; class Controller extends Section { add() { this.$.model.insert({ - dueDated: new Date(), + dueDated: Date.vnNew(), bankFk: this.vnConfig.local.bankFk }); } diff --git a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js index d42184ae5..f3c7a5093 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js @@ -60,9 +60,9 @@ module.exports = Self => { try { query = ` SELECT MAX(issued) issued - FROM vn.invoiceOut io - JOIN vn.time t ON t.dated = io.issued - WHERE io.serial = 'A' + FROM vn.invoiceOut io + JOIN vn.time t ON t.dated = io.issued + WHERE io.serial = 'A' AND t.year = YEAR(?) AND io.companyFk = ?`; const [maxIssued] = await Self.rawSql(query, [ @@ -77,7 +77,7 @@ module.exports = Self => { if (args.invoiceDate < args.maxShipped) args.maxShipped = args.invoiceDate; - const minShipped = new Date(); + const minShipped = Date.vnNew(); minShipped.setFullYear(minShipped.getFullYear() - 1); minShipped.setMonth(1); minShipped.setDate(1); @@ -131,11 +131,11 @@ module.exports = Self => { const models = Self.app.models; const args = ctx.args; const query = `SELECT DISTINCT clientFk AS id - FROM ticket t + FROM ticket t JOIN ticketPackaging tp ON t.id = tp.ticketFk JOIN client c ON c.id = t.clientFk WHERE t.shipped BETWEEN '2017-11-21' AND ? - AND t.clientFk >= ? + AND t.clientFk >= ? AND (t.clientFk <= ? OR ? IS NULL) AND c.isActive`; return models.InvoiceOut.rawSql(query, [ @@ -149,16 +149,16 @@ module.exports = Self => { async function getInvoiceableClients(ctx, options) { const models = Self.app.models; const args = ctx.args; - const minShipped = new Date(); + const minShipped = Date.vnNew(); minShipped.setFullYear(minShipped.getFullYear() - 1); const query = `SELECT c.id, SUM(IFNULL ( - s.quantity * + s.quantity * s.price * (100-s.discount)/100, - 0) + 0) + IFNULL(ts.quantity * ts.price,0) ) AS sumAmount, c.hasToInvoiceByAddress, @@ -170,7 +170,7 @@ module.exports = Self => { LEFT JOIN ticketService ts ON ts.ticketFk = t.id JOIN address a ON a.id = t.addressFk JOIN client c ON c.id = t.clientFk - WHERE ISNULL(t.refFk) AND c.id >= ? + WHERE ISNULL(t.refFk) AND c.id >= ? AND (t.clientFk <= ? OR ? IS NULL) AND t.shipped BETWEEN ? AND util.dayEnd(?) AND t.companyFk = ? AND c.hasToInvoice diff --git a/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js index 297afa8e8..a458aa18e 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/createManualInvoice.js @@ -108,14 +108,14 @@ module.exports = Self => { throw new UserError(`This client is not invoiceable`); // Can't invoice tickets into future - const tomorrow = new Date(); + const tomorrow = Date.vnNew(); tomorrow.setDate(tomorrow.getDate() + 1); if (maxShipped >= tomorrow) throw new UserError(`Can't invoice to future`); const maxInvoiceDate = await getMaxIssued(args.serial, companyId, myOptions); - if (new Date() < maxInvoiceDate) + if (Date.vnNew() < maxInvoiceDate) throw new UserError(`Can't invoice to past`); if (ticketId) { @@ -155,7 +155,7 @@ module.exports = Self => { async function isInvoiceable(clientId, options) { const models = Self.app.models; const query = `SELECT (hasToInvoice AND isTaxDataChecked) AS invoiceable - FROM client + FROM client WHERE id = ?`; const [result] = await models.InvoiceOut.rawSql(query, [clientId], options); @@ -172,12 +172,12 @@ module.exports = Self => { async function getMaxIssued(serial, companyId, options) { const models = Self.app.models; - const query = `SELECT MAX(issued) AS issued - FROM invoiceOut + const query = `SELECT MAX(issued) AS issued + FROM invoiceOut WHERE serial = ? AND companyFk = ?`; const [maxIssued] = await models.InvoiceOut.rawSql(query, [serial, companyId], options); - const maxInvoiceDate = maxIssued && maxIssued.issued || new Date(); + const maxInvoiceDate = maxIssued && maxIssued.issued || Date.vnNew(); return maxInvoiceDate; } diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js index e5cf5fda0..d3d789393 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/filter.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('InvoiceOut filter()', () => { - let today = new Date(); + let today = Date.vnNew(); today.setHours(2, 0, 0, 0); it('should return the invoice out matching ref', async() => { diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js index 5f890de26..9a0574dba 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/invoiceClient.spec.js @@ -5,7 +5,7 @@ describe('InvoiceOut invoiceClient()', () => { const clientId = 1101; const addressId = 121; const companyFk = 442; - const minShipped = new Date(); + const minShipped = Date.vnNew(); minShipped.setFullYear(minShipped.getFullYear() - 1); minShipped.setMonth(1); minShipped.setDate(1); @@ -33,8 +33,8 @@ describe('InvoiceOut invoiceClient()', () => { ctx.args = { clientId: clientId, addressId: addressId, - invoiceDate: new Date(), - maxShipped: new Date(), + invoiceDate: Date.vnNew(), + maxShipped: Date.vnNew(), companyFk: companyFk, minShipped: minShipped }; diff --git a/modules/invoiceOut/front/index/global-invoicing/index.js b/modules/invoiceOut/front/index/global-invoicing/index.js index f772a4936..0c5773adc 100644 --- a/modules/invoiceOut/front/index/global-invoicing/index.js +++ b/modules/invoiceOut/front/index/global-invoicing/index.js @@ -6,7 +6,7 @@ class Controller extends Dialog { constructor($element, $, $transclude) { super($element, $, $transclude); this.invoice = { - maxShipped: new Date() + maxShipped: Date.vnNew() }; this.clientsNumber = 'allClients'; } diff --git a/modules/invoiceOut/front/index/global-invoicing/index.spec.js b/modules/invoiceOut/front/index/global-invoicing/index.spec.js index e88b0b1d4..aa9674b0e 100644 --- a/modules/invoiceOut/front/index/global-invoicing/index.spec.js +++ b/modules/invoiceOut/front/index/global-invoicing/index.spec.js @@ -76,8 +76,8 @@ describe('InvoiceOut', () => { jest.spyOn(controller.vnApp, 'showError'); controller.invoice = { - invoiceDate: new Date(), - maxShipped: new Date() + invoiceDate: Date.vnNew(), + maxShipped: Date.vnNew() }; controller.responseHandler('accept'); @@ -88,14 +88,14 @@ describe('InvoiceOut', () => { it('should make an http POST query and then call to the showSuccess() method', () => { jest.spyOn(controller.vnApp, 'showSuccess'); - const minShipped = new Date(); + const minShipped = Date.vnNew(); minShipped.setFullYear(minShipped.getFullYear() - 1); minShipped.setMonth(1); minShipped.setDate(1); minShipped.setHours(0, 0, 0, 0); controller.invoice = { - invoiceDate: new Date(), - maxShipped: new Date(), + invoiceDate: Date.vnNew(), + maxShipped: Date.vnNew(), fromClientId: 1101, toClientId: 1101, companyFk: 442, diff --git a/modules/invoiceOut/front/index/manual/index.js b/modules/invoiceOut/front/index/manual/index.js index ed50e37da..3abe4b825 100644 --- a/modules/invoiceOut/front/index/manual/index.js +++ b/modules/invoiceOut/front/index/manual/index.js @@ -8,7 +8,7 @@ class Controller extends Dialog { this.isInvoicing = false; this.invoice = { - maxShipped: new Date() + maxShipped: Date.vnNew() }; } diff --git a/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js b/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js index 68eacfbad..5c3fec7d6 100644 --- a/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js +++ b/modules/item/back/methods/fixed-price/specs/upsertFixedPrice.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('upsertFixedPrice()', () => { - const now = new Date(); + const now = Date.vnNew(); const fixedPriceId = 1; let originalFixedPrice; diff --git a/modules/item/back/methods/item-image-queue/downloadImages.js b/modules/item/back/methods/item-image-queue/downloadImages.js index 05b223598..0f57856c7 100644 --- a/modules/item/back/methods/item-image-queue/downloadImages.js +++ b/modules/item/back/methods/item-image-queue/downloadImages.js @@ -27,7 +27,7 @@ module.exports = Self => { }); for (let image of images) { - const currentStamp = new Date().getTime(); + const currentStamp = Date.vnNew().getTime(); const updatedStamp = image.updated.getTime(); const graceTime = Math.abs(currentStamp - updatedStamp); const maxTTL = 3600 * 48 * 1000; // 48 hours in ms; @@ -97,7 +97,7 @@ module.exports = Self => { await row.updateAttributes({ error: error, attempts: row.attempts + 1, - updated: new Date() + updated: Date.vnNew() }); } diff --git a/modules/item/back/methods/item/getVisibleAvailable.js b/modules/item/back/methods/item/getVisibleAvailable.js index b291ad9b4..612f64022 100644 --- a/modules/item/back/methods/item/getVisibleAvailable.js +++ b/modules/item/back/methods/item/getVisibleAvailable.js @@ -29,7 +29,7 @@ module.exports = Self => { } }); - Self.getVisibleAvailable = async(id, warehouseFk, dated = new Date(), options) => { + Self.getVisibleAvailable = async(id, warehouseFk, dated = Date.vnNew(), options) => { const myOptions = {}; if (typeof options == 'object') diff --git a/modules/item/back/methods/item/getWasteByItem.js b/modules/item/back/methods/item/getWasteByItem.js index b93d534da..56b90b04a 100644 --- a/modules/item/back/methods/item/getWasteByItem.js +++ b/modules/item/back/methods/item/getWasteByItem.js @@ -32,7 +32,7 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const wastes = await Self.rawSql(` SELECT *, 100 * dwindle / total AS percentage @@ -43,7 +43,7 @@ module.exports = Self => { sum(ws.saleTotal) AS total, sum(ws.saleWaste) AS dwindle FROM bs.waste ws - WHERE buyer = ? AND family = ? + WHERE buyer = ? AND family = ? AND year = YEAR(TIMESTAMPADD(WEEK,-1, ?)) AND week = WEEK(TIMESTAMPADD(WEEK,-1, ?), 1) GROUP BY buyer, itemFk diff --git a/modules/item/back/methods/item/getWasteByWorker.js b/modules/item/back/methods/item/getWasteByWorker.js index 4c3c64a91..8fa351eed 100644 --- a/modules/item/back/methods/item/getWasteByWorker.js +++ b/modules/item/back/methods/item/getWasteByWorker.js @@ -19,7 +19,7 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const wastes = await Self.rawSql(` SELECT *, 100 * dwindle / total AS percentage diff --git a/modules/item/back/methods/item/regularize.js b/modules/item/back/methods/item/regularize.js index 0878e3242..dfbcaa69f 100644 --- a/modules/item/back/methods/item/regularize.js +++ b/modules/item/back/methods/item/regularize.js @@ -94,8 +94,8 @@ module.exports = Self => { } async function createTicket(ctx, options) { - ctx.args.shipped = new Date(); - ctx.args.landed = new Date(); + ctx.args.shipped = Date.vnNew(); + ctx.args.landed = Date.vnNew(); ctx.args.companyId = null; ctx.args.agencyModeId = null; ctx.args.routeId = null; @@ -106,10 +106,10 @@ module.exports = Self => { } async function getTicketId(params, options) { - const minDate = new Date(); + const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); - const maxDate = new Date(); + const maxDate = Date.vnNew(); maxDate.setHours(23, 59, 59, 59); let ticket = await Self.app.models.Ticket.findOne({ diff --git a/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js b/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js index 8e4864ee8..13b2417d7 100644 --- a/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js +++ b/modules/item/back/methods/item/specs/getVisibleAvailable.spec.js @@ -8,7 +8,7 @@ describe('item getVisibleAvailable()', () => { try { const itemFk = 1; const warehouseFk = 1; - const dated = new Date(); + const dated = Date.vnNew(); const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options); @@ -29,7 +29,7 @@ describe('item getVisibleAvailable()', () => { try { const itemFk = 1; const warehouseFk = 1; - const dated = new Date(); + const dated = Date.vnNew(); dated.setDate(dated.getDate() - 1); const result = await models.Item.getVisibleAvailable(itemFk, warehouseFk, dated, options); diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js index 25e661aee..00488e534 100644 --- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js +++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js @@ -1,9 +1,9 @@ const {models} = require('vn-loopback/server/server'); describe('item lastEntriesFilter()', () => { it('should return one entry for the given item', async() => { - const minDate = new Date(); + const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); - const maxDate = new Date(); + const maxDate = Date.vnNew(); maxDate.setHours(23, 59, 59, 59); const tx = await models.Item.beginTransaction({}); @@ -23,11 +23,11 @@ describe('item lastEntriesFilter()', () => { }); it('should return five entries for the given item', async() => { - const minDate = new Date(); + const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); minDate.setMonth(minDate.getMonth() - 2, 1); - const maxDate = new Date(); + const maxDate = Date.vnNew(); maxDate.setHours(23, 59, 59, 59); const tx = await models.Item.beginTransaction({}); diff --git a/modules/item/front/descriptor/index.js b/modules/item/front/descriptor/index.js index 133b11b48..b88f24456 100644 --- a/modules/item/front/descriptor/index.js +++ b/modules/item/front/descriptor/index.js @@ -80,7 +80,7 @@ class Controller extends Descriptor { } onUploadResponse() { - const timestamp = new Date().getTime(); + const timestamp = Date.vnNew().getTime(); const src = this.$rootScope.imagePath('catalog', '200x200', this.item.id); const zoomSrc = this.$rootScope.imagePath('catalog', '1600x900', this.item.id); const newSrc = `${src}&t=${timestamp}`; diff --git a/modules/item/front/diary/index.js b/modules/item/front/diary/index.js index c997ea491..1e93f9f16 100644 --- a/modules/item/front/diary/index.js +++ b/modules/item/front/diary/index.js @@ -7,7 +7,7 @@ class Controller extends Section { super($element, $scope); this.$anchorScroll = $anchorScroll; this.$location = $location; - let today = new Date(); + let today = Date.vnNew(); today.setHours(0, 0, 0, 0); this.today = today.toJSON(); } diff --git a/modules/item/front/fixed-price/index.spec.js b/modules/item/front/fixed-price/index.spec.js index 94621e352..42dd898b3 100644 --- a/modules/item/front/fixed-price/index.spec.js +++ b/modules/item/front/fixed-price/index.spec.js @@ -24,7 +24,7 @@ describe('fixed price', () => { }); it('should perform an http request to update the price', () => { - const now = new Date(); + const now = Date.vnNew(); jest.spyOn(controller.vnApp, 'showSuccess'); $httpBackend.expectPATCH('FixedPrices/upsertFixedPrice').respond(); diff --git a/modules/item/front/last-entries/index.js b/modules/item/front/last-entries/index.js index 014761da9..0c6804838 100644 --- a/modules/item/front/last-entries/index.js +++ b/modules/item/front/last-entries/index.js @@ -5,11 +5,11 @@ class Controller extends Section { constructor($element, $) { super($element, $); - const from = new Date(); + const from = Date.vnNew(); from.setDate(from.getDate() - 75); from.setHours(0, 0, 0, 0); - const to = new Date(); + const to = Date.vnNew(); to.setDate(to.getDate() + 10); to.setHours(23, 59, 59, 59); diff --git a/modules/item/front/request-search-panel/index.spec.js b/modules/item/front/request-search-panel/index.spec.js index 2fb339209..56c76eabf 100644 --- a/modules/item/front/request-search-panel/index.spec.js +++ b/modules/item/front/request-search-panel/index.spec.js @@ -15,7 +15,7 @@ describe(' Component vnRequestSearchPanel', () => { it('should clear the scope days when setting the from property', () => { controller.filter.scopeDays = 1; - controller.from = new Date(); + controller.from = Date.vnNew(); expect(controller.filter.scopeDays).toBeNull(); expect(controller.from).toBeDefined(); @@ -26,7 +26,7 @@ describe(' Component vnRequestSearchPanel', () => { it('should clear the scope days when setting the to property', () => { controller.filter.scopeDays = 1; - controller.to = new Date(); + controller.to = Date.vnNew(); expect(controller.filter.scopeDays).toBeNull(); expect(controller.to).toBeDefined(); @@ -35,8 +35,8 @@ describe(' Component vnRequestSearchPanel', () => { describe('scopeDays() setter', () => { it('should clear the date range when setting the scopeDays property', () => { - controller.filter.from = new Date(); - controller.filter.to = new Date(); + controller.filter.from = Date.vnNew(); + controller.filter.to = Date.vnNew(); controller.scopeDays = 1; diff --git a/modules/item/front/request/index.js b/modules/item/front/request/index.js index 2fe08ada6..747cbeff2 100644 --- a/modules/item/front/request/index.js +++ b/modules/item/front/request/index.js @@ -7,10 +7,10 @@ export default class Controller extends Section { super($element, $); if (!this.$state.q) { - const today = new Date(); + const today = Date.vnNew(); today.setHours(0, 0, 0, 0); - const nextWeek = new Date(); + const nextWeek = Date.vnNew(); nextWeek.setHours(23, 59, 59, 59); nextWeek.setDate(nextWeek.getDate() + 7); @@ -27,7 +27,7 @@ export default class Controller extends Section { $params.scopeDays = 1; if (typeof $params.scopeDays === 'number') { - const from = new Date(); + const from = Date.vnNew(); from.setHours(0, 0, 0, 0); const to = new Date(from.getTime()); @@ -82,7 +82,7 @@ export default class Controller extends Section { } compareDate(date) { - let today = new Date(); + let today = Date.vnNew(); today.setHours(0, 0, 0, 0); let timeTicket = new Date(date); timeTicket.setHours(0, 0, 0, 0); diff --git a/modules/item/front/request/index.spec.js b/modules/item/front/request/index.spec.js index 0fc061023..aadeaddca 100644 --- a/modules/item/front/request/index.spec.js +++ b/modules/item/front/request/index.spec.js @@ -93,7 +93,7 @@ describe('Item', () => { }); it(`should return "warning" if date is today`, () => { - let date = new Date(); + let date = Date.vnNew(); let result = controller.compareDate(date); expect(result).toEqual('warning'); diff --git a/modules/mdb/back/methods/mdbApp/lock.js b/modules/mdb/back/methods/mdbApp/lock.js index 98e61fb53..a12a93814 100644 --- a/modules/mdb/back/methods/mdbApp/lock.js +++ b/modules/mdb/back/methods/mdbApp/lock.js @@ -51,7 +51,7 @@ module.exports = Self => { const updatedMdbApp = await mdbApp.updateAttributes({ userFk: userId, - locked: new Date() + locked: Date.vnNew() }, myOptions); if (tx) await tx.commit(); diff --git a/modules/monitor/back/methods/sales-monitor/clientsFilter.js b/modules/monitor/back/methods/sales-monitor/clientsFilter.js index 09ea24eb1..13e38f8e1 100644 --- a/modules/monitor/back/methods/sales-monitor/clientsFilter.js +++ b/modules/monitor/back/methods/sales-monitor/clientsFilter.js @@ -34,7 +34,7 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const stmt = new ParameterizedSQL(` SELECT @@ -51,7 +51,7 @@ module.exports = Self => { JOIN account.user u ON c.salesPersonFk = u.id LEFT JOIN sharingCart sc ON sc.workerFk = c.salesPersonFk AND ? BETWEEN sc.started AND sc.ended - LEFT JOIN workerTeamCollegues wtc + LEFT JOIN workerTeamCollegues wtc ON wtc.collegueFk = IFNULL(sc.workerSubstitute, c.salesPersonFk)`, [date]); diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 7be130dda..881fc637a 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -104,7 +104,7 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; const conn = Self.dataSource.connector; const models = Self.app.models; - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const args = ctx.args; const myOptions = {}; diff --git a/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js b/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js index bcb37830c..febfc5357 100644 --- a/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js +++ b/modules/monitor/back/methods/sales-monitor/specs/clientsFilter.spec.js @@ -8,8 +8,8 @@ describe('SalesMonitor clientsFilter()', () => { const options = {transaction: tx}; const ctx = {req: {accessToken: {userId: 18}}, args: {}}; - const from = new Date(); - const to = new Date(); + const from = Date.vnNew(); + const to = Date.vnNew(); from.setHours(0, 0, 0, 0); to.setHours(23, 59, 59, 59); @@ -35,9 +35,9 @@ describe('SalesMonitor clientsFilter()', () => { try { const options = {transaction: tx}; const ctx = {req: {accessToken: {userId: 18}}, args: {}}; - const yesterday = new Date(); + const yesterday = Date.vnNew(); yesterday.setDate(yesterday.getDate() - 1); - const today = new Date(); + const today = Date.vnNew(); yesterday.setHours(0, 0, 0, 0); today.setHours(23, 59, 59, 59); diff --git a/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js b/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js index d2e1a5bec..4e0fb85b7 100644 --- a/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js +++ b/modules/monitor/back/methods/sales-monitor/specs/salesFilter.spec.js @@ -26,9 +26,9 @@ describe('SalesMonitor salesFilter()', () => { try { const options = {transaction: tx}; - const yesterday = new Date(); + const yesterday = Date.vnNew(); yesterday.setHours(0, 0, 0, 0); - const today = new Date(); + const today = Date.vnNew(); today.setHours(23, 59, 59, 59); const ctx = {req: {accessToken: {userId: 9}}, args: { @@ -54,10 +54,10 @@ describe('SalesMonitor salesFilter()', () => { try { const options = {transaction: tx}; - const yesterday = new Date(); + const yesterday = Date.vnNew(); yesterday.setDate(yesterday.getDate() - 1); yesterday.setHours(0, 0, 0, 0); - const today = new Date(); + const today = Date.vnNew(); today.setHours(23, 59, 59, 59); const ctx = {req: {accessToken: {userId: 9}}, args: { @@ -205,10 +205,10 @@ describe('SalesMonitor salesFilter()', () => { try { const options = {transaction: tx}; - const yesterday = new Date(); + const yesterday = Date.vnNew(); yesterday.setDate(yesterday.getDate() - 1); yesterday.setHours(0, 0, 0, 0); - const today = new Date(); + const today = Date.vnNew(); today.setHours(23, 59, 59, 59); const ctx = {req: {accessToken: {userId: 18}}, args: {}}; @@ -234,10 +234,10 @@ describe('SalesMonitor salesFilter()', () => { try { const options = {transaction: tx}; - const yesterday = new Date(); + const yesterday = Date.vnNew(); yesterday.setDate(yesterday.getDate() - 1); yesterday.setHours(0, 0, 0, 0); - const today = new Date(); + const today = Date.vnNew(); today.setHours(23, 59, 59, 59); const ctx = {req: {accessToken: {userId: 18}}, args: {}}; diff --git a/modules/monitor/front/index/clients/index.js b/modules/monitor/front/index/clients/index.js index 58613f09d..ac3ce9140 100644 --- a/modules/monitor/front/index/clients/index.js +++ b/modules/monitor/front/index/clients/index.js @@ -5,7 +5,7 @@ export default class Controller extends Section { constructor($element, $) { super($element, $); - const date = new Date(); + const date = Date.vnNew(); this.dateFrom = date; this.dateTo = date; this.filter = { @@ -64,9 +64,9 @@ export default class Controller extends Section { let from = this.dateFrom; let to = this.dateTo; if (!from) - from = new Date(); + from = Date.vnNew(); if (!to) - to = new Date(); + to = Date.vnNew(); const minHour = new Date(from); minHour.setHours(0, 0, 0, 0); const maxHour = new Date(to); diff --git a/modules/monitor/front/index/orders/index.js b/modules/monitor/front/index/orders/index.js index e3a47f68b..40100b79f 100644 --- a/modules/monitor/front/index/orders/index.js +++ b/modules/monitor/front/index/orders/index.js @@ -26,7 +26,7 @@ export default class Controller extends Section { } chipColor(date) { - const today = new Date(); + const today = Date.vnNew(); today.setHours(0, 0, 0, 0); const orderLanded = new Date(date); diff --git a/modules/monitor/front/index/search-panel/index.spec.js b/modules/monitor/front/index/search-panel/index.spec.js index f862e8d77..18cf1abfc 100644 --- a/modules/monitor/front/index/search-panel/index.spec.js +++ b/modules/monitor/front/index/search-panel/index.spec.js @@ -38,7 +38,7 @@ describe('Monitor Component vnMonitorSalesSearchPanel', () => { it('should clear the scope days when setting the from property', () => { controller.filter.scopeDays = 1; - controller.from = new Date(); + controller.from = Date.vnNew(); expect(controller.filter.scopeDays).toBeNull(); expect(controller.from).toBeDefined(); @@ -49,7 +49,7 @@ describe('Monitor Component vnMonitorSalesSearchPanel', () => { it('should clear the scope days when setting the to property', () => { controller.filter.scopeDays = 1; - controller.to = new Date(); + controller.to = Date.vnNew(); expect(controller.filter.scopeDays).toBeNull(); expect(controller.to).toBeDefined(); @@ -58,8 +58,8 @@ describe('Monitor Component vnMonitorSalesSearchPanel', () => { describe('scopeDays() setter', () => { it('should clear the date range when setting the scopeDays property', () => { - controller.filter.from = new Date(); - controller.filter.to = new Date(); + controller.filter.from = Date.vnNew(); + controller.filter.to = Date.vnNew(); controller.scopeDays = 1; diff --git a/modules/monitor/front/index/tickets/index.js b/modules/monitor/front/index/tickets/index.js index 91d9079d8..2f2dead05 100644 --- a/modules/monitor/front/index/tickets/index.js +++ b/modules/monitor/front/index/tickets/index.js @@ -91,7 +91,7 @@ export default class Controller extends Section { $params.scopeDays = 1; if (typeof $params.scopeDays === 'number') { - const from = new Date(); + const from = Date.vnNew(); from.setHours(0, 0, 0, 0); const to = new Date(from.getTime()); @@ -105,7 +105,7 @@ export default class Controller extends Section { } compareDate(date) { - let today = new Date(); + let today = Date.vnNew(); today.setHours(0, 0, 0, 0); let timeTicket = new Date(date); timeTicket.setHours(0, 0, 0, 0); diff --git a/modules/monitor/front/index/tickets/index.spec.js b/modules/monitor/front/index/tickets/index.spec.js index 5d42743c1..c12ea6844 100644 --- a/modules/monitor/front/index/tickets/index.spec.js +++ b/modules/monitor/front/index/tickets/index.spec.js @@ -32,7 +32,7 @@ describe('Component vnMonitorSalesTickets', () => { let params = controller.fetchParams({ scopeDays: 2 }); - const from = new Date(); + const from = Date.vnNew(); from.setHours(0, 0, 0, 0); const to = new Date(from.getTime()); to.setDate(to.getDate() + params.scopeDays); @@ -66,14 +66,14 @@ describe('Component vnMonitorSalesTickets', () => { describe('compareDate()', () => { it('should return warning when the date is the present', () => { - let today = new Date(); + let today = Date.vnNew(); let result = controller.compareDate(today); expect(result).toEqual('warning'); }); it('should return sucess when the date is in the future', () => { - let futureDate = new Date(); + let futureDate = Date.vnNew(); futureDate = futureDate.setDate(futureDate.getDate() + 10); let result = controller.compareDate(futureDate); @@ -81,7 +81,7 @@ describe('Component vnMonitorSalesTickets', () => { }); it('should return undefined when the date is in the past', () => { - let pastDate = new Date(); + let pastDate = Date.vnNew(); pastDate = pastDate.setDate(pastDate.getDate() - 10); let result = controller.compareDate(pastDate); @@ -99,7 +99,7 @@ describe('Component vnMonitorSalesTickets', () => { describe('dateRange()', () => { it('should return two dates with the hours at the start and end of the given date', () => { - const now = new Date(); + const now = Date.vnNew(); const today = now.getDate(); diff --git a/modules/order/back/methods/order/specs/new.spec.js b/modules/order/back/methods/order/specs/new.spec.js index 5873189f8..f11367579 100644 --- a/modules/order/back/methods/order/specs/new.spec.js +++ b/modules/order/back/methods/order/specs/new.spec.js @@ -9,7 +9,7 @@ describe('order new()', () => { try { const options = {transaction: tx}; - const landed = new Date(); + const landed = Date.vnNew(); const addressFk = 6; const agencyModeFk = 1; @@ -30,7 +30,7 @@ describe('order new()', () => { try { const options = {transaction: tx}; - const landed = new Date(); + const landed = Date.vnNew(); const addressFk = 121; const agencyModeFk = 1; diff --git a/modules/order/front/basic-data/index.spec.js b/modules/order/front/basic-data/index.spec.js index 01009d085..21dee0765 100644 --- a/modules/order/front/basic-data/index.spec.js +++ b/modules/order/front/basic-data/index.spec.js @@ -46,7 +46,7 @@ describe('Order', () => { it('should set agencyModeFk to null and get the available agencies if the order has landed and client', async() => { controller.order.agencyModeFk = 999; controller.order.addressFk = 999; - controller.order.landed = new Date(); + controller.order.landed = Date.vnNew(); const expectedAgencies = [{id: 1}, {id: 2}]; diff --git a/modules/order/front/index/index.js b/modules/order/front/index/index.js index a8e6e977e..750f2e226 100644 --- a/modules/order/front/index/index.js +++ b/modules/order/front/index/index.js @@ -8,7 +8,7 @@ export default class Controller extends Section { } compareDate(date) { - let today = new Date(); + let today = Date.vnNew(); today.setHours(0, 0, 0, 0); date = new Date(date); diff --git a/modules/order/front/index/index.spec.js b/modules/order/front/index/index.spec.js index 5b85b3333..abe336478 100644 --- a/modules/order/front/index/index.spec.js +++ b/modules/order/front/index/index.spec.js @@ -26,14 +26,14 @@ describe('Component vnOrderIndex', () => { describe('compareDate()', () => { it('should return warning when the date is the present', () => { - let curDate = new Date(); + let curDate = Date.vnNew(); let result = controller.compareDate(curDate); expect(result).toEqual('warning'); }); it('should return sucess when the date is in the future', () => { - let futureDate = new Date(); + let futureDate = Date.vnNew(); futureDate = futureDate.setDate(futureDate.getDate() + 10); let result = controller.compareDate(futureDate); @@ -41,7 +41,7 @@ describe('Component vnOrderIndex', () => { }); it('should return undefined when the date is in the past', () => { - let pastDate = new Date(); + let pastDate = Date.vnNew(); pastDate = pastDate.setDate(pastDate.getDate() - 10); let result = controller.compareDate(pastDate); diff --git a/modules/route/back/methods/agency-term/filter.js b/modules/route/back/methods/agency-term/filter.js index 0ecec7e88..9d1268958 100644 --- a/modules/route/back/methods/agency-term/filter.js +++ b/modules/route/back/methods/agency-term/filter.js @@ -74,35 +74,35 @@ module.exports = Self => { filter = mergeFilters(filter, {where}); - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const stmts = []; const stmt = new ParameterizedSQL( `SELECT * FROM ( - SELECT r.id routeFk, - r.created, - r.agencyModeFk, + SELECT r.id routeFk, + r.created, + r.agencyModeFk, am.name agencyModeName, - am.agencyFk, + am.agencyFk, a.name agencyAgreement, SUM(t.packages) packages, r.m3, - r.kmEnd - r.kmStart kmTotal, - CAST(IFNULL(sat.routePrice, - (sat.kmPrice * (GREATEST(r.kmEnd - r.kmStart , sat.minimumKm)) - + GREATEST(r.m3 , sat.minimumM3) * sat.m3Price) - + sat.packagePrice * SUM(t.packages) ) + r.kmEnd - r.kmStart kmTotal, + CAST(IFNULL(sat.routePrice, + (sat.kmPrice * (GREATEST(r.kmEnd - r.kmStart , sat.minimumKm)) + + GREATEST(r.m3 , sat.minimumM3) * sat.m3Price) + + sat.packagePrice * SUM(t.packages) ) AS DECIMAL(10,2)) price, r.invoiceInFk, sat.supplierFk, s.name supplierName FROM vn.route r - LEFT JOIN vn.agencyMode am ON r.agencyModeFk = am.id + LEFT JOIN vn.agencyMode am ON r.agencyModeFk = am.id LEFT JOIN vn.agency a ON am.agencyFk = a.id LEFT JOIN vn.ticket t ON t.routeFk = r.id LEFT JOIN vn.supplierAgencyTerm sat ON sat.agencyFk = a.id - LEFT JOIN vn.supplier s ON s.id = sat.supplierFk + LEFT JOIN vn.supplier s ON s.id = sat.supplierFk WHERE r.created > DATE_ADD(?, INTERVAL -2 MONTH) AND sat.supplierFk IS NOT NULL GROUP BY r.id ) a` diff --git a/modules/route/back/methods/agency-term/specs/filter.spec.js b/modules/route/back/methods/agency-term/specs/filter.spec.js index d6c00e585..41e696157 100644 --- a/modules/route/back/methods/agency-term/specs/filter.spec.js +++ b/modules/route/back/methods/agency-term/specs/filter.spec.js @@ -3,7 +3,7 @@ const models = require('vn-loopback/server/server').models; describe('AgencyTerm filter()', () => { const authUserId = 9; - const today = new Date(); + const today = Date.vnNew(); today.setHours(2, 0, 0, 0); it('should return all results matching the filter', async() => { @@ -57,10 +57,10 @@ describe('AgencyTerm filter()', () => { const options = {transaction: tx}; try { - const from = new Date(); + const from = Date.vnNew(); from.setHours(0, 0, 0, 0); - const to = new Date(); + const to = Date.vnNew(); to.setHours(23, 59, 59, 999); const ctx = { diff --git a/modules/route/back/methods/route/specs/clone.spec.js b/modules/route/back/methods/route/specs/clone.spec.js index d1fc6b297..9192854f8 100644 --- a/modules/route/back/methods/route/specs/clone.spec.js +++ b/modules/route/back/methods/route/specs/clone.spec.js @@ -1,7 +1,7 @@ const app = require('vn-loopback/server/server'); describe('route clone()', () => { - const createdDate = new Date(); + const createdDate = Date.vnNew(); it('should throw an error if the amount of ids pased to the clone function do no match the database', async() => { const ids = [996, 997, 998, 999]; diff --git a/modules/route/back/methods/route/specs/filter.spec.js b/modules/route/back/methods/route/specs/filter.spec.js index 9d481f21e..18c0ca04f 100644 --- a/modules/route/back/methods/route/specs/filter.spec.js +++ b/modules/route/back/methods/route/specs/filter.spec.js @@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server'); const models = require('vn-loopback/server/server').models; describe('Route filter()', () => { - const today = new Date(); + const today = Date.vnNew(); today.setHours(2, 0, 0, 0); it('should return the routes matching "search"', async() => { @@ -23,10 +23,10 @@ describe('Route filter()', () => { const options = {transaction: tx}; try { - const from = new Date(); + const from = Date.vnNew(); from.setHours(0, 0, 0, 0); - const to = new Date(); + const to = Date.vnNew(); to.setHours(23, 59, 59, 999); const ctx = { args: { diff --git a/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js b/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js index bb38cb50e..0acc6c1a7 100644 --- a/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js +++ b/modules/route/back/methods/route/specs/getSuggestedTickets.spec.js @@ -23,7 +23,7 @@ describe('route getSuggestedTickets()', () => { await ticketInRoute.updateAttributes({ routeFk: null, - landed: new Date() + landed: Date.vnNew() }, options); const result = await models.Route.getSuggestedTickets(routeID, options); diff --git a/modules/route/back/methods/route/specs/insertTicket.spec.js b/modules/route/back/methods/route/specs/insertTicket.spec.js index 7c60e755f..19d02e1ef 100644 --- a/modules/route/back/methods/route/specs/insertTicket.spec.js +++ b/modules/route/back/methods/route/specs/insertTicket.spec.js @@ -23,7 +23,7 @@ describe('route insertTicket()', () => { const ticketInRoute = await app.models.Ticket.findById(ticketId, null, options); await ticketInRoute.updateAttributes({ routeFk: null, - landed: new Date() + landed: Date.vnNew() }, options); const result = await app.models.Route.insertTicket(routeId, ticketId, options); diff --git a/modules/route/front/index/index.js b/modules/route/front/index/index.js index 9258c8fac..d1595e35d 100644 --- a/modules/route/front/index/index.js +++ b/modules/route/front/index/index.js @@ -44,7 +44,7 @@ export default class Controller extends Section { openClonationDialog() { this.$.clonationDialog.show(); - this.createdDate = new Date(); + this.createdDate = Date.vnNew(); } cloneSelectedRoutes() { diff --git a/modules/route/front/index/index.spec.js b/modules/route/front/index/index.spec.js index 05dd56433..00ceac6a0 100644 --- a/modules/route/front/index/index.spec.js +++ b/modules/route/front/index/index.spec.js @@ -60,7 +60,7 @@ describe('Component vnRouteIndex', () => { describe('cloneSelectedRoutes()', () => { it('should perform an http request to Routes/clone', () => { - controller.createdDate = new Date(); + controller.createdDate = Date.vnNew(); $httpBackend.expect('POST', 'Routes/clone').respond(); controller.cloneSelectedRoutes(); diff --git a/modules/route/front/main/index.js b/modules/route/front/main/index.js index 938f81bcc..8c57bbad6 100644 --- a/modules/route/front/main/index.js +++ b/modules/route/front/main/index.js @@ -3,11 +3,11 @@ import ModuleMain from 'salix/components/module-main'; export default class Route extends ModuleMain { $postLink() { - const to = new Date(); + const to = Date.vnNew(); to.setDate(to.getDate() + 1); to.setHours(0, 0, 0, 0); - const from = new Date(); + const from = Date.vnNew(); from.setDate(from.getDate()); from.setHours(0, 0, 0, 0); @@ -21,7 +21,7 @@ export default class Route extends ModuleMain { $params.scopeDays = 1; if (typeof $params.scopeDays === 'number') { - const from = new Date(); + const from = Date.vnNew(); from.setHours(0, 0, 0, 0); const to = new Date(from.getTime()); diff --git a/modules/route/front/main/index.spec.js b/modules/route/front/main/index.spec.js index e5724b493..0c16a7b1f 100644 --- a/modules/route/front/main/index.spec.js +++ b/modules/route/front/main/index.spec.js @@ -15,7 +15,7 @@ describe('Route Component vnRoute', () => { let params = controller.fetchParams({ scopeDays: 2 }); - const from = new Date(); + const from = Date.vnNew(); from.setHours(0, 0, 0, 0); const to = new Date(from.getTime()); to.setDate(to.getDate() + params.scopeDays); diff --git a/modules/route/front/search-panel/index.spec.js b/modules/route/front/search-panel/index.spec.js index 16e1a5cfc..ae15e16e4 100644 --- a/modules/route/front/search-panel/index.spec.js +++ b/modules/route/front/search-panel/index.spec.js @@ -15,7 +15,7 @@ describe('Route Component vnRouteSearchPanel', () => { it('should clear the scope days when setting the from property', () => { controller.filter.scopeDays = 1; - controller.from = new Date(); + controller.from = Date.vnNew(); expect(controller.filter.scopeDays).toBeNull(); expect(controller.from).toBeDefined(); @@ -26,7 +26,7 @@ describe('Route Component vnRouteSearchPanel', () => { it('should clear the scope days when setting the to property', () => { controller.filter.scopeDays = 1; - controller.to = new Date(); + controller.to = Date.vnNew(); expect(controller.filter.scopeDays).toBeNull(); expect(controller.to).toBeDefined(); @@ -35,8 +35,8 @@ describe('Route Component vnRouteSearchPanel', () => { describe('scopeDays() setter', () => { it('should clear the date range when setting the scopeDays property', () => { - controller.filter.from = new Date(); - controller.filter.to = new Date(); + controller.filter.from = Date.vnNew(); + controller.filter.to = Date.vnNew(); controller.scopeDays = 1; diff --git a/modules/supplier/front/consumption/index.js b/modules/supplier/front/consumption/index.js index 8de6a1e71..9af0d1747 100644 --- a/modules/supplier/front/consumption/index.js +++ b/modules/supplier/front/consumption/index.js @@ -11,11 +11,11 @@ class Controller extends Section { } setDefaultFilter() { - const minDate = new Date(); + const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); minDate.setMonth(minDate.getMonth() - 2); - const maxDate = new Date(); + const maxDate = Date.vnNew(); maxDate.setHours(23, 59, 59, 59); this.filterParams = { diff --git a/modules/supplier/front/consumption/index.spec.js b/modules/supplier/front/consumption/index.spec.js index ebf19ccec..0ac531a68 100644 --- a/modules/supplier/front/consumption/index.spec.js +++ b/modules/supplier/front/consumption/index.spec.js @@ -28,7 +28,7 @@ describe('Supplier', () => { it('should call the window.open function', () => { jest.spyOn(window, 'open').mockReturnThis(); - const now = new Date(); + const now = Date.vnNew(); controller.$.model.userParams = { from: now, to: now @@ -86,7 +86,7 @@ describe('Supplier', () => { {id: 1, email: 'batman@gothamcity.com'} ]); - const now = new Date(); + const now = Date.vnNew(); controller.$.model.userParams = { from: now, to: now diff --git a/modules/supplier/front/descriptor/index.js b/modules/supplier/front/descriptor/index.js index a26d9c510..9f23ce68c 100644 --- a/modules/supplier/front/descriptor/index.js +++ b/modules/supplier/front/descriptor/index.js @@ -13,7 +13,7 @@ class Controller extends Descriptor { get entryFilter() { if (!this.supplier) return null; - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const from = new Date(date.getTime()); diff --git a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js index 67919e76c..ac397d38e 100644 --- a/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js +++ b/modules/ticket/back/methods/expedition/specs/moveExpeditions.spec.js @@ -14,7 +14,7 @@ describe('ticket moveExpeditions()', () => { const options = {transaction: tx}; myCtx.args = { clientId: 1101, - landed: new Date(), + landed: Date.vnNew(), warehouseId: 1, addressId: 121, agencyModeId: 1, diff --git a/modules/ticket/back/methods/sale/getClaimableFromTicket.js b/modules/ticket/back/methods/sale/getClaimableFromTicket.js index ecbc52b94..c51781f59 100644 --- a/modules/ticket/back/methods/sale/getClaimableFromTicket.js +++ b/modules/ticket/back/methods/sale/getClaimableFromTicket.js @@ -24,24 +24,24 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const query = ` - SELECT - s.id AS saleFk, - t.id AS ticketFk, + SELECT + s.id AS saleFk, + t.id AS ticketFk, t.landed, - s.concept, - s.itemFk, - s.quantity, - s.price, - s.discount, + s.concept, + s.itemFk, + s.quantity, + s.price, + s.discount, t.nickname - FROM vn.ticket t + FROM vn.ticket t INNER JOIN vn.sale s ON s.ticketFk = t.id LEFT JOIN vn.claimBeginning cb ON cb.saleFk = s.id - WHERE (t.landed) >= TIMESTAMPADD(DAY, -7, ?) + WHERE (t.landed) >= TIMESTAMPADD(DAY, -7, ?) AND t.id = ? AND cb.id IS NULL ORDER BY t.landed DESC, t.id DESC`; diff --git a/modules/ticket/back/methods/sale/refund.js b/modules/ticket/back/methods/sale/refund.js index c0c431636..febef9730 100644 --- a/modules/ticket/back/methods/sale/refund.js +++ b/modules/ticket/back/methods/sale/refund.js @@ -64,7 +64,7 @@ module.exports = Self => { const refundTickets = []; - const now = new Date(); + const now = Date.vnNew(); const mappedTickets = new Map(); for (let ticketId of ticketsIds) { diff --git a/modules/ticket/back/methods/ticket-tracking/specs/changeState.spec.js b/modules/ticket/back/methods/ticket-tracking/specs/changeState.spec.js index 746e1b7fc..175bc4e4b 100644 --- a/modules/ticket/back/methods/ticket-tracking/specs/changeState.spec.js +++ b/modules/ticket/back/methods/ticket-tracking/specs/changeState.spec.js @@ -9,7 +9,7 @@ describe('ticket changeState()', () => { accessToken: {userId: 9}, }; const ctx = {req: activeCtx}; - const now = new Date(); + const now = Date.vnNew(); const sampleTicket = { shipped: now, landed: now, diff --git a/modules/ticket/back/methods/ticket/canBeInvoiced.js b/modules/ticket/back/methods/ticket/canBeInvoiced.js index a009d63cf..6b8f9e71a 100644 --- a/modules/ticket/back/methods/ticket/canBeInvoiced.js +++ b/modules/ticket/back/methods/ticket/canBeInvoiced.js @@ -43,7 +43,7 @@ module.exports = function(Self) { ticketBases => ticketBases.hasSomeNegativeBase ); - const today = new Date(); + const today = Date.vnNew(); const invalidTickets = tickets.some(ticket => { const shipped = new Date(ticket.shipped); diff --git a/modules/ticket/back/methods/ticket/closeAll.js b/modules/ticket/back/methods/ticket/closeAll.js index 327278c2b..3726d85b7 100644 --- a/modules/ticket/back/methods/ticket/closeAll.js +++ b/modules/ticket/back/methods/ticket/closeAll.js @@ -17,14 +17,14 @@ module.exports = Self => { }); Self.closeAll = async() => { - const toDate = new Date(); + const toDate = Date.vnNew(); toDate.setHours(0, 0, 0, 0); toDate.setDate(toDate.getDate() - 1); - const todayMinDate = new Date(); + const todayMinDate = Date.vnNew(); todayMinDate.setHours(0, 0, 0, 0); - const todayMaxDate = new Date(); + const todayMaxDate = Date.vnNew(); todayMaxDate.setHours(23, 59, 59, 59); // Prevent closure for current day @@ -32,7 +32,7 @@ module.exports = Self => { throw new UserError('You cannot close tickets for today'); const tickets = await Self.rawSql(` - SELECT + SELECT t.id, t.clientFk, t.companyFk, @@ -53,7 +53,7 @@ module.exports = Self => { JOIN country co ON co.id = p.countryFk LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk WHERE al.code = 'PACKED' OR (am.code = 'refund' AND al.code != 'delivered') - AND DATE(t.shipped) BETWEEN DATE_ADD(?, INTERVAL -2 DAY) + AND DATE(t.shipped) BETWEEN DATE_ADD(?, INTERVAL -2 DAY) AND util.dayEnd(?) AND t.refFk IS NULL GROUP BY t.id diff --git a/modules/ticket/back/methods/ticket/filter.js b/modules/ticket/back/methods/ticket/filter.js index a2add2e82..262b3fd74 100644 --- a/modules/ticket/back/methods/ticket/filter.js +++ b/modules/ticket/back/methods/ticket/filter.js @@ -137,7 +137,7 @@ module.exports = Self => { Self.filter = async(ctx, filter, options) => { const userId = ctx.req.accessToken.userId; const conn = Self.dataSource.connector; - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const models = Self.app.models; const args = ctx.args; @@ -295,10 +295,10 @@ module.exports = Self => { stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.sale_getProblems'); stmt = new ParameterizedSQL(` - CREATE TEMPORARY TABLE tmp.sale_getProblems + CREATE TEMPORARY TABLE tmp.sale_getProblems (INDEX (ticketFk)) ENGINE = MEMORY - SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped + SELECT f.id ticketFk, f.clientFk, f.warehouseFk, f.shipped FROM tmp.filter f LEFT JOIN alertLevel al ON al.id = f.alertLevel WHERE (al.code = 'FREE' OR f.alertLevel IS NULL) @@ -350,7 +350,7 @@ module.exports = Self => { const ticketsIndex = stmts.push(stmt) - 1; stmts.push( - `DROP TEMPORARY TABLE + `DROP TEMPORARY TABLE tmp.filter, tmp.ticket_problems`); diff --git a/modules/ticket/back/methods/ticket/makeInvoice.js b/modules/ticket/back/methods/ticket/makeInvoice.js index 4e9c22a24..9739f5985 100644 --- a/modules/ticket/back/methods/ticket/makeInvoice.js +++ b/modules/ticket/back/methods/ticket/makeInvoice.js @@ -26,7 +26,7 @@ module.exports = function(Self) { Self.makeInvoice = async(ctx, ticketsIds, options) => { const userId = ctx.req.accessToken.userId; const models = Self.app.models; - const date = new Date(); + const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const myOptions = {}; diff --git a/modules/ticket/back/methods/ticket/restore.js b/modules/ticket/back/methods/ticket/restore.js index c9bb126fd..722c3294e 100644 --- a/modules/ticket/back/methods/ticket/restore.js +++ b/modules/ticket/back/methods/ticket/restore.js @@ -38,7 +38,7 @@ module.exports = Self => { }] }, myOptions); - const now = new Date(); + const now = Date.vnNew(); const maxDate = new Date(ticket.updated); maxDate.setHours(maxDate.getHours() + 1); @@ -56,7 +56,7 @@ module.exports = Self => { await models.Chat.sendCheckingPresence(ctx, salesPersonId, message); } - const fullYear = new Date().getFullYear(); + const fullYear = Date.vnNew().getFullYear(); const newShipped = ticket.shipped; const newLanded = ticket.landed; newShipped.setFullYear(fullYear); diff --git a/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js b/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js index 8b7e1685d..806f80227 100644 --- a/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js +++ b/modules/ticket/back/methods/ticket/specs/canBeInvoiced.spec.js @@ -61,7 +61,7 @@ describe('ticket canBeInvoiced()', () => { const ticket = await models.Ticket.findById(ticketId, null, options); - const shipped = new Date(); + const shipped = Date.vnNew(); shipped.setDate(shipped.getDate() + 1); await ticket.updateAttribute('shipped', shipped, options); diff --git a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js index 3a9c2db50..d65c87654 100644 --- a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js +++ b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js @@ -4,8 +4,8 @@ const LoopBackContext = require('loopback-context'); describe('ticket componentUpdate()', () => { const userID = 1101; const ticketID = 11; - const today = new Date(); - const tomorrow = new Date(); + const today = Date.vnNew(); + const tomorrow = Date.vnNew(); tomorrow.setDate(tomorrow.getDate() + 1); @@ -19,11 +19,11 @@ describe('ticket componentUpdate()', () => { beforeAll(async() => { const deliveryComponenet = await models.Component.findOne({where: {code: 'delivery'}}); deliveryComponentId = deliveryComponenet.id; - componentOfSaleSeven = `SELECT value - FROM vn.saleComponent + componentOfSaleSeven = `SELECT value + FROM vn.saleComponent WHERE saleFk = 7 AND componentFk = ${deliveryComponentId}`; - componentOfSaleEight = `SELECT value - FROM vn.saleComponent + componentOfSaleEight = `SELECT value + FROM vn.saleComponent WHERE saleFk = 8 AND componentFk = ${deliveryComponentId}`; [componentValue] = await models.SaleComponent.rawSql(componentOfSaleSeven); firstvalueBeforeChange = componentValue.value; diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index 688b0de61..6cc1a3ad2 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -26,9 +26,9 @@ describe('ticket filter()', () => { try { const options = {transaction: tx}; - const yesterday = new Date(); + const yesterday = Date.vnNew(); yesterday.setHours(0, 0, 0, 0); - const today = new Date(); + const today = Date.vnNew(); today.setHours(23, 59, 59, 59); const ctx = {req: {accessToken: {userId: 9}}, args: { @@ -54,10 +54,10 @@ describe('ticket filter()', () => { try { const options = {transaction: tx}; - const yesterday = new Date(); + const yesterday = Date.vnNew(); yesterday.setDate(yesterday.getDate() - 1); yesterday.setHours(0, 0, 0, 0); - const today = new Date(); + const today = Date.vnNew(); today.setHours(23, 59, 59, 59); const ctx = {req: {accessToken: {userId: 9}}, args: { diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js index aab053127..46315d1ac 100644 --- a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js @@ -1,9 +1,9 @@ const models = require('vn-loopback/server/server').models; describe('TicketFuture getTicketsAdvance()', () => { - const today = new Date(); + const today = Date.vnNew(); today.setHours(0, 0, 0, 0); - let tomorrow = new Date(); + let tomorrow = Date.vnNew(); tomorrow.setDate(today.getDate() + 1); it('should return the tickets passing the required data', async() => { diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js index c05ba764d..ac6155337 100644 --- a/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTicketsFuture.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('ticket getTicketsFuture()', () => { - const today = new Date(); + const today = Date.vnNew(); today.setHours(0, 0, 0, 0); it('should return the tickets passing the required data', async() => { diff --git a/modules/ticket/back/methods/ticket/specs/merge.spec.js b/modules/ticket/back/methods/ticket/specs/merge.spec.js index 275484f67..6b533e47c 100644 --- a/modules/ticket/back/methods/ticket/specs/merge.spec.js +++ b/modules/ticket/back/methods/ticket/specs/merge.spec.js @@ -5,8 +5,8 @@ describe('ticket merge()', () => { const tickets = [{ originId: 13, destinationId: 12, - originShipped: new Date(), - destinationShipped: new Date(), + originShipped: Date.vnNew(), + destinationShipped: Date.vnNew(), workerFk: 1 }]; diff --git a/modules/ticket/back/methods/ticket/specs/new.spec.js b/modules/ticket/back/methods/ticket/specs/new.spec.js index fce7cdceb..0a2f93bc4 100644 --- a/modules/ticket/back/methods/ticket/specs/new.spec.js +++ b/modules/ticket/back/methods/ticket/specs/new.spec.js @@ -2,7 +2,7 @@ const models = require('vn-loopback/server/server').models; let UserError = require('vn-loopback/util/user-error'); describe('ticket new()', () => { - const today = new Date(); + const today = Date.vnNew(); const ctx = {req: {accessToken: {userId: 1}}}; it('should throw an error if the client isnt frozen and isnt active', async() => { diff --git a/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js b/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js index 5470382f9..1db1b6eaa 100644 --- a/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js +++ b/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js @@ -8,7 +8,7 @@ describe('sale priceDifference()', () => { try { const options = {transaction: tx}; - const tomorrow = new Date(); + const tomorrow = Date.vnNew(); tomorrow.setDate(tomorrow.getDate() + 1); const ctx = {req: {accessToken: {userId: 1106}}}; @@ -45,8 +45,8 @@ describe('sale priceDifference()', () => { const ctx = {req: {accessToken: {userId: 1106}}}; ctx.args = { id: 1, - landed: new Date(), - shipped: new Date(), + landed: Date.vnNew(), + shipped: Date.vnNew(), addressId: 121, zoneId: 3, warehouseId: 1 @@ -68,7 +68,7 @@ describe('sale priceDifference()', () => { try { const options = {transaction: tx}; - const tomorrow = new Date(); + const tomorrow = Date.vnNew(); tomorrow.setDate(tomorrow.getDate() + 1); const ctx = {req: {accessToken: {userId: 1106}}}; diff --git a/modules/ticket/back/methods/ticket/specs/restore.spec.js b/modules/ticket/back/methods/ticket/specs/restore.spec.js index bd976d124..3b35ae2b4 100644 --- a/modules/ticket/back/methods/ticket/specs/restore.spec.js +++ b/modules/ticket/back/methods/ticket/specs/restore.spec.js @@ -24,8 +24,8 @@ describe('ticket restore()', () => { let error; const tx = await app.models.Ticket.beginTransaction({}); - const now = new Date(); - now.setHours(now.getHours() - 1); + const now = Date.vnNew(); + now.setHours(now.getHours() - 1.1); try { const options = {transaction: tx}; @@ -46,7 +46,7 @@ describe('ticket restore()', () => { it('should restore the ticket making its state no longer deleted', async() => { const tx = await app.models.Ticket.beginTransaction({}); - const now = new Date(); + const now = Date.vnNew(); try { const options = {transaction: tx}; diff --git a/modules/ticket/front/advance/index.js b/modules/ticket/front/advance/index.js index 1404f9472..ba8b29259 100644 --- a/modules/ticket/front/advance/index.js +++ b/modules/ticket/front/advance/index.js @@ -60,7 +60,7 @@ export default class Controller extends Section { } setDefaultFilter() { - let today = new Date(); + let today = Date.vnNew(); const tomorrow = new Date(today); tomorrow.setDate(tomorrow.getDate() + 1); this.filterParams = { @@ -72,7 +72,7 @@ export default class Controller extends Section { } compareDate(date) { - let today = new Date(); + let today = Date.vnNew(); today.setHours(0, 0, 0, 0); let timeTicket = new Date(date); timeTicket.setHours(0, 0, 0, 0); diff --git a/modules/ticket/front/advance/index.spec.js b/modules/ticket/front/advance/index.spec.js index c5a04daee..6874f914b 100644 --- a/modules/ticket/front/advance/index.spec.js +++ b/modules/ticket/front/advance/index.spec.js @@ -26,14 +26,14 @@ describe('Component vnTicketAdvance', () => { describe('compareDate()', () => { it('should return warning when the date is the present', () => { - let today = new Date(); + let today = Date.vnNew(); let result = controller.compareDate(today); expect(result).toEqual('warning'); }); it('should return sucess when the date is in the future', () => { - let futureDate = new Date(); + let futureDate = Date.vnNew(); futureDate = futureDate.setDate(futureDate.getDate() + 10); let result = controller.compareDate(futureDate); @@ -41,7 +41,7 @@ describe('Component vnTicketAdvance', () => { }); it('should return undefined when the date is in the past', () => { - let pastDate = new Date(); + let pastDate = Date.vnNew(); pastDate = pastDate.setDate(pastDate.getDate() - 10); let result = controller.compareDate(pastDate); @@ -81,7 +81,7 @@ describe('Component vnTicketAdvance', () => { describe('dateRange()', () => { it('should return two dates with the hours at the start and end of the given date', () => { - const now = new Date(); + const now = Date.vnNew(); const today = now.getDate(); diff --git a/modules/ticket/front/basic-data/step-one/index.spec.js b/modules/ticket/front/basic-data/step-one/index.spec.js index 2b14c18cc..30946dab0 100644 --- a/modules/ticket/front/basic-data/step-one/index.spec.js +++ b/modules/ticket/front/basic-data/step-one/index.spec.js @@ -67,7 +67,7 @@ describe('Ticket', () => { jest.spyOn(controller, 'getShipped'); controller.ticket.addressFk = 99; controller.addressId = 100; - const landed = new Date(); + const landed = Date.vnNew(); const expectedResult = { landed: landed, addressFk: 100, @@ -101,7 +101,7 @@ describe('Ticket', () => { describe('shipped() getter', () => { it('should return the shipped property', () => { - const shipped = new Date(); + const shipped = Date.vnNew(); controller.ticket.shipped = shipped; expect(controller.shipped).toEqual(shipped); @@ -111,7 +111,7 @@ describe('Ticket', () => { describe('shipped() setter', () => { it('should set shipped property and call getLanded() method ', () => { jest.spyOn(controller, 'getLanded'); - const shipped = new Date(); + const shipped = Date.vnNew(); const expectedResult = { shipped: shipped, addressFk: 121, @@ -126,7 +126,7 @@ describe('Ticket', () => { describe('landed() getter', () => { it('should return the landed property', () => { - const landed = new Date(); + const landed = Date.vnNew(); controller.ticket.landed = landed; expect(controller.landed).toEqual(landed); @@ -136,7 +136,7 @@ describe('Ticket', () => { describe('landed() setter', () => { it('should set shipped property and call getShipped() method ', () => { jest.spyOn(controller, 'getShipped'); - const landed = new Date(); + const landed = Date.vnNew(); const expectedResult = { landed: landed, addressFk: 121, @@ -161,7 +161,7 @@ describe('Ticket', () => { it('should set agencyModeId property and call getLanded() method', () => { jest.spyOn(controller, 'getLanded'); controller.$.agencyMode = {selection: {warehouseFk: 1}}; - const shipped = new Date(); + const shipped = Date.vnNew(); const agencyModeId = 8; const expectedResult = { shipped: shipped, @@ -177,7 +177,7 @@ describe('Ticket', () => { it('should do nothing if attempting to set the same agencyMode id', () => { jest.spyOn(controller, 'getShipped'); - const landed = new Date(); + const landed = Date.vnNew(); const agencyModeId = 7; const expectedResult = { landed: landed, @@ -278,8 +278,8 @@ describe('Ticket', () => { agencyModeFk: 1, companyFk: 442, warehouseFk: 1, - shipped: new Date(), - landed: new Date() + shipped: Date.vnNew(), + landed: Date.vnNew() }; expect(controller.isFormInvalid()).toBeFalsy(); @@ -288,7 +288,7 @@ describe('Ticket', () => { describe('onStepChange()', () => { it('should call onStepChange method and return a NO_AGENCY_AVAILABLE signal error', async() => { - let landed = new Date(); + let landed = Date.vnNew(); landed.setHours(0, 0, 0, 0); controller._ticket = { @@ -299,7 +299,7 @@ describe('Ticket', () => { agencyModeFk: 1, companyFk: 442, warehouseFk: 1, - shipped: new Date(), + shipped: Date.vnNew(), landed: landed }; @@ -314,8 +314,8 @@ describe('Ticket', () => { describe('getLanded()', () => { it('should return an available landed date', async() => { - const shipped = new Date(); - const expectedResult = {landed: new Date()}; + const shipped = Date.vnNew(); + const expectedResult = {landed: Date.vnNew()}; const params = { shipped: shipped, addressFk: 121, @@ -336,8 +336,8 @@ describe('Ticket', () => { describe('getShipped()', () => { it('should return an available shipped date', async() => { - const landed = new Date(); - const expectedResult = {shipped: new Date()}; + const landed = Date.vnNew(); + const expectedResult = {shipped: Date.vnNew()}; const params = { landed: landed, addressFk: 121, @@ -358,7 +358,7 @@ describe('Ticket', () => { describe('zoneWhere() getter', () => { it('should return an object containing filter properties', async() => { - const shipped = new Date(); + const shipped = Date.vnNew(); controller.ticket.shipped = shipped; const expectedResult = { diff --git a/modules/ticket/front/descriptor-menu/index.js b/modules/ticket/front/descriptor-menu/index.js index f6001c6b8..ff029db78 100644 --- a/modules/ticket/front/descriptor-menu/index.js +++ b/modules/ticket/front/descriptor-menu/index.js @@ -177,7 +177,7 @@ class Controller extends Section { get canRestoreTicket() { const isDeleted = this.ticket.isDeleted; - const now = new Date(); + const now = Date.vnNew(); const maxDate = new Date(this.ticket.updated); maxDate.setHours(maxDate.getHours() + 1); diff --git a/modules/ticket/front/descriptor-menu/index.spec.js b/modules/ticket/front/descriptor-menu/index.spec.js index 67dc0affa..babc22038 100644 --- a/modules/ticket/front/descriptor-menu/index.spec.js +++ b/modules/ticket/front/descriptor-menu/index.spec.js @@ -43,7 +43,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { describe('canRestoreTicket() getter', () => { it('should return true for a ticket deleted within the last hour', () => { controller.ticket.isDeleted = true; - controller.ticket.updated = new Date(); + controller.ticket.updated = Date.vnNew(); const result = controller.canRestoreTicket; @@ -51,7 +51,7 @@ describe('Ticket Component vnTicketDescriptorMenu', () => { }); it('should return false for a ticket deleted more than one hour ago', () => { - const pastHour = new Date(); + const pastHour = Date.vnNew(); pastHour.setHours(pastHour.getHours() - 2); controller.ticket.isDeleted = true; diff --git a/modules/ticket/front/expedition/index.js b/modules/ticket/front/expedition/index.js index 7ffe2fe5e..2d4432fe8 100644 --- a/modules/ticket/front/expedition/index.js +++ b/modules/ticket/front/expedition/index.js @@ -4,7 +4,7 @@ import Section from 'salix/components/section'; class Controller extends Section { constructor($element, $scope) { super($element, $scope); - this.landed = new Date(); + this.landed = Date.vnNew(); this.newRoute = null; } diff --git a/modules/ticket/front/expedition/index.spec.js b/modules/ticket/front/expedition/index.spec.js index 5a538b1c8..71e32151c 100644 --- a/modules/ticket/front/expedition/index.spec.js +++ b/modules/ticket/front/expedition/index.spec.js @@ -76,7 +76,7 @@ describe('Ticket', () => { it('should make a query and then call to the $state go() method', () => { jest.spyOn(controller.$state, 'go').mockReturnThis(); - const landed = new Date(); + const landed = Date.vnNew(); const ticket = { clientFk: 1101, landed: landed, diff --git a/modules/ticket/front/future/index.js b/modules/ticket/front/future/index.js index 56ba1608e..cb87e1d1b 100644 --- a/modules/ticket/front/future/index.js +++ b/modules/ticket/front/future/index.js @@ -55,7 +55,7 @@ export default class Controller extends Section { } setDefaultFilter() { - const today = new Date(); + const today = Date.vnNew(); this.filterParams = { originDated: today, @@ -66,7 +66,7 @@ export default class Controller extends Section { } compareDate(date) { - let today = new Date(); + let today = Date.vnNew(); today.setHours(0, 0, 0, 0); let timeTicket = new Date(date); timeTicket.setHours(0, 0, 0, 0); diff --git a/modules/ticket/front/future/index.spec.js b/modules/ticket/front/future/index.spec.js index c609a4891..188421298 100644 --- a/modules/ticket/front/future/index.spec.js +++ b/modules/ticket/front/future/index.spec.js @@ -2,7 +2,7 @@ import './index.js'; import crudModel from 'core/mocks/crud-model'; describe('Component vnTicketFuture', () => { - const today = new Date(); + const today = Date.vnNew(); let controller; let $httpBackend; @@ -32,7 +32,7 @@ describe('Component vnTicketFuture', () => { }); it('should return sucess when the date is in the future', () => { - let futureDate = new Date(); + let futureDate = Date.vnNew(); futureDate = futureDate.setDate(futureDate.getDate() + 10); let result = controller.compareDate(futureDate); @@ -40,7 +40,7 @@ describe('Component vnTicketFuture', () => { }); it('should return undefined when the date is in the past', () => { - let pastDate = new Date(); + let pastDate = Date.vnNew(); pastDate = pastDate.setDate(pastDate.getDate() - 10); let result = controller.compareDate(pastDate); diff --git a/modules/ticket/front/index/index.js b/modules/ticket/front/index/index.js index 3039a2a03..42332ccc8 100644 --- a/modules/ticket/front/index/index.js +++ b/modules/ticket/front/index/index.js @@ -90,7 +90,7 @@ export default class Controller extends Section { } compareDate(date) { - let today = new Date(); + let today = Date.vnNew(); today.setHours(0, 0, 0, 0); let timeTicket = new Date(date); timeTicket.setHours(0, 0, 0, 0); diff --git a/modules/ticket/front/index/index.spec.js b/modules/ticket/front/index/index.spec.js index 03071654e..5046387b0 100644 --- a/modules/ticket/front/index/index.spec.js +++ b/modules/ticket/front/index/index.spec.js @@ -31,14 +31,14 @@ describe('Component vnTicketIndex', () => { describe('compareDate()', () => { it('should return warning when the date is the present', () => { - let today = new Date(); + let today = Date.vnNew(); let result = controller.compareDate(today); expect(result).toEqual('warning'); }); it('should return sucess when the date is in the future', () => { - let futureDate = new Date(); + let futureDate = Date.vnNew(); futureDate = futureDate.setDate(futureDate.getDate() + 10); let result = controller.compareDate(futureDate); @@ -46,7 +46,7 @@ describe('Component vnTicketIndex', () => { }); it('should return undefined when the date is in the past', () => { - let pastDate = new Date(); + let pastDate = Date.vnNew(); pastDate = pastDate.setDate(pastDate.getDate() - 10); let result = controller.compareDate(pastDate); diff --git a/modules/ticket/front/main/index.js b/modules/ticket/front/main/index.js index 1b807216b..3f9482fc4 100644 --- a/modules/ticket/front/main/index.js +++ b/modules/ticket/front/main/index.js @@ -22,7 +22,7 @@ export default class Ticket extends ModuleMain { $params.scopeDays = 1; if (typeof $params.scopeDays === 'number') { - const from = new Date(); + const from = Date.vnNew(); from.setHours(0, 0, 0, 0); const to = new Date(from.getTime()); diff --git a/modules/ticket/front/package/index.js b/modules/ticket/front/package/index.js index ed13f12d8..fd67ce583 100644 --- a/modules/ticket/front/package/index.js +++ b/modules/ticket/front/package/index.js @@ -6,7 +6,7 @@ class Controller extends Section { this.$.model.insert({ packagingFk: null, quantity: null, - created: new Date(), + created: Date.vnNew(), ticketFk: this.$params.id }); } diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 618d4727d..f3fb89d04 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -51,7 +51,7 @@ class Controller extends Section { const hasClaimManagerRole = this.aclService.hasAny(['claimManager']); - return landedPlusWeek >= new Date() || hasClaimManagerRole; + return landedPlusWeek >= Date.vnNew() || hasClaimManagerRole; } return false; } diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index fbee966fd..8585503cc 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -15,9 +15,9 @@ describe('Ticket', () => { const ticket = { id: 1, clientFk: 1101, - shipped: new Date(), - landed: new Date(), - created: new Date(), + shipped: Date.vnNew(), + landed: Date.vnNew(), + created: Date.vnNew(), client: {salesPersonFk: 1}, address: {mobile: 111111111} }; diff --git a/modules/ticket/front/search-panel/index.spec.js b/modules/ticket/front/search-panel/index.spec.js index 41c32c047..df320b55b 100644 --- a/modules/ticket/front/search-panel/index.spec.js +++ b/modules/ticket/front/search-panel/index.spec.js @@ -38,7 +38,7 @@ describe('Ticket Component vnTicketSearchPanel', () => { it('should clear the scope days when setting the from property', () => { controller.filter.scopeDays = 1; - controller.from = new Date(); + controller.from = Date.vnNew(); expect(controller.filter.scopeDays).toBeNull(); expect(controller.from).toBeDefined(); @@ -49,7 +49,7 @@ describe('Ticket Component vnTicketSearchPanel', () => { it('should clear the scope days when setting the to property', () => { controller.filter.scopeDays = 1; - controller.to = new Date(); + controller.to = Date.vnNew(); expect(controller.filter.scopeDays).toBeNull(); expect(controller.to).toBeDefined(); @@ -58,8 +58,8 @@ describe('Ticket Component vnTicketSearchPanel', () => { describe('scopeDays() setter', () => { it('should clear the date range when setting the scopeDays property', () => { - controller.filter.from = new Date(); - controller.filter.to = new Date(); + controller.filter.from = Date.vnNew(); + controller.filter.to = Date.vnNew(); controller.scopeDays = 1; diff --git a/modules/travel/back/methods/thermograph/createThermograph.js b/modules/travel/back/methods/thermograph/createThermograph.js index 23d9d6037..75d967628 100644 --- a/modules/travel/back/methods/thermograph/createThermograph.js +++ b/modules/travel/back/methods/thermograph/createThermograph.js @@ -40,7 +40,7 @@ module.exports = Self => { const models = Self.app.models; let tx; const myOptions = {}; - const date = new Date(); + const date = Date.vnNew(); if (typeof options == 'object') Object.assign(myOptions, options); diff --git a/modules/travel/back/methods/travel/cloneWithEntries.js b/modules/travel/back/methods/travel/cloneWithEntries.js index 611f4e429..e5b6b1580 100644 --- a/modules/travel/back/methods/travel/cloneWithEntries.js +++ b/modules/travel/back/methods/travel/cloneWithEntries.js @@ -39,8 +39,8 @@ module.exports = Self => { 'ref' ] }); - const started = new Date(); - const ended = new Date(); + const started = Date.vnNew(); + const ended = Date.vnNew(); if (!travel) throw new UserError('Travel not found'); diff --git a/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js b/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js index 2e79ff193..0e434e048 100644 --- a/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js +++ b/modules/travel/back/methods/travel/specs/cloneWithEntries.spec.js @@ -49,7 +49,7 @@ describe('Travel cloneWithEntries()', () => { pending('#2687 - Cannot make a data rollback because of the triggers'); const warehouseThree = 3; const agencyModeOne = 1; - const yesterday = new Date(); + const yesterday = Date.vnNew(); yesterday.setDate(yesterday.getDate() - 1); travelBefore = await models.Travel.findById(travelId); diff --git a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js index 3693aae82..599851b55 100644 --- a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js +++ b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js @@ -95,10 +95,10 @@ describe('Travel extraCommunityFilter()', () => { }); it('should return the routes matching "shipped from" and "landed to"', async() => { - const from = new Date(); + const from = Date.vnNew(); from.setDate(from.getDate() - 2); from.setHours(0, 0, 0, 0); - const to = new Date(); + const to = Date.vnNew(); to.setHours(23, 59, 59, 999); to.setDate(to.getDate() + 7); const ctx = { diff --git a/modules/travel/back/methods/travel/specs/filter.spec.js b/modules/travel/back/methods/travel/specs/filter.spec.js index c739866a0..1a6ee895c 100644 --- a/modules/travel/back/methods/travel/specs/filter.spec.js +++ b/modules/travel/back/methods/travel/specs/filter.spec.js @@ -54,8 +54,8 @@ describe('Travel filter()', () => { }); it('should return the routes matching "shipped from" and "shipped to"', async() => { - const from = new Date(); - const to = new Date(); + const from = Date.vnNew(); + const to = Date.vnNew(); from.setHours(0, 0, 0, 0); to.setHours(23, 59, 59, 999); to.setDate(to.getDate() + 1); diff --git a/modules/travel/front/create/index.spec.js b/modules/travel/front/create/index.spec.js index e3f85d9ae..cdff8cfb9 100644 --- a/modules/travel/front/create/index.spec.js +++ b/modules/travel/front/create/index.spec.js @@ -53,7 +53,7 @@ describe('Travel Component vnTravelCreate', () => { it(`should do nothing if there's no response data.`, () => { controller.travel = {agencyModeFk: 4}; - const tomorrow = new Date(); + const tomorrow = Date.vnNew(); const query = `travels/getAverageDays?agencyModeFk=${controller.travel.agencyModeFk}`; $httpBackend.expectGET(query).respond(undefined); @@ -67,7 +67,7 @@ describe('Travel Component vnTravelCreate', () => { it(`should fill the fields when it's selected a date and agency.`, () => { controller.travel = {agencyModeFk: 1}; - const tomorrow = new Date(); + const tomorrow = Date.vnNew(); tomorrow.setDate(tomorrow.getDate() + 9); const expectedResponse = { id: 8, diff --git a/modules/travel/front/extra-community/index.js b/modules/travel/front/extra-community/index.js index 2389570b9..920339469 100644 --- a/modules/travel/front/extra-community/index.js +++ b/modules/travel/front/extra-community/index.js @@ -25,12 +25,12 @@ class Controller extends Section { this.droppableElement = 'tbody[vn-droppable]'; const twoDays = 2; - const shippedFrom = new Date(); + const shippedFrom = Date.vnNew(); shippedFrom.setDate(shippedFrom.getDate() - twoDays); shippedFrom.setHours(0, 0, 0, 0); const sevenDays = 7; - const landedTo = new Date(); + const landedTo = Date.vnNew(); landedTo.setDate(landedTo.getDate() + sevenDays); landedTo.setHours(23, 59, 59, 59); diff --git a/modules/travel/front/index/index.js b/modules/travel/front/index/index.js index 50036831f..7701289b7 100644 --- a/modules/travel/front/index/index.js +++ b/modules/travel/front/index/index.js @@ -20,7 +20,7 @@ export default class Controller extends Section { } compareDate(date) { - let today = new Date(); + let today = Date.vnNew(); today.setHours(0, 0, 0, 0); date = new Date(date); diff --git a/modules/travel/front/index/index.spec.js b/modules/travel/front/index/index.spec.js index 9abe46a64..9083c4519 100644 --- a/modules/travel/front/index/index.spec.js +++ b/modules/travel/front/index/index.spec.js @@ -50,7 +50,7 @@ describe('Travel Component vnTravelIndex', () => { describe('compareDate()', () => { it('should return warning if the date passed to compareDate() is todays', () => { - const today = new Date(); + const today = Date.vnNew(); const result = controller.compareDate(today); @@ -58,7 +58,7 @@ describe('Travel Component vnTravelIndex', () => { }); it('should return success if the date passed to compareDate() is in the future', () => { - const tomorrow = new Date(); + const tomorrow = Date.vnNew(); tomorrow.setDate(tomorrow.getDate() + 1); const result = controller.compareDate(tomorrow); @@ -67,7 +67,7 @@ describe('Travel Component vnTravelIndex', () => { }); it('should return undefined if the date passed to compareDate() is in the past', () => { - const yesterday = new Date(); + const yesterday = Date.vnNew(); yesterday.setDate(yesterday.getDate() - 1); const result = controller.compareDate(yesterday); diff --git a/modules/travel/front/main/index.js b/modules/travel/front/main/index.js index d6f103033..fbaf78c16 100644 --- a/modules/travel/front/main/index.js +++ b/modules/travel/front/main/index.js @@ -15,7 +15,7 @@ export default class Travel extends ModuleMain { $params.scopeDays = 1; if (typeof $params.scopeDays === 'number') { - const shippedFrom = new Date(); + const shippedFrom = Date.vnNew(); shippedFrom.setHours(0, 0, 0, 0); const shippedTo = new Date(shippedFrom.getTime()); diff --git a/modules/travel/front/main/index.spec.js b/modules/travel/front/main/index.spec.js index 6d9db4dc8..bf5a27b41 100644 --- a/modules/travel/front/main/index.spec.js +++ b/modules/travel/front/main/index.spec.js @@ -15,7 +15,7 @@ describe('Travel Component vnTravel', () => { let params = controller.fetchParams({ scopeDays: 2 }); - const shippedFrom = new Date(); + const shippedFrom = Date.vnNew(); shippedFrom.setHours(0, 0, 0, 0); const shippedTo = new Date(shippedFrom.getTime()); shippedTo.setDate(shippedTo.getDate() + params.scopeDays); diff --git a/modules/travel/front/search-panel/index.spec.js b/modules/travel/front/search-panel/index.spec.js index a1f3c36b3..884f4fb17 100644 --- a/modules/travel/front/search-panel/index.spec.js +++ b/modules/travel/front/search-panel/index.spec.js @@ -15,7 +15,7 @@ describe('Travel Component vnTravelSearchPanel', () => { it('should clear the scope days when setting the from property', () => { controller.filter.scopeDays = 1; - controller.shippedFrom = new Date(); + controller.shippedFrom = Date.vnNew(); expect(controller.filter.scopeDays).toBeNull(); expect(controller.shippedFrom).toBeDefined(); @@ -26,7 +26,7 @@ describe('Travel Component vnTravelSearchPanel', () => { it('should clear the scope days when setting the to property', () => { controller.filter.scopeDays = 1; - controller.shippedTo = new Date(); + controller.shippedTo = Date.vnNew(); expect(controller.filter.scopeDays).toBeNull(); expect(controller.shippedTo).toBeDefined(); @@ -35,8 +35,8 @@ describe('Travel Component vnTravelSearchPanel', () => { describe('scopeDays() setter', () => { it('should clear the date range when setting the scopeDays property', () => { - controller.filter.shippedFrom = new Date(); - controller.filter.shippedTo = new Date(); + controller.filter.shippedFrom = Date.vnNew(); + controller.filter.shippedTo = Date.vnNew(); controller.scopeDays = 1; diff --git a/modules/worker/back/methods/calendar/absences.js b/modules/worker/back/methods/calendar/absences.js index ddf38a604..8420ed770 100644 --- a/modules/worker/back/methods/calendar/absences.js +++ b/modules/worker/back/methods/calendar/absences.js @@ -35,12 +35,12 @@ module.exports = Self => { Self.absences = async(ctx, workerFk, businessFk, year, options) => { const models = Self.app.models; - const started = new Date(); + const started = Date.vnNew(); started.setFullYear(year); started.setMonth(0); started.setDate(1); - const ended = new Date(); + const ended = Date.vnNew(); ended.setFullYear(year); ended.setMonth(12); ended.setDate(0); diff --git a/modules/worker/back/methods/calendar/specs/absences.spec.js b/modules/worker/back/methods/calendar/specs/absences.spec.js index 2180a5312..365773182 100644 --- a/modules/worker/back/methods/calendar/specs/absences.spec.js +++ b/modules/worker/back/methods/calendar/specs/absences.spec.js @@ -6,7 +6,7 @@ describe('Worker absences()', () => { const workerId = 1106; const businessId = 1106; - const now = new Date(); + const now = Date.vnNew(); const year = now.getFullYear(); const [absences] = await app.models.Calendar.absences(ctx, workerId, businessId, year); @@ -22,7 +22,7 @@ describe('Worker absences()', () => { const businessId = 1106; const ctx = {req: {accessToken: {userId: 9}}}; - const now = new Date(); + const now = Date.vnNew(); const year = now.getFullYear(); const tx = await app.models.Calendar.beginTransaction({}); @@ -55,15 +55,15 @@ describe('Worker absences()', () => { const workerId = 1106; const userId = 1106; - const today = new Date(); + const today = Date.vnNew(); // getting how many days in a year - const yearStart = new Date(); + const yearStart = Date.vnNew(); yearStart.setHours(0, 0, 0, 0); yearStart.setMonth(0); yearStart.setDate(1); - const yearEnd = new Date(); + const yearEnd = Date.vnNew(); const currentYear = yearEnd.getFullYear(); yearEnd.setFullYear(currentYear + 1); yearEnd.setHours(0, 0, 0, 0); @@ -92,7 +92,7 @@ describe('Worker absences()', () => { // normal test begins const contract = await app.models.WorkerLabour.findById(businessId, null, options); - const startingContract = new Date(); + const startingContract = Date.vnNew(); startingContract.setHours(0, 0, 0, 0); startingContract.setMonth(today.getMonth()); startingContract.setDate(1); diff --git a/modules/worker/back/methods/holiday/getByWarehouse.js b/modules/worker/back/methods/holiday/getByWarehouse.js index 093885d13..50029e62b 100644 --- a/modules/worker/back/methods/holiday/getByWarehouse.js +++ b/modules/worker/back/methods/holiday/getByWarehouse.js @@ -17,7 +17,7 @@ module.exports = Self => { }); Self.getByWarehouse = async warehouseFk => { - let beginningYear = new Date(); + let beginningYear = Date.vnNew(); beginningYear.setMonth(0); beginningYear.setDate(1); beginningYear.setHours(0, 0, 0, 0); diff --git a/modules/worker/back/methods/worker-time-control-mail/checkInbox.js b/modules/worker/back/methods/worker-time-control-mail/checkInbox.js index 7825f38b8..4d9f98cc3 100644 --- a/modules/worker/back/methods/worker-time-control-mail/checkInbox.js +++ b/modules/worker/back/methods/worker-time-control-mail/checkInbox.js @@ -93,7 +93,7 @@ module.exports = Self => { }; async function emailConfirm(buffer) { - const now = new Date(); + const now = Date.vnNew(); const from = JSON.stringify(Imap.parseHeader(buffer).from); const subject = JSON.stringify(Imap.parseHeader(buffer).subject); @@ -121,7 +121,7 @@ module.exports = Self => { } async function emailReply(buffer, emailBody) { - const now = new Date(); + const now = Date.vnNew(); const from = JSON.stringify(Imap.parseHeader(buffer).from); const subject = JSON.stringify(Imap.parseHeader(buffer).subject); diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index b38405c1d..b91eeb324 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -49,8 +49,8 @@ module.exports = Self => { try { if (!args.week || !args.year) { - const from = new Date(); - const to = new Date(); + const from = Date.vnNew(); + const to = Date.vnNew(); const time = await models.Time.findOne({ where: { @@ -86,7 +86,7 @@ module.exports = Self => { week: args.week }; await models.WorkerTimeControlMail.updateAll(where, { - updated: new Date(), state: 'SENDED' + updated: Date.vnNew(), state: 'SENDED' }, myOptions); stmt = new ParameterizedSQL( @@ -109,7 +109,7 @@ module.exports = Self => { week: args.week }; await models.WorkerTimeControlMail.updateAll(where, { - updated: new Date(), state: 'SENDED' + updated: Date.vnNew(), state: 'SENDED' }, myOptions); stmt = new ParameterizedSQL(`CALL vn.timeControl_calculateAll(?, ?)`, [started, ended]); @@ -215,11 +215,11 @@ module.exports = Self => { let timeTableDecimalInSeconds = 0; for (let journey of journeys) { - const start = new Date(); + const start = Date.vnNew(); const [startHours, startMinutes, startSeconds] = getTime(journey.start); start.setHours(startHours, startMinutes, startSeconds, 0); - const end = new Date(); + const end = Date.vnNew(); const [endHours, endMinutes, endSeconds] = getTime(journey.end); end.setHours(endHours, endMinutes, endSeconds, 0); diff --git a/modules/worker/back/methods/worker-time-control/specs/filter.spec.js b/modules/worker/back/methods/worker-time-control/specs/filter.spec.js index 927d83df3..0c4d229f2 100644 --- a/modules/worker/back/methods/worker-time-control/specs/filter.spec.js +++ b/modules/worker/back/methods/worker-time-control/specs/filter.spec.js @@ -3,9 +3,9 @@ const models = require('vn-loopback/server/server').models; describe('workerTimeControl filter()', () => { it('should return 1 result filtering by id', async() => { const ctx = {req: {accessToken: {userId: 1106}}, args: {workerFk: 1106}}; - const firstHour = new Date(); + const firstHour = Date.vnNew(); firstHour.setHours(7, 0, 0, 0); - const lastHour = new Date(); + const lastHour = Date.vnNew(); lastHour.setDate(lastHour.getDate() + 1); lastHour.setHours(15, 0, 0, 0); @@ -21,9 +21,9 @@ describe('workerTimeControl filter()', () => { it('should return a privilege error for a non subordinate worker', async() => { const ctx = {req: {accessToken: {userId: 1107}}, args: {workerFk: 1106}}; - const firstHour = new Date(); + const firstHour = Date.vnNew(); firstHour.setHours(7, 0, 0, 0); - const lastHour = new Date(); + const lastHour = Date.vnNew(); lastHour.setDate(lastHour.getDate() + 1); lastHour.setHours(15, 0, 0, 0); diff --git a/modules/worker/back/methods/worker-time-control/specs/timeEntry.spec.js b/modules/worker/back/methods/worker-time-control/specs/timeEntry.spec.js index e9924c67b..e90c849b7 100644 --- a/modules/worker/back/methods/worker-time-control/specs/timeEntry.spec.js +++ b/modules/worker/back/methods/worker-time-control/specs/timeEntry.spec.js @@ -35,7 +35,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { let error; try { - ctx.args = {timed: new Date(), direction: 'in'}; + ctx.args = {timed: Date.vnNew(), direction: 'in'}; await models.WorkerTimeControl.addTimeEntry(ctx, workerId); } catch (e) { error = e; @@ -52,7 +52,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { let error; try { - ctx.args = {timed: new Date(), direction: 'in'}; + ctx.args = {timed: Date.vnNew(), direction: 'in'}; await models.WorkerTimeControl.addTimeEntry(ctx, workerId); } catch (e) { error = e; @@ -71,7 +71,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { try { const options = {transaction: tx}; - const todayAtOne = new Date(); + const todayAtOne = Date.vnNew(); todayAtOne.setHours(1, 0, 0, 0); ctx.args = {timed: todayAtOne, direction: 'in'}; @@ -95,7 +95,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { try { const options = {transaction: tx}; - const todayAtOne = new Date(); + const todayAtOne = Date.vnNew(); todayAtOne.setHours(1, 0, 0, 0); ctx.args = {timed: todayAtOne, direction: 'in'}; @@ -123,7 +123,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { try { const options = {transaction: tx}; - const todayAtOne = new Date(); + const todayAtOne = Date.vnNew(); todayAtOne.setHours(1, 0, 0, 0); ctx.args = {timed: todayAtOne, direction: 'in'}; @@ -151,7 +151,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { try { const options = {transaction: tx}; - const todayAtOne = new Date(); + const todayAtOne = Date.vnNew(); todayAtOne.setHours(1, 0, 0, 0); ctx.args = {timed: todayAtOne, direction: 'in'}; @@ -179,7 +179,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { try { const options = {transaction: tx}; - const todayAtOne = new Date(); + const todayAtOne = Date.vnNew(); todayAtOne.setHours(1, 0, 0, 0); ctx.args = {timed: todayAtOne, direction: 'in'}; @@ -204,7 +204,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { pending('https://redmine.verdnatura.es/issues/4707'); activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; - const date = new Date(); + const date = Date.vnNew(); date.setDate(date.getDate() - 16); date.setHours(8, 0, 0); let error; @@ -227,7 +227,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { it('should fail to add a time entry for a worker without an existing contract', async() => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; - const date = new Date(); + const date = Date.vnNew(); date.setFullYear(date.getFullYear() - 2); let error; @@ -252,7 +252,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; - let date = new Date(); + let date = Date.vnNew(); date.setDate(date.getDate() - 21); date = weekDay(date, monday); let error; @@ -282,7 +282,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; - let date = new Date(); + let date = Date.vnNew(); date.setDate(date.getDate() - 21); date = weekDay(date, monday); let error; @@ -316,7 +316,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; - let date = new Date(); + let date = Date.vnNew(); date.setDate(date.getDate() - 21); date = weekDay(date, monday); let error; @@ -350,7 +350,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; - let date = new Date(); + let date = Date.vnNew(); date.setDate(date.getDate() - 21); date = weekDay(date, monday); let error; @@ -384,7 +384,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; - let date = new Date(); + let date = Date.vnNew(); date.setDate(date.getDate() - 21); date = weekDay(date, monday); let error; @@ -421,7 +421,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; - let date = new Date(); + let date = Date.vnNew(); date.setDate(date.getDate() - 21); date = weekDay(date, monday); let error; @@ -456,7 +456,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; - let date = new Date(); + let date = Date.vnNew(); date.setDate(date.getDate() - 21); date = weekDay(date, monday); let error; @@ -493,7 +493,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { activeCtx.accessToken.userId = salesBossId; const workerId = jessicaJonesId; - let date = new Date(); + let date = Date.vnNew(); date.setDate(date.getDate() - 21); date = weekDay(date, monday); let error; @@ -528,7 +528,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { activeCtx.accessToken.userId = salesBossId; const workerId = jessicaJonesId; - let date = new Date(); + let date = Date.vnNew(); date.setDate(date.getDate() - 21); date = weekDay(date, monday); let error; @@ -565,7 +565,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; - let date = new Date(); + let date = Date.vnNew(); date.setMonth(date.getMonth() - 2); date.setDate(1); let error; @@ -600,7 +600,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; - let date = new Date(); + let date = Date.vnNew(); date.setMonth(date.getMonth() - 2); date.setDate(1); let error; @@ -634,7 +634,7 @@ describe('workerTimeControl add/delete timeEntry()', () => { activeCtx.accessToken.userId = salesBossId; const workerId = hankPymId; - let date = new Date(); + let date = Date.vnNew(); date.setMonth(date.getMonth() - 2); date.setDate(1); let error; diff --git a/modules/worker/back/methods/worker/activeContract.js b/modules/worker/back/methods/worker/activeContract.js index 05dcee6b5..d3d439cd0 100644 --- a/modules/worker/back/methods/worker/activeContract.js +++ b/modules/worker/back/methods/worker/activeContract.js @@ -27,7 +27,7 @@ module.exports = Self => { if (!isSubordinate) throw new UserError(`You don't have enough privileges`); - const now = new Date(); + const now = Date.vnNew(); return models.WorkerLabour.findOne({ where: { diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 1467d6d6b..43a9f4d23 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -80,8 +80,8 @@ module.exports = Self => { if (hasHoursRecorded && isNotHalfAbsence) throw new UserError(`The worker has hours recorded that day`); - const date = new Date(); - const now = new Date(); + const date = Date.vnNew(); + const now = Date.vnNew(); date.setHours(0, 0, 0, 0); const [result] = await Self.rawSql( `SELECT COUNT(*) halfHolidayCounter diff --git a/modules/worker/back/methods/worker/holidays.js b/modules/worker/back/methods/worker/holidays.js index 7f093a330..9c214e0f7 100644 --- a/modules/worker/back/methods/worker/holidays.js +++ b/modules/worker/back/methods/worker/holidays.js @@ -45,13 +45,13 @@ module.exports = Self => { if (!isSubordinate) throw new UserError(`You don't have enough privileges`); - const started = new Date(); + const started = Date.vnNew(); started.setFullYear(args.year); started.setMonth(0); started.setDate(1); started.setHours(0, 0, 0, 0); - const ended = new Date(); + const ended = Date.vnNew(); ended.setFullYear(args.year); ended.setMonth(12); ended.setDate(0); diff --git a/modules/worker/back/methods/worker/specs/createAbsence.spec.js b/modules/worker/back/methods/worker/specs/createAbsence.spec.js index 7214e815e..346e43c51 100644 --- a/modules/worker/back/methods/worker/specs/createAbsence.spec.js +++ b/modules/worker/back/methods/worker/specs/createAbsence.spec.js @@ -10,7 +10,7 @@ describe('Worker createAbsence()', () => { args: { businessFk: 18, absenceTypeId: 1, - dated: new Date() + dated: Date.vnNew() } }; @@ -45,7 +45,7 @@ describe('Worker createAbsence()', () => { args: { businessFk: 18, absenceTypeId: 1, - dated: new Date() + dated: Date.vnNew() } }; ctx.req.__ = value => { @@ -82,7 +82,7 @@ describe('Worker createAbsence()', () => { id: 1, businessFk: 1, absenceTypeId: 6, - dated: new Date() + dated: Date.vnNew() } }; const workerId = 1; @@ -111,7 +111,7 @@ describe('Worker createAbsence()', () => { id: 1106, businessFk: 1106, absenceTypeId: 1, - dated: new Date() + dated: Date.vnNew() } }; const workerId = 1106; diff --git a/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js b/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js index a105669cf..0f3f913dc 100644 --- a/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js +++ b/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js @@ -28,7 +28,7 @@ describe('Worker deleteAbsence()', () => { const createdAbsence = await app.models.Calendar.create({ businessFk: businessId, dayOffTypeFk: 1, - dated: new Date() + dated: Date.vnNew() }, options); ctx.args = {absenceId: createdAbsence.id}; @@ -59,7 +59,7 @@ describe('Worker deleteAbsence()', () => { const createdAbsence = await app.models.Calendar.create({ businessFk: businessId, dayOffTypeFk: 1, - dated: new Date() + dated: Date.vnNew() }, options); ctx.args = {absenceId: createdAbsence.id}; diff --git a/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js b/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js index 054a829e5..f5b06cc9e 100644 --- a/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js +++ b/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js @@ -3,10 +3,10 @@ const models = require('vn-loopback/server/server').models; describe('Worker getWorkedHours()', () => { it(`should return the expected hours and the worked hours of a given date`, async() => { const workerID = 1106; - const started = new Date(); + const started = Date.vnNew(); started.setHours(0, 0, 0, 0); - const ended = new Date(); + const ended = Date.vnNew(); ended.setHours(23, 59, 59, 999); const [result] = await models.Worker.getWorkedHours(workerID, started, ended); diff --git a/modules/worker/back/methods/worker/specs/holidays.spec.js b/modules/worker/back/methods/worker/specs/holidays.spec.js index d8310b738..f23b247ca 100644 --- a/modules/worker/back/methods/worker/specs/holidays.spec.js +++ b/modules/worker/back/methods/worker/specs/holidays.spec.js @@ -17,7 +17,7 @@ describe('Worker holidays()', () => { }); it('should now get the absence calendar for a full year contract', async() => { - const now = new Date(); + const now = Date.vnNew(); const year = now.getFullYear(); ctx.args = {businessFk: businessId, year: year}; @@ -29,7 +29,7 @@ describe('Worker holidays()', () => { }); it('should now get the payed holidays calendar for a worker', async() => { - const now = new Date(); + const now = Date.vnNew(); const year = now.getFullYear(); ctx.args = {businessFk: businessId, year: year}; diff --git a/modules/worker/back/methods/worker/specs/updateAbsence.spec.js b/modules/worker/back/methods/worker/specs/updateAbsence.spec.js index 6339b3163..a624fc1d3 100644 --- a/modules/worker/back/methods/worker/specs/updateAbsence.spec.js +++ b/modules/worker/back/methods/worker/specs/updateAbsence.spec.js @@ -21,7 +21,7 @@ describe('Worker updateAbsence()', () => { createdAbsence = await app.models.Calendar.create({ businessFk: businessId, dayOffTypeFk: 1, - dated: new Date() + dated: Date.vnNew() }); }); diff --git a/modules/worker/front/calendar/index.js b/modules/worker/front/calendar/index.js index 95e1fc134..4ca0fc929 100644 --- a/modules/worker/front/calendar/index.js +++ b/modules/worker/front/calendar/index.js @@ -5,7 +5,7 @@ import './style.scss'; class Controller extends Section { constructor($element, $) { super($element, $); - this.date = new Date(); + this.date = Date.vnNew(); this.events = {}; this.buildYearFilter(); } @@ -15,7 +15,7 @@ class Controller extends Section { } set year(value) { - const newYear = new Date(); + const newYear = Date.vnNew(); newYear.setFullYear(value); this.date = newYear; @@ -76,7 +76,7 @@ class Controller extends Section { } buildYearFilter() { - const now = new Date(); + const now = Date.vnNew(); now.setFullYear(now.getFullYear() + 1); const maxYear = now.getFullYear(); diff --git a/modules/worker/front/calendar/index.spec.js b/modules/worker/front/calendar/index.spec.js index 1da4066d9..586a7223d 100644 --- a/modules/worker/front/calendar/index.spec.js +++ b/modules/worker/front/calendar/index.spec.js @@ -6,7 +6,7 @@ describe('Worker', () => { let $httpParamSerializer; let $scope; let controller; - let year = new Date().getFullYear(); + let year = Date.vnNew().getFullYear(); beforeEach(ngModule('worker')); @@ -67,7 +67,7 @@ describe('Worker', () => { controller.getIsSubordinate = jest.fn(); controller.getActiveContract = jest.fn(); - let today = new Date(); + let today = Date.vnNew(); let tomorrow = new Date(today.getTime()); tomorrow.setDate(tomorrow.getDate() + 1); @@ -105,7 +105,7 @@ describe('Worker', () => { describe('getContractHolidays()', () => { it(`should return the worker holidays amount and then set the contractHolidays property`, () => { - const today = new Date(); + const today = Date.vnNew(); const year = today.getFullYear(); const serializedParams = $httpParamSerializer({year}); @@ -119,7 +119,7 @@ describe('Worker', () => { describe('formatDay()', () => { it(`should set the day element style`, () => { - const today = new Date(); + const today = Date.vnNew(); controller.events[today.getTime()] = { name: 'Holiday', @@ -170,7 +170,7 @@ describe('Worker', () => { it(`should call to the create() method`, () => { jest.spyOn(controller, 'create').mockReturnThis(); - const selectedDay = new Date(); + const selectedDay = Date.vnNew(); const $event = { target: { closest: () => { @@ -188,7 +188,7 @@ describe('Worker', () => { it(`should call to the delete() method`, () => { jest.spyOn(controller, 'delete').mockReturnThis(); - const selectedDay = new Date(); + const selectedDay = Date.vnNew(); const expectedEvent = { dated: selectedDay, type: 'holiday', @@ -212,7 +212,7 @@ describe('Worker', () => { it(`should call to the edit() method`, () => { jest.spyOn(controller, 'edit').mockReturnThis(); - const selectedDay = new Date(); + const selectedDay = Date.vnNew(); const expectedEvent = { dated: selectedDay, type: 'leaveOfAbsence', @@ -238,7 +238,7 @@ describe('Worker', () => { it(`should make a HTTP POST query and then call to the repaintCanceller() method`, () => { jest.spyOn(controller, 'repaintCanceller').mockReturnThis(); - const dated = new Date(); + const dated = Date.vnNew(); const calendarElement = {}; const expectedResponse = {id: 10}; @@ -287,7 +287,7 @@ describe('Worker', () => { const expectedParams = {absenceId: 10}; const calendarElement = {}; - const selectedDay = new Date(); + const selectedDay = Date.vnNew(); const expectedEvent = { dated: selectedDay, type: 'leaveOfAbsence', diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js index 2ff032def..ef2f64e85 100644 --- a/modules/worker/front/descriptor/index.js +++ b/modules/worker/front/descriptor/index.js @@ -82,7 +82,7 @@ class Controller extends Descriptor { } onUploadResponse() { - const timestamp = new Date().getTime(); + const timestamp = Date.vnNew().getTime(); const src = this.$rootScope.imagePath('user', '520x520', this.worker.id); const zoomSrc = this.$rootScope.imagePath('user', '1600x1600', this.worker.id); const newSrc = `${src}&t=${timestamp}`; diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js index c3d3e5eab..f7379fea0 100644 --- a/modules/worker/front/time-control/index.js +++ b/modules/worker/front/time-control/index.js @@ -16,7 +16,7 @@ class Controller extends Section { $postLink() { const timestamp = this.$params.timestamp; - let initialDate = new Date(); + let initialDate = Date.vnNew(); if (timestamp) { initialDate = new Date(timestamp * 1000); @@ -199,7 +199,7 @@ class Controller extends Section { getFinishTime() { if (!this.weekDays) return; - let today = new Date(); + let today = Date.vnNew(); today.setHours(0, 0, 0, 0); let todayInWeek = this.weekDays.find(day => day.dated.getTime() === today.getTime()); diff --git a/modules/worker/front/time-control/index.spec.js b/modules/worker/front/time-control/index.spec.js index 4f317a5e6..b68162d39 100644 --- a/modules/worker/front/time-control/index.spec.js +++ b/modules/worker/front/time-control/index.spec.js @@ -18,7 +18,7 @@ describe('Component vnWorkerTimeControl', () => { describe('date() setter', () => { it(`should set the weekDays, the date in the controller and call fetchHours`, () => { - let today = new Date(); + let today = Date.vnNew(); jest.spyOn(controller, 'fetchHours').mockReturnThis(); controller.date = today; @@ -33,7 +33,7 @@ describe('Component vnWorkerTimeControl', () => { describe('hours() setter', () => { it(`should set hours data at it's corresponding week day`, () => { - let today = new Date(); + let today = Date.vnNew(); jest.spyOn(controller, 'fetchHours').mockReturnThis(); controller.date = today; @@ -64,7 +64,7 @@ describe('Component vnWorkerTimeControl', () => { describe('getWorkedHours() ', () => { it('should set the weekdays expected and worked hours plus the total worked hours', () => { - let today = new Date(); + let today = Date.vnNew(); jest.spyOn(controller, 'fetchHours').mockReturnThis(); controller.date = today; @@ -117,7 +117,7 @@ describe('Component vnWorkerTimeControl', () => { describe('save() ', () => { it(`should make a query an then call to the fetchHours() method`, () => { controller.fetchHours = jest.fn(); - controller.selectedRow = {id: 1, timed: new Date(), direction: 'in'}; + controller.selectedRow = {id: 1, timed: Date.vnNew(), direction: 'in'}; controller.$.editEntry = { hide: () => {} }; diff --git a/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js b/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js index bc7aa1ed9..4f79b2315 100644 --- a/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js +++ b/modules/zone/back/methods/agency/specs/getAgenciesWithWarehouse.spec.js @@ -1,7 +1,7 @@ const app = require('vn-loopback/server/server'); describe('Agency getAgenciesWithWarehouse()', () => { - const today = new Date(); + const today = Date.vnNew(); it('should return the agencies that can handle the given delivery request', async() => { const tx = await app.models.Zone.beginTransaction({}); diff --git a/modules/zone/back/methods/agency/specs/getLanded.spec.js b/modules/zone/back/methods/agency/specs/getLanded.spec.js index c199b2ba6..e2e6b3eb3 100644 --- a/modules/zone/back/methods/agency/specs/getLanded.spec.js +++ b/modules/zone/back/methods/agency/specs/getLanded.spec.js @@ -3,7 +3,7 @@ const models = require('vn-loopback/server/server').models; describe('agency getLanded()', () => { it('should return a landing date', async() => { const ctx = {req: {accessToken: {userId: 1}}}; - const shipped = new Date(); + const shipped = Date.vnNew(); shipped.setDate(shipped.getDate() + 1); const addressFk = 121; const agencyModeFk = 7; diff --git a/modules/zone/back/methods/agency/specs/getShipped.spec.js b/modules/zone/back/methods/agency/specs/getShipped.spec.js index f2b36fc94..43e2c1208 100644 --- a/modules/zone/back/methods/agency/specs/getShipped.spec.js +++ b/modules/zone/back/methods/agency/specs/getShipped.spec.js @@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server'); describe('agency getShipped()', () => { it('should return a shipment date', async() => { - const landed = new Date(); + const landed = Date.vnNew(); landed.setDate(landed.getDate() + 1); const addressFk = 121; const agencyModeFk = 7; @@ -25,7 +25,7 @@ describe('agency getShipped()', () => { }); it('should not return a shipment date', async() => { - const newDate = new Date(); + const newDate = Date.vnNew(); newDate.setMonth(newDate.getMonth() - 1); const landed = newDate; const addressFk = 121; diff --git a/modules/zone/back/methods/agency/specs/landsThatDay.spec.js b/modules/zone/back/methods/agency/specs/landsThatDay.spec.js index 7d207b383..ea10e708f 100644 --- a/modules/zone/back/methods/agency/specs/landsThatDay.spec.js +++ b/modules/zone/back/methods/agency/specs/landsThatDay.spec.js @@ -1,7 +1,7 @@ const app = require('vn-loopback/server/server'); describe('Agency landsThatDay()', () => { - const today = new Date(); + const today = Date.vnNew(); it('should return a list of agencies that can land a shipment on a day for an address', async() => { const tx = await app.models.Agency.beginTransaction({}); diff --git a/modules/zone/back/methods/zone/deleteZone.js b/modules/zone/back/methods/zone/deleteZone.js index fb228bcf4..e3846132b 100644 --- a/modules/zone/back/methods/zone/deleteZone.js +++ b/modules/zone/back/methods/zone/deleteZone.js @@ -22,7 +22,7 @@ module.exports = Self => { const models = Self.app.models; const token = ctx.req.accessToken; const userId = token.userId; - const today = new Date(); + const today = Date.vnNew(); today.setHours(0, 0, 0, 0); let tx; diff --git a/modules/zone/back/methods/zone/specs/exclusionGeo.spec.js b/modules/zone/back/methods/zone/specs/exclusionGeo.spec.js index 3a345f2ce..a34132be4 100644 --- a/modules/zone/back/methods/zone/specs/exclusionGeo.spec.js +++ b/modules/zone/back/methods/zone/specs/exclusionGeo.spec.js @@ -2,7 +2,7 @@ const models = require('vn-loopback/server/server').models; describe('zone exclusionGeo()', () => { const zoneId = 1; - const today = new Date(); + const today = Date.vnNew(); it(`should show an error when location isn't selected`, async() => { const tx = await models.Zone.beginTransaction({}); diff --git a/modules/zone/back/methods/zone/specs/getEventsFiltered.spec.js b/modules/zone/back/methods/zone/specs/getEventsFiltered.spec.js index 8160ee05e..6fd6bb994 100644 --- a/modules/zone/back/methods/zone/specs/getEventsFiltered.spec.js +++ b/modules/zone/back/methods/zone/specs/getEventsFiltered.spec.js @@ -6,7 +6,7 @@ describe('zone getEventsFiltered()', () => { try { const options = {transaction: tx}; - const today = new Date(); + const today = Date.vnNew(); const result = await models.Zone.getEventsFiltered(10, today, today, options); @@ -26,7 +26,7 @@ describe('zone getEventsFiltered()', () => { try { const options = {transaction: tx}; - const today = new Date(); + const today = Date.vnNew(); const result = await models.Zone.getEventsFiltered(9, today, today, options); @@ -45,7 +45,7 @@ describe('zone getEventsFiltered()', () => { try { const options = {transaction: tx}; - const date = new Date(); + const date = Date.vnNew(); date.setFullYear(date.getFullYear() - 2); const dateTomorrow = new Date(date.setDate(date.getDate() + 1)); diff --git a/modules/zone/back/methods/zone/specs/getZoneClosing.spec.js b/modules/zone/back/methods/zone/specs/getZoneClosing.spec.js index 4fb4b4e5c..cdd6fe584 100644 --- a/modules/zone/back/methods/zone/specs/getZoneClosing.spec.js +++ b/modules/zone/back/methods/zone/specs/getZoneClosing.spec.js @@ -6,7 +6,7 @@ describe('zone getZoneClosing()', () => { try { const options = {transaction: tx}; - const date = new Date(); + const date = Date.vnNew(); const today = date.toISOString().split('T')[0]; const result = await models.Zone.getZoneClosing([1, 2, 3], today, options); diff --git a/modules/zone/back/methods/zone/specs/includingExpired.spec.js b/modules/zone/back/methods/zone/specs/includingExpired.spec.js index 98fdc272d..121a84887 100644 --- a/modules/zone/back/methods/zone/specs/includingExpired.spec.js +++ b/modules/zone/back/methods/zone/specs/includingExpired.spec.js @@ -50,7 +50,7 @@ describe('zone includingExpired()', () => { it('should return an array containing available zones', async() => { const ctx = {req: {accessToken: {userId: 1}}}; const where = { - shipped: new Date(), + shipped: Date.vnNew(), addressFk: addressId, agencyModeFk: inhousePickupId, warehouseFk: warehouseId diff --git a/modules/zone/front/calendar/index.js b/modules/zone/front/calendar/index.js index 3bc7158ef..288a8f328 100644 --- a/modules/zone/front/calendar/index.js +++ b/modules/zone/front/calendar/index.js @@ -8,7 +8,7 @@ class Controller extends Component { this.vnWeekDays = vnWeekDays; this.nMonths = 4; - let date = new Date(); + let date = Date.vnNew(); date.setDate(1); date.setHours(0, 0, 0, 0); this.date = date; diff --git a/modules/zone/front/calendar/index.spec.js b/modules/zone/front/calendar/index.spec.js index 338f47917..43280a9e8 100644 --- a/modules/zone/front/calendar/index.spec.js +++ b/modules/zone/front/calendar/index.spec.js @@ -22,7 +22,7 @@ describe('component vnZoneCalendar', () => { it('should set the month property and then call the refreshEvents() method', () => { jest.spyOn(controller, 'refreshEvents').mockReturnThis(); - controller.date = new Date(); + controller.date = Date.vnNew(); expect(controller.refreshEvents).toHaveBeenCalledWith(); expect(controller.months.length).toEqual(4); @@ -31,7 +31,7 @@ describe('component vnZoneCalendar', () => { describe('step()', () => { it('should set the date month to 4 months backwards', () => { - const now = new Date(); + const now = Date.vnNew(); now.setDate(15); now.setMonth(now.getMonth() - 4); @@ -44,7 +44,7 @@ describe('component vnZoneCalendar', () => { }); it('should set the date month to 4 months forwards', () => { - const now = new Date(); + const now = Date.vnNew(); now.setDate(15); now.setMonth(now.getMonth() + 4); @@ -63,13 +63,13 @@ describe('component vnZoneCalendar', () => { controller.data = { exclusions: [{ - dated: new Date() + dated: Date.vnNew() }], events: [{ - dated: new Date() + dated: Date.vnNew() }], geoExclusions: [{ - dated: new Date() + dated: Date.vnNew() }], }; @@ -85,9 +85,9 @@ describe('component vnZoneCalendar', () => { describe('refreshEvents()', () => { it('should fill the days property with the events.', () => { controller.data = []; - controller.firstDay = new Date(); + controller.firstDay = Date.vnNew(); - const lastDay = new Date(); + const lastDay = Date.vnNew(); lastDay.setDate(lastDay.getDate() + 10); controller.lastDay = lastDay; @@ -114,7 +114,7 @@ describe('component vnZoneCalendar', () => { jest.spyOn(controller, 'emit'); const $event = {}; - const $days = [new Date()]; + const $days = [Date.vnNew()]; const $type = 'day'; const $weekday = 1; @@ -136,7 +136,7 @@ describe('component vnZoneCalendar', () => { describe('hasEvents()', () => { it('should return true for an existing event on a date', () => { - const dated = new Date(); + const dated = Date.vnNew(); controller.days[dated.getTime()] = true; @@ -148,7 +148,7 @@ describe('component vnZoneCalendar', () => { describe('getClass()', () => { it('should return the className "excluded" for an excluded date', () => { - const dated = new Date(); + const dated = Date.vnNew(); controller.exclusions = []; controller.exclusions[dated.getTime()] = true; @@ -159,7 +159,7 @@ describe('component vnZoneCalendar', () => { }); it('should return the className "geoExcluded" for a date with geo excluded', () => { - const dated = new Date(); + const dated = Date.vnNew(); controller.geoExclusions = []; controller.geoExclusions[dated.getTime()] = true; diff --git a/modules/zone/front/create/index.js b/modules/zone/front/create/index.js index 859204d8d..db337a9a3 100644 --- a/modules/zone/front/create/index.js +++ b/modules/zone/front/create/index.js @@ -7,7 +7,7 @@ export default class Controller extends Section { travelingDays: 0, price: 0.20, bonus: 0.20, - hour: new Date() + hour: Date.vnNew() }; } diff --git a/modules/zone/front/delivery-days/index.spec.js b/modules/zone/front/delivery-days/index.spec.js index 63c87fbea..28705880c 100644 --- a/modules/zone/front/delivery-days/index.spec.js +++ b/modules/zone/front/delivery-days/index.spec.js @@ -103,7 +103,7 @@ describe('Zone Component vnZoneDeliveryDays', () => { const target = document.createElement('div'); target.dispatchEvent(event); - const day = new Date(); + const day = Date.vnNew(); const events = [ {zoneFk: 1}, {zoneFk: 2}, diff --git a/modules/zone/front/descriptor/index.js b/modules/zone/front/descriptor/index.js index 08ada0606..3f4863a60 100644 --- a/modules/zone/front/descriptor/index.js +++ b/modules/zone/front/descriptor/index.js @@ -28,7 +28,7 @@ class Controller extends Descriptor { onDelete() { const $t = this.$translate.instant; - const today = new Date(); + const today = Date.vnNew(); today.setHours(0, 0, 0, 0); const filter = {where: {zoneFk: this.id, shipped: {gte: today}}}; this.$http.get(`Tickets`, {filter}).then(res => { diff --git a/modules/zone/front/events/index.spec.js b/modules/zone/front/events/index.spec.js index b4ff800d6..558d97b6f 100644 --- a/modules/zone/front/events/index.spec.js +++ b/modules/zone/front/events/index.spec.js @@ -68,7 +68,7 @@ describe('component vnZoneEvents', () => { it('should call the createInclusion() method', () => { jest.spyOn(controller, 'createInclusion').mockReturnThis(); - const weekday = {dated: new Date()}; + const weekday = {dated: Date.vnNew()}; const days = [weekday]; const type = 'EventType'; const events = []; @@ -114,7 +114,7 @@ describe('component vnZoneEvents', () => { jest.spyOn(controller, 'createExclusion').mockReturnThis(); const weekday = {}; - const days = [{dated: new Date()}]; + const days = [{dated: Date.vnNew()}]; const type = 'EventType'; const events = []; const exclusions = []; @@ -156,7 +156,7 @@ describe('component vnZoneEvents', () => { it('shoud set the excludeSelected property and then call the excludeDialog show() method', () => { controller.$.excludeDialog = {show: jest.fn()}; - const days = [new Date()]; + const days = [Date.vnNew()]; controller.createExclusion(days); expect(controller.excludeSelected).toBeDefined(); @@ -170,7 +170,7 @@ describe('component vnZoneEvents', () => { controller.$.includeDialog = {show: jest.fn()}; const type = 'weekday'; - const days = [new Date()]; + const days = [Date.vnNew()]; const weekday = 1; controller.createInclusion(type, days, weekday); @@ -187,7 +187,7 @@ describe('component vnZoneEvents', () => { controller.$.includeDialog = {show: jest.fn()}; const type = 'nonListedType'; - const days = [new Date()]; + const days = [Date.vnNew()]; const weekday = 1; controller.createInclusion(type, days, weekday); diff --git a/print/templates/email/buyer-week-waste/buyer-week-waste.js b/print/templates/email/buyer-week-waste/buyer-week-waste.js index 9d4fe1ce1..1ae40cd98 100755 --- a/print/templates/email/buyer-week-waste/buyer-week-waste.js +++ b/print/templates/email/buyer-week-waste/buyer-week-waste.js @@ -13,7 +13,7 @@ module.exports = { dated: function() { const filters = this.$options.filters; - return filters.date(new Date(), '%d-%m-%Y'); + return filters.date(Date.vnNew(), '%d-%m-%Y'); } }, methods: { diff --git a/print/templates/email/osticket-report/osticket-report.js b/print/templates/email/osticket-report/osticket-report.js index eb9c76a89..0d39947d5 100755 --- a/print/templates/email/osticket-report/osticket-report.js +++ b/print/templates/email/osticket-report/osticket-report.js @@ -37,7 +37,7 @@ module.exports = { dated: function() { const filters = this.$options.filters; - return filters.date(new Date(), '%d-%m-%Y'); + return filters.date(Date.vnNew(), '%d-%m-%Y'); }, startedTime: function() { return new Date(this.started).getTime(); diff --git a/print/templates/reports/balance-compensation/balance-compensation.js b/print/templates/reports/balance-compensation/balance-compensation.js index 98a9cf577..8709b8fd6 100644 --- a/print/templates/reports/balance-compensation/balance-compensation.js +++ b/print/templates/reports/balance-compensation/balance-compensation.js @@ -16,7 +16,7 @@ module.exports = { }, currentDate() { - const current = new Date(); + const current = Date.vnNew(); const date = `${current.getDate()}/${current.getMonth() + 1}/${current.getFullYear()}`; return date; } 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 5c7002e47..ec0aa79b3 100755 --- a/print/templates/reports/claim-pickup-order/claim-pickup-order.js +++ b/print/templates/reports/claim-pickup-order/claim-pickup-order.js @@ -15,7 +15,7 @@ module.exports = { dated: function() { const filters = this.$options.filters; - return filters.date(new Date(), '%d-%m-%Y'); + return filters.date(Date.vnNew(), '%d-%m-%Y'); } }, methods: { 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 45b97518f..b14d5c6aa 100755 --- a/print/templates/reports/client-debt-statement/client-debt-statement.js +++ b/print/templates/reports/client-debt-statement/client-debt-statement.js @@ -15,7 +15,7 @@ module.exports = { dated: function() { const filters = this.$options.filters; - return filters.date(new Date(), '%d-%m-%Y'); + return filters.date(Date.vnNew(), '%d-%m-%Y'); } }, data() { diff --git a/print/templates/reports/credit-request/credit-request.js b/print/templates/reports/credit-request/credit-request.js index c1aa74e1b..83a134c1d 100755 --- a/print/templates/reports/credit-request/credit-request.js +++ b/print/templates/reports/credit-request/credit-request.js @@ -8,7 +8,7 @@ const rptCreditRequest = { dated: function() { const filters = this.$options.filters; - return filters.date(new Date(), '%d-%m-%Y'); + return filters.date(Date.vnNew(), '%d-%m-%Y'); } }, components: { diff --git a/print/templates/reports/expedition-pallet-label/expedition-pallet-label.js b/print/templates/reports/expedition-pallet-label/expedition-pallet-label.js index 0e8c297e8..ea4a32830 100644 --- a/print/templates/reports/expedition-pallet-label/expedition-pallet-label.js +++ b/print/templates/reports/expedition-pallet-label/expedition-pallet-label.js @@ -27,7 +27,7 @@ module.exports = { let QRdata = JSON.stringify({ company: 'vnl', user: this.userFk, - created: new Date(), + created: Date.vnNew(), table: 'expeditionPallet', id: this.id }); diff --git a/print/templates/reports/extra-community/extra-community.js b/print/templates/reports/extra-community/extra-community.js index 4dfe6e278..2337320eb 100755 --- a/print/templates/reports/extra-community/extra-community.js +++ b/print/templates/reports/extra-community/extra-community.js @@ -41,7 +41,7 @@ module.exports = { }, computed: { dated: function() { - return this.filters.date(new Date(), '%d-%m-%Y'); + return this.filters.date(Date.vnNew(), '%d-%m-%Y'); }, landedEnd: function() { if (!this.landedTo) return; @@ -83,12 +83,12 @@ module.exports = { query = db.merge(query, where); query = db.merge(query, 'GROUP BY t.id'); query = db.merge(query, ` - ORDER BY - shipped ASC, - landed ASC, - travelFk, - loadPriority, - agencyModeFk, + ORDER BY + shipped ASC, + landed ASC, + travelFk, + loadPriority, + agencyModeFk, evaNotes `); diff --git a/print/templates/reports/incoterms-authorization/incoterms-authorization.js b/print/templates/reports/incoterms-authorization/incoterms-authorization.js index bfe675985..117152adc 100755 --- a/print/templates/reports/incoterms-authorization/incoterms-authorization.js +++ b/print/templates/reports/incoterms-authorization/incoterms-authorization.js @@ -12,7 +12,7 @@ module.exports = { }, computed: { issued: function() { - return new Date(); + return Date.vnNew(); } }, components: { diff --git a/print/templates/reports/item-label/item-label.js b/print/templates/reports/item-label/item-label.js index 6341bd11a..fe555d44a 100755 --- a/print/templates/reports/item-label/item-label.js +++ b/print/templates/reports/item-label/item-label.js @@ -17,7 +17,7 @@ module.exports = { dated() { const filters = this.$options.filters; - return filters.date(new Date(), '%W/%d'); + return filters.date(Date.vnNew(), '%W/%d'); }, labelPage() { const labelNumber = this.labelNumber ? this.labelNumber : 1; diff --git a/print/templates/reports/letter-debtor/letter-debtor.js b/print/templates/reports/letter-debtor/letter-debtor.js index 749fde4ed..2cb33926e 100755 --- a/print/templates/reports/letter-debtor/letter-debtor.js +++ b/print/templates/reports/letter-debtor/letter-debtor.js @@ -15,7 +15,7 @@ module.exports = { dated: function() { const filters = this.$options.filters; - return filters.date(new Date(), '%d-%m-%Y'); + return filters.date(Date.vnNew(), '%d-%m-%Y'); } }, data() { diff --git a/print/templates/reports/sepa-core/sepa-core.js b/print/templates/reports/sepa-core/sepa-core.js index ee8a64842..1a22e37ff 100755 --- a/print/templates/reports/sepa-core/sepa-core.js +++ b/print/templates/reports/sepa-core/sepa-core.js @@ -16,7 +16,7 @@ const rptSepaCore = { dated: function() { const filters = this.$options.filters; - return filters.date(new Date(), '%d-%m-%Y'); + return filters.date(Date.vnNew(), '%d-%m-%Y'); } }, methods: { From ea36c0deb5c512fbcabf109a792d865d45a3fb5b Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 17 Jan 2023 14:06:18 +0100 Subject: [PATCH 25/94] feat: el pdf de las rutas se descarga en un zip --- .../route/back/methods/route/downloadZip.js | 62 +++++++++++++++++++ modules/route/back/models/route.js | 1 + modules/route/front/index/index.js | 14 +++-- 3 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 modules/route/back/methods/route/downloadZip.js diff --git a/modules/route/back/methods/route/downloadZip.js b/modules/route/back/methods/route/downloadZip.js new file mode 100644 index 000000000..597f1d1f6 --- /dev/null +++ b/modules/route/back/methods/route/downloadZip.js @@ -0,0 +1,62 @@ +const JSZip = require('jszip'); + +module.exports = Self => { + Self.remoteMethodCtx('downloadZip', { + description: 'Download a zip file with multiple routes pdfs', + accessType: 'READ', + accepts: [ + { + arg: 'id', + type: 'string', + description: 'The routes ids', + } + ], + 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: '/downloadZip', + verb: 'GET' + } + }); + + Self.downloadZip = async function(ctx, id, options) { + const models = Self.app.models; + const myOptions = {}; + const zip = new JSZip(); + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const ids = id.split(','); + for (let id of ids) { + ctx.args.id = id; + const routePdf = await models.Route.driverRoutePdf(ctx, id); + const fileName = extractFileName(routePdf[2]); + const body = routePdf[0]; + + zip.file(fileName, body); + } + + const stream = zip.generateNodeStream({streamFiles: true}); + + return [stream, 'application/zip', `filename="download.zip"`]; + }; + + function extractFileName(str) { + const matches = str.match(/"(.*?)"/); + return matches ? matches[1] : str; + } +}; diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js index 08cabd30e..883f4597e 100644 --- a/modules/route/back/models/route.js +++ b/modules/route/back/models/route.js @@ -13,6 +13,7 @@ module.exports = Self => { require('../methods/route/driverRoutePdf')(Self); require('../methods/route/driverRouteEmail')(Self); require('../methods/route/sendSms')(Self); + require('../methods/route/downloadZip')(Self); Self.validate('kmStart', validateDistance, { message: 'Distance must be lesser than 1000' diff --git a/modules/route/front/index/index.js b/modules/route/front/index/index.js index 9258c8fac..273657cec 100644 --- a/modules/route/front/index/index.js +++ b/modules/route/front/index/index.js @@ -34,12 +34,16 @@ export default class Controller extends Section { } showRouteReport() { - const routes = []; + const routesIds = []; for (let route of this.checked) - routes.push(route.id); - const routesId = routes.join(','); - - this.vnReport.show(`Routes/${routesId}/driver-route-pdf`); + routesIds.push(route.id); + const stringRoutesIds = routesIds.join(','); + const serializedParams = this.$httpParamSerializer({ + access_token: this.vnToken.token, + id: stringRoutesIds + }); + const url = `api/Routes/downloadZip?${serializedParams}`; + window.open(url, '_blank'); } openClonationDialog() { From 849f4e1a6d4368db50a7e55910219c5af1064c85 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 17 Jan 2023 14:24:04 +0100 Subject: [PATCH 26/94] fix: frontTest --- modules/route/front/index/index.spec.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/route/front/index/index.spec.js b/modules/route/front/index/index.spec.js index 05dd56433..c1f414d5e 100644 --- a/modules/route/front/index/index.spec.js +++ b/modules/route/front/index/index.spec.js @@ -44,17 +44,15 @@ describe('Component vnRouteIndex', () => { describe('showRouteReport()', () => { it('should call to the vnReport show method', () => { - controller.vnReport.show = jest.fn(); + jest.spyOn(window, 'open').mockReturnThis(); const data = controller.$.model.data; data[0].checked = true; data[2].checked = true; - const routeIds = '1,3'; - controller.showRouteReport(); - expect(controller.vnReport.show).toHaveBeenCalledWith(`Routes/${routeIds}/driver-route-pdf`); + expect(window.open).toHaveBeenCalled(); }); }); From 8d33aa845418df08bf6d36ab60d27a7b372fd43b Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 17 Jan 2023 15:36:39 +0100 Subject: [PATCH 27/94] fix(fixtures): use static dates --- db/dump/fixtures.sql | 8 ++++---- e2e/paths/02-client/14_balance.spec.js | 2 +- front/core/services/date.js | 15 ++++++++------- front/salix/services/index.js | 16 ++++++++-------- jest-front.js | 7 ++++--- loopback/server/boot/date.js | 16 ++++++++-------- 6 files changed, 33 insertions(+), 31 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 9d31c9b33..9047f8b54 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -934,10 +934,10 @@ INSERT INTO `vn`.`expedition`(`id`, `agencyModeFk`, `ticketFk`, `freightItemFk`, (7, 2, 4, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -3 MONTH), 1, 18, NULL, 94, NULL,NULL), (8, 3, 5, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -4 MONTH), 1, 18, NULL, 94, 1, NULL), (9, 3, 6, 71, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 18, NULL, 94, 2, NULL), - (10, 7, 7, 71, NOW(), 1, 18, NULL, 94, 3, NULL), - (11, 7, 8, 71, NOW(), 1, 18, NULL, 94, 3, NULL), - (12, 7, 9, 71, NOW(), 1, 18, NULL, 94, 3, NULL), - (13, 1, 10,71, NOW(), 1, 18, NULL, 94, 3, NULL); + (10, 7, 7, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL), + (11, 7, 8, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL), + (12, 7, 9, 71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL), + (13, 1, 10,71, util.VN_NOW(), 1, 18, NULL, 94, 3, NULL); INSERT INTO `vn`.`expeditionState`(`id`, `created`, `expeditionFk`, `typeFk`, `userFk`) diff --git a/e2e/paths/02-client/14_balance.spec.js b/e2e/paths/02-client/14_balance.spec.js index d3de842e3..7906fc021 100644 --- a/e2e/paths/02-client/14_balance.spec.js +++ b/e2e/paths/02-client/14_balance.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors'; import getBrowser from '../../helpers/puppeteer'; -describe('Client balance path', () => { +fdescribe('Client balance path', () => { let browser; let page; beforeAll(async() => { diff --git a/front/core/services/date.js b/front/core/services/date.js index 0d013b9f6..977d77430 100644 --- a/front/core/services/date.js +++ b/front/core/services/date.js @@ -1,3 +1,11 @@ +Date.vnUTC = () => { + const env = process.env.NODE_ENV; + if (!env || env === 'development') + return new Date(Date.UTC(2022, 5, 15, 11)); + + return new Date(Date.UTC()); +}; + Date.vnNew = () => { return new Date(Date.vnUTC()); }; @@ -6,10 +14,3 @@ Date.vnNow = () => { return new Date(Date.vnUTC()).getTime(); }; -Date.vnUTC = () => { - const env = process.env.NODE_ENV; - if (!env || env === 'development') - return new Date(Date.UTC(2022, 5, 15, 11)); - - return new Date(Date.UTC()); -}; diff --git a/front/salix/services/index.js b/front/salix/services/index.js index 0fe541d1f..6d510638f 100644 --- a/front/salix/services/index.js +++ b/front/salix/services/index.js @@ -1,11 +1,3 @@ -Date.vnNew = () => { - return new Date(Date.vnUTC()); -}; - -Date.vnNow = () => { - return new Date(Date.vnUTC()).getTime(); -}; - Date.vnUTC = () => { const env = process.env.NODE_ENV; if (!env || env === 'development') @@ -13,3 +5,11 @@ Date.vnUTC = () => { return new Date(Date.UTC()); }; + +Date.vnNew = () => { + return new Date(Date.vnUTC()); +}; + +Date.vnNow = () => { + return new Date(Date.vnUTC()).getTime(); +}; diff --git a/jest-front.js b/jest-front.js index 45fed2319..0a2db5ec1 100644 --- a/jest-front.js +++ b/jest-front.js @@ -36,16 +36,17 @@ window.ngModule = function(moduleName, ...args) { if (args.length) fns = fns.concat(args); + Date.vnUTC = () => { - return new Date(Date.UTC(2000, 0, 1, 11)); + return new Date(Date.UTC(2022, 5, 15, 11)); }; Date.vnNew = () => { - return new Date(Date.UTC(2000, 0, 1, 11)); + return new Date(Date.UTC(2022, 5, 15, 11)); }; Date.vnNow = () => { - return new Date(Date.UTC(2000, 0, 1, 11)).getTime(); + return new Date(Date.UTC(2022, 5, 15, 11)).getTime(); }; return angular.mock.module(...fns); }; diff --git a/loopback/server/boot/date.js b/loopback/server/boot/date.js index 73eebf3be..27fbbd589 100644 --- a/loopback/server/boot/date.js +++ b/loopback/server/boot/date.js @@ -1,12 +1,4 @@ module.exports = () => { - Date.vnNew = () => { - return new Date(Date.vnUTC()); - }; - - Date.vnNow = () => { - return new Date(Date.vnUTC()).getTime(); - }; - Date.vnUTC = () => { const env = process.env.NODE_ENV; if (!env || env === 'development') @@ -14,4 +6,12 @@ module.exports = () => { return new Date(Date.UTC()); }; + + Date.vnNew = () => { + return new Date(Date.vnUTC()); + }; + + Date.vnNow = () => { + return new Date(Date.vnUTC()).getTime(); + }; }; From cc806cc08feaccc361a41850c9ee141696c86536 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Wed, 18 Jan 2023 07:41:10 +0100 Subject: [PATCH 28/94] requested changes --- back/models/notificationSubscription.js | 13 +++++-------- db/dump/structure.sql | 5 +++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/back/models/notificationSubscription.js b/back/models/notificationSubscription.js index eafa9d51b..674629413 100644 --- a/back/models/notificationSubscription.js +++ b/back/models/notificationSubscription.js @@ -7,9 +7,7 @@ module.exports = Self => { const user = await ctx.instance.userFk; const modifiedUser = await getUserToModify(null, user, models); - if (userId == modifiedUser.id || userId == modifiedUser.bossFk) - return; - else + if (userId != modifiedUser.id && userId != modifiedUser.bossFk) throw new UserError('You dont have permission to modify this user'); }); @@ -42,14 +40,13 @@ module.exports = Self => { const user = ctx.req.accessToken.userId; const modifiedUser = await getUserToModify(notificationId, null, models); - if (user == modifiedUser.id || modifiedUser.bossFk == user) { - await models.NotificationSubscription.destroyById(notificationId); - return; - } else + if (user != modifiedUser.id && user != modifiedUser.bossFk) throw new UserError('You dont have permission to modify this user'); + + await models.NotificationSubscription.destroyById(notificationId); }; - async function getUserToModify(notificationId = null, userFk = null, models) { + async function getUserToModify(notificationId, userFk, models) { if (notificationId != null) { const subscription = await models.NotificationSubscription.findById(notificationId); const user = await subscription.userFk; diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 510a51d94..4213f918a 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -19726,10 +19726,11 @@ DROP TABLE IF EXISTS `notificationSubscription`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `notificationSubscription` ( - `Id` int(11) NOT NULL AUTO_INCREMENT, + `id` int(11) NOT NULL AUTO_INCREMENT, `notificationFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, - PRIMARY KEY (`Id`), + PRIMARY KEY (`id`), + KEY `notificationSubscription_ibfk_1` (`notificationFk`), KEY `notificationSubscription_ibfk_2` (`userFk`), CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `notification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `notificationSubscription_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE From a5f83021dba3848bbb009c7cd86f3b658544d681 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Wed, 18 Jan 2023 09:06:17 +0100 Subject: [PATCH 29/94] requested changes --- back/models/notificationSubscription.js | 24 +++++++------------ .../00-uniqueKeyNotificationSubscription.sql | 4 ++++ 2 files changed, 13 insertions(+), 15 deletions(-) create mode 100644 db/changes/230201/00-uniqueKeyNotificationSubscription.sql diff --git a/back/models/notificationSubscription.js b/back/models/notificationSubscription.js index 674629413..f1b2811fa 100644 --- a/back/models/notificationSubscription.js +++ b/back/models/notificationSubscription.js @@ -47,22 +47,16 @@ module.exports = Self => { }; async function getUserToModify(notificationId, userFk, models) { - if (notificationId != null) { + let userToModify = userFk; + if (notificationId) { const subscription = await models.NotificationSubscription.findById(notificationId); - const user = await subscription.userFk; - return await models.Worker.findOne({ - fields: ['id', 'bossFk'], - where: { - id: user - } - }); - } else { - return await models.Worker.findOne({ - fields: ['id', 'bossFk'], - where: { - id: userFk - } - }); + userToModify = subscription.userFk; } + return await models.Worker.findOne({ + fields: ['id', 'bossFk'], + where: { + id: userToModify + } + }); } }; diff --git a/db/changes/230201/00-uniqueKeyNotificationSubscription.sql b/db/changes/230201/00-uniqueKeyNotificationSubscription.sql new file mode 100644 index 000000000..623ecf770 --- /dev/null +++ b/db/changes/230201/00-uniqueKeyNotificationSubscription.sql @@ -0,0 +1,4 @@ +ALTER TABLE + `util`.`notificationSubscription` +ADD + CONSTRAINT `notificationSubscription_UN` UNIQUE KEY (`notificationFk`, `userFk`); \ No newline at end of file From a425d54bf6bbcfe0294854ffb88e3a2e552728b3 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Wed, 18 Jan 2023 12:16:47 +0100 Subject: [PATCH 30/94] add back test --- .../specs/notificationSubscription.spec.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 back/models/specs/notificationSubscription.spec.js diff --git a/back/models/specs/notificationSubscription.spec.js b/back/models/specs/notificationSubscription.spec.js new file mode 100644 index 000000000..bcb1db9d8 --- /dev/null +++ b/back/models/specs/notificationSubscription.spec.js @@ -0,0 +1,22 @@ +const app = require('vn-loopback/server/server'); + +describe('loopback model NotificationSubscription', () => { + it('Should fail to delete a notification if the user is not editing itself or a subordinate', async() => { + const user = 9; + const notificationSubscriptionId = 2; + const ctx = {req: {accessToken: {userId: user}}}; + const models = app.models; + const notification = await models.NotificationSubscription.findById(notificationSubscriptionId); + + let error; + + try { + await models.NotificationSubscription.deleteNotification(ctx, notification.id); + } catch (e) { + error = e; + } + + expect(error.message).toContain('You dont have permission to modify this user'); + }); +}); + From c77f1b17a60b72f0ec7d0dfde4803742ca9f17b1 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 20 Jan 2023 08:32:18 +0100 Subject: [PATCH 31/94] movida sql a nueva carpeta changes --- db/changes/{230201 => 230401}/00-ACL_tag_update.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/changes/{230201 => 230401}/00-ACL_tag_update.sql (100%) diff --git a/db/changes/230201/00-ACL_tag_update.sql b/db/changes/230401/00-ACL_tag_update.sql similarity index 100% rename from db/changes/230201/00-ACL_tag_update.sql rename to db/changes/230401/00-ACL_tag_update.sql From 7148da7b72c1f26f563baa5e12a763eed0dd5817 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 20 Jan 2023 08:53:30 +0100 Subject: [PATCH 32/94] feat: cuando se descarga una sola factura, no descarga el zip --- CHANGELOG.md | 19 ++++++++++--------- modules/route/front/index/index.js | 18 ++++++++++++------ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8a04cfe8..bd3a13a7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,25 +8,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2304.01] - 2023-02-09 ### Added -- +- ### Changed -- +- ### Fixed -- +- ## [2302.01] - 2023-01-26 ### Added -- (General -> Inicio) Permite recuperar la contraseña -- (Tickets -> Opciones) Subir albarán a Docuware -- (Tickets -> Opciones) Enviar correo con PDF de Docuware -- (Artículos -> Datos Básicos) Añadido campo Unidades/Caja +- (General -> Inicio) Permite recuperar la contraseña +- (Tickets -> Opciones) Subir albarán a Docuware +- (Tickets -> Opciones) Enviar correo con PDF de Docuware +- (Artículos -> Datos Básicos) Añadido campo Unidades/Caja +- (Rutas) Al descargar varias facturas se comprime en un zip ### Changed -- (Reclamaciones -> Descriptor) Cambiado el campo Agencia por Zona -- (Tickets -> Líneas preparadas) Actualizada sección para que sea más visual +- (Reclamaciones -> Descriptor) Cambiado el campo Agencia por Zona +- (Tickets -> Líneas preparadas) Actualizada sección para que sea más visual ### Fixed - (General) Al utilizar el traductor de Google se descuadraban los iconos diff --git a/modules/route/front/index/index.js b/modules/route/front/index/index.js index 273657cec..94f6db09c 100644 --- a/modules/route/front/index/index.js +++ b/modules/route/front/index/index.js @@ -38,12 +38,18 @@ export default class Controller extends Section { for (let route of this.checked) routesIds.push(route.id); const stringRoutesIds = routesIds.join(','); - const serializedParams = this.$httpParamSerializer({ - access_token: this.vnToken.token, - id: stringRoutesIds - }); - const url = `api/Routes/downloadZip?${serializedParams}`; - window.open(url, '_blank'); + + if (this.checked.length <= 1) { + const url = `api/Routes/${stringRoutesIds}/driver-route-pdf?access_token=${this.vnToken.token}`; + window.open(url, '_blank'); + } else { + const serializedParams = this.$httpParamSerializer({ + access_token: this.vnToken.token, + id: stringRoutesIds + }); + const url = `api/Routes/downloadZip?${serializedParams}`; + window.open(url, '_blank'); + } } openClonationDialog() { From f30b1ecff1f3e2e2811ffa5a318c919f7db48dd3 Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 20 Jan 2023 10:03:00 +0100 Subject: [PATCH 33/94] refs #4927 changed hook for validateAsync --- modules/supplier/back/models/supplier.js | 41 ++++++++++++++++-------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index cba220af8..4e509aafc 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -113,24 +113,37 @@ module.exports = Self => { throw new UserError('You can not modify is pay method checked'); }); + Self.validateAsync('name', 'countryFk', hasSupplierSameName, { + message: 'A supplier with the same name already exists. Change the country.' + }); + + async function hasSupplierSameName(err, done) { + if (!this.name || !this.countryFk) done(); + const supplier = await Self.app.models.Supplier.findOne( + { + where: { + name: this.name, + countryFk: this.countryFk + }, + fields: ['id'] + }); + + if (supplier && supplier.id != this.id) + err(); + + done(); + } + Self.observe('before save', async function(ctx) { const changes = ctx.data || ctx.instance; const orgData = ctx.currentInstance; + + const socialName = changes.name || orgData.name; const hasChanges = orgData && changes; + const socialNameChanged = hasChanges + && orgData.socialName != socialName; - if (hasChanges) { - const name = changes.name || orgData.name; - const nameChanged = hasChanges && orgData.name != name; - const countryFk = changes.countryFk || orgData.countryFk; - const countryChanged = hasChanges && orgData.countryFk != countryFk; - - if (nameChanged || countryChanged) { - if (!isAlpha(name)) throw new UserError('The social name has an invalid format'); - - const supplier = await Self.app.models.Supplier.findOne({where: {name, countryFk}, fields: ['id']}); - if (supplier) - throw new UserError('A supplier with the same name already exists. Change the country.'); - } - } + if ((socialNameChanged) && !isAlpha(socialName)) + throw new UserError('The social name has an invalid format'); }); }; From b281a51d90e7ef3b813bf418e74b0b4ce04b13c0 Mon Sep 17 00:00:00 2001 From: alexandre Date: Fri, 20 Jan 2023 10:33:23 +0100 Subject: [PATCH 34/94] refs #4927 refresh structure --- db/dump/structure.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 772d6055d..4626279e4 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -80203,4 +80203,3 @@ USE `vncontrol`; -- Dump completed on 2022-11-21 7:57:28 - From 5a19e5801f9af4a12d0f7b9cdcc3daa0c92e28a7 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 23 Jan 2023 11:50:54 +0100 Subject: [PATCH 35/94] fix: enabled button when an error occurs --- front/core/components/smart-table/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 770dcdf32..24d121aac 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -589,7 +589,8 @@ export default class SmartTable extends Component { refresh() { this.isRefreshing = true; this.model.refresh() - .then(() => this.isRefreshing = false); + .then(() => this.isRefreshing = false) + .catch(() => this.isRefreshing = false); } } From 9eb65507b5d165f80fb39a3a798613c4137c23d9 Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 23 Jan 2023 14:43:31 +0100 Subject: [PATCH 36/94] fix: elimino this.model.refresh que siempre daba fallo --- front/core/components/smart-table/index.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 24d121aac..79c5c17c8 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -231,7 +231,6 @@ export default class SmartTable extends Component { } this.model.order = order; - this.refresh(); } registerColumns() { @@ -479,7 +478,6 @@ export default class SmartTable extends Component { const params = {q: JSON.stringify(stateFilter)}; this.$state.go(this.$state.current.name, params, {location: 'replace'}); - this.refresh(); } applySort() { @@ -500,7 +498,6 @@ export default class SmartTable extends Component { const params = {q: JSON.stringify(stateFilter)}; this.$state.go(this.$state.current.name, params, {location: 'replace'}); - this.refresh(); } filterSanitizer(field) { From 4a06b8e8a90a081726d88f9ae62833531501ce83 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 23 Jan 2023 15:16:42 +0100 Subject: [PATCH 37/94] fix: import date.js and fix e2e --- db/dump/fixtures.sql | 2 +- e2e/helpers/puppeteer.js | 1 + e2e/paths/02-client/14_balance.spec.js | 2 +- front/core/services/date.js | 13 +++++-------- front/salix/index.ejs | 2 +- front/salix/index.js | 2 +- front/salix/services/index.js | 15 --------------- jest-front.js | 15 ++++----------- jest.front.config.js | 1 + 9 files changed, 15 insertions(+), 38 deletions(-) delete mode 100644 front/salix/services/index.js diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 599a6dac9..6d88d53cb 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2,7 +2,7 @@ CREATE SCHEMA IF NOT EXISTS `vn2008`; CREATE SCHEMA IF NOT EXISTS `tmp`; UPDATE `util`.`config` - SET `environment`= 'test'; + SET `environment`= 'development'; ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1; diff --git a/e2e/helpers/puppeteer.js b/e2e/helpers/puppeteer.js index abd76b434..3e7643839 100644 --- a/e2e/helpers/puppeteer.js +++ b/e2e/helpers/puppeteer.js @@ -2,6 +2,7 @@ import Puppeteer from 'puppeteer'; import {extendPage} from './extensions'; import {url as defaultURL} from './config'; +import 'vn-loopback/server/boot/date.js'; export async function getBrowser() { const args = [ diff --git a/e2e/paths/02-client/14_balance.spec.js b/e2e/paths/02-client/14_balance.spec.js index 7906fc021..d3de842e3 100644 --- a/e2e/paths/02-client/14_balance.spec.js +++ b/e2e/paths/02-client/14_balance.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors'; import getBrowser from '../../helpers/puppeteer'; -fdescribe('Client balance path', () => { +describe('Client balance path', () => { let browser; let page; beforeAll(async() => { diff --git a/front/core/services/date.js b/front/core/services/date.js index 977d77430..3b7193d7b 100644 --- a/front/core/services/date.js +++ b/front/core/services/date.js @@ -1,16 +1,13 @@ -Date.vnUTC = () => { - const env = process.env.NODE_ENV; - if (!env || env === 'development') - return new Date(Date.UTC(2022, 5, 15, 11)); +// try import 'vn-loopback/server/boot/date'; - return new Date(Date.UTC()); +Date.vnUTC = () => { + return new Date(Date.UTC(2022, 5, 15, 11)); }; Date.vnNew = () => { - return new Date(Date.vnUTC()); + return new Date(Date.UTC(2022, 5, 15, 11)); }; Date.vnNow = () => { - return new Date(Date.vnUTC()).getTime(); + return new Date(Date.UTC(2022, 5, 15, 11)).getTime(); }; - diff --git a/front/salix/index.ejs b/front/salix/index.ejs index 1c13c3541..3aed9d9a6 100644 --- a/front/salix/index.ejs +++ b/front/salix/index.ejs @@ -10,7 +10,7 @@ diff --git a/front/salix/index.js b/front/salix/index.js index 5220f36f6..2488ef9b6 100644 --- a/front/salix/index.js +++ b/front/salix/index.js @@ -1,5 +1,5 @@ import './module'; import './routes'; import './components'; -import './services'; import './styles'; +import 'vn-loopback/server/boot/date'; diff --git a/front/salix/services/index.js b/front/salix/services/index.js deleted file mode 100644 index 6d510638f..000000000 --- a/front/salix/services/index.js +++ /dev/null @@ -1,15 +0,0 @@ -Date.vnUTC = () => { - const env = process.env.NODE_ENV; - if (!env || env === 'development') - return new Date(Date.UTC(2000, 0, 1, 11)); - - return new Date(Date.UTC()); -}; - -Date.vnNew = () => { - return new Date(Date.vnUTC()); -}; - -Date.vnNow = () => { - return new Date(Date.vnUTC()).getTime(); -}; diff --git a/jest-front.js b/jest-front.js index 0a2db5ec1..eabda9110 100644 --- a/jest-front.js +++ b/jest-front.js @@ -14,6 +14,10 @@ import './modules/ticket/front/module.js'; import './modules/travel/front/module.js'; import './modules/worker/front/module.js'; import './modules/shelving/front/module.js'; +import 'vn-loopback/server/boot/date'; + +// Set NODE_ENV +process.env.NODE_ENV = 'development'; core.run(vnInterceptor => { vnInterceptor.setApiPath(null); @@ -37,17 +41,6 @@ window.ngModule = function(moduleName, ...args) { if (args.length) fns = fns.concat(args); - Date.vnUTC = () => { - return new Date(Date.UTC(2022, 5, 15, 11)); - }; - - Date.vnNew = () => { - return new Date(Date.UTC(2022, 5, 15, 11)); - }; - - Date.vnNow = () => { - return new Date(Date.UTC(2022, 5, 15, 11)).getTime(); - }; return angular.mock.module(...fns); }; diff --git a/jest.front.config.js b/jest.front.config.js index a03c61d11..3289df8bb 100644 --- a/jest.front.config.js +++ b/jest.front.config.js @@ -1,5 +1,6 @@ // For a detailed explanation regarding each configuration property, visit: // https://jestjs.io/docs/en/configuration.html +/* eslint max-len: ["error", { "code": 150 }]*/ module.exports = { name: 'front end', From 092501f0ef95cd5861f15ec555734ae8ecc45acc Mon Sep 17 00:00:00 2001 From: vicent Date: Mon, 23 Jan 2023 21:29:48 +0100 Subject: [PATCH 38/94] actualizado changelof --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd3a13a7d..01620fee4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2304.01] - 2023-02-09 ### Added +- (Rutas) Al descargar varias facturas se comprime en un zip - ### Changed @@ -23,7 +24,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - (Tickets -> Opciones) Subir albarán a Docuware - (Tickets -> Opciones) Enviar correo con PDF de Docuware - (Artículos -> Datos Básicos) Añadido campo Unidades/Caja -- (Rutas) Al descargar varias facturas se comprime en un zip ### Changed - (Reclamaciones -> Descriptor) Cambiado el campo Agencia por Zona From ec5e2a21f7706ad5b69ec0c9d865889274a9db42 Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 24 Jan 2023 08:09:35 +0100 Subject: [PATCH 39/94] =?UTF-8?q?feat:=20a=C3=B1adido=20icono=20carro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/shelving/front/routes.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/shelving/front/routes.json b/modules/shelving/front/routes.json index 09a8e389b..4059e5095 100644 --- a/modules/shelving/front/routes.json +++ b/modules/shelving/front/routes.json @@ -1,12 +1,12 @@ { "module": "shelving", "name": "Shelvings", - "icon" : "contact_support", + "icon" : "icon-inventory", "dependencies": ["worker"], "validations" : true, "menus": { "main": [ - {"state": "shelving.index", "icon": "contact_support"} + {"state": "shelving.index", "icon": "icon-inventory"} ], "card": [ {"state": "shelving.card.basicData", "icon": "settings"}, @@ -20,7 +20,7 @@ "abstract": true, "component": "vn-shelving", "description": "Shelvings" - }, + }, { "url": "/index?q", "state": "shelving.index", @@ -32,13 +32,13 @@ "state": "shelving.create", "component": "vn-shelving-create", "description": "New shelving" - }, + }, { "url": "/:id", "state": "shelving.card", "abstract": true, "component": "vn-shelving-card" - }, + }, { "url": "/summary", "state": "shelving.card.summary", @@ -47,7 +47,7 @@ "params": { "shelving": "$ctrl.shelving" } - }, + }, { "url": "/basic-data", "state": "shelving.card.basicData", @@ -56,7 +56,7 @@ "params": { "shelving": "$ctrl.shelving" } - }, + }, { "url" : "/log", "state": "shelving.card.log", @@ -64,4 +64,4 @@ "description": "Log" } ] -} \ No newline at end of file +} From c13bffcc573817e7b4e075f7fd872b40df330ceb Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 24 Jan 2023 10:11:16 +0100 Subject: [PATCH 40/94] refs #4797 @1h requested changes --- .../specs/notificationSubscription.spec.js | 78 +++++++++++++++---- .../00-acl_notifications.sql | 0 db/changes/230401/00-alter_notSubs.sql | 10 +++ db/dump/fixtures.sql | 5 +- 4 files changed, 79 insertions(+), 14 deletions(-) rename db/changes/{230201 => 230401}/00-acl_notifications.sql (100%) create mode 100644 db/changes/230401/00-alter_notSubs.sql diff --git a/back/models/specs/notificationSubscription.spec.js b/back/models/specs/notificationSubscription.spec.js index bcb1db9d8..b1a54e0c2 100644 --- a/back/models/specs/notificationSubscription.spec.js +++ b/back/models/specs/notificationSubscription.spec.js @@ -1,22 +1,74 @@ -const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; describe('loopback model NotificationSubscription', () => { it('Should fail to delete a notification if the user is not editing itself or a subordinate', async() => { - const user = 9; - const notificationSubscriptionId = 2; - const ctx = {req: {accessToken: {userId: user}}}; - const models = app.models; - const notification = await models.NotificationSubscription.findById(notificationSubscriptionId); - - let error; + const tx = await models.NotificationSubscription.beginTransaction({}); try { - await models.NotificationSubscription.deleteNotification(ctx, notification.id); - } catch (e) { - error = e; - } + const options = {transaction: tx}; + const user = 9; + const notificationSubscriptionId = 2; + const ctx = {req: {accessToken: {userId: user}}}; + const notification = await models.NotificationSubscription.findById(notificationSubscriptionId); - expect(error.message).toContain('You dont have permission to modify this user'); + let error; + + try { + await models.NotificationSubscription.deleteNotification(ctx, notification.id, options); + } catch (e) { + error = e; + } + + expect(error.message).toContain('You dont have permission to modify this user'); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('Should delete a notification if the user is editing itself', async() => { + const tx = await models.NotificationSubscription.beginTransaction({}); + + try { + const options = {transaction: tx}; + const user = 9; + const notificationSubscriptionId = 5; + const ctx = {req: {accessToken: {userId: user}}}; + const notification = await models.NotificationSubscription.findById(notificationSubscriptionId); + + await models.NotificationSubscription.deleteNotification(ctx, notification.id, options); + + const deletedNotification = await models.NotificationSubscription.findById(notificationSubscriptionId); + + expect(deletedNotification).toBeNull(); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('Should delete a notification if the user is editing a subordinate', async() => { + const tx = await models.NotificationSubscription.beginTransaction({}); + + try { + const options = {transaction: tx}; + const user = 9; + const notificationSubscriptionId = 6; + const ctx = {req: {accessToken: {userId: user}}}; + const notification = await models.NotificationSubscription.findById(notificationSubscriptionId); + + await models.NotificationSubscription.deleteNotification(ctx, notification.id, options); + + const deletedNotification = await models.NotificationSubscription.findById(notificationSubscriptionId); + + expect(deletedNotification).toBeNull(); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } }); }); diff --git a/db/changes/230201/00-acl_notifications.sql b/db/changes/230401/00-acl_notifications.sql similarity index 100% rename from db/changes/230201/00-acl_notifications.sql rename to db/changes/230401/00-acl_notifications.sql diff --git a/db/changes/230401/00-alter_notSubs.sql b/db/changes/230401/00-alter_notSubs.sql new file mode 100644 index 000000000..3ead323b0 --- /dev/null +++ b/db/changes/230401/00-alter_notSubs.sql @@ -0,0 +1,10 @@ +CREATE OR REPLACE TABLE `util`.`notificationSubscription` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `notificationFk` int(11) NOT NULL, + `userFk` int(10) unsigned NOT NULL, + PRIMARY KEY (`id`), + KEY `notificationSubscription_ibfk_1` (`notificationFk`), + KEY `notificationSubscription_ibfk_2` (`userFk`), + CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `notification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `notificationSubscription_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 0783a06df..bb4f00ff5 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2701,7 +2701,10 @@ INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) VALUES (1, 1109), (1, 1110), - (3, 1109); + (3, 1109), + (1,9), + (1,3); + INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) VALUES From a2150b8b080cb62a207d05d4eb2e37c143d0fc1d Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 24 Jan 2023 10:15:32 +0100 Subject: [PATCH 41/94] change test to adhere to the fixtures --- back/models/specs/notificationSubscription.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/back/models/specs/notificationSubscription.spec.js b/back/models/specs/notificationSubscription.spec.js index b1a54e0c2..c7f37abed 100644 --- a/back/models/specs/notificationSubscription.spec.js +++ b/back/models/specs/notificationSubscription.spec.js @@ -33,7 +33,7 @@ describe('loopback model NotificationSubscription', () => { try { const options = {transaction: tx}; const user = 9; - const notificationSubscriptionId = 5; + const notificationSubscriptionId = 4; const ctx = {req: {accessToken: {userId: user}}}; const notification = await models.NotificationSubscription.findById(notificationSubscriptionId); @@ -55,7 +55,7 @@ describe('loopback model NotificationSubscription', () => { try { const options = {transaction: tx}; const user = 9; - const notificationSubscriptionId = 6; + const notificationSubscriptionId = 5; const ctx = {req: {accessToken: {userId: user}}}; const notification = await models.NotificationSubscription.findById(notificationSubscriptionId); From 5a70fd4779d3c2bcd850c719b34761b8e0e32d0d Mon Sep 17 00:00:00 2001 From: vicent Date: Tue, 24 Jan 2023 14:45:35 +0100 Subject: [PATCH 42/94] fix: las peticiones no colisionan --- front/core/components/smart-table/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 79c5c17c8..416d24d16 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -231,6 +231,7 @@ export default class SmartTable extends Component { } this.model.order = order; + this.refresh(); } registerColumns() { @@ -477,7 +478,8 @@ export default class SmartTable extends Component { const params = {q: JSON.stringify(stateFilter)}; - this.$state.go(this.$state.current.name, params, {location: 'replace'}); + this.$state.go(this.$state.current.name, params, {location: 'replace'}) + .then(() => this.refresh()); } applySort() { @@ -497,7 +499,8 @@ export default class SmartTable extends Component { stateFilter.tableOrder = order; const params = {q: JSON.stringify(stateFilter)}; - this.$state.go(this.$state.current.name, params, {location: 'replace'}); + this.$state.go(this.$state.current.name, params, {location: 'replace'}) + .then(() => this.refresh()); } filterSanitizer(field) { From eb59efbb85d19b42f3b4a8943f61b32cc70db636 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 24 Jan 2023 15:12:16 +0100 Subject: [PATCH 43/94] refactor(front): use vn-loopback/boot/date --- front/core/services/date.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/front/core/services/date.js b/front/core/services/date.js index 3b7193d7b..120297951 100644 --- a/front/core/services/date.js +++ b/front/core/services/date.js @@ -1,13 +1,2 @@ -// try import 'vn-loopback/server/boot/date'; - -Date.vnUTC = () => { - return new Date(Date.UTC(2022, 5, 15, 11)); -}; - -Date.vnNew = () => { - return new Date(Date.UTC(2022, 5, 15, 11)); -}; - -Date.vnNow = () => { - return new Date(Date.UTC(2022, 5, 15, 11)).getTime(); -}; +import * as date from 'vn-loopback/server/boot/date'; +date.default(); From d77730dd47607141fd2488f004f11276564cb647 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 25 Jan 2023 10:10:25 +0100 Subject: [PATCH 44/94] fix: mockedDate in e2e --- back/methods/collection/setSaleQuantity.js | 2 +- e2e/helpers/puppeteer.js | 1 - e2e/helpers/tests.js | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/back/methods/collection/setSaleQuantity.js b/back/methods/collection/setSaleQuantity.js index b6c56ddc4..4ac3d6d4b 100644 --- a/back/methods/collection/setSaleQuantity.js +++ b/back/methods/collection/setSaleQuantity.js @@ -24,7 +24,7 @@ module.exports = Self => { } }); - Self.setSaleQuantity = async(saleId, quantity) => { + Self.setSaleQuantity = async(saleId, quantity, options) => { const models = Self.app.models; const myOptions = {}; let tx; diff --git a/e2e/helpers/puppeteer.js b/e2e/helpers/puppeteer.js index 3e7643839..abd76b434 100644 --- a/e2e/helpers/puppeteer.js +++ b/e2e/helpers/puppeteer.js @@ -2,7 +2,6 @@ import Puppeteer from 'puppeteer'; import {extendPage} from './extensions'; import {url as defaultURL} from './config'; -import 'vn-loopback/server/boot/date.js'; export async function getBrowser() { const args = [ diff --git a/e2e/helpers/tests.js b/e2e/helpers/tests.js index aac9963dd..992ec051f 100644 --- a/e2e/helpers/tests.js +++ b/e2e/helpers/tests.js @@ -1,6 +1,7 @@ require('@babel/register')({presets: ['@babel/env']}); require('core-js/stable'); require('regenerator-runtime/runtime'); +require('vn-loopback/server/boot/date')(); const axios = require('axios'); const Docker = require('../../db/docker.js'); From 0a096bc96fd24acee677f00440b29f7c322f5d6d Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 25 Jan 2023 15:29:01 +0100 Subject: [PATCH 45/94] fix: updateWorkCenter --- db/dump/mockDate.sql | 2 +- loopback/server/boot/date.js | 2 +- modules/route/back/methods/route/updateWorkCenter.js | 5 +++-- .../worker/back/methods/worker/specs/getWorkedHours.spec.js | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/db/dump/mockDate.sql b/db/dump/mockDate.sql index 5334bbe81..6452b38da 100644 --- a/db/dump/mockDate.sql +++ b/db/dump/mockDate.sql @@ -7,7 +7,7 @@ CREATE FUNCTION `util`.`mockedDate`() RETURNS DATETIME DETERMINISTIC BEGIN - RETURN '2022-06-15 11:00:00'; + RETURN '2000-06-15 11:00:00'; END ;; DELIMITER ; diff --git a/loopback/server/boot/date.js b/loopback/server/boot/date.js index 27fbbd589..e56393437 100644 --- a/loopback/server/boot/date.js +++ b/loopback/server/boot/date.js @@ -2,7 +2,7 @@ module.exports = () => { Date.vnUTC = () => { const env = process.env.NODE_ENV; if (!env || env === 'development') - return new Date(Date.UTC(2022, 5, 15, 11)); + return new Date(Date.UTC(2000, 5, 15, 11)); return new Date(Date.UTC()); }; diff --git a/modules/route/back/methods/route/updateWorkCenter.js b/modules/route/back/methods/route/updateWorkCenter.js index 7796fba41..75169ce7e 100644 --- a/modules/route/back/methods/route/updateWorkCenter.js +++ b/modules/route/back/methods/route/updateWorkCenter.js @@ -33,12 +33,13 @@ module.exports = Self => { } try { + const date = Date.vnNew(); const [result] = await Self.rawSql(` SELECT IFNULL(wl.workCenterFk, r.defaultWorkCenterFk) AS commissionWorkCenter FROM vn.routeConfig r LEFT JOIN vn.workerLabour wl ON wl.workerFk = ? - AND CURDATE() BETWEEN wl.started AND IFNULL(wl.ended, CURDATE()); - `, [userId], myOptions); + AND ? BETWEEN wl.started AND IFNULL(wl.ended, ?); + `, [userId, date, date], myOptions); const route = await models.Route.findById(id, null, myOptions); await route.updateAttribute('commissionWorkCenterFk', result.commissionWorkCenter, myOptions); diff --git a/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js b/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js index f5b06cc9e..a6117e68a 100644 --- a/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js +++ b/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -describe('Worker getWorkedHours()', () => { +fdescribe('Worker getWorkedHours()', () => { it(`should return the expected hours and the worked hours of a given date`, async() => { const workerID = 1106; const started = Date.vnNew(); From 51400b1c747e1cf9e1e2552c2e241de7dadb60e1 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 26 Jan 2023 08:19:52 +0100 Subject: [PATCH 46/94] =?UTF-8?q?reactor:=20eliminado=20try=20y=20catch,?= =?UTF-8?q?=20y=20a=C3=B1adido=20finally?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/core/components/smart-table/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/front/core/components/smart-table/index.js b/front/core/components/smart-table/index.js index 416d24d16..ad9883950 100644 --- a/front/core/components/smart-table/index.js +++ b/front/core/components/smart-table/index.js @@ -589,8 +589,7 @@ export default class SmartTable extends Component { refresh() { this.isRefreshing = true; this.model.refresh() - .then(() => this.isRefreshing = false) - .catch(() => this.isRefreshing = false); + .finally(() => this.isRefreshing = false); } } From 3184dcd39d8d51974b9c62dd9e41035eb0ba891c Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Thu, 26 Jan 2023 08:41:12 +0100 Subject: [PATCH 47/94] requested changes --- db/changes/230401/00-acl_notifications.sql | 6 +++--- db/changes/230401/00-alter_notSubs.sql | 14 ++++---------- db/dump/structure.sql | 3 +-- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/db/changes/230401/00-acl_notifications.sql b/db/changes/230401/00-acl_notifications.sql index 4b86e2cd0..ab40b16a5 100644 --- a/db/changes/230401/00-acl_notifications.sql +++ b/db/changes/230401/00-acl_notifications.sql @@ -1,4 +1,4 @@ INSERT INTO `salix`.`ACL` (model,property,accessType,principalId) - VALUES ('NotificationSubscription','*','*','employee'); -INSERT INTO `salix`.`ACL` (model,property,accessType,principalId) - VALUES ('NotificationAcl','*','*','employee'); + VALUES + ('NotificationSubscription','*','*','employee'), + ('NotificationAcl','*','READ','employee'); diff --git a/db/changes/230401/00-alter_notSubs.sql b/db/changes/230401/00-alter_notSubs.sql index 3ead323b0..a4177bba4 100644 --- a/db/changes/230401/00-alter_notSubs.sql +++ b/db/changes/230401/00-alter_notSubs.sql @@ -1,10 +1,4 @@ -CREATE OR REPLACE TABLE `util`.`notificationSubscription` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `notificationFk` int(11) NOT NULL, - `userFk` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `notificationSubscription_ibfk_1` (`notificationFk`), - KEY `notificationSubscription_ibfk_2` (`userFk`), - CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `notification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `notificationSubscription_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +ALTER TABLE util.notificationSubscription +ADD Id int(11) auto_increment NULL, +DROP PRIMARY KEY, +ADD CONSTRAINT PRIMARY KEY (Id); diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 97d7603f6..831296bc6 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -19726,10 +19726,9 @@ DROP TABLE IF EXISTS `notificationSubscription`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `notificationSubscription` ( - `id` int(11) NOT NULL AUTO_INCREMENT, `notificationFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), + PRIMARY KEY (`notificationFk`,`userFk`), KEY `notificationSubscription_ibfk_1` (`notificationFk`), KEY `notificationSubscription_ibfk_2` (`userFk`), CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `notification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, From 25f0c0d9e3b0cd6f0695f1b50037a52be6af2cb9 Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 26 Jan 2023 14:16:30 +0100 Subject: [PATCH 48/94] refs #5141 province added --- modules/claim/front/card/index.js | 24 +++++++++++++++++++---- modules/claim/front/descriptor/index.html | 6 +++++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/modules/claim/front/card/index.js b/modules/claim/front/card/index.js index 8fb35db75..4a8677c90 100644 --- a/modules/claim/front/card/index.js +++ b/modules/claim/front/card/index.js @@ -19,10 +19,26 @@ class Controller extends ModuleCard { }, { relation: 'ticket', scope: { - fields: ['zoneFk'], - include: { - relation: 'zone' - } + fields: ['zoneFk', 'addressFk'], + include: [ + { + relation: 'zone', + scope: { + fields: ['name'] + } + }, + { + relation: 'address', + scope: { + fields: ['provinceFk'], + include: { + relation: 'province', + scope: { + fields: ['name'] + } + } + } + }] } }, { relation: 'claimState', diff --git a/modules/claim/front/descriptor/index.html b/modules/claim/front/descriptor/index.html index 90246824b..f346ecf17 100644 --- a/modules/claim/front/descriptor/index.html +++ b/modules/claim/front/descriptor/index.html @@ -55,9 +55,13 @@ - {{$ctrl.claim.ticket.zoneFk}} + {{$ctrl.claim.ticket.zone.name}} + + Date: Fri, 27 Jan 2023 10:05:03 +0100 Subject: [PATCH 49/94] refs #5077 hours set 00:00:00 only when date change --- modules/ticket/front/basic-data/step-one/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/ticket/front/basic-data/step-one/index.js b/modules/ticket/front/basic-data/step-one/index.js index f532265e2..99782de44 100644 --- a/modules/ticket/front/basic-data/step-one/index.js +++ b/modules/ticket/front/basic-data/step-one/index.js @@ -75,8 +75,10 @@ class Controller extends Component { } set shipped(value) { + if (new Date(this.ticket.shipped).toDateString() != value.toDateString()) + value.setHours(0, 0, 0, 0); + this.ticket.shipped = value; - this.ticket.shipped.setHours(0, 0, 0, 0); this.getLanded({ shipped: value, addressFk: this.ticket.addressFk, From b1de5bc94e263814a4efc71473b2d5931ad58b92 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Fri, 27 Jan 2023 10:06:46 +0100 Subject: [PATCH 50/94] refs #5174, fix banch being created from another branch and not from dev --- e2e/helpers/selectors.js | 12 +- modules/ticket/front/weekly/index.html | 187 ++++++++++++++----------- modules/ticket/front/weekly/index.js | 39 ++++++ 3 files changed, 150 insertions(+), 88 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index a1412f431..d405278a5 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -562,15 +562,15 @@ export default { payoutBank: '.vn-dialog vn-autocomplete[ng-model="$ctrl.bankFk"]', payoutDescription: 'vn-textfield[ng-model="$ctrl.receipt.description"]', submitPayout: '.vn-dialog button[response="accept"]', - searchWeeklyResult: 'vn-ticket-weekly-index vn-table vn-tbody > vn-tr', + searchWeeklyResult: 'vn-ticket-weekly-index vn-card smart-table slot-table table tbody tr', searchResultDate: 'vn-ticket-summary [label=Landed] span', topbarSearch: 'vn-searchbar', moreMenu: 'vn-ticket-index vn-icon-button[icon=more_vert]', - fourthWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tbody vn-tr:nth-child(4)', - fiveWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tbody vn-tr:nth-child(5)', - weeklyTicket: 'vn-ticket-weekly-index vn-table > div > vn-tbody > vn-tr', - firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-tr:nth-child(1) vn-icon-button[icon="delete"]', - firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-tr:nth-child(1) [ng-model="weekly.agencyModeFk"]', + fourthWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(4)', + fiveWeeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(5)', + weeklyTicket: 'vn-ticket-weekly-index vn-card smart-table slot-table table tbody tr', + firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(1) vn-icon-button[icon="delete"]', + firstWeeklyTicketAgency: 'vn-ticket-weekly-index vn-card smart-table slot-table tr:nth-child(1) [ng-model="weekly.agencyModeFk"]', acceptDeleteTurn: '.vn-confirm.shown button[response="accept"]' }, createTicketView: { diff --git a/modules/ticket/front/weekly/index.html b/modules/ticket/front/weekly/index.html index 3c739d5f9..ca3b6e662 100644 --- a/modules/ticket/front/weekly/index.html +++ b/modules/ticket/front/weekly/index.html @@ -17,87 +17,110 @@ model="model"> - - - - - - Ticket ID - Client - Shipment - Agency - Warehouse - Salesperson - - - - - - - - {{weekly.ticketFk}} - - - - - {{::weekly.clientName}} - - - - - - - - - - - {{::weekly.warehouseName}} - - - {{::weekly.userName}} - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Ticket ID + + Client + + Shipment + + Agency + + Warehouse + + Salesperson +
+ + {{weekly.ticketFk}} + + + + {{::weekly.clientName}} + + + + + + + + {{weekly.warehouseName}} + + {{::weekly.userName}} + + + + +
+
+
+
@@ -112,4 +135,4 @@ on-accept="$ctrl.onDeleteWeeklyAccept($data)" question="This ticket will be removed from weekly tickets! Continue anyway?" message="You are going to delete this weekly ticket"> - + \ No newline at end of file diff --git a/modules/ticket/front/weekly/index.js b/modules/ticket/front/weekly/index.js index 71365c4b3..a10ff7184 100644 --- a/modules/ticket/front/weekly/index.js +++ b/modules/ticket/front/weekly/index.js @@ -1,3 +1,4 @@ + import ngModule from '../module'; import Section from 'salix/components/section'; @@ -15,6 +16,44 @@ export default class Controller extends Section { {id: 5, name: 'Saturday'}, {id: 6, name: 'Sunday'} ]; + + this.smartTableOptions = { + activeButtons: { + search: true, + shownColumns: true, + }, + columns: [ + { + field: 'ticketFk', + searchable: false + }, + { + field: 'clientName', + }, + { + field: 'weekDay', + searchable: false, + }, + { + field: 'agencyModeFk', + searchable: false, + }, + { + field: 'warehouseFk', + searchable: false, + }, + { + field: 'nickname', + }, + ] + }; + } + + exprBuilder(param, value) { + switch (param) { + case 'clientName': return {'c.name': value}; + case 'nickName': return {'u.name': value}; + } } onUpdate(ticketFk, field, value) { From 29c6ca35ff112093d47d1b193f12bd3f1fd2e597 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 27 Jan 2023 13:39:19 +0100 Subject: [PATCH 51/94] fix: test e2e --- modules/item/back/methods/tag/onSubmit.js | 24 ++++++----------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/modules/item/back/methods/tag/onSubmit.js b/modules/item/back/methods/tag/onSubmit.js index aec67e92a..7abbe60d4 100644 --- a/modules/item/back/methods/tag/onSubmit.js +++ b/modules/item/back/methods/tag/onSubmit.js @@ -47,44 +47,32 @@ module.exports = function(Self) { } try { - const promises = []; - if (args.deletes) { - for (const itemTagId of args.deletes) { - const itemTagDeleted = models.ItemTag.destroyById(itemTagId, myOptions); - promises.push(itemTagDeleted); - } + for (const itemTagId of args.deletes) + await models.ItemTag.destroyById(itemTagId, myOptions); } if (args.updates) { for (const row of args.updates) { if (row.data.priority) { const itemTag = await models.ItemTag.findById(row.where.id, null, myOptions); - const itemTagUpdatedPriority = itemTag.updateAttributes({ + await itemTag.updateAttributes({ priority: row.data.priority + args.maxPriority }, myOptions); - promises.push(itemTagUpdatedPriority); } } for (const row of args.updates) { const itemTag = await models.ItemTag.findById(row.where.id, null, myOptions); - const itemTagUpdated = itemTag.updateAttributes(row.data, myOptions); - promises.push(itemTagUpdated); + await itemTag.updateAttributes(row.data, myOptions); } } if (args.creates) { - for (const itemTag of args.creates) { - const newItemTag = models.ItemTag.create(itemTag, myOptions); - promises.push(newItemTag); - } + for (const itemTag of args.creates) + await models.ItemTag.create(itemTag, myOptions); } - const resolvedPromises = await Promise.all(promises); - if (tx) await tx.commit(); - - return resolvedPromises; } catch (e) { if (tx) await tx.rollback(); throw e; From 79bf1739baff7947c697ac5473a1f76294b18726 Mon Sep 17 00:00:00 2001 From: vicent Date: Fri, 27 Jan 2023 13:52:14 +0100 Subject: [PATCH 52/94] fix: backTest --- modules/item/back/methods/tag/specs/onSubmit.spec.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/modules/item/back/methods/tag/specs/onSubmit.spec.js b/modules/item/back/methods/tag/specs/onSubmit.spec.js index a8077db67..f24aad7e4 100644 --- a/modules/item/back/methods/tag/specs/onSubmit.spec.js +++ b/modules/item/back/methods/tag/specs/onSubmit.spec.js @@ -12,9 +12,8 @@ describe('tag onSubmit()', () => { deletes: deletes } }; - const result = await models.Tag.onSubmit(ctx, options); + await models.Tag.onSubmit(ctx, options); - expect(result.length).toEqual(1); await tx.rollback(); } catch (e) { await tx.rollback(); @@ -33,9 +32,8 @@ describe('tag onSubmit()', () => { updates: updates } }; - const result = await models.Tag.onSubmit(ctx, options); + await models.Tag.onSubmit(ctx, options); - expect(result.length).toEqual(1); await tx.rollback(); } catch (e) { await tx.rollback(); @@ -62,9 +60,8 @@ describe('tag onSubmit()', () => { creates: creates } }; - const result = await models.Tag.onSubmit(ctx, options); + await models.Tag.onSubmit(ctx, options); - expect(result.length).toEqual(1); await tx.rollback(); } catch (e) { await tx.rollback(); @@ -88,9 +85,8 @@ describe('tag onSubmit()', () => { } }; - const result = await models.Tag.onSubmit(ctx, options); + await models.Tag.onSubmit(ctx, options); - expect(result.length).toEqual(4); await tx.rollback(); } catch (e) { await tx.rollback(); From 7e5f50e637a8e8f67e2527a1de46a556d1d4db26 Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 30 Jan 2023 08:30:39 +0100 Subject: [PATCH 53/94] refs #5072 email validation added --- db/changes/230401/00-updateIsToBeMailed.sql | 6 ++++++ loopback/locale/es.json | 3 ++- modules/client/back/models/client.js | 10 ++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 db/changes/230401/00-updateIsToBeMailed.sql diff --git a/db/changes/230401/00-updateIsToBeMailed.sql b/db/changes/230401/00-updateIsToBeMailed.sql new file mode 100644 index 000000000..c04090663 --- /dev/null +++ b/db/changes/230401/00-updateIsToBeMailed.sql @@ -0,0 +1,6 @@ +UPDATE vn.client + SET isToBeMailed = FALSE + WHERE + mailAddress is NULL + AND email is NULL + AND isToBeMailed = TRUE; diff --git a/loopback/locale/es.json b/loopback/locale/es.json index d65054f37..1bf6c18f0 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -259,5 +259,6 @@ "Try again": "Vuelve a intentarlo", "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9", "Failed to upload file": "Error al subir archivo", - "The DOCUWARE PDF document does not exists": "The DOCUWARE PDF document does not exists" + "The DOCUWARE PDF document does not exists": "The DOCUWARE PDF document does not exists", + "There is no assigned email for this client": "No hay correo asignado para este cliente" } diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index e07993f79..2d8e7bd27 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -141,6 +141,16 @@ module.exports = Self => { done(); } + Self.validateAsync('isToBeMailed', isToBeMailed, { + message: 'There is no assigned email for this client' + }); + + function isToBeMailed(err, done) { + if (this.isToBeMailed == true && !this.email) + err(); + done(); + } + Self.validateAsync('defaultAddressFk', isActive, {message: 'Unable to default a disabled consignee'} ); From fbf252b634772ff61c9f6bba70aa8c00bcfd5014 Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 30 Jan 2023 08:31:56 +0100 Subject: [PATCH 54/94] refs #5072 template strings --- db/changes/230401/00-updateIsToBeMailed.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/changes/230401/00-updateIsToBeMailed.sql b/db/changes/230401/00-updateIsToBeMailed.sql index c04090663..1bb177f57 100644 --- a/db/changes/230401/00-updateIsToBeMailed.sql +++ b/db/changes/230401/00-updateIsToBeMailed.sql @@ -1,4 +1,4 @@ -UPDATE vn.client +UPDATE `vn`.`client` SET isToBeMailed = FALSE WHERE mailAddress is NULL From cf64de39f9653c0d88bb60e0dff0339a276a9507 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Mon, 30 Jan 2023 09:01:20 +0100 Subject: [PATCH 55/94] refs #5146 @1h add step to vn-inputs --- modules/supplier/front/agency-term/index/index.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/supplier/front/agency-term/index/index.html b/modules/supplier/front/agency-term/index/index.html index 9d53226c5..44c6deba9 100644 --- a/modules/supplier/front/agency-term/index/index.html +++ b/modules/supplier/front/agency-term/index/index.html @@ -24,36 +24,42 @@ From 46ee12de6d29c65cf2925a630c18c683399c60fe Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 30 Jan 2023 09:45:10 +0100 Subject: [PATCH 56/94] refs #5088 text deleted --- print/templates/reports/receipt/receipt.html | 6 +++--- print/templates/reports/receipt/sql/receipt.sql | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/print/templates/reports/receipt/receipt.html b/print/templates/reports/receipt/receipt.html index e0bab5ecf..5dd4299be 100644 --- a/print/templates/reports/receipt/receipt.html +++ b/print/templates/reports/receipt/receipt.html @@ -4,9 +4,9 @@

{{$t('title')}}

- Recibo de {{client.socialName}}, la cantidad de - {{receipt.amountPaid}} € en concepto de 'entrega a cuenta', quedando pendiente en - la cuenta del cliente un saldo de {{receipt.amountUnpaid}} €. + Recibo de {{client.socialName}}, + la cantidad de {{receipt.amountPaid}} € + en concepto de 'entrega a cuenta'.

diff --git a/print/templates/reports/receipt/sql/receipt.sql b/print/templates/reports/receipt/sql/receipt.sql index b8f5a4112..4094d25b3 100644 --- a/print/templates/reports/receipt/sql/receipt.sql +++ b/print/templates/reports/receipt/sql/receipt.sql @@ -1,11 +1,10 @@ -SELECT - r.id, - r.amountPaid, - cr.amount AS amountUnpaid, - r.payed, +SELECT + r.id, + r.amountPaid, + r.payed, r.companyFk FROM receipt r JOIN client c ON c.id = r.clientFk JOIN vn.clientRisk cr ON cr.clientFk = c.id AND cr.companyFk = r.companyFk -WHERE r.id = ? \ No newline at end of file +WHERE r.id = ? From 77742d94d77a34576980f13f8f79250318fcd586 Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 30 Jan 2023 12:19:11 +0100 Subject: [PATCH 57/94] refs #5138 summary changed like route/tickets --- .../route/back/methods/route/getTickets.js | 11 ++- modules/route/front/summary/index.html | 82 ++++++++++--------- modules/route/front/tickets/index.html | 26 +++--- 3 files changed, 66 insertions(+), 53 deletions(-) diff --git a/modules/route/back/methods/route/getTickets.js b/modules/route/back/methods/route/getTickets.js index 708644c1a..1eb9e27f5 100644 --- a/modules/route/back/methods/route/getTickets.js +++ b/modules/route/back/methods/route/getTickets.js @@ -50,14 +50,17 @@ module.exports = Self => { am.name AS agencyModeName, u.nickname AS userNickname, vn.ticketTotalVolume(t.id) AS volume, - tob.description + tob.description, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt FROM vn.route r JOIN ticket t ON t.routeFk = r.id + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk LEFT JOIN ticketState ts ON ts.ticketFk = t.id LEFT JOIN state st ON st.id = ts.stateFk LEFT JOIN warehouse wh ON wh.id = t.warehouseFk LEFT JOIN observationType ot ON ot.code = 'delivery' - LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id + LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id AND tob.observationTypeFk = ot.id LEFT JOIN address a ON a.id = t.addressFk LEFT JOIN agencyMode am ON am.id = t.agencyModeFk @@ -70,7 +73,9 @@ module.exports = Self => { const where = filter.where; where['r.id'] = filter.id; - stmt.merge(conn.makeSuffix(filter)); + stmt.merge(conn.makeWhere(filter.where)); + stmt.merge(conn.makeGroupBy('t.id')); + stmt.merge(conn.makeOrderBy(filter.order)); const tickets = await conn.executeStmt(stmt, myOptions); diff --git a/modules/route/front/summary/index.html b/modules/route/front/summary/index.html index 86f558634..a64ad4ff7 100644 --- a/modules/route/front/summary/index.html +++ b/modules/route/front/summary/index.html @@ -10,26 +10,26 @@ - - - - - {{$ctrl.summary.route.worker.user.name}} - @@ -40,35 +40,35 @@ - - - -

- Ticket

-

Ticket @@ -77,45 +77,49 @@ Order - Ticket id - Alias + Street + City + PC + Client + Warehouse Packages - Warehouse - PC - Street + Packaging + Ticket {{ticket.priority | dashIfEmpty}} + {{ticket.street}} + {{ticket.city}} + {{ticket.postalCode}} + + + {{ticket.nickname}} + + + {{ticket.warehouseName}} + {{ticket.packages}} + {{ticket.volume}} + {{ticket.ipt}} - {{ticket.id}} - - {{ticket.nickname}} - - - {{ticket.packages}} - {{ticket.volume}} - {{ticket.warehouseName}} - {{ticket.postalCode}} - {{ticket.street}} - - - + + @@ -123,12 +127,12 @@ - - diff --git a/modules/route/front/tickets/index.html b/modules/route/front/tickets/index.html index dae894ac7..18d6fb160 100644 --- a/modules/route/front/tickets/index.html +++ b/modules/route/front/tickets/index.html @@ -6,9 +6,9 @@ data="$ctrl.tickets" auto-load="true"> - -
@@ -25,18 +25,18 @@ vn-tooltip="Open buscaman" icon="icon-buscaman"> - - - City PC Client + Warehouse Packages + Packaging Ticket @@ -100,8 +102,10 @@ {{::ticket.nickname}} + {{ticket.warehouseName}} {{::ticket.packages}} {{::ticket.volume | number:2}} + {{::ticket.ipt}}
- - @@ -160,7 +164,7 @@ - - - \ No newline at end of file + From 03d75c5b72ce142e0683d6373ce79d23d868ba1b Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 30 Jan 2023 12:25:57 +0100 Subject: [PATCH 58/94] refs #4927 changelog modified --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57be4697b..7f7a28f0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - (Trabajadores -> Nuevo trabajador) Nueva sección ### Changed -- +- (Proveedores -> Crear/Editar) Permite añadir Proveedores con la misma razón social pero con países distintos ### Fixed - (Artículos -> Etiquetas) Permite intercambiar la relevancia entre dos etiquetas. @@ -29,7 +29,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - (Reclamaciones -> Descriptor) Cambiado el campo Agencia por Zona - (Tickets -> Líneas preparadas) Actualizada sección para que sea más visual -- (Proveedores -> Crear/Editar) Permite añadir Proveedores con la misma razón social pero con países distintos ### Fixed - (General) Al utilizar el traductor de Google se descuadraban los iconos From a43f2cd35fcf1005435eb56fdf9d78f9eb143ea8 Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 30 Jan 2023 12:31:17 +0100 Subject: [PATCH 59/94] refs #5138 changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d00cafc2b..7aa44e258 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - (Trabajadores -> Nuevo trabajador) Nueva sección ### Changed -- +- (Rutas -> Sumario/Tickets) Actualizados campos de los tickets ### Fixed - (Artículos -> Etiquetas) Permite intercambiar la relevancia entre dos etiquetas. From f7a65cfa6ea63d6f5811fc6d09a3df6efcac2282 Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 30 Jan 2023 12:35:09 +0100 Subject: [PATCH 60/94] refs #5072 changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d00cafc2b..bda004470 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - (Artículos -> Etiquetas) Permite intercambiar la relevancia entre dos etiquetas. +- (Cliente -> Datos Fiscales) No se permite seleccionar 'Notificar vía e-mail' a los clientes sin e-mail ## [2302.01] - 2023-01-26 From c08836a1d1a6ce44670ef55e85d78bb144d20113 Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 30 Jan 2023 12:38:29 +0100 Subject: [PATCH 62/94] refs #5077 changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d00cafc2b..f2b966850 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - (Artículos -> Etiquetas) Permite intercambiar la relevancia entre dos etiquetas. +- (Tickets -> Datos básicos) Permite guardar la hora de envío ## [2302.01] - 2023-01-26 From 8580851b5b74883f54046e1fafca104587bbfe43 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Mon, 30 Jan 2023 13:32:09 +0100 Subject: [PATCH 63/94] refs #5148 @0:30h change style to pre-line --- front/salix/components/log/style.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/front/salix/components/log/style.scss b/front/salix/components/log/style.scss index bc943996d..68cd5a047 100644 --- a/front/salix/components/log/style.scss +++ b/front/salix/components/log/style.scss @@ -42,6 +42,7 @@ vn-log { & > td.after, & > th.after { width: 40%; + white-space: pre-line; } } } From 9cb363e4e5236083ca6b1841d8c3edadab64fdab Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 30 Jan 2023 13:34:08 +0100 Subject: [PATCH 64/94] refs #5074 deleted null in reference --- CHANGELOG.md | 2 +- modules/client/front/balance/create/index.js | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d00cafc2b..22efa1b28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - (Artículos -> Etiquetas) Permite intercambiar la relevancia entre dos etiquetas. - +- (Tickets -> Añadir pago) Eliminado "null" en las referencias ## [2302.01] - 2023-01-26 diff --git a/modules/client/front/balance/create/index.js b/modules/client/front/balance/create/index.js index 35b2e0b38..b64129e2e 100644 --- a/modules/client/front/balance/create/index.js +++ b/modules/client/front/balance/create/index.js @@ -59,13 +59,11 @@ class Controller extends Dialog { if (value) { const accountingType = value.accountingType; - if (this.originalDescription) { - this.receipt.description = - `${accountingType && accountingType.receiptDescription}, ${this.originalDescription}`; - } else { - this.receipt.description = - `${accountingType && accountingType.receiptDescription}`; - } + if (accountingType.receiptDescription != null) { + this.receipt.description = accountingType.receiptDescription; + if (this.originalDescription) this.receipt.description += `, ${this.originalDescription}`; + } else if (this.originalDescription) + this.receipt.description = this.originalDescription; this.maxAmount = accountingType && accountingType.maxAmount; this.receipt.payed = new Date(); From 896988279302a23febc45dd8dc3504e7aa66eda7 Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 30 Jan 2023 14:13:38 +0100 Subject: [PATCH 65/94] Removed where property dependency --- modules/ticket/back/methods/state/editableStates.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/state/editableStates.js b/modules/ticket/back/methods/state/editableStates.js index 2c90ac43b..115876f26 100644 --- a/modules/ticket/back/methods/state/editableStates.js +++ b/modules/ticket/back/methods/state/editableStates.js @@ -24,7 +24,7 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - let statesList = await models.State.find({where: filter.where}, myOptions); + let statesList = await models.State.find(filter, myOptions); const isProduction = await models.Account.hasRole(userId, 'production', myOptions); const isSalesPerson = await models.Account.hasRole(userId, 'salesPerson', myOptions); const isAdministrative = await models.Account.hasRole(userId, 'administrative', myOptions); From a74fb31b5b9c9b4ae5d5d8c846730d88c06378f8 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 30 Jan 2023 15:15:27 +0100 Subject: [PATCH 67/94] fix: vn.time --- db/dump/fixtures.sql | 26 +++++++++++++++++++ db/dump/mockDate.sql | 2 +- loopback/server/boot/date.js | 2 +- .../worker/specs/getWorkedHours.spec.js | 2 +- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 6d88d53cb..e9b694159 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -4,6 +4,32 @@ CREATE SCHEMA IF NOT EXISTS `tmp`; UPDATE `util`.`config` SET `environment`= 'development'; +-- FOR MOCK vn.time + +DROP PROCEDURE IF EXISTS `vn`.`mockVnTime`; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`mockVnTime`() +BEGIN + + DECLARE vDate DATE; + SET vDate = '2000-01-01'; + + WHILE ( YEAR(vDate) <= 2007 ) DO + INSERT IGNORE INTO vn.`time` (dated, period, `month`, `year`, `day`, week, yearMonth, salesYear) + VALUES (vDate, CONCAT(YEAR(vDate), (WEEK(vDate)+1)), MONTH(vDate), YEAR(vDate), DAY(vDate), WEEK(vDate)+1, CONCAT(YEAR(vDate), MONTH(vDate)), YEAR(vDate)); + + SET vDate = DATE_ADD(vDate, INTERVAL 1 DAY); + END WHILE; + +END$$ +DELIMITER ; + +CALL `vn`.`mockVnTime`(); +DROP PROCEDURE IF EXISTS `vn`.`mockVnTime`; +-- END MOCK vn.time + ALTER TABLE `vn`.`itemTaxCountry` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`address` AUTO_INCREMENT = 1; ALTER TABLE `vn`.`zoneGeo` AUTO_INCREMENT = 1; diff --git a/db/dump/mockDate.sql b/db/dump/mockDate.sql index 6452b38da..e9a81eb86 100644 --- a/db/dump/mockDate.sql +++ b/db/dump/mockDate.sql @@ -7,7 +7,7 @@ CREATE FUNCTION `util`.`mockedDate`() RETURNS DATETIME DETERMINISTIC BEGIN - RETURN '2000-06-15 11:00:00'; + RETURN '2001-01-01 11:00:00'; END ;; DELIMITER ; diff --git a/loopback/server/boot/date.js b/loopback/server/boot/date.js index e56393437..0875b6d5f 100644 --- a/loopback/server/boot/date.js +++ b/loopback/server/boot/date.js @@ -2,7 +2,7 @@ module.exports = () => { Date.vnUTC = () => { const env = process.env.NODE_ENV; if (!env || env === 'development') - return new Date(Date.UTC(2000, 5, 15, 11)); + return new Date(Date.UTC(2001, 0, 1, 11)); return new Date(Date.UTC()); }; diff --git a/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js b/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js index a6117e68a..f5b06cc9e 100644 --- a/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js +++ b/modules/worker/back/methods/worker/specs/getWorkedHours.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('Worker getWorkedHours()', () => { +describe('Worker getWorkedHours()', () => { it(`should return the expected hours and the worked hours of a given date`, async() => { const workerID = 1106; const started = Date.vnNew(); From 444d2ae4c4b518b2d306d49b74190553de903b69 Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 30 Jan 2023 15:28:47 +0100 Subject: [PATCH 68/94] refs #5104 grouping/packing unified --- modules/entry/front/latest-buys/locale/es.yml | 4 +- modules/entry/front/summary/index.html | 14 +++-- modules/item/front/last-entries/index.html | 52 +++++++++---------- 3 files changed, 34 insertions(+), 36 deletions(-) diff --git a/modules/entry/front/latest-buys/locale/es.yml b/modules/entry/front/latest-buys/locale/es.yml index 8d70844fa..795e3f5f4 100644 --- a/modules/entry/front/latest-buys/locale/es.yml +++ b/modules/entry/front/latest-buys/locale/es.yml @@ -1,5 +1,5 @@ Edit buy(s): Editar compra(s) -Buying value: Precio +Buying value: Coste Freight value: Porte Commission value: Comisión Package value: Embalaje @@ -16,4 +16,4 @@ Field to edit: Campo a editar PackageName: Cubo Edit: Editar buy(s): compra(s) -Package out: Embalaje envíos \ No newline at end of file +Package out: Embalaje envíos diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html index 04844ab99..8f1cd924d 100644 --- a/modules/entry/front/summary/index.html +++ b/modules/entry/front/summary/index.html @@ -38,7 +38,7 @@ - {{$ctrl.entryData.travel.ref}} @@ -114,8 +114,7 @@ Grouping Buying value Import - Grouping price - Packing price + PVP @@ -125,19 +124,18 @@ {{::line.packageFk | dashIfEmpty}} {{::line.weight}} - + {{::line.packing | dashIfEmpty}} - + {{::line.grouping | dashIfEmpty}} {{::line.buyingValue | currency: 'EUR':2}} {{::line.quantity * line.buyingValue | currency: 'EUR':2}} - {{::line.price2 | currency: 'EUR':2}} - {{::line.price3 | currency: 'EUR':2}} + {{::line.price2 | currency: 'EUR':2 | dashIfEmpty}} / {{::line.price3 | currency: 'EUR':2 | dashIfEmpty}} @@ -195,7 +193,7 @@ vn-id="item-descriptor" warehouse-fk="$ctrl.vnConfig.warehouseFk"> - diff --git a/modules/item/front/last-entries/index.html b/modules/item/front/last-entries/index.html index 0348d4f66..1c2db10a5 100644 --- a/modules/item/front/last-entries/index.html +++ b/modules/item/front/last-entries/index.html @@ -9,15 +9,15 @@ - + @@ -35,8 +35,7 @@ Warehouse Landed Entry - P.P.U - P.P.P + PVP Label Packing Grouping @@ -51,7 +50,7 @@ - @@ -65,30 +64,31 @@ {{::entry.entryFk | dashIfEmpty}} - {{::entry.price2 | dashIfEmpty}} - {{::entry.price3 | dashIfEmpty}} + + {{::entry.price2 | currency: 'EUR':2 | dashIfEmpty}} / {{::entry.price3 | currency: 'EUR':2 | dashIfEmpty}} + {{entry.stickers | dashIfEmpty}} - + {{::entry.packing | dashIfEmpty}} - + {{::entry.grouping | dashIfEmpty}} {{::entry.stems | dashIfEmpty}} {{::entry.quantity}} - - {{::entry.cost | dashIfEmpty}} + {{::$ctrl.$t('Cost')}}: {{::entry.buyingValue | currency: 'EUR':2 | dashIfEmpty}}
+ {{::$ctrl.$t('Package')}}: {{::entry.packageValue | currency: 'EUR':2 | dashIfEmpty}}
+ {{::$ctrl.$t('Freight')}}: {{::entry.freightValue | currency: 'EUR':2 | dashIfEmpty}}
+ {{::$ctrl.$t('Comission')}}: {{::entry.comissionValue | currency: 'EUR':2 | dashIfEmpty}}"> + {{::entry.cost | currency: 'EUR':2 | dashIfEmpty}}
{{::entry.weight | dashIfEmpty}} @@ -113,24 +113,24 @@ ng-click="contextmenu.filterBySelection()"> Filter by selection - Exclude selection - Remove filter - Remove all filters - Copy value - \ No newline at end of file + From 2bbd7cb2170eb9fd5b9a0bb943e36ea60c015853 Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 30 Jan 2023 15:40:08 +0100 Subject: [PATCH 69/94] refs #5104 changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d00cafc2b..3f2faeb13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - (Trabajadores -> Nuevo trabajador) Nueva sección ### Changed -- +- (Entradas -> Compras) Cambiados los campos "Precio Grouping/Packing" por "PVP" y "Precio" por "Coste" +- (Artículos -> Últimas compras) Cambiados los campos "P.P.U." y "P.P.P." por "PVP" ### Fixed - (Artículos -> Etiquetas) Permite intercambiar la relevancia entre dos etiquetas. From 53349fcea74961767c63de4e38c7b6c359f0c891 Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 30 Jan 2023 15:41:04 +0100 Subject: [PATCH 70/94] refs #5104 changelog modified --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f2faeb13..e65983d33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - (Entradas -> Compras) Cambiados los campos "Precio Grouping/Packing" por "PVP" y "Precio" por "Coste" -- (Artículos -> Últimas compras) Cambiados los campos "P.P.U." y "P.P.P." por "PVP" +- (Artículos -> Últimas entradas) Cambiados los campos "P.P.U." y "P.P.P." por "PVP" ### Fixed - (Artículos -> Etiquetas) Permite intercambiar la relevancia entre dos etiquetas. From 7d617c0ac420afa0e7d63362569e5bf24abd2183 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 09:04:45 +0100 Subject: [PATCH 72/94] refs #5129 translations and userErrors added --- loopback/locale/en.json | 19 +++++----- loopback/locale/es.json | 6 ++-- modules/ticket/back/methods/sale/canEdit.js | 9 ++++- .../ticket/back/methods/sale/deleteSales.js | 4 +-- .../back/methods/sale/recalculatePrice.js | 4 +-- modules/ticket/back/methods/sale/reserve.js | 4 +-- .../back/methods/sale/specs/canEdit.spec.js | 36 +++++++++---------- .../ticket/back/methods/sale/updateConcept.js | 5 +-- .../ticket/back/methods/sale/updatePrice.js | 4 +-- .../back/methods/sale/updateQuantity.js | 4 +-- 10 files changed, 47 insertions(+), 48 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index a406b55a5..c810e5a69 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -67,7 +67,7 @@ "Changed client paymethod": "I have changed the pay method for client [{{clientName}} ({{clientId}})]({{{url}}})", "Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} ({{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [{{ticketId}}]({{{ticketUrl}}})", "Change quantity": "{{concept}} change of {{oldQuantity}} to {{newQuantity}}", - "Claim will be picked": "The product from the claim [({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked", + "Claim will be picked": "The product from the claim [({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked", "Claim state has changed to incomplete": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *incomplete*", "Claim state has changed to canceled": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *canceled*", "Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member", @@ -137,15 +137,18 @@ "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", - "Claim pickup order sent": "Claim pickup order sent [{{claimId}}]({{{claimUrl}}}) to client *{{clientName}}*", + "Claim pickup order sent": "Claim pickup order sent [{{claimId}}]({{{claimUrl}}}) to client *{{clientName}}*", "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", - "Email verify": "Email verify", + "Email verify": "Email verify", "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) merged with [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})", - "Sale(s) blocked, please contact production": "Sale(s) blocked, please contact production", "App locked": "App locked by user {{userId}}", - "The sales of the receiver ticket can't be modified": "The sales of the receiver ticket can't be modified", - "Receipt's bank was not found": "Receipt's bank was not found", - "This receipt was not compensated": "This receipt was not compensated", - "Client's email was not found": "Client's email was not found" + "The sales of the receiver ticket can't be modified": "The sales of the receiver ticket can't be modified", + "Receipt's bank was not found": "Receipt's bank was not found", + "This receipt was not compensated": "This receipt was not compensated", + "Client's email was not found": "Client's email was not found", + "It is not possible to modify tracked sales": "It is not possible to modify tracked sales", + "It is not possible to modify sales that their articles are from Floramondo": "It is not possible to modify sales that their articles are from Floramondo", + "It is not possible to modify cloned sales": "It is not possible to modify cloned sales", + "Valid priorities: 1,2,3": "Valid priorities: 1,2,3" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index d65054f37..06c3efa2b 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -84,7 +84,6 @@ "The current ticket can't be modified": "El ticket actual no puede ser modificado", "The current claim can't be modified": "La reclamación actual no puede ser modificada", "The sales of this ticket can't be modified": "Las lineas de este ticket no pueden ser modificadas", - "Sale(s) blocked, contact production": "Linea(s) bloqueada(s), contacte con produccion", "Please select at least one sale": "Por favor selecciona al menos una linea", "All sales must belong to the same ticket": "Todas las lineas deben pertenecer al mismo ticket", "NO_ZONE_FOR_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada", @@ -259,5 +258,8 @@ "Try again": "Vuelve a intentarlo", "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9", "Failed to upload file": "Error al subir archivo", - "The DOCUWARE PDF document does not exists": "The DOCUWARE PDF document does not exists" + "The DOCUWARE PDF document does not exists": "The DOCUWARE PDF document does not exists", + "It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que estén en marcha", + "It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo", + "It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas" } diff --git a/modules/ticket/back/methods/sale/canEdit.js b/modules/ticket/back/methods/sale/canEdit.js index f44bd6743..3091ebca7 100644 --- a/modules/ticket/back/methods/sale/canEdit.js +++ b/modules/ticket/back/methods/sale/canEdit.js @@ -56,6 +56,13 @@ module.exports = Self => { const shouldEditCloned = canEditCloned || !hasSaleCloned; const shouldEditFloramondo = canEditFloramondo || !hasSaleFloramondo; - return shouldEditTracked && shouldEditCloned && shouldEditFloramondo; + if (!shouldEditTracked) + throw new UserError('It is not possible to modify tracked sales'); + if (!shouldEditCloned) + throw new UserError('It is not possible to modify cloned sales'); + if (!shouldEditFloramondo) + throw new UserError('It is not possible to modify sales that their articles are from Floramondo'); + + return true; }; }; diff --git a/modules/ticket/back/methods/sale/deleteSales.js b/modules/ticket/back/methods/sale/deleteSales.js index c045b9197..5d1463a66 100644 --- a/modules/ticket/back/methods/sale/deleteSales.js +++ b/modules/ticket/back/methods/sale/deleteSales.js @@ -43,9 +43,7 @@ module.exports = Self => { try { const saleIds = sales.map(sale => sale.id); - const canEditSales = await models.Sale.canEdit(ctx, saleIds, myOptions); - if (!canEditSales) - throw new UserError(`Sale(s) blocked, please contact production`); + await models.Sale.canEdit(ctx, saleIds, myOptions); const ticket = await models.Ticket.findById(ticketId, { include: { diff --git a/modules/ticket/back/methods/sale/recalculatePrice.js b/modules/ticket/back/methods/sale/recalculatePrice.js index 38c68d7f6..2c8e6768b 100644 --- a/modules/ticket/back/methods/sale/recalculatePrice.js +++ b/modules/ticket/back/methods/sale/recalculatePrice.js @@ -37,9 +37,7 @@ module.exports = Self => { try { const salesIds = sales.map(sale => sale.id); - const canEditSale = await models.Sale.canEdit(ctx, salesIds, myOptions); - if (!canEditSale) - throw new UserError(`Sale(s) blocked, please contact production`); + await models.Sale.canEdit(ctx, salesIds, myOptions); const query = ` DROP TEMPORARY TABLE IF EXISTS tmp.recalculateSales; diff --git a/modules/ticket/back/methods/sale/reserve.js b/modules/ticket/back/methods/sale/reserve.js index 648e6de23..2dc368af6 100644 --- a/modules/ticket/back/methods/sale/reserve.js +++ b/modules/ticket/back/methods/sale/reserve.js @@ -51,9 +51,7 @@ module.exports = Self => { try { const salesIds = sales.map(sale => sale.id); - const canEditSale = await models.Sale.canEdit(ctx, salesIds, myOptions); - if (!canEditSale) - throw new UserError(`Sale(s) blocked, please contact production`); + await models.Sale.canEdit(ctx, salesIds, myOptions); let changesMade = ''; const promises = []; diff --git a/modules/ticket/back/methods/sale/specs/canEdit.spec.js b/modules/ticket/back/methods/sale/specs/canEdit.spec.js index 2aa873df5..58d8f0635 100644 --- a/modules/ticket/back/methods/sale/specs/canEdit.spec.js +++ b/modules/ticket/back/methods/sale/specs/canEdit.spec.js @@ -50,7 +50,7 @@ describe('sale canEdit()', () => { it('should return false if any of the sales has a saleTracking record', async() => { const tx = await models.Sale.beginTransaction({}); - + let error; try { const options = {transaction: tx}; @@ -59,15 +59,15 @@ describe('sale canEdit()', () => { const sales = [31]; - const result = await models.Sale.canEdit(ctx, sales, options); - - expect(result).toEqual(false); - + await models.Sale.canEdit(ctx, sales, options); await tx.rollback(); } catch (e) { await tx.rollback(); - throw e; + error = e; } + + expect(error).toEqual( + new Error('It is not possible to modify tracked sales')); }); }); @@ -75,22 +75,22 @@ describe('sale canEdit()', () => { const saleCloned = [29]; it('should return false if any of the sales is cloned', async() => { const tx = await models.Sale.beginTransaction({}); - + let error; try { const options = {transaction: tx}; const buyerId = 35; const ctx = {req: {accessToken: {userId: buyerId}}}; - const result = await models.Sale.canEdit(ctx, saleCloned, options); - - expect(result).toEqual(false); - + await models.Sale.canEdit(ctx, saleCloned, options); await tx.rollback(); } catch (e) { await tx.rollback(); - throw e; + error = e; } + + expect(error).toEqual( + new Error('It is not possible to modify cloned sales')); }); it('should return true if any of the sales is cloned and has the correct role', async() => { @@ -130,7 +130,7 @@ describe('sale canEdit()', () => { it('should return false if any of the sales isFloramondo', async() => { const tx = await models.Sale.beginTransaction({}); const sales = [26]; - + let error; try { const options = {transaction: tx}; @@ -140,15 +140,15 @@ describe('sale canEdit()', () => { const saleToEdit = await models.Sale.findById(sales[0], null, options); await saleToEdit.updateAttribute('itemFk', 9, options); - const result = await models.Sale.canEdit(ctx, sales, options); - - expect(result).toEqual(false); - + await models.Sale.canEdit(ctx, sales, options); await tx.rollback(); } catch (e) { await tx.rollback(); - throw e; + error = e; } + + expect(error).toEqual( + new Error('It is not possible to modify sales that their articles are from Floramondo')); }); it('should return true if any of the sales is of isFloramondo and has the correct role', async() => { diff --git a/modules/ticket/back/methods/sale/updateConcept.js b/modules/ticket/back/methods/sale/updateConcept.js index 0730f85e2..dcd25dcbb 100644 --- a/modules/ticket/back/methods/sale/updateConcept.js +++ b/modules/ticket/back/methods/sale/updateConcept.js @@ -40,10 +40,7 @@ module.exports = Self => { try { const currentLine = await models.Sale.findById(id, null, myOptions); - const canEditSale = await models.Sale.canEdit(ctx, [id], myOptions); - - if (!canEditSale) - throw new UserError(`Sale(s) blocked, please contact production`); + await models.Sale.canEdit(ctx, [id], myOptions); const line = await currentLine.updateAttributes({concept: newConcept}, myOptions); diff --git a/modules/ticket/back/methods/sale/updatePrice.js b/modules/ticket/back/methods/sale/updatePrice.js index 8f27e1af5..505de5180 100644 --- a/modules/ticket/back/methods/sale/updatePrice.js +++ b/modules/ticket/back/methods/sale/updatePrice.js @@ -66,9 +66,7 @@ module.exports = Self => { const sale = await models.Sale.findById(id, filter, myOptions); - const canEditSale = await models.Sale.canEdit(ctx, [id], myOptions); - if (!canEditSale) - throw new UserError(`Sale(s) blocked, please contact production`); + await models.Sale.canEdit(ctx, [id], myOptions); const oldPrice = sale.price; const userId = ctx.req.accessToken.userId; diff --git a/modules/ticket/back/methods/sale/updateQuantity.js b/modules/ticket/back/methods/sale/updateQuantity.js index 8cf0720ce..d2927c65c 100644 --- a/modules/ticket/back/methods/sale/updateQuantity.js +++ b/modules/ticket/back/methods/sale/updateQuantity.js @@ -41,9 +41,7 @@ module.exports = Self => { } try { - const canEditSale = await models.Sale.canEdit(ctx, [id], myOptions); - if (!canEditSale) - throw new UserError(`Sale(s) blocked, please contact production`); + await models.Sale.canEdit(ctx, [id], myOptions); const filter = { include: { From 4740cdbbb9696b8d2c8c2565a21a8bdb2c7034d0 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 31 Jan 2023 10:37:18 +0100 Subject: [PATCH 73/94] fix: e2e --- e2e/paths/03-worker/04_time_control.spec.js | 3 + front/core/components/button-menu/index.js | 1 + modules/ticket/front/sale/index.html | 1 + modules/ticket/front/summary/index.html | 61 +++++++++++---------- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/e2e/paths/03-worker/04_time_control.spec.js b/e2e/paths/03-worker/04_time_control.spec.js index bba7ced89..b5da799fc 100644 --- a/e2e/paths/03-worker/04_time_control.spec.js +++ b/e2e/paths/03-worker/04_time_control.spec.js @@ -23,6 +23,7 @@ describe('Worker time control path', () => { it('should go to the next month, go to current month and go 1 month in the past', async() => { let date = new Date(); + date.setDate(1); date.setMonth(date.getMonth() + 1); let month = date.toLocaleString('default', {month: 'long'}); @@ -32,6 +33,7 @@ describe('Worker time control path', () => { expect(result).toContain(month); date = new Date(); + date.setDate(1); month = date.toLocaleString('default', {month: 'long'}); await page.click(selectors.workerTimeControl.previousMonthButton); @@ -40,6 +42,7 @@ describe('Worker time control path', () => { expect(result).toContain(month); date = new Date(); + date.setDate(1); date.setMonth(date.getMonth() - 1); const timestamp = Math.round(date.getTime() / 1000); month = date.toLocaleString('default', {month: 'long'}); diff --git a/front/core/components/button-menu/index.js b/front/core/components/button-menu/index.js index c19962b08..e9e4e5ab7 100644 --- a/front/core/components/button-menu/index.js +++ b/front/core/components/button-menu/index.js @@ -87,6 +87,7 @@ ngModule.vnComponent('vnButtonMenu', { selectFields: ' diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html index fe49a301f..af44ed67c 100644 --- a/modules/ticket/front/summary/index.html +++ b/modules/ticket/front/summary/index.html @@ -1,6 +1,6 @@
- - Ticket #{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}} + Ticket #{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}} ({{$ctrl.summary.client.id}}) - {{$ctrl.summary.nickname}} - -
- - {{$ctrl.summary.client.salesPersonUser.name}} - @@ -47,11 +48,11 @@ {{$ctrl.summary.zone.name}} - - {{$ctrl.summary.routeFk}} @@ -66,17 +67,17 @@ - - -

- Sale @@ -146,13 +147,13 @@ vn-tooltip="{{::$ctrl.$t('Claim')}}: {{::sale.claimBeginning.claimFk}}"> - - @@ -170,22 +171,22 @@ - {{sale.itemFk | zeroFill:6}} - {{::sale.visible}} - {{::sale.available}} @@ -216,7 +217,7 @@

- Packages @@ -241,7 +242,7 @@

- Service @@ -276,7 +277,7 @@

- Purchase request @@ -304,7 +305,7 @@ {{::request.quantity}} {{::request.price}} - @@ -336,9 +337,9 @@ - - - \ No newline at end of file + From ffdc539851a5eefa4b3e25690b395b4ca41628b5 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 11:29:07 +0100 Subject: [PATCH 74/94] refs #5138 fix e2e --- e2e/helpers/selectors.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index a1412f431..986c6547b 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -944,9 +944,9 @@ export default { routeSummary: { header: 'vn-route-summary > vn-card > h5', cost: 'vn-route-summary vn-label-value[label="Cost"]', - firstTicketID: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(2) > span', + firstTicketID: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(10) > span', firstTicketDescriptor: '.vn-popover.shown vn-ticket-descriptor', - firstAlias: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(3) > span', + firstAlias: 'vn-route-summary vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(5) > span', firstClientDescriptor: '.vn-popover.shown vn-client-descriptor', goToRouteSummaryButton: 'vn-route-summary > vn-card > h5 > a', From a358e58171ca37eef21e513a662f4040a5b1e483 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 12:12:25 +0100 Subject: [PATCH 75/94] docuware translation --- loopback/locale/es.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 06c3efa2b..df17b82a3 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -258,7 +258,7 @@ "Try again": "Vuelve a intentarlo", "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9", "Failed to upload file": "Error al subir archivo", - "The DOCUWARE PDF document does not exists": "The DOCUWARE PDF document does not exists", + "The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe", "It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que estén en marcha", "It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo", "It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas" From 331b278726e59558894857a31dd43c9a44b6c02a Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 13:00:25 +0100 Subject: [PATCH 76/94] refs #5131 checkbox pending origin destination --- db/changes/230401/00-ticket_canAdvance.sql | 100 ++++++++++++++++++ .../back/methods/ticket/getTicketsAdvance.js | 16 +-- .../front/advance-search-panel/index.html | 32 +++--- .../front/advance-search-panel/index.js | 15 --- .../front/advance-search-panel/locale/es.yml | 2 + 5 files changed, 122 insertions(+), 43 deletions(-) create mode 100644 db/changes/230401/00-ticket_canAdvance.sql diff --git a/db/changes/230401/00-ticket_canAdvance.sql b/db/changes/230401/00-ticket_canAdvance.sql new file mode 100644 index 000000000..497defebe --- /dev/null +++ b/db/changes/230401/00-ticket_canAdvance.sql @@ -0,0 +1,100 @@ +DROP PROCEDURE IF EXISTS vn.ticket_canAdvance; + +DELIMITER $$ +$$ +CREATE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_canAdvance`(vDateFuture DATE, vDateToAdvance DATE, vWarehouseFk INT) +BEGIN +/** + * Devuelve los tickets y la cantidad de lineas de venta que se pueden adelantar. + * + * @param vDateFuture Fecha de los tickets que se quieren adelantar. + * @param vDateToAdvance Fecha a cuando se quiere adelantar. + * @param vWarehouseFk Almacén + */ + + DECLARE vDateInventory DATE; + + SELECT inventoried INTO vDateInventory FROM vn.config; + + DROP TEMPORARY TABLE IF EXISTS tmp.stock; + CREATE TEMPORARY TABLE tmp.stock + (itemFk INT PRIMARY KEY, + amount INT) + ENGINE = MEMORY; + + INSERT INTO tmp.stock(itemFk, amount) + SELECT itemFk, SUM(quantity) amount FROM + ( + SELECT itemFk, quantity + FROM vn.itemTicketOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM vn.itemEntryIn + WHERE landed >= vDateInventory + AND landed < vDateFuture + AND isVirtualStock = FALSE + AND warehouseInFk = vWarehouseFk + UNION ALL + SELECT itemFk, quantity + FROM vn.itemEntryOut + WHERE shipped >= vDateInventory + AND shipped < vDateFuture + AND warehouseOutFk = vWarehouseFk + ) t + GROUP BY itemFk HAVING amount != 0; + + DROP TEMPORARY TABLE IF EXISTS tmp.filter; + CREATE TEMPORARY TABLE tmp.filter + (INDEX (id)) + SELECT s.ticketFk futureId, + t2.ticketFk id, + sum((s.quantity <= IFNULL(st.amount,0))) hasStock, + count(DISTINCT s.id) saleCount, + t2.state, + t2.isNotValidated, + st.name futureState, + st.isNotValidated futureIsNotValidated, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, + t2.ipt, + t.workerFk, + CAST(sum(litros) AS DECIMAL(10,0)) liters, + CAST(count(*) AS DECIMAL(10,0)) `lines`, + t2.shipped, + t.shipped futureShipped, + t2.totalWithVat, + t.totalWithVat futureTotalWithVat + FROM vn.ticket t + JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN vn.state st ON st.id = ts.stateFk + JOIN vn.saleVolume sv ON t.id = sv.ticketFk + JOIN (SELECT + t2.id ticketFk, + t2.addressFk, + st.isNotValidated, + st.name state, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, + t2.shipped, + t2.totalWithVat + FROM vn.ticket t2 + JOIN vn.sale s ON s.ticketFk = t2.id + JOIN vn.item i ON i.id = s.itemFk + JOIN vn.ticketState ts ON ts.ticketFk = t2.id + JOIN vn.state st ON st.id = ts.stateFk + LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + WHERE t2.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) + AND t2.warehouseFk = vWarehouseFk + GROUP BY t2.id) t2 ON t2.addressFk = t.addressFk + JOIN vn.sale s ON s.ticketFk = t.id + JOIN vn.item i ON i.id = s.itemFk + LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk + WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) + AND t.warehouseFk = vWarehouseFk + GROUP BY t.id; + + DROP TEMPORARY TABLE tmp.stock; +END$$ +DELIMITER ; diff --git a/modules/ticket/back/methods/ticket/getTicketsAdvance.js b/modules/ticket/back/methods/ticket/getTicketsAdvance.js index 19571bb51..a7dea56e2 100644 --- a/modules/ticket/back/methods/ticket/getTicketsAdvance.js +++ b/modules/ticket/back/methods/ticket/getTicketsAdvance.js @@ -50,14 +50,14 @@ module.exports = Self => { required: false }, { - arg: 'state', - type: 'string', + arg: 'isNotValidated', + type: 'boolean', description: 'Origin state', required: false }, { - arg: 'futureState', - type: 'string', + arg: 'futureIsNotValidated', + type: 'boolean', description: 'Destination state', required: false }, @@ -95,10 +95,10 @@ module.exports = Self => { return {'f.ipt': value}; case 'futureIpt': return {'f.futureIpt': value}; - case 'state': - return {'f.stateCode': {like: `%${value}%`}}; - case 'futureState': - return {'f.futureStateCode': {like: `%${value}%`}}; + case 'isNotValidated': + return {'f.isNotValidated': value}; + case 'futureIsNotValidated': + return {'f.futureIsNotValidated': value}; } }); diff --git a/modules/ticket/front/advance-search-panel/index.html b/modules/ticket/front/advance-search-panel/index.html index e8d5dc60d..dfe1f6b08 100644 --- a/modules/ticket/front/advance-search-panel/index.html +++ b/modules/ticket/front/advance-search-panel/index.html @@ -39,26 +39,18 @@ - - - {{name}} - - - - - {{name}} - - + + + + { - for (let state of res.data) { - groupedStates.push({ - id: state.id, - code: state.code, - name: this.$t(state.code) - }); - } - this.groupedStates = groupedStates; - }); - } - getItemPackingTypes() { let itemPackingTypes = []; const filter = { diff --git a/modules/ticket/front/advance-search-panel/locale/es.yml b/modules/ticket/front/advance-search-panel/locale/es.yml index 3dce7dae5..4ea2fc737 100644 --- a/modules/ticket/front/advance-search-panel/locale/es.yml +++ b/modules/ticket/front/advance-search-panel/locale/es.yml @@ -1 +1,3 @@ Advance tickets: Adelantar tickets +Pending Origin: Pendiente origen +Pending Destination: Pendiente destino From e5b7ebd8b4de413b4a73131fb6ebc1f8299df479 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 13:06:58 +0100 Subject: [PATCH 77/94] refs #5131 IPT null or value --- .../back/methods/ticket/getTicketsAdvance.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/getTicketsAdvance.js b/modules/ticket/back/methods/ticket/getTicketsAdvance.js index a7dea56e2..1e1646cba 100644 --- a/modules/ticket/back/methods/ticket/getTicketsAdvance.js +++ b/modules/ticket/back/methods/ticket/getTicketsAdvance.js @@ -92,9 +92,19 @@ module.exports = Self => { case 'futureId': return {'f.futureId': value}; case 'ipt': - return {'f.ipt': value}; + return {or: + [ + {'f.ipt': {like: `%${value}%`}}, + {'f.ipt': null} + ] + }; case 'futureIpt': - return {'f.futureIpt': value}; + return {or: + [ + {'f.futureIpt': {like: `%${value}%`}}, + {'f.futureIpt': null} + ] + }; case 'isNotValidated': return {'f.isNotValidated': value}; case 'futureIsNotValidated': From 87bef62e350544e8c5d83db990540cf85f49f79b Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 13:21:51 +0100 Subject: [PATCH 78/94] refs #5131 hasStock refers to origin --- db/changes/230401/00-ticket_canAdvance.sql | 21 +++++++++++---------- modules/ticket/front/advance/index.html | 8 ++++---- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/db/changes/230401/00-ticket_canAdvance.sql b/db/changes/230401/00-ticket_canAdvance.sql index 497defebe..05200aa57 100644 --- a/db/changes/230401/00-ticket_canAdvance.sql +++ b/db/changes/230401/00-ticket_canAdvance.sql @@ -51,7 +51,6 @@ BEGIN (INDEX (id)) SELECT s.ticketFk futureId, t2.ticketFk id, - sum((s.quantity <= IFNULL(st.amount,0))) hasStock, count(DISTINCT s.id) saleCount, t2.state, t2.isNotValidated, @@ -65,32 +64,34 @@ BEGIN t2.shipped, t.shipped futureShipped, t2.totalWithVat, - t.totalWithVat futureTotalWithVat + t.totalWithVat futureTotalWithVat, + t2.hasStock FROM vn.ticket t JOIN vn.ticketState ts ON ts.ticketFk = t.id JOIN vn.state st ON st.id = ts.stateFk JOIN vn.saleVolume sv ON t.id = sv.ticketFk JOIN (SELECT - t2.id ticketFk, - t2.addressFk, - st.isNotValidated, - st.name state, - GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, - t2.shipped, - t2.totalWithVat + t2.id ticketFk, + t2.addressFk, + st.isNotValidated, + st.name state, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, + t2.shipped, + t2.totalWithVat, + sum((s.quantity <= IFNULL(st.amount,0))) hasStock FROM vn.ticket t2 JOIN vn.sale s ON s.ticketFk = t2.id JOIN vn.item i ON i.id = s.itemFk JOIN vn.ticketState ts ON ts.ticketFk = t2.id JOIN vn.state st ON st.id = ts.stateFk LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk WHERE t2.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) AND t2.warehouseFk = vWarehouseFk GROUP BY t2.id) t2 ON t2.addressFk = t.addressFk JOIN vn.sale s ON s.ticketFk = t.id JOIN vn.item i ON i.id = s.itemFk LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk - LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) AND t.warehouseFk = vWarehouseFk GROUP BY t.id; diff --git a/modules/ticket/front/advance/index.html b/modules/ticket/front/advance/index.html index f63c0fbf7..bd274b7fb 100644 --- a/modules/ticket/front/advance/index.html +++ b/modules/ticket/front/advance/index.html @@ -55,6 +55,9 @@ State + + Stock + Import @@ -73,9 +76,6 @@ Liters - - Stock - Lines @@ -111,6 +111,7 @@ {{::ticket.futureState | dashIfEmpty}} + {{::ticket.hasStock | dashIfEmpty}} {{::(ticket.futureTotalWithVat ? ticket.futureTotalWithVat : 0) | currency: 'EUR': 2}} @@ -136,7 +137,6 @@ {{::ticket.liters | dashIfEmpty}} - {{::ticket.hasStock | dashIfEmpty}} {{::ticket.lines | dashIfEmpty}} From b70557ee868fd7b1cafe21db29d4ede57572f899 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 14:20:08 +0100 Subject: [PATCH 79/94] refs #5131 agencies icon --- db/changes/230401/00-ticket_canAdvance.sql | 7 ++++++- modules/ticket/front/advance/index.html | 15 ++++++++++++--- modules/ticket/front/advance/index.js | 6 ++++++ modules/ticket/front/advance/locale/es.yml | 3 +++ modules/ticket/front/advance/style.scss | 7 +++++++ 5 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 modules/ticket/front/advance/style.scss diff --git a/db/changes/230401/00-ticket_canAdvance.sql b/db/changes/230401/00-ticket_canAdvance.sql index 05200aa57..2072259b1 100644 --- a/db/changes/230401/00-ticket_canAdvance.sql +++ b/db/changes/230401/00-ticket_canAdvance.sql @@ -65,7 +65,9 @@ BEGIN t.shipped futureShipped, t2.totalWithVat, t.totalWithVat futureTotalWithVat, - t2.hasStock + t2.hasStock, + t2.agency, + am.name futureAgency FROM vn.ticket t JOIN vn.ticketState ts ON ts.ticketFk = t.id JOIN vn.state st ON st.id = ts.stateFk @@ -78,12 +80,14 @@ BEGIN GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, t2.shipped, t2.totalWithVat, + am.name agency, sum((s.quantity <= IFNULL(st.amount,0))) hasStock FROM vn.ticket t2 JOIN vn.sale s ON s.ticketFk = t2.id JOIN vn.item i ON i.id = s.itemFk JOIN vn.ticketState ts ON ts.ticketFk = t2.id JOIN vn.state st ON st.id = ts.stateFk + JOIN vn.agencyMode am ON t2.agencyModeFk = am.id LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk WHERE t2.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) @@ -91,6 +95,7 @@ BEGIN GROUP BY t2.id) t2 ON t2.addressFk = t.addressFk JOIN vn.sale s ON s.ticketFk = t.id JOIN vn.item i ON i.id = s.itemFk + JOIN vn.agencyMode am ON t.agencyModeFk = am.id LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) AND t.warehouseFk = vWarehouseFk diff --git a/modules/ticket/front/advance/index.html b/modules/ticket/front/advance/index.html index bd274b7fb..d82d8cc50 100644 --- a/modules/ticket/front/advance/index.html +++ b/modules/ticket/front/advance/index.html @@ -32,7 +32,7 @@ - Origin + Origin Destination @@ -43,13 +43,15 @@ check-field="checked"> + + ID Date - + IPT @@ -67,7 +69,7 @@ Date - + IPT @@ -92,6 +94,13 @@ vn-click-stop> + + + + ' + this.$t(`Destination agency`, {agency: agency}); + } + moveTicketsAdvance() { let ticketsToMove = []; this.checked.forEach(ticket => { diff --git a/modules/ticket/front/advance/locale/es.yml b/modules/ticket/front/advance/locale/es.yml index b444fbdd3..da22cd433 100644 --- a/modules/ticket/front/advance/locale/es.yml +++ b/modules/ticket/front/advance/locale/es.yml @@ -4,3 +4,6 @@ Advance confirmation: ¿Desea adelantar {{checked}} tickets? Success: Tickets movidos correctamente Lines: Líneas Liters: Litros +Item Packing Type: Encajado +Origin agency: "Agencia origen: {{agency}}" +Destination agency: "Agencia destino: {{agency}}" diff --git a/modules/ticket/front/advance/style.scss b/modules/ticket/front/advance/style.scss new file mode 100644 index 000000000..8fa9de438 --- /dev/null +++ b/modules/ticket/front/advance/style.scss @@ -0,0 +1,7 @@ +@import "variables"; + +vn-ticket-advance{ + vn-icon { + color: #f7931e + } +} From 19d7e7e6102a97b849501d5c199e49e93309ea6a Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 14:23:40 +0100 Subject: [PATCH 80/94] refs #5131 totalWithVat order --- modules/ticket/front/advance/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ticket/front/advance/index.html b/modules/ticket/front/advance/index.html index d82d8cc50..9f271b498 100644 --- a/modules/ticket/front/advance/index.html +++ b/modules/ticket/front/advance/index.html @@ -60,7 +60,7 @@ Stock - + Import @@ -81,7 +81,7 @@ Lines - + Import From 3622eda589eaadd9fc6a5216c4fa00bbd4c48436 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 15:09:16 +0100 Subject: [PATCH 81/94] refs #5131 added lines liters to origin ticket --- db/changes/230401/00-ticket_canAdvance.sql | 18 +++++++++++------- modules/ticket/front/advance/index.html | 12 ++++++++++-- modules/ticket/front/advance/index.js | 4 ++++ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/db/changes/230401/00-ticket_canAdvance.sql b/db/changes/230401/00-ticket_canAdvance.sql index 2072259b1..fd9d451bf 100644 --- a/db/changes/230401/00-ticket_canAdvance.sql +++ b/db/changes/230401/00-ticket_canAdvance.sql @@ -59,15 +59,17 @@ BEGIN GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt, t2.ipt, t.workerFk, - CAST(sum(litros) AS DECIMAL(10,0)) liters, - CAST(count(*) AS DECIMAL(10,0)) `lines`, + CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters, + CAST(COUNT(*) AS DECIMAL(10,0)) `futureLines`, t2.shipped, t.shipped futureShipped, t2.totalWithVat, t.totalWithVat futureTotalWithVat, - t2.hasStock, t2.agency, - am.name futureAgency + am.name futureAgency, + t2.lines, + t2.liters, + SUM((s.quantity <= IFNULL(st.amount,0))) hasStock FROM vn.ticket t JOIN vn.ticketState ts ON ts.ticketFk = t.id JOIN vn.state st ON st.id = ts.stateFk @@ -77,19 +79,20 @@ BEGIN t2.addressFk, st.isNotValidated, st.name state, - GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, + GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) ipt, t2.shipped, t2.totalWithVat, am.name agency, - sum((s.quantity <= IFNULL(st.amount,0))) hasStock + CAST(SUM(litros) AS DECIMAL(10,0)) liters, + CAST(COUNT(*) AS DECIMAL(10,0)) `lines` FROM vn.ticket t2 + JOIN vn.saleVolume sv ON t2.id = sv.ticketFk JOIN vn.sale s ON s.ticketFk = t2.id JOIN vn.item i ON i.id = s.itemFk JOIN vn.ticketState ts ON ts.ticketFk = t2.id JOIN vn.state st ON st.id = ts.stateFk JOIN vn.agencyMode am ON t2.agencyModeFk = am.id LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk - LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk WHERE t2.shipped BETWEEN vDateToAdvance AND util.dayend(vDateToAdvance) AND t2.warehouseFk = vWarehouseFk GROUP BY t2.id) t2 ON t2.addressFk = t.addressFk @@ -97,6 +100,7 @@ BEGIN JOIN vn.item i ON i.id = s.itemFk JOIN vn.agencyMode am ON t.agencyModeFk = am.id LEFT JOIN vn.itemPackingType ipt ON ipt.code = i.itemPackingTypeFk + LEFT JOIN tmp.stock st ON st.itemFk = s.itemFk WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture) AND t.warehouseFk = vWarehouseFk GROUP BY t.id; diff --git a/modules/ticket/front/advance/index.html b/modules/ticket/front/advance/index.html index 9f271b498..3dd52b909 100644 --- a/modules/ticket/front/advance/index.html +++ b/modules/ticket/front/advance/index.html @@ -32,8 +32,8 @@ - Origin - Destination + Origin + Destination @@ -57,9 +57,15 @@ State + + Liters + Stock + + Lines + Import @@ -120,7 +126,9 @@ {{::ticket.futureState | dashIfEmpty}} + {{::ticket.futureLiters | dashIfEmpty}} {{::ticket.hasStock | dashIfEmpty}} + {{::ticket.futureLines | dashIfEmpty}} {{::(ticket.futureTotalWithVat ? ticket.futureTotalWithVat : 0) | currency: 'EUR': 2}} diff --git a/modules/ticket/front/advance/index.js b/modules/ticket/front/advance/index.js index ae299b00c..a29d2db97 100644 --- a/modules/ticket/front/advance/index.js +++ b/modules/ticket/front/advance/index.js @@ -163,6 +163,10 @@ export default class Controller extends Section { return {'liters': value}; case 'lines': return {'lines': value}; + case 'futureLiters': + return {'futureLiters': value}; + case 'futureLines': + return {'futureLines': value}; case 'ipt': return {'ipt': value}; case 'futureIpt': From 349829e5ed51a9a8eff91b5754fdda2bfa24f89f Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 15:29:00 +0100 Subject: [PATCH 82/94] refs #5131 fixed tests --- e2e/helpers/selectors.js | 4 +- e2e/paths/05-ticket/22_advance.spec.js | 61 ++++++------------- .../ticket/specs/getTicketsAdvance.spec.js | 14 ++--- 3 files changed, 27 insertions(+), 52 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index a1412f431..347396c94 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -778,8 +778,8 @@ export default { ipt: 'vn-autocomplete[label="Destination IPT"]', tableIpt: 'vn-autocomplete[name="ipt"]', tableFutureIpt: 'vn-autocomplete[name="futureIpt"]', - futureState: 'vn-autocomplete[label="Origin Grouped State"]', - state: 'vn-autocomplete[label="Destination Grouped State"]', + futureState: 'vn-check[label="Pending Origin"]', + state: 'vn-check[label="Pending Destination"]', warehouseFk: 'vn-autocomplete[label="Warehouse"]', tableButtonSearch: 'vn-button[vn-tooltip="Search"]', moveButton: 'vn-button[vn-tooltip="Advance tickets"]', diff --git a/e2e/paths/05-ticket/22_advance.spec.js b/e2e/paths/05-ticket/22_advance.spec.js index 6aaa81591..3a6234fe9 100644 --- a/e2e/paths/05-ticket/22_advance.spec.js +++ b/e2e/paths/05-ticket/22_advance.spec.js @@ -50,7 +50,7 @@ describe('Ticket Advance path', () => { await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); await page.autocompleteSearch(selectors.ticketAdvance.ipt, 'Horizontal'); await page.waitToClick(selectors.ticketAdvance.submit); - await page.waitForNumberOfElements(selectors.ticketAdvance.table, 0); + await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); await page.clearInput(selectors.ticketAdvance.ipt); @@ -62,7 +62,7 @@ describe('Ticket Advance path', () => { await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); await page.autocompleteSearch(selectors.ticketAdvance.futureIpt, 'Horizontal'); await page.waitToClick(selectors.ticketAdvance.submit); - await page.waitForNumberOfElements(selectors.ticketAdvance.table, 0); + await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); await page.clearInput(selectors.ticketAdvance.futureIpt); @@ -70,26 +70,36 @@ describe('Ticket Advance path', () => { await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); }); - it('should search with the origin grouped state', async() => { + it('should search with the origin pending state', async() => { await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.autocompleteSearch(selectors.ticketAdvance.futureState, 'Free'); + await page.waitToClick(selectors.ticketAdvance.futureState); await page.waitToClick(selectors.ticketAdvance.submit); await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.clearInput(selectors.ticketAdvance.futureState); + await page.waitToClick(selectors.ticketAdvance.futureState); + await page.waitToClick(selectors.ticketAdvance.submit); + await page.waitForNumberOfElements(selectors.ticketAdvance.table, 0); + + await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); + await page.waitToClick(selectors.ticketAdvance.futureState); await page.waitToClick(selectors.ticketAdvance.submit); await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); }); it('should search with the destination grouped state', async() => { await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.autocompleteSearch(selectors.ticketAdvance.state, 'Free'); + await page.waitToClick(selectors.ticketAdvance.state); await page.waitToClick(selectors.ticketAdvance.submit); await page.waitForNumberOfElements(selectors.ticketAdvance.table, 0); await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.clearInput(selectors.ticketAdvance.state); + await page.waitToClick(selectors.ticketAdvance.state); + await page.waitToClick(selectors.ticketAdvance.submit); + await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); + + await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); + await page.waitToClick(selectors.ticketAdvance.state); await page.waitToClick(selectors.ticketAdvance.submit); await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); }); @@ -116,42 +126,7 @@ describe('Ticket Advance path', () => { await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); }); - it('should search in smart-table with stock', async() => { - await page.waitToClick(selectors.ticketAdvance.tableButtonSearch); - await page.write(selectors.ticketAdvance.tableStock, '5'); - await page.waitForNumberOfElements(selectors.ticketAdvance.table, 2); - - await page.waitToClick(selectors.ticketAdvance.tableButtonSearch); - await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.waitToClick(selectors.ticketAdvance.submit); - await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); - }); - - it('should search in smart-table with especified Lines', async() => { - await page.waitToClick(selectors.ticketAdvance.tableButtonSearch); - await page.write(selectors.ticketAdvance.tableLines, '0'); - await page.keyboard.press('Enter'); - await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); - - await page.waitToClick(selectors.ticketAdvance.tableButtonSearch); - await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.waitToClick(selectors.ticketAdvance.submit); - await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); - }); - - it('should search in smart-table with especified Liters', async() => { - await page.waitToClick(selectors.ticketAdvance.tableButtonSearch); - await page.write(selectors.ticketAdvance.tableLiters, '0'); - await page.keyboard.press('Enter'); - await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); - - await page.waitToClick(selectors.ticketAdvance.tableButtonSearch); - await page.waitToClick(selectors.ticketAdvance.openAdvancedSearchButton); - await page.waitToClick(selectors.ticketAdvance.submit); - await page.waitForNumberOfElements(selectors.ticketAdvance.table, 1); - }); - - it('should check the three last tickets and move to the future', async() => { + it('should check the one ticket and move to the present', async() => { await page.waitToClick(selectors.ticketAdvance.multiCheck); await page.waitToClick(selectors.ticketAdvance.moveButton); await page.waitToClick(selectors.ticketAdvance.acceptButton); diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js index aab053127..7d3bc174d 100644 --- a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js @@ -29,7 +29,7 @@ describe('TicketFuture getTicketsAdvance()', () => { } }); - it('should return the tickets matching the origin grouped state', async() => { + it('should return the tickets matching the origin pending state', async() => { const tx = await models.Ticket.beginTransaction({}); try { @@ -39,7 +39,7 @@ describe('TicketFuture getTicketsAdvance()', () => { dateFuture: tomorrow, dateToAdvance: today, warehouseFk: 1, - state: 'OK' + futureIsNotValidated: true }; const ctx = {req: {accessToken: {userId: 9}}, args}; @@ -54,7 +54,7 @@ describe('TicketFuture getTicketsAdvance()', () => { } }); - it('should return the tickets matching the destination grouped state', async() => { + it('should return the tickets matching the destination pending state', async() => { const tx = await models.Ticket.beginTransaction({}); try { @@ -64,13 +64,13 @@ describe('TicketFuture getTicketsAdvance()', () => { dateFuture: tomorrow, dateToAdvance: today, warehouseFk: 1, - futureState: 'FREE' + isNotValidated: true }; const ctx = {req: {accessToken: {userId: 9}}, args}; const result = await models.Ticket.getTicketsAdvance(ctx, options); - expect(result.length).toBeGreaterThan(0); + expect(result.length).toEqual(0); await tx.rollback(); } catch (e) { @@ -89,7 +89,7 @@ describe('TicketFuture getTicketsAdvance()', () => { dateFuture: tomorrow, dateToAdvance: today, warehouseFk: 1, - ipt: 'Vertical' + ipt: 'V' }; const ctx = {req: {accessToken: {userId: 9}}, args}; @@ -114,7 +114,7 @@ describe('TicketFuture getTicketsAdvance()', () => { dateFuture: tomorrow, dateToAdvance: today, warehouseFk: 1, - tfIpt: 'Vertical' + tfIpt: 'V' }; const ctx = {req: {accessToken: {userId: 9}}, args}; From a3da71996ac56793e24fed3762d596f434dcb531 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 15:36:51 +0100 Subject: [PATCH 83/94] refs #5131 changelog --- CHANGELOG.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22efa1b28..d103f3194 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,14 +9,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - (Rutas) Al descargar varias facturas se comprime en un zip -- (Trabajadores -> Nuevo trabajador) Nueva sección +- (Trabajadores -> Nuevo trabajador) Nueva sección +- (Tickets -> Adelantar tickets) Añadidos campos "líneas" y "litros" al ticket origen +- (Tickets -> Adelantar tickets) Nuevo icono muestra cuando las agencias de los tickets origen/destino son distintas ### Changed -- +- (Tickets -> Adelantar tickets) Cambiados selectores de estado por checks "Pendiente origen/destino" +- (Tickets -> Adelantar tickets) Cambiado stock de destino a origen. ### Fixed - (Artículos -> Etiquetas) Permite intercambiar la relevancia entre dos etiquetas. - (Tickets -> Añadir pago) Eliminado "null" en las referencias +- (Tickets -> Adelantar tickets) Permite ordenar por importe +- (Tickets -> Adelantar tickets) El filtrado por encajado muestra también los tickets sin tipo de encajado ## [2302.01] - 2023-01-26 From fd440a4db38d8f328bca88f7a684db2a5cc1e1e4 Mon Sep 17 00:00:00 2001 From: alexandre Date: Tue, 31 Jan 2023 15:42:36 +0100 Subject: [PATCH 84/94] refs #5129 better translation tracked sales --- loopback/locale/es.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index df17b82a3..f86d211f7 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -259,7 +259,7 @@ "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9", "Failed to upload file": "Error al subir archivo", "The DOCUWARE PDF document does not exists": "El documento PDF Docuware no existe", - "It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que estén en marcha", + "It is not possible to modify tracked sales": "No es posible modificar líneas de pedido que se hayan empezado a preparar", "It is not possible to modify sales that their articles are from Floramondo": "No es posible modificar líneas de pedido cuyos artículos sean de Floramondo", "It is not possible to modify cloned sales": "No es posible modificar líneas de pedido clonadas" } From 17bb4b60727794f948e95a362d4dd40cdda6bf31 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 1 Feb 2023 07:17:16 +0100 Subject: [PATCH 85/94] refs #5088 added receiptId --- print/templates/reports/receipt/receipt.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/print/templates/reports/receipt/receipt.html b/print/templates/reports/receipt/receipt.html index 5dd4299be..be0bfc375 100644 --- a/print/templates/reports/receipt/receipt.html +++ b/print/templates/reports/receipt/receipt.html @@ -4,7 +4,7 @@

{{$t('title')}}

- Recibo de {{client.socialName}}, + Recibo #{{receipt.id}} de {{client.socialName}}, la cantidad de {{receipt.amountPaid}} € en concepto de 'entrega a cuenta'.

From 00ffc82f8d8a41753ce5c61c62c1fcd6254aa8de Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 1 Feb 2023 08:34:14 +0100 Subject: [PATCH 86/94] use CURDATE() in rawSQL --- modules/route/back/methods/route/updateWorkCenter.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/route/back/methods/route/updateWorkCenter.js b/modules/route/back/methods/route/updateWorkCenter.js index 75169ce7e..7796fba41 100644 --- a/modules/route/back/methods/route/updateWorkCenter.js +++ b/modules/route/back/methods/route/updateWorkCenter.js @@ -33,13 +33,12 @@ module.exports = Self => { } try { - const date = Date.vnNew(); const [result] = await Self.rawSql(` SELECT IFNULL(wl.workCenterFk, r.defaultWorkCenterFk) AS commissionWorkCenter FROM vn.routeConfig r LEFT JOIN vn.workerLabour wl ON wl.workerFk = ? - AND ? BETWEEN wl.started AND IFNULL(wl.ended, ?); - `, [userId, date, date], myOptions); + AND CURDATE() BETWEEN wl.started AND IFNULL(wl.ended, CURDATE()); + `, [userId], myOptions); const route = await models.Route.findById(id, null, myOptions); await route.updateAttribute('commissionWorkCenterFk', result.commissionWorkCenter, myOptions); From 650cc68f4a789e427cecb1a87941e915e581823b Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Wed, 1 Feb 2023 08:42:20 +0100 Subject: [PATCH 87/94] requested changes --- db/changes/230401/00-alter_notSubs.sql | 4 ++-- .../00-uniqueKeyNotificationSubscription.sql | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename db/changes/{230201 => 230401}/00-uniqueKeyNotificationSubscription.sql (100%) diff --git a/db/changes/230401/00-alter_notSubs.sql b/db/changes/230401/00-alter_notSubs.sql index a4177bba4..992675837 100644 --- a/db/changes/230401/00-alter_notSubs.sql +++ b/db/changes/230401/00-alter_notSubs.sql @@ -1,4 +1,4 @@ ALTER TABLE util.notificationSubscription -ADD Id int(11) auto_increment NULL, +ADD id int(11) auto_increment NULL, DROP PRIMARY KEY, -ADD CONSTRAINT PRIMARY KEY (Id); +ADD CONSTRAINT PRIMARY KEY (id); diff --git a/db/changes/230201/00-uniqueKeyNotificationSubscription.sql b/db/changes/230401/00-uniqueKeyNotificationSubscription.sql similarity index 100% rename from db/changes/230201/00-uniqueKeyNotificationSubscription.sql rename to db/changes/230401/00-uniqueKeyNotificationSubscription.sql From 56f7794d87f632152bc1a6547efa21b2f6519cbb Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 1 Feb 2023 08:48:47 +0100 Subject: [PATCH 88/94] typo --- db/changes/230401/00-alter_notSubs.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/changes/230401/00-alter_notSubs.sql b/db/changes/230401/00-alter_notSubs.sql index 992675837..9cbfcbb3c 100644 --- a/db/changes/230401/00-alter_notSubs.sql +++ b/db/changes/230401/00-alter_notSubs.sql @@ -1,4 +1,4 @@ -ALTER TABLE util.notificationSubscription -ADD id int(11) auto_increment NULL, -DROP PRIMARY KEY, -ADD CONSTRAINT PRIMARY KEY (id); +ALTER TABLE `util`.`notificationSubscription` +ADD `id` int(11) auto_increment NULL, +DROP PRIMARY KEY, +ADD CONSTRAINT PRIMARY KEY (`id`); From 39d4b538723fcd698b209d87b8cece3212ddad6c Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 1 Feb 2023 09:00:49 +0100 Subject: [PATCH 89/94] fix: sql fail in real structure... --- .../230401/{00-alter_notSubs.sql => 01-alter_notSubs.sql} | 3 +++ db/dump/structure.sql | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) rename db/changes/230401/{00-alter_notSubs.sql => 01-alter_notSubs.sql} (55%) diff --git a/db/changes/230401/00-alter_notSubs.sql b/db/changes/230401/01-alter_notSubs.sql similarity index 55% rename from db/changes/230401/00-alter_notSubs.sql rename to db/changes/230401/01-alter_notSubs.sql index 9cbfcbb3c..07ea7c2bf 100644 --- a/db/changes/230401/00-alter_notSubs.sql +++ b/db/changes/230401/01-alter_notSubs.sql @@ -2,3 +2,6 @@ ALTER TABLE `util`.`notificationSubscription` ADD `id` int(11) auto_increment NULL, DROP PRIMARY KEY, ADD CONSTRAINT PRIMARY KEY (`id`); + +ALTER TABLE `util`.`notificationSubscription` +ADD KEY `notificationSubscription_ibfk_1` (`notificationFk`); diff --git a/db/dump/structure.sql b/db/dump/structure.sql index 831296bc6..772d6055d 100644 --- a/db/dump/structure.sql +++ b/db/dump/structure.sql @@ -19729,7 +19729,6 @@ CREATE TABLE `notificationSubscription` ( `notificationFk` int(11) NOT NULL, `userFk` int(10) unsigned NOT NULL, PRIMARY KEY (`notificationFk`,`userFk`), - KEY `notificationSubscription_ibfk_1` (`notificationFk`), KEY `notificationSubscription_ibfk_2` (`userFk`), CONSTRAINT `notificationSubscription_ibfk_1` FOREIGN KEY (`notificationFk`) REFERENCES `notification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `notificationSubscription_ibfk_2` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE From 4a587049fcb0ac30d878d0ed13a30691fe6f7d06 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 1 Feb 2023 15:13:38 +0100 Subject: [PATCH 90/94] feat(recover-password): use user refs #5170 --- back/methods/account/recover-password.js | 17 +++++++++++++---- e2e/helpers/selectors.js | 2 +- e2e/paths/01-salix/04_recoverPassword.spec.js | 14 +++++++++++++- .../components/recover-password/index.html | 4 ++-- .../salix/components/recover-password/index.js | 2 +- .../components/recover-password/locale/es.yml | 1 + 6 files changed, 31 insertions(+), 9 deletions(-) diff --git a/back/methods/account/recover-password.js b/back/methods/account/recover-password.js index ddea76829..787a45284 100644 --- a/back/methods/account/recover-password.js +++ b/back/methods/account/recover-password.js @@ -3,9 +3,9 @@ module.exports = Self => { description: 'Send email to the user', accepts: [ { - arg: 'email', + arg: 'user', type: 'string', - description: 'The email of user', + description: 'The user name or email', required: true } ], @@ -15,11 +15,20 @@ module.exports = Self => { } }); - Self.recoverPassword = async function(email) { + Self.recoverPassword = async function(user) { const models = Self.app.models; + const usesEmail = user.indexOf('@') !== -1; + if (!usesEmail) { + const account = await models.Account.findOne({ + fields: ['email'], + where: {name: user} + }); + user = account.email; + } + try { - await models.user.resetPassword({email, emailTemplate: 'recover-password'}); + await models.user.resetPassword({email: user, emailTemplate: 'recover-password'}); } catch (err) { if (err.code === 'EMAIL_NOT_FOUND') return; diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 986c6547b..3e8904572 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -31,7 +31,7 @@ export default { }, recoverPassword: { recoverPasswordButton: 'vn-login a[ui-sref="recover-password"]', - email: 'vn-recover-password vn-textfield[ng-model="$ctrl.email"]', + email: 'vn-recover-password vn-textfield[ng-model="$ctrl.user"]', sendEmailButton: 'vn-recover-password vn-submit', }, accountIndex: { diff --git a/e2e/paths/01-salix/04_recoverPassword.spec.js b/e2e/paths/01-salix/04_recoverPassword.spec.js index e6cb02ab1..aa0389648 100644 --- a/e2e/paths/01-salix/04_recoverPassword.spec.js +++ b/e2e/paths/01-salix/04_recoverPassword.spec.js @@ -26,7 +26,7 @@ describe('RecoverPassword path', async() => { expect(message.text).toContain('Notification sent!'); }); - it('should send email', async() => { + it('should send email using email', async() => { await page.waitForState('login'); await page.waitToClick(selectors.recoverPassword.recoverPasswordButton); @@ -37,4 +37,16 @@ describe('RecoverPassword path', async() => { expect(message.text).toContain('Notification sent!'); }); + + it('should send email using username', async() => { + await page.waitForState('login'); + await page.waitToClick(selectors.recoverPassword.recoverPasswordButton); + + await page.write(selectors.recoverPassword.email, 'BruceWayne'); + await page.waitToClick(selectors.recoverPassword.sendEmailButton); + const message = await page.waitForSnackbar(); + await page.waitForState('login'); + + expect(message.text).toContain('Notification sent!'); + }); }); diff --git a/front/salix/components/recover-password/index.html b/front/salix/components/recover-password/index.html index 73f5401d9..5121f81bd 100644 --- a/front/salix/components/recover-password/index.html +++ b/front/salix/components/recover-password/index.html @@ -1,7 +1,7 @@
Recover password
Date: Thu, 2 Feb 2023 09:21:12 +0100 Subject: [PATCH 91/94] Added version 23.06.01 --- CHANGELOG.md | 11 +++++++++++ db/changes/230601/.gitkeep | 0 package.json | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 db/changes/230601/.gitkeep diff --git a/CHANGELOG.md b/CHANGELOG.md index bf8cfd17c..91ce818a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2306.01] - 2023-02-23 + +### Added +- + +### Changed +- + +### Fixed +- + ## [2304.01] - 2023-02-09 ### Added diff --git a/db/changes/230601/.gitkeep b/db/changes/230601/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/package.json b/package.json index 46b7d4ffc..f9828624d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "23.04.01", + "version": "23.06.01", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From 15429293dd19fdba7f8d9f3573679fbdc24d728a Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 2 Feb 2023 11:34:13 +0100 Subject: [PATCH 92/94] fix: frontTest --- front/core/components/smart-table/index.spec.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/front/core/components/smart-table/index.spec.js b/front/core/components/smart-table/index.spec.js index 5fd4c33b7..5a1be98e1 100644 --- a/front/core/components/smart-table/index.spec.js +++ b/front/core/components/smart-table/index.spec.js @@ -160,7 +160,7 @@ describe('Component smartTable', () => { describe('applySort()', () => { it('should call the $state go and model refresh without making changes on the model order', () => { controller.$state = { - go: jest.fn(), + go: jest.fn().mockReturnValue(new Promise(resolve => resolve())), current: { name: 'section' } @@ -171,13 +171,12 @@ describe('Component smartTable', () => { expect(controller.model.order).toBeUndefined(); expect(controller.$state.go).toHaveBeenCalled(); - expect(controller.refresh).toHaveBeenCalled(); }); it('should call the $state go and model refresh after setting model order according to the controller sortCriteria', () => { const orderBy = {field: 'myField', sortType: 'ASC'}; controller.$state = { - go: jest.fn(), + go: jest.fn().mockReturnValue(new Promise(resolve => resolve())), current: { name: 'section' } @@ -190,7 +189,6 @@ describe('Component smartTable', () => { expect(controller.model.order).toEqual(`${orderBy.field} ${orderBy.sortType}`); expect(controller.$state.go).toHaveBeenCalled(); - expect(controller.refresh).toHaveBeenCalled(); }); }); @@ -293,12 +291,10 @@ describe('Component smartTable', () => { controller.$inputsScope = { searchProps: {} }; - jest.spyOn(controller, 'refresh'); controller.defaultFilter(); expect(controller.model.addFilter).toHaveBeenCalled(); - expect(controller.refresh).toHaveBeenCalled(); }); }); From 8a50c56284328362b7b97661e403ca86abea773d Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 2 Feb 2023 14:52:40 +0100 Subject: [PATCH 93/94] fix(updateWorkCenter): use vnNew() --- db/dump/mockDate.sql | 2 +- modules/route/back/methods/route/updateWorkCenter.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/db/dump/mockDate.sql b/db/dump/mockDate.sql index e9a81eb86..937da071c 100644 --- a/db/dump/mockDate.sql +++ b/db/dump/mockDate.sql @@ -7,7 +7,7 @@ CREATE FUNCTION `util`.`mockedDate`() RETURNS DATETIME DETERMINISTIC BEGIN - RETURN '2001-01-01 11:00:00'; + RETURN CONVERT_TZ('2001-01-01 11:00:00', 'utc', 'Europe/Madrid'); END ;; DELIMITER ; diff --git a/modules/route/back/methods/route/updateWorkCenter.js b/modules/route/back/methods/route/updateWorkCenter.js index 7796fba41..75169ce7e 100644 --- a/modules/route/back/methods/route/updateWorkCenter.js +++ b/modules/route/back/methods/route/updateWorkCenter.js @@ -33,12 +33,13 @@ module.exports = Self => { } try { + const date = Date.vnNew(); const [result] = await Self.rawSql(` SELECT IFNULL(wl.workCenterFk, r.defaultWorkCenterFk) AS commissionWorkCenter FROM vn.routeConfig r LEFT JOIN vn.workerLabour wl ON wl.workerFk = ? - AND CURDATE() BETWEEN wl.started AND IFNULL(wl.ended, CURDATE()); - `, [userId], myOptions); + AND ? BETWEEN wl.started AND IFNULL(wl.ended, ?); + `, [userId, date, date], myOptions); const route = await models.Route.findById(id, null, myOptions); await route.updateAttribute('commissionWorkCenterFk', result.commissionWorkCenter, myOptions); From 03d7a2908ba72f1e78aa835ef7e8b0dfc28c7873 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 3 Feb 2023 11:25:14 +0100 Subject: [PATCH 94/94] refactor: only mock vn.time from 2000 to 2002 --- db/dump/fixtures.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 8af1cbccd..5c7bbf192 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -16,7 +16,7 @@ BEGIN DECLARE vDate DATE; SET vDate = '2000-01-01'; - WHILE ( YEAR(vDate) <= 2007 ) DO + WHILE ( YEAR(vDate) <= 2002 ) DO INSERT IGNORE INTO vn.`time` (dated, period, `month`, `year`, `day`, week, yearMonth, salesYear) VALUES (vDate, CONCAT(YEAR(vDate), (WEEK(vDate)+1)), MONTH(vDate), YEAR(vDate), DAY(vDate), WEEK(vDate)+1, CONCAT(YEAR(vDate), MONTH(vDate)), YEAR(vDate));