From 42df7114640289156b9416778e608fc716247431 Mon Sep 17 00:00:00 2001 From: pablone Date: Sun, 15 Oct 2023 11:15:07 +0200 Subject: [PATCH 001/153] refs #6130 --- commitlint.config.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 commitlint.config.js diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 000000000..28fe5c5bf --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1 @@ +module.exports = {extends: ['@commitlint/config-conventional']} From 38ee64d8f120669a16da7548aa3d8d54a1024169 Mon Sep 17 00:00:00 2001 From: pablone Date: Sun, 15 Oct 2023 11:15:35 +0200 Subject: [PATCH 002/153] refs #6131 --- commitlint.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commitlint.config.js b/commitlint.config.js index 28fe5c5bf..3347cb961 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1 +1 @@ -module.exports = {extends: ['@commitlint/config-conventional']} +module.exports = {extends: ['@commitlint/config-conventional']}; From a2f843f4e2aad6a09c166afa6b5fcf030c95f003 Mon Sep 17 00:00:00 2001 From: pablone Date: Sun, 15 Oct 2023 11:21:13 +0200 Subject: [PATCH 003/153] refs #6130 --- .husky/commit-msg | 4 ++++ package-lock.json | 22 ++++++++++++++++++++++ package.json | 1 + 3 files changed, 27 insertions(+) create mode 100755 .husky/commit-msg diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 000000000..c160a7712 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx --no -- commitlint --edit ${1} diff --git a/package-lock.json b/package-lock.json index c3f88bc2c..96db6a921 100644 --- a/package-lock.json +++ b/package-lock.json @@ -78,6 +78,7 @@ "html-loader": "^0.4.5", "html-loader-jest": "^0.2.1", "html-webpack-plugin": "^5.5.1", + "husky": "^8.0.3", "identity-obj-proxy": "^3.0.0", "jasmine": "^5.0.0", "jasmine-reporters": "^2.4.0", @@ -11721,6 +11722,21 @@ "ms": "^2.0.0" } }, + "node_modules/husky": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", + "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", + "dev": true, + "bin": { + "husky": "lib/bin.js" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/i18n": { "version": "0.8.6", "integrity": "sha512-aMsJq8i1XXrb+BBsgmJBwak9mr69zPEIAUPb6c5yw2G/O4k1Q52lBxL+agZdQDN/RGf1ylQzrCswsOOgIiC1FA==", @@ -36379,6 +36395,12 @@ "ms": "^2.0.0" } }, + "husky": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.3.tgz", + "integrity": "sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==", + "dev": true + }, "i18n": { "version": "0.8.6", "integrity": "sha512-aMsJq8i1XXrb+BBsgmJBwak9mr69zPEIAUPb6c5yw2G/O4k1Q52lBxL+agZdQDN/RGf1ylQzrCswsOOgIiC1FA==", diff --git a/package.json b/package.json index 3320705f5..21e728253 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,7 @@ "html-loader": "^0.4.5", "html-loader-jest": "^0.2.1", "html-webpack-plugin": "^5.5.1", + "husky": "^8.0.3", "identity-obj-proxy": "^3.0.0", "jasmine": "^5.0.0", "jasmine-reporters": "^2.4.0", From a0eb6d0399d002167cfdb81502e3314b621cd8db Mon Sep 17 00:00:00 2001 From: pablone Date: Sun, 15 Oct 2023 11:33:05 +0200 Subject: [PATCH 004/153] feat(git): add commit lint refs#6130 --- .husky/commit-msg | 2 +- package.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.husky/commit-msg b/.husky/commit-msg index c160a7712..482222a2b 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1,4 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -npx --no -- commitlint --edit ${1} +npm run commitlint ${1} diff --git a/package.json b/package.json index 21e728253..a2da79062 100644 --- a/package.json +++ b/package.json @@ -114,7 +114,8 @@ "test:front": "jest --watch", "back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back", "lint": "eslint ./ --cache --ignore-pattern .gitignore", - "docker": "docker build --progress=plain -t salix-db ./db" + "docker": "docker build --progress=plain -t salix-db ./db", + "commitlint": "commitlint --edit" }, "jest": { "projects": [ From 597c5bd7500aac75f5d13dbf25ab63d609025e6a Mon Sep 17 00:00:00 2001 From: pablone Date: Sun, 15 Oct 2023 11:35:15 +0200 Subject: [PATCH 005/153] feat(git): add commit lint refs #6130 --- modules/claim/front/basic-data/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/claim/front/basic-data/index.html b/modules/claim/front/basic-data/index.html index 10aa7623a..308c069b6 100644 --- a/modules/claim/front/basic-data/index.html +++ b/modules/claim/front/basic-data/index.html @@ -17,7 +17,7 @@ label="Client" ng-model="$ctrl.claim.client.name" readonly="true"> - + Date: Sun, 15 Oct 2023 11:38:27 +0200 Subject: [PATCH 006/153] fix(claim): remove blank space refs #6130 --- modules/claim/front/basic-data/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/claim/front/basic-data/index.html b/modules/claim/front/basic-data/index.html index 308c069b6..10aa7623a 100644 --- a/modules/claim/front/basic-data/index.html +++ b/modules/claim/front/basic-data/index.html @@ -17,7 +17,7 @@ label="Client" ng-model="$ctrl.claim.client.name" readonly="true"> - + Date: Thu, 9 Nov 2023 07:56:35 +0100 Subject: [PATCH 007/153] =?UTF-8?q?refactor(printer-notification):=20refs?= =?UTF-8?q?=20#6005=20refactor=20de=20la=20notificaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../234601/00-sectorBackUpLabelerFk.sql | 19 +++++++++++++++++++ db/dump/fixtures.sql | 15 +++++++-------- modules/shelving/back/models/sector.json | 2 +- .../methods/operator/spec/operator.spec.js | 2 +- modules/worker/back/models/operator.js | 10 +++++----- .../assets/css/import.js | 0 .../backup-printer-selected.html | 14 ++++++++++++++ .../backup-printer-selected.js} | 4 ++-- .../backup-printer-selected/locale/en.yml | 3 +++ .../backup-printer-selected/locale/es.yml | 3 +++ .../sql/printer.sql | 3 ++- .../backup-printer-selected/sql/sector.sql | 5 +++++ .../sql/worker.sql | 0 .../not-main-printer-configured/locale/en.yml | 3 --- .../not-main-printer-configured/locale/es.yml | 3 --- .../not-main-printer-configured.html | 8 -------- .../sql/sector.sql | 3 --- 17 files changed, 62 insertions(+), 35 deletions(-) create mode 100644 db/changes/234601/00-sectorBackUpLabelerFk.sql rename print/templates/email/{not-main-printer-configured => backup-printer-selected}/assets/css/import.js (100%) create mode 100644 print/templates/email/backup-printer-selected/backup-printer-selected.html rename print/templates/email/{not-main-printer-configured/not-main-printer-configured.js => backup-printer-selected/backup-printer-selected.js} (92%) create mode 100644 print/templates/email/backup-printer-selected/locale/en.yml create mode 100644 print/templates/email/backup-printer-selected/locale/es.yml rename print/templates/email/{not-main-printer-configured => backup-printer-selected}/sql/printer.sql (63%) create mode 100644 print/templates/email/backup-printer-selected/sql/sector.sql rename print/templates/email/{not-main-printer-configured => backup-printer-selected}/sql/worker.sql (100%) delete mode 100644 print/templates/email/not-main-printer-configured/locale/en.yml delete mode 100644 print/templates/email/not-main-printer-configured/locale/es.yml delete mode 100644 print/templates/email/not-main-printer-configured/not-main-printer-configured.html delete mode 100644 print/templates/email/not-main-printer-configured/sql/sector.sql diff --git a/db/changes/234601/00-sectorBackUpLabelerFk.sql b/db/changes/234601/00-sectorBackUpLabelerFk.sql new file mode 100644 index 000000000..ac512493c --- /dev/null +++ b/db/changes/234601/00-sectorBackUpLabelerFk.sql @@ -0,0 +1,19 @@ +ALTER TABLE `vn`.`sector` CHANGE `mainPrinterFk` `backupPrinterFk` tinyint(3) unsigned DEFAULT NULL NULL; + +ALTER TABLE `util`.`notificationSubscription` DROP FOREIGN KEY `notificationSubscription_ibfk_1`; +ALTER TABLE `util`.`notificationQueue` DROP FOREIGN KEY `nnotificationQueue_ibfk_1`; +ALTER TABLE `util`.`notificationAcl` DROP FOREIGN KEY `notificationAcl_ibfk_1`; + +ALTER TABLE `util`.`notification` MODIFY COLUMN `id` int(11) auto_increment NOT NULL; + +ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`); +ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`name`); +ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`); + +DELETE FROM `util`.`notification` + WHERE `name` = 'not-main-printer-configured'; + +INSERT INTO `util`.`notification` + SET `id` = 15, + `name` = 'backup-printer-selected', + `description` = 'The worker has selected the backup printer for their sector'; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index d70279e7d..0fab05bda 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -174,19 +174,16 @@ INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory (13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 2, 1, 0), (60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0); - -INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`) - VALUES - (1, 'First sector', 1, 1, 'FIRST'), - (2, 'Second sector', 2, 0, 'SECOND'); - INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAddress`) VALUES (1, 'printer1', 'path1', 0, 1 , NULL), (2, 'printer2', 'path2', 1, 1 , NULL), (4, 'printer4', 'path4', 0, NULL, '10.1.10.4'); -UPDATE `vn`.`sector` SET mainPrinterFk = 1 WHERE id = 1; +INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `backupPrinterFk`) + VALUES + (1, 'First sector', 1, 1, 'FIRST', 1), + (2, 'Second sector', 2, 0, 'SECOND', NULL); INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`,`bossFk`, `phone`) VALUES @@ -2780,11 +2777,13 @@ INSERT INTO `util`.`notification` (`id`, `name`, `description`) VALUES (1, 'print-email', 'notification fixture one'), (2, 'invoice-electronic', 'A electronic invoice has been generated'), - (3, 'not-main-printer-configured', 'A printer distinct than main has been configured'), (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'), (5, 'modified-entry', 'An entry has been modified'), (6, 'book-entry-deleted', 'accounting entries deleted'); +INSERT IGNORE INTO `util`.`notification` (`id`, `name`, `description`) + VALUES (3, 'backup-printer-selected', 'A printer distinct than main has been configured'); + INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) VALUES (1, 9), diff --git a/modules/shelving/back/models/sector.json b/modules/shelving/back/models/sector.json index 47d66bd8d..36a25ed3b 100644 --- a/modules/shelving/back/models/sector.json +++ b/modules/shelving/back/models/sector.json @@ -56,7 +56,7 @@ "type": "number", "required": false }, - "mainPrinterFk": { + "backupPrinterFk": { "type": "number", "required": false }, diff --git a/modules/worker/back/methods/operator/spec/operator.spec.js b/modules/worker/back/methods/operator/spec/operator.spec.js index 1253be474..2d402b0d1 100644 --- a/modules/worker/back/methods/operator/spec/operator.spec.js +++ b/modules/worker/back/methods/operator/spec/operator.spec.js @@ -4,7 +4,7 @@ describe('Operator', () => { const authorFk = 9; const sectorId = 1; const mainPrinter = 1; - const notificationName = 'not-main-printer-configured'; + const notificationName = 'backup-printer-selected'; const operator = { workerFk: 1, trainFk: 1, diff --git a/modules/worker/back/models/operator.js b/modules/worker/back/models/operator.js index db1ac7e49..f51a6431c 100644 --- a/modules/worker/back/models/operator.js +++ b/modules/worker/back/models/operator.js @@ -1,5 +1,5 @@ module.exports = function(Self) { - Self.observe('after save', async function(ctx) { + Self.observe('after save', async ctx => { const instance = ctx.data || ctx.instance; const models = Self.app.models; const options = ctx.options; @@ -7,13 +7,13 @@ module.exports = function(Self) { if (!instance?.sectorFk || !instance?.labelerFk) return; const sector = await models.Sector.findById(instance.sectorFk, { - fields: ['mainPrinterFk'] + fields: ['backupPrinterFk'] }, options); - if (sector.mainPrinterFk && sector.mainPrinterFk != instance.labelerFk) { - const userId = ctx.options.accessToken.userId; + if (sector.backupPrinterFk && sector.backupPrinterFk == instance.labelerFk) { + const {userId} = ctx.options.accessToken; await models.NotificationQueue.create({ - notificationFk: 'not-main-printer-configured', + notificationFk: 'backup-printer-selected', authorFk: userId, params: JSON.stringify( { diff --git a/print/templates/email/not-main-printer-configured/assets/css/import.js b/print/templates/email/backup-printer-selected/assets/css/import.js similarity index 100% rename from print/templates/email/not-main-printer-configured/assets/css/import.js rename to print/templates/email/backup-printer-selected/assets/css/import.js diff --git a/print/templates/email/backup-printer-selected/backup-printer-selected.html b/print/templates/email/backup-printer-selected/backup-printer-selected.html new file mode 100644 index 000000000..51fb41773 --- /dev/null +++ b/print/templates/email/backup-printer-selected/backup-printer-selected.html @@ -0,0 +1,14 @@ + +
+
+

{{ $t('title') }}

+

+

+
+
diff --git a/print/templates/email/not-main-printer-configured/not-main-printer-configured.js b/print/templates/email/backup-printer-selected/backup-printer-selected.js similarity index 92% rename from print/templates/email/not-main-printer-configured/not-main-printer-configured.js rename to print/templates/email/backup-printer-selected/backup-printer-selected.js index c381991fa..0e56396db 100755 --- a/print/templates/email/not-main-printer-configured/not-main-printer-configured.js +++ b/print/templates/email/backup-printer-selected/backup-printer-selected.js @@ -2,7 +2,7 @@ const Component = require(`vn-print/core/component`); const emailBody = new Component('email-body'); module.exports = { - name: 'not-main-printer-configured', + name: 'backup-printer-selected', async serverPrefetch() { this.sector = await this.findOneFromDef('sector', [this.sectorId]); @@ -10,7 +10,7 @@ module.exports = { throw new Error('Something went wrong'); this.labeler = await this.findOneFromDef('printer', [this.labelerId]); - this.mainPrinter = await this.findOneFromDef('printer', [this.sector.mainPrinterFk]); + this.mainPrinter = await this.findOneFromDef('printer', [this.sector.backupPrinterFk]); this.worker = await this.findOneFromDef('worker', [this.workerId]); }, components: { diff --git a/print/templates/email/backup-printer-selected/locale/en.yml b/print/templates/email/backup-printer-selected/locale/en.yml new file mode 100644 index 000000000..917881641 --- /dev/null +++ b/print/templates/email/backup-printer-selected/locale/en.yml @@ -0,0 +1,3 @@ +subject: Not main printer configured +title: Not main printer configured +description: 'The worker #{0} is using the backup printer {1} for their sector {2}.' diff --git a/print/templates/email/backup-printer-selected/locale/es.yml b/print/templates/email/backup-printer-selected/locale/es.yml new file mode 100644 index 000000000..a250ba20f --- /dev/null +++ b/print/templates/email/backup-printer-selected/locale/es.yml @@ -0,0 +1,3 @@ +subject: Configurada impresora no principal +title: Configurada impresora no principal +description: 'El trabajador #{0} esta utilizando la impresora de repuesto {1} su sector {2}.' diff --git a/print/templates/email/not-main-printer-configured/sql/printer.sql b/print/templates/email/backup-printer-selected/sql/printer.sql similarity index 63% rename from print/templates/email/not-main-printer-configured/sql/printer.sql rename to print/templates/email/backup-printer-selected/sql/printer.sql index 265818129..2a98a8f08 100644 --- a/print/templates/email/not-main-printer-configured/sql/printer.sql +++ b/print/templates/email/backup-printer-selected/sql/printer.sql @@ -1,3 +1,4 @@ -SELECT id, name +SELECT id, + name FROM vn.printer WHERE id = ? diff --git a/print/templates/email/backup-printer-selected/sql/sector.sql b/print/templates/email/backup-printer-selected/sql/sector.sql new file mode 100644 index 000000000..9514c4e38 --- /dev/null +++ b/print/templates/email/backup-printer-selected/sql/sector.sql @@ -0,0 +1,5 @@ +SELECT id, + description, + backupPrinterFk + FROM vn.sector + WHERE id = ? diff --git a/print/templates/email/not-main-printer-configured/sql/worker.sql b/print/templates/email/backup-printer-selected/sql/worker.sql similarity index 100% rename from print/templates/email/not-main-printer-configured/sql/worker.sql rename to print/templates/email/backup-printer-selected/sql/worker.sql diff --git a/print/templates/email/not-main-printer-configured/locale/en.yml b/print/templates/email/not-main-printer-configured/locale/en.yml deleted file mode 100644 index 2a3051145..000000000 --- a/print/templates/email/not-main-printer-configured/locale/en.yml +++ /dev/null @@ -1,3 +0,0 @@ -subject: Not main printer configured -title: Not main printer configured -description: 'Printer #{0} {1} has been configured in sector #{2} {3} (the main printer for that sector is #{4} {5}). Ask the worker {6}.' diff --git a/print/templates/email/not-main-printer-configured/locale/es.yml b/print/templates/email/not-main-printer-configured/locale/es.yml deleted file mode 100644 index b6fe5f9a0..000000000 --- a/print/templates/email/not-main-printer-configured/locale/es.yml +++ /dev/null @@ -1,3 +0,0 @@ -subject: Configurada impresora no principal -title: Configurada impresora no principal -description: 'Se ha configurado la impresora #{0} {1} en el sector #{2} {3} (la impresora principal de ese sector es la #{4} {5}). Preguntar al trabajador {6}.' diff --git a/print/templates/email/not-main-printer-configured/not-main-printer-configured.html b/print/templates/email/not-main-printer-configured/not-main-printer-configured.html deleted file mode 100644 index 1e9ffed7a..000000000 --- a/print/templates/email/not-main-printer-configured/not-main-printer-configured.html +++ /dev/null @@ -1,8 +0,0 @@ - -
-
-

{{ $t('title') }}

-

-
-
-
diff --git a/print/templates/email/not-main-printer-configured/sql/sector.sql b/print/templates/email/not-main-printer-configured/sql/sector.sql deleted file mode 100644 index 5d54eeeb9..000000000 --- a/print/templates/email/not-main-printer-configured/sql/sector.sql +++ /dev/null @@ -1,3 +0,0 @@ -SELECT id, description, mainPrinterFk - FROM vn.sector - WHERE id = ? From 1e4f778ef97745a9b41439d07cf3b7ca02728eaf Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 9 Nov 2023 13:22:12 +0100 Subject: [PATCH 008/153] refactor(main-labeler): refs #6005 refactor de mainLabeler a backupPrinterFk --- db/dump/fixtures.sql | 14 +++++++++----- .../back/methods/operator/spec/operator.spec.js | 11 +++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 5413e4d03..7a1473f18 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -174,16 +174,20 @@ INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory (13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 2, 1, 0), (60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0); +INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `backupPrinterFk`) + VALUES + (1, 'First sector', 1, 1, 'FIRST', NULL), + (2, 'Second sector', 2, 0, 'SECOND', NULL); + INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAddress`) VALUES (1, 'printer1', 'path1', 0, 1 , NULL), (2, 'printer2', 'path2', 1, 1 , NULL), (4, 'printer4', 'path4', 0, NULL, '10.1.10.4'); -INSERT INTO `vn`.`sector`(`id`, `description`, `warehouseFk`, `isPreviousPreparedByPacking`, `code`, `backupPrinterFk`) - VALUES - (1, 'First sector', 1, 1, 'FIRST', 1), - (2, 'Second sector', 2, 0, 'SECOND', NULL); +UPDATE `vn`.`sector` + SET `backupPrinterFk` = 1 + WHERE `id` = 1; INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`,`bossFk`, `phone`) VALUES @@ -2771,7 +2775,7 @@ INSERT INTO `vn`.`packingSiteConfig` (`shinobiUrl`, `shinobiToken`, `shinobiGrou VALUES ('', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000); INSERT INTO `util`.`notificationConfig` - SET `cleanDays` = 90; + SET `cleanDays` = 90; INSERT INTO `util`.`notification` (`id`, `name`, `description`) VALUES diff --git a/modules/worker/back/methods/operator/spec/operator.spec.js b/modules/worker/back/methods/operator/spec/operator.spec.js index 2d402b0d1..35aecf538 100644 --- a/modules/worker/back/methods/operator/spec/operator.spec.js +++ b/modules/worker/back/methods/operator/spec/operator.spec.js @@ -3,7 +3,6 @@ const models = require('vn-loopback/server/server').models; describe('Operator', () => { const authorFk = 9; const sectorId = 1; - const mainPrinter = 1; const notificationName = 'backup-printer-selected'; const operator = { workerFk: 1, @@ -23,17 +22,17 @@ describe('Operator', () => { }, options); } - it('should create notification when configured a not main printer in the sector', async() => { + it('should create notification when configured a backup printer in the sector', async() => { const tx = await models.Operator.beginTransaction({}); try { const options = {transaction: tx, accessToken: {userId: authorFk}}; - const notificationQueue = await createOperator(2, options); + const notificationQueue = await createOperator(1, options); const params = JSON.parse(notificationQueue.params); expect(notificationQueue.notificationFk).toEqual(notificationName); expect(notificationQueue.authorFk).toEqual(authorFk); - expect(params.labelerId).toEqual(2); + expect(params.labelerId).toEqual(1); expect(params.sectorId).toEqual(1); expect(params.workerId).toEqual(9); @@ -44,12 +43,12 @@ describe('Operator', () => { } }); - it('should not create notification when configured the main printer in the sector', async() => { + it('should not create notification when configured a non backup printer in the sector', async() => { const tx = await models.Operator.beginTransaction({}); try { const options = {transaction: tx, accessToken: {userId: authorFk}}; - const notificationQueue = await createOperator(mainPrinter, options); + const notificationQueue = await createOperator(2, options); expect(notificationQueue).toEqual(null); From 1b4ce1a0b5780d0454d0e52a15c4786877643450 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 23 Nov 2023 08:22:24 +0100 Subject: [PATCH 009/153] feat(noSpam): refs #6005 check if exists a previous notification --- back/models/notification.json | 3 ++ .../00-sectorBackUpLabelerFk.sql | 6 ++- db/dump/fixtures.sql | 20 +++++----- .../methods/operator/spec/operator.spec.js | 28 +++++++++++++ modules/worker/back/models/operator.js | 39 +++++++++++++------ 5 files changed, 75 insertions(+), 21 deletions(-) rename db/changes/{234601 => 234801}/00-sectorBackUpLabelerFk.sql (85%) diff --git a/back/models/notification.json b/back/models/notification.json index 56f66bf1d..07702d99d 100644 --- a/back/models/notification.json +++ b/back/models/notification.json @@ -18,6 +18,9 @@ }, "description": { "type": "string" + }, + "delay": { + "type": "number" } }, "relations": { diff --git a/db/changes/234601/00-sectorBackUpLabelerFk.sql b/db/changes/234801/00-sectorBackUpLabelerFk.sql similarity index 85% rename from db/changes/234601/00-sectorBackUpLabelerFk.sql rename to db/changes/234801/00-sectorBackUpLabelerFk.sql index ac512493c..bf7126693 100644 --- a/db/changes/234601/00-sectorBackUpLabelerFk.sql +++ b/db/changes/234801/00-sectorBackUpLabelerFk.sql @@ -1,3 +1,6 @@ +ALTER TABLE `util`.`notification` ADD delay INT NULL + COMMENT 'Minimum Milliseconds Interval to Prevent Spam from Same-Type Notifications'; + ALTER TABLE `vn`.`sector` CHANGE `mainPrinterFk` `backupPrinterFk` tinyint(3) unsigned DEFAULT NULL NULL; ALTER TABLE `util`.`notificationSubscription` DROP FOREIGN KEY `notificationSubscription_ibfk_1`; @@ -16,4 +19,5 @@ DELETE FROM `util`.`notification` INSERT INTO `util`.`notification` SET `id` = 15, `name` = 'backup-printer-selected', - `description` = 'The worker has selected the backup printer for their sector'; + `description` = 'The worker has selected the backup printer for their sector', + `delay` = 600000; diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index b492a7aed..870f56a30 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2782,17 +2782,19 @@ INSERT INTO `vn`.`packingSiteConfig` (`shinobiUrl`, `shinobiToken`, `shinobiGrou ('', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000); INSERT INTO `util`.`notificationConfig` SET `cleanDays` = 90; - -INSERT INTO `util`.`notification` (`id`, `name`, `description`) + +INSERT IGNORE INTO `util`.`notification` (`id`, `name`, `description`, `delay`) VALUES - (1, 'print-email', 'notification fixture one'), - (2, 'invoice-electronic', 'A electronic invoice has been generated'), - (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'), - (5, 'modified-entry', 'An entry has been modified'), - (6, 'book-entry-deleted', 'accounting entries deleted'); + (1, 'print-email', 'notification fixture one', NULL), + (2, 'invoice-electronic', 'A electronic invoice has been generated', NULL), + (3, 'backup-printer-selected', 'A printer distinct than main has been configured', 600000), + (4, 'supplier-pay-method-update', 'A supplier pay method has been updated', NULL), + (5, 'modified-entry', 'An entry has been modified', NULL), + (6, 'book-entry-deleted', 'accounting entries deleted', NULL); -INSERT IGNORE INTO `util`.`notification` (`id`, `name`, `description`) - VALUES (3, 'backup-printer-selected', 'A printer distinct than main has been configured'); +UPDATE `util`.`notification` + SET `id` = 3 + WHERE `name` = 'backup-printer-selected'; INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) VALUES diff --git a/modules/worker/back/methods/operator/spec/operator.spec.js b/modules/worker/back/methods/operator/spec/operator.spec.js index 35aecf538..1d4a9a84d 100644 --- a/modules/worker/back/methods/operator/spec/operator.spec.js +++ b/modules/worker/back/methods/operator/spec/operator.spec.js @@ -58,4 +58,32 @@ describe('Operator', () => { throw e; } }); + + it('should not create notification when is already notified', async() => { + const tx = await models.Operator.beginTransaction({}); + + try { + const options = {transaction: tx, accessToken: {userId: authorFk}}; + await models.NotificationQueue.create({ + authorFk: 1, + notificationFk: notificationName, + params: JSON.stringify({'labelerId': 10, 'sectorId': 10, 'workerId': 10}), + created: Date.vnNow(), + }, options); + + const notificationQueue = await createOperator(1, options); + const params = JSON.parse(notificationQueue.params); + + expect(notificationQueue.notificationFk).toEqual(notificationName); + expect(notificationQueue.authorFk).toEqual(1); + expect(params.labelerId).toEqual(10); + expect(params.sectorId).toEqual(10); + expect(params.workerId).toEqual(10); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); diff --git a/modules/worker/back/models/operator.js b/modules/worker/back/models/operator.js index f51a6431c..75ee07821 100644 --- a/modules/worker/back/models/operator.js +++ b/modules/worker/back/models/operator.js @@ -3,6 +3,7 @@ module.exports = function(Self) { const instance = ctx.data || ctx.instance; const models = Self.app.models; const options = ctx.options; + const notification = 'backup-printer-selected'; if (!instance?.sectorFk || !instance?.labelerFk) return; @@ -12,17 +13,33 @@ module.exports = function(Self) { if (sector.backupPrinterFk && sector.backupPrinterFk == instance.labelerFk) { const {userId} = ctx.options.accessToken; - await models.NotificationQueue.create({ - notificationFk: 'backup-printer-selected', - authorFk: userId, - params: JSON.stringify( - { - 'labelerId': instance.labelerFk, - 'sectorId': instance.sectorFk, - 'workerId': userId - } - ) - }, options); + const {delay} = await models.Notification.findOne({ + where: {name: notification} + }); + const hasNotified = await models.NotificationQueue.findOne({ + where: { + notificationFk: notification, + and: [ + {params: {like: '%\"labelerId\":' + instance.labelerFk + '%'}}, + {params: {like: '%\"sectorId\":' + instance.sectorFk + '%'}} + ] + }, + order: 'CREATED DESC', + }); + + if (hasNotified?.created - Date.now() > delay || !hasNotified?.created) { + await models.NotificationQueue.create({ + notificationFk: notification, + authorFk: userId, + params: JSON.stringify( + { + 'labelerId': instance.labelerFk, + 'sectorId': instance.sectorFk, + 'workerId': userId + } + ) + }, options); + } } }); }; From a35a79015524ee4889d06c7c72e028285f947c0b Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 23 Nov 2023 08:33:30 +0100 Subject: [PATCH 010/153] remove(getVideo.spec.js): refs #6005 created task to review the spec --- .../methods/boxing/specs/getVideo.spec.js | 40 ------------------- 1 file changed, 40 deletions(-) delete mode 100644 modules/ticket/back/methods/boxing/specs/getVideo.spec.js diff --git a/modules/ticket/back/methods/boxing/specs/getVideo.spec.js b/modules/ticket/back/methods/boxing/specs/getVideo.spec.js deleted file mode 100644 index 8e8cdc5b9..000000000 --- a/modules/ticket/back/methods/boxing/specs/getVideo.spec.js +++ /dev/null @@ -1,40 +0,0 @@ -const models = require('vn-loopback/server/server').models; -const https = require('https'); - -xdescribe('boxing getVideo()', () => { - it('should return data', async() => { - const tx = await models.PackingSiteConfig.beginTransaction({}); - - try { - const options = {transaction: tx}; - - const id = 1; - const video = 'video.mp4'; - - const response = { - pipe: () => {}, - on: () => {}, - end: () => {}, - }; - - const req = { - headers: 'apiHeader', - data: { - pipe: () => {}, - on: () => {}, - } - }; - - spyOn(https, 'request').and.returnValue(response); - - const result = await models.Boxing.getVideo(id, video, req, null, options); - - expect(result[0]).toEqual(response.data.videos[0].filename); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); -}); From 754150d17d4f69eb190ac171aebd9c2b5b79a158 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 23 Nov 2023 10:10:09 +0100 Subject: [PATCH 011/153] feat(operator.spec): refs #6005 add spec for delay and fix spec for spam --- .../methods/operator/spec/operator.spec.js | 50 +++++++++++++++---- modules/worker/back/models/operator.js | 8 +-- 2 files changed, 44 insertions(+), 14 deletions(-) diff --git a/modules/worker/back/methods/operator/spec/operator.spec.js b/modules/worker/back/methods/operator/spec/operator.spec.js index 1d4a9a84d..6a8b02e04 100644 --- a/modules/worker/back/methods/operator/spec/operator.spec.js +++ b/modules/worker/back/methods/operator/spec/operator.spec.js @@ -3,6 +3,7 @@ const models = require('vn-loopback/server/server').models; describe('Operator', () => { const authorFk = 9; const sectorId = 1; + const labeler = 1; const notificationName = 'backup-printer-selected'; const operator = { workerFk: 1, @@ -17,8 +18,10 @@ describe('Operator', () => { await models.Operator.create(operator, options); return models.NotificationQueue.findOne({ where: { - notificationFk: notificationName - } + notificationFk: notificationName, + authorFk: authorFk, + }, + order: 'created DESC', }, options); } @@ -27,7 +30,7 @@ describe('Operator', () => { try { const options = {transaction: tx, accessToken: {userId: authorFk}}; - const notificationQueue = await createOperator(1, options); + const notificationQueue = await createOperator(labeler, options); const params = JSON.parse(notificationQueue.params); expect(notificationQueue.notificationFk).toEqual(notificationName); @@ -59,7 +62,7 @@ describe('Operator', () => { } }); - it('should not create notification when is already notified', async() => { + it('should not create notification when is already notified by another worker', async() => { const tx = await models.Operator.beginTransaction({}); try { @@ -67,18 +70,45 @@ describe('Operator', () => { await models.NotificationQueue.create({ authorFk: 1, notificationFk: notificationName, - params: JSON.stringify({'labelerId': 10, 'sectorId': 10, 'workerId': 10}), + params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 10}), created: Date.vnNow(), }, options); - const notificationQueue = await createOperator(1, options); + const notificationQueue = await createOperator(labeler, options); + + expect(notificationQueue).toEqual(null); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should create notification when delay is null', async() => { + const tx = await models.Operator.beginTransaction({}); + + try { + const options = {transaction: tx, accessToken: {userId: authorFk}}; + + await models.NotificationQueue.create({ + authorFk: 1, + notificationFk: notificationName, + params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 10}), + created: Date.vnNow(), + }, options); + + const notification = await models.Notification.findOne({where: {name: notificationName}}, options); + await notification.updateAttributes({delay: null}, options); + + const notificationQueue = await createOperator(labeler, options); const params = JSON.parse(notificationQueue.params); expect(notificationQueue.notificationFk).toEqual(notificationName); - expect(notificationQueue.authorFk).toEqual(1); - expect(params.labelerId).toEqual(10); - expect(params.sectorId).toEqual(10); - expect(params.workerId).toEqual(10); + expect(notificationQueue.authorFk).toEqual(authorFk); + expect(params.labelerId).toEqual(1); + expect(params.sectorId).toEqual(1); + expect(params.workerId).toEqual(9); await tx.rollback(); } catch (e) { diff --git a/modules/worker/back/models/operator.js b/modules/worker/back/models/operator.js index 75ee07821..51fd0bfa1 100644 --- a/modules/worker/back/models/operator.js +++ b/modules/worker/back/models/operator.js @@ -15,7 +15,7 @@ module.exports = function(Self) { const {userId} = ctx.options.accessToken; const {delay} = await models.Notification.findOne({ where: {name: notification} - }); + }, options); const hasNotified = await models.NotificationQueue.findOne({ where: { notificationFk: notification, @@ -24,10 +24,10 @@ module.exports = function(Self) { {params: {like: '%\"sectorId\":' + instance.sectorFk + '%'}} ] }, - order: 'CREATED DESC', - }); + order: 'created DESC', + }, options); - if (hasNotified?.created - Date.now() > delay || !hasNotified?.created) { + if (hasNotified?.created - Date.now() > delay || !hasNotified?.created || !delay) { await models.NotificationQueue.create({ notificationFk: notification, authorFk: userId, From c9291197971f1b84a251dee0abf00fe6bcea77cd Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 28 Nov 2023 08:11:42 +0100 Subject: [PATCH 012/153] fix(spec): refs #6005 backupLabeler spec --- .../notification/specs/getList.spec.js | 5 +- .../specs/notificationSubscription.spec.js | 11 ++-- .../234801/00-sectorBackUpLabelerFk.sql | 19 ++++--- db/dump/dumpedFixtures.sql | 26 +++++++++ db/dump/fixtures.sql | 54 +++++++------------ db/export-data.sh | 2 + 6 files changed, 67 insertions(+), 50 deletions(-) diff --git a/back/methods/notification/specs/getList.spec.js b/back/methods/notification/specs/getList.spec.js index 52ac497a5..6c8507986 100644 --- a/back/methods/notification/specs/getList.spec.js +++ b/back/methods/notification/specs/getList.spec.js @@ -2,12 +2,11 @@ const models = require('vn-loopback/server/server').models; describe('NotificationSubscription getList()', () => { it('should return a list of available and active notifications of a user', async() => { - const userId = 9; - const {active, available} = await models.NotificationSubscription.getList(userId); + const {active, available} = await models.NotificationSubscription.getList(100); const notifications = await models.Notification.find({}); const totalAvailable = notifications.length - active.length; - expect(active.length).toEqual(2); + expect(active.length).toEqual(0); expect(available.length).toEqual(totalAvailable); }); }); diff --git a/back/models/specs/notificationSubscription.spec.js b/back/models/specs/notificationSubscription.spec.js index c2adcbc59..1d4b2354c 100644 --- a/back/models/specs/notificationSubscription.spec.js +++ b/back/models/specs/notificationSubscription.spec.js @@ -41,8 +41,7 @@ describe('loopback model NotificationSubscription', () => { try { const options = {transaction: tx, accessToken: {userId: 9}}; - const notificationSubscriptionId = 2; - await models.NotificationSubscription.destroyAll({id: notificationSubscriptionId}, options); + await models.NotificationSubscription.destroyAll({id: 2}, options); await tx.rollback(); } catch (e) { @@ -76,8 +75,7 @@ describe('loopback model NotificationSubscription', () => { try { const options = {transaction: tx, accessToken: {userId: 9}}; - const notificationSubscriptionId = 6; - await models.NotificationSubscription.destroyAll({id: notificationSubscriptionId}, options); + await models.NotificationSubscription.destroyAll({id: 6}, options); await tx.rollback(); } catch (e) { @@ -94,7 +92,7 @@ describe('loopback model NotificationSubscription', () => { try { const options = {transaction: tx, accessToken: {userId: 9}}; - await models.NotificationSubscription.create({notificationFk: 1, userFk: 5}, options); + await models.NotificationSubscription.create({notificationFk: 12, userFk: 5}, options); await tx.rollback(); } catch (e) { @@ -111,8 +109,7 @@ describe('loopback model NotificationSubscription', () => { try { const options = {transaction: tx, accessToken: {userId: 19}}; - const notificationSubscriptionId = 4; - await models.NotificationSubscription.destroyAll({id: notificationSubscriptionId}, options); + await models.NotificationSubscription.destroyAll({id: 4}, options); await tx.rollback(); } catch (e) { diff --git a/db/changes/234801/00-sectorBackUpLabelerFk.sql b/db/changes/234801/00-sectorBackUpLabelerFk.sql index bf7126693..605571fc8 100644 --- a/db/changes/234801/00-sectorBackUpLabelerFk.sql +++ b/db/changes/234801/00-sectorBackUpLabelerFk.sql @@ -9,15 +9,22 @@ ALTER TABLE `util`.`notificationAcl` DROP FOREIGN KEY `notificationAcl_ibfk_1`; ALTER TABLE `util`.`notification` MODIFY COLUMN `id` int(11) auto_increment NOT NULL; -ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`); -ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`name`); -ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`); +ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`name`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; DELETE FROM `util`.`notification` WHERE `name` = 'not-main-printer-configured'; -INSERT INTO `util`.`notification` - SET `id` = 15, - `name` = 'backup-printer-selected', +INSERT INTO `util`.`notification` + SET `name` = 'backup-printer-selected', `description` = 'The worker has selected the backup printer for their sector', `delay` = 600000; + +INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) + SELECT `n`.`id`, `r`.`id` + FROM `util`.`notification` `n` + JOIN `account`.`role` `r` + WHERE `n`.`name` = 'backup-printer-selected' + AND `r`.`name` = 'system' + LIMIT 1; diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index 3e46c8e04..3596eeb75 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -232,6 +232,32 @@ LOCK TABLES `agencyTermConfig` WRITE; /*!40000 ALTER TABLE `agencyTermConfig` DISABLE KEYS */; INSERT INTO `agencyTermConfig` VALUES ('6240000000','4721000015',21.0000000000,'Adquisiciones intracomunitarias de servicios'); /*!40000 ALTER TABLE `agencyTermConfig` ENABLE KEYS */; +UNLOCK TABLES; + +LOCK TABLES `notification` WRITE; +INSERT INTO `util`.`notification` (id, name, description) + VALUES(1, 'vehicle-event-expired', 'scheduled event of a vehicle'), + (2, 'invoice-electronic', 'A electronic invoice has been generated'), + (3, 'supplier-pay-method-update', 'A supplier pay method has been updated'), + (4, 'book-entries-imported-incorrectly', 'accounting entries exported incorrectly'), + (5, 'greuge-wrong', 'A wrong greuge has been created'), + (6, 'not-main-printer-configured', 'A printer distinct than main has been configured'), + (7, 'entry-update-comission', 'entry change comission'), + (8, 'modified-entry', 'An entry has been modified'), + (9, 'book-entry-deleted', 'accounting entries deleted'), + (10, 'modified-collection-volumetry', 'A collection volumetry has been modified'); +UNLOCK TABLES; + +LOCK TABLES `notificationAcl` WRITE; +INSERT INTO `util`.`notificationAcl` (notificationFk, roleFk) + VALUES(1, 57), + (3, 73), + (4, 5), + (6, 108), + (7, 30), + (7, 35), + (8, 15), + (9, 5); UNLOCK TABLES; -- diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 870f56a30..3215e6164 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2780,49 +2780,35 @@ INSERT INTO `vn`.`packingSite` (`id`, `code`, `hostFk`, `monitorId`) INSERT INTO `vn`.`packingSiteConfig` (`shinobiUrl`, `shinobiToken`, `shinobiGroupKey`, `avgBoxingTime`) VALUES ('', 'SHINNOBI_TOKEN', 'GROUP_TOKEN', 6000); -INSERT INTO `util`.`notificationConfig` - SET `cleanDays` = 90; - -INSERT IGNORE INTO `util`.`notification` (`id`, `name`, `description`, `delay`) - VALUES - (1, 'print-email', 'notification fixture one', NULL), - (2, 'invoice-electronic', 'A electronic invoice has been generated', NULL), - (3, 'backup-printer-selected', 'A printer distinct than main has been configured', 600000), - (4, 'supplier-pay-method-update', 'A supplier pay method has been updated', NULL), - (5, 'modified-entry', 'An entry has been modified', NULL), - (6, 'book-entry-deleted', 'accounting entries deleted', NULL); -UPDATE `util`.`notification` - SET `id` = 3 - WHERE `name` = 'backup-printer-selected'; +INSERT INTO `util`.`notificationConfig` + SET `cleanDays` = 90; -INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) - VALUES - (1, 9), - (1, 1), - (2, 1), - (3, 9), - (4, 1), - (5, 9), - (6, 9); +INSERT IGNORE INTO `util`.`notification` (`name`, `description`, `delay`) + VALUES ('print-email', 'notification fixture one', NULL); -INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`) - VALUES - (1, 'print-email', '{"id": "1"}', 9, 'pending', util.VN_CURDATE()), - (2, 'print-email', '{"id": "2"}', null, 'pending', util.VN_CURDATE()), - (3, 'print-email', null, null, 'pending', util.VN_CURDATE()); +INSERT INTO `util`.`notificationQueue` (`notificationFk`, `params`, `authorFk`, `status`, `created`) + VALUES ('print-email', '{"id": "1"}', 9, 'pending', util.VN_CURDATE()), + ('print-email', '{"id": "2"}', null, 'pending', util.VN_CURDATE()), + ('print-email', null, null, 'pending', util.VN_CURDATE()); INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) - VALUES - (1, 1109), - (1, 1110), + VALUES (12, 1109), + (12, 1110), (2, 1110), (4, 1110), (2, 1109), - (1, 9), - (1, 3), - (6, 9); + (12, 9), + (12, 3); +INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) + VALUES (12, 9), + (12, 1), + (4, 1), + (2, 1), + (3, 9), + (5, 9), + (10,1); INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) VALUES diff --git a/db/export-data.sh b/db/export-data.sh index 97092da4f..96a8754f9 100755 --- a/db/export-data.sh +++ b/db/export-data.sh @@ -16,6 +16,8 @@ TABLES=( config version versionLog + notification + notificationAcl ) dump_tables ${TABLES[@]} From 17501a3c9407b55d07e4013366a9b753109969d0 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 28 Nov 2023 09:13:45 +0100 Subject: [PATCH 013/153] feat: refs #6005 mover sql a la ultima carpeta --- db/changes/{234801 => 235001}/00-sectorBackUpLabelerFk.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/changes/{234801 => 235001}/00-sectorBackUpLabelerFk.sql (100%) diff --git a/db/changes/234801/00-sectorBackUpLabelerFk.sql b/db/changes/235001/00-sectorBackUpLabelerFk.sql similarity index 100% rename from db/changes/234801/00-sectorBackUpLabelerFk.sql rename to db/changes/235001/00-sectorBackUpLabelerFk.sql From d5fcfdfd79181a4604da729273cd2763674bc031 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 28 Nov 2023 12:24:54 +0100 Subject: [PATCH 014/153] fix(yml): refs #6005 backUpLabeler yml fix --- print/templates/email/backup-printer-selected/locale/en.yml | 2 +- print/templates/email/backup-printer-selected/locale/es.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/print/templates/email/backup-printer-selected/locale/en.yml b/print/templates/email/backup-printer-selected/locale/en.yml index 917881641..038e16e00 100644 --- a/print/templates/email/backup-printer-selected/locale/en.yml +++ b/print/templates/email/backup-printer-selected/locale/en.yml @@ -1,3 +1,3 @@ subject: Not main printer configured title: Not main printer configured -description: 'The worker #{0} is using the backup printer {1} for their sector {2}.' +description: 'The worker {0} is using the backup printer {1} for their sector {2}.' \ No newline at end of file diff --git a/print/templates/email/backup-printer-selected/locale/es.yml b/print/templates/email/backup-printer-selected/locale/es.yml index a250ba20f..d172f2560 100644 --- a/print/templates/email/backup-printer-selected/locale/es.yml +++ b/print/templates/email/backup-printer-selected/locale/es.yml @@ -1,3 +1,3 @@ -subject: Configurada impresora no principal -title: Configurada impresora no principal -description: 'El trabajador #{0} esta utilizando la impresora de repuesto {1} su sector {2}.' +subject: Seleccionada impresora de repuesto +title: Seleccionada impresora de repuesto +description: 'El trabajador {0} esta utilizando la impresora de repuesto {1} del sector {2}.' From d8cf0590275b46c31e4fc413152bea3ad7c7d6d6 Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 29 Nov 2023 09:10:45 +0100 Subject: [PATCH 015/153] fix: refs #6005 add fixtures for a spec --- back/methods/notification/specs/getList.spec.js | 2 +- db/dump/fixtures.sql | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/back/methods/notification/specs/getList.spec.js b/back/methods/notification/specs/getList.spec.js index 6c8507986..d828abcb7 100644 --- a/back/methods/notification/specs/getList.spec.js +++ b/back/methods/notification/specs/getList.spec.js @@ -6,7 +6,7 @@ describe('NotificationSubscription getList()', () => { const notifications = await models.Notification.find({}); const totalAvailable = notifications.length - active.length; - expect(active.length).toEqual(0); + expect(active.length).toEqual(1); expect(available.length).toEqual(totalAvailable); }); }); diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index d270ca13a..0d967f8e6 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2799,7 +2799,8 @@ INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) (4, 1110), (2, 1109), (12, 9), - (12, 3); + (12, 3), + (12, 100); INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) VALUES (12, 9), From f68529960e5ea177a6fb42ae2e4c5eb69e6e944c Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 19 Dec 2023 10:51:18 +0100 Subject: [PATCH 016/153] fix(notification): refs #6005 notification changes --- .vscode/settings.json | 2 +- .../notification/specs/getList.spec.js | 4 +- back/models/notificationQueue.js | 29 +++++++++++ .../specs/notificationSubscription.spec.js | 2 +- db/changes/235001/00-printerChangeIdType.sql | 10 ++++ db/changes/235001/01-printerChangeIdType.sql | 21 ++++++++ ...lerFk.sql => 03-sectorBackUpLabelerFk.sql} | 18 ++----- db/dump/dumpedFixtures.sql | 27 ----------- db/dump/fixtures.sql | 48 +++++++++++-------- db/export-data.sh | 2 - .../methods/operator/spec/operator.spec.js | 10 +++- modules/worker/back/models/operator.js | 38 +++++---------- 12 files changed, 114 insertions(+), 97 deletions(-) create mode 100644 back/models/notificationQueue.js create mode 100644 db/changes/235001/00-printerChangeIdType.sql create mode 100644 db/changes/235001/01-printerChangeIdType.sql rename db/changes/235001/{00-sectorBackUpLabelerFk.sql => 03-sectorBackUpLabelerFk.sql} (65%) diff --git a/.vscode/settings.json b/.vscode/settings.json index 899dfc788..e3897122d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,7 +3,7 @@ // Carácter predeterminado de final de línea. "files.eol": "\n", "editor.codeActionsOnSave": { - "source.fixAll.eslint": true + "source.fixAll.eslint": "explicit" }, "search.useIgnoreFiles": false, "editor.defaultFormatter": "dbaeumer.vscode-eslint", diff --git a/back/methods/notification/specs/getList.spec.js b/back/methods/notification/specs/getList.spec.js index d828abcb7..8f8c9e5e3 100644 --- a/back/methods/notification/specs/getList.spec.js +++ b/back/methods/notification/specs/getList.spec.js @@ -2,11 +2,11 @@ const models = require('vn-loopback/server/server').models; describe('NotificationSubscription getList()', () => { it('should return a list of available and active notifications of a user', async() => { - const {active, available} = await models.NotificationSubscription.getList(100); + const {active, available} = await models.NotificationSubscription.getList(9); const notifications = await models.Notification.find({}); const totalAvailable = notifications.length - active.length; - expect(active.length).toEqual(1); + expect(active.length).toEqual(2); expect(available.length).toEqual(totalAvailable); }); }); diff --git a/back/models/notificationQueue.js b/back/models/notificationQueue.js new file mode 100644 index 000000000..a22bb6ce3 --- /dev/null +++ b/back/models/notificationQueue.js @@ -0,0 +1,29 @@ +module.exports = Self => { + Self.observe('before save', async ctx => { + const instance = ctx.data || ctx.instance; + const {notificationFk} = instance; + + if (!(notificationFk === 'backup-printer-selected')) return; + const {models} = Self.app; + const params = JSON.parse(instance.params); + const options = ctx.options; + const {delay} = await models.Notification.findOne({ + where: {name: notificationFk} + }, options); + + const hasNotified = await models.NotificationQueue.findOne({ + where: { + notificationFk: notificationFk, + and: [ + {params: {like: '%\"labelerId\":' + params.labelerId + '%'}}, + {params: {like: '%\"sectorId\":' + params.sectorId + '%'}} + ] + }, + order: 'created DESC', + }, options); + + if (hasNotified?.created - Date.now() > delay || !hasNotified?.created || !delay) return; + + throw new Error('Is already Notified'); + }); +}; diff --git a/back/models/specs/notificationSubscription.spec.js b/back/models/specs/notificationSubscription.spec.js index 1d4b2354c..33badfd91 100644 --- a/back/models/specs/notificationSubscription.spec.js +++ b/back/models/specs/notificationSubscription.spec.js @@ -92,7 +92,7 @@ describe('loopback model NotificationSubscription', () => { try { const options = {transaction: tx, accessToken: {userId: 9}}; - await models.NotificationSubscription.create({notificationFk: 12, userFk: 5}, options); + await models.NotificationSubscription.create({notificationFk: 1, userFk: 5}, options); await tx.rollback(); } catch (e) { diff --git a/db/changes/235001/00-printerChangeIdType.sql b/db/changes/235001/00-printerChangeIdType.sql new file mode 100644 index 000000000..759ac7939 --- /dev/null +++ b/db/changes/235001/00-printerChangeIdType.sql @@ -0,0 +1,10 @@ +ALTER TABLE `vn`.`packingSite` DROP FOREIGN KEY `packingSite_FK_4`; +ALTER TABLE `vn`.`arcRead` DROP FOREIGN KEY `worker_printer_FK`; +ALTER TABLE `vn`.`host` DROP FOREIGN KEY `configHost_FK`; +ALTER TABLE `vn`.`operator` DROP FOREIGN KEY `operator_FK_5`; +ALTER TABLE `vn`.`packingSite` DROP FOREIGN KEY `packingSite_FK_1`; +ALTER TABLE `vn`.`printQueue` DROP FOREIGN KEY `printQueue_printerFk`; +ALTER TABLE `vn`.`sector` DROP FOREIGN KEY `sector_FK_1`; +ALTER TABLE `vn`.`worker` DROP FOREIGN KEY `worker_FK`; + + diff --git a/db/changes/235001/01-printerChangeIdType.sql b/db/changes/235001/01-printerChangeIdType.sql new file mode 100644 index 000000000..3fd7d3798 --- /dev/null +++ b/db/changes/235001/01-printerChangeIdType.sql @@ -0,0 +1,21 @@ +ALTER TABLE `vn`.`printer` MODIFY COLUMN `id` int unsigned auto_increment NOT NULL; + +ALTER TABLE `vn`.`arcRead` MODIFY COLUMN `printerFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`arcRead` ADD CONSTRAINT `arcRead_FK` FOREIGN KEY (printerFk) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE `vn`.`host` MODIFY COLUMN `printerFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`host` ADD CONSTRAINT `host_FK` FOREIGN KEY (printerFk) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE CASCADE; + +ALTER TABLE `vn`.`operator` MODIFY COLUMN `labelerFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`operator` ADD CONSTRAINT `operator_FK_4` FOREIGN KEY (labelerFk) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE `vn`.`packingSite` MODIFY COLUMN `printerRfidFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`packingSite` MODIFY COLUMN `printerFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`packingSite` ADD CONSTRAINT `packingSite_FK_1` FOREIGN KEY (printerFk) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE RESTRICT; +ALTER TABLE `vn`.`packingSite` ADD CONSTRAINT `packingSite_FK_4` FOREIGN KEY (printerRfidFk) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE CASCADE; + +ALTER TABLE `vn`.`printQueue` MODIFY COLUMN `printerFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`printQueue` ADD CONSTRAINT `printQueue_FK` FOREIGN KEY (id) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE CASCADE; + +ALTER TABLE `vn`.`sector` MODIFY COLUMN `mainPrinterFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`sector` ADD CONSTRAINT `sector_FK` FOREIGN KEY (mainPrinterFk) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/changes/235001/00-sectorBackUpLabelerFk.sql b/db/changes/235001/03-sectorBackUpLabelerFk.sql similarity index 65% rename from db/changes/235001/00-sectorBackUpLabelerFk.sql rename to db/changes/235001/03-sectorBackUpLabelerFk.sql index 605571fc8..8ca12e7e4 100644 --- a/db/changes/235001/00-sectorBackUpLabelerFk.sql +++ b/db/changes/235001/03-sectorBackUpLabelerFk.sql @@ -1,7 +1,9 @@ ALTER TABLE `util`.`notification` ADD delay INT NULL COMMENT 'Minimum Milliseconds Interval to Prevent Spam from Same-Type Notifications'; -ALTER TABLE `vn`.`sector` CHANGE `mainPrinterFk` `backupPrinterFk` tinyint(3) unsigned DEFAULT NULL NULL; +ALTER TABLE vn.sector DROP FOREIGN KEY sector_FK; + +ALTER TABLE `vn`.`sector` CHANGE `mainPrinterFk` `backupPrinterFk` int unsigned DEFAULT NULL NULL; ALTER TABLE `util`.`notificationSubscription` DROP FOREIGN KEY `notificationSubscription_ibfk_1`; ALTER TABLE `util`.`notificationQueue` DROP FOREIGN KEY `nnotificationQueue_ibfk_1`; @@ -13,18 +15,4 @@ ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscr ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`name`) ON DELETE CASCADE ON UPDATE CASCADE; ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; -DELETE FROM `util`.`notification` - WHERE `name` = 'not-main-printer-configured'; -INSERT INTO `util`.`notification` - SET `name` = 'backup-printer-selected', - `description` = 'The worker has selected the backup printer for their sector', - `delay` = 600000; - -INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) - SELECT `n`.`id`, `r`.`id` - FROM `util`.`notification` `n` - JOIN `account`.`role` `r` - WHERE `n`.`name` = 'backup-printer-selected' - AND `r`.`name` = 'system' - LIMIT 1; diff --git a/db/dump/dumpedFixtures.sql b/db/dump/dumpedFixtures.sql index 3596eeb75..7e3964c2b 100644 --- a/db/dump/dumpedFixtures.sql +++ b/db/dump/dumpedFixtures.sql @@ -233,33 +233,6 @@ LOCK TABLES `agencyTermConfig` WRITE; INSERT INTO `agencyTermConfig` VALUES ('6240000000','4721000015',21.0000000000,'Adquisiciones intracomunitarias de servicios'); /*!40000 ALTER TABLE `agencyTermConfig` ENABLE KEYS */; UNLOCK TABLES; - -LOCK TABLES `notification` WRITE; -INSERT INTO `util`.`notification` (id, name, description) - VALUES(1, 'vehicle-event-expired', 'scheduled event of a vehicle'), - (2, 'invoice-electronic', 'A electronic invoice has been generated'), - (3, 'supplier-pay-method-update', 'A supplier pay method has been updated'), - (4, 'book-entries-imported-incorrectly', 'accounting entries exported incorrectly'), - (5, 'greuge-wrong', 'A wrong greuge has been created'), - (6, 'not-main-printer-configured', 'A printer distinct than main has been configured'), - (7, 'entry-update-comission', 'entry change comission'), - (8, 'modified-entry', 'An entry has been modified'), - (9, 'book-entry-deleted', 'accounting entries deleted'), - (10, 'modified-collection-volumetry', 'A collection volumetry has been modified'); -UNLOCK TABLES; - -LOCK TABLES `notificationAcl` WRITE; -INSERT INTO `util`.`notificationAcl` (notificationFk, roleFk) - VALUES(1, 57), - (3, 73), - (4, 5), - (6, 108), - (7, 30), - (7, 35), - (8, 15), - (9, 5); -UNLOCK TABLES; - -- -- Dumping data for table `alertLevel` -- diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index f95f7aef6..7dd9032a9 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -2788,32 +2788,40 @@ INSERT INTO `vn`.`packingSiteConfig` (`shinobiUrl`, `shinobiToken`, `shinobiGrou INSERT INTO `util`.`notificationConfig` SET `cleanDays` = 90; -INSERT IGNORE INTO `util`.`notification` (`name`, `description`, `delay`) - VALUES ('print-email', 'notification fixture one', NULL); +INSERT INTO `util`.`notification` (`id`, `name`, `description`, `delay`) + VALUES (1, 'print-email', 'notification fixture one', NULL), + (2, 'invoice-electronic', 'A electronic invoice has been generated', NULL), + (3, 'backup-printer-selected', 'A printer distinct than main has been configured', 600000), + (4, 'supplier-pay-method-update', 'A supplier pay method has been updated', NULL), + (5, 'modified-entry', 'An entry has been modified', NULL), + (6, 'book-entry-deleted', 'accounting entries deleted', NULL); -INSERT INTO `util`.`notificationQueue` (`notificationFk`, `params`, `authorFk`, `status`, `created`) - VALUES ('print-email', '{"id": "1"}', 9, 'pending', util.VN_CURDATE()), - ('print-email', '{"id": "2"}', null, 'pending', util.VN_CURDATE()), - ('print-email', null, null, 'pending', util.VN_CURDATE()); +INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) + VALUES + (1, 9), + (1, 1), + (2, 1), + (3, 9), + (4, 1), + (5, 9), + (6, 9); + +INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`) + VALUES + (1, 'print-email', '{"id": "1"}', 9, 'pending', util.VN_CURDATE()), + (2, 'print-email', '{"id": "2"}', null, 'pending', util.VN_CURDATE()), + (3, 'print-email', null, null, 'pending', util.VN_CURDATE()); INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) - VALUES (12, 1109), - (12, 1110), + VALUES + (1, 1109), + (1, 1110), (2, 1110), (4, 1110), (2, 1109), - (12, 9), - (12, 3), - (12, 100); - -INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) - VALUES (12, 9), - (12, 1), - (4, 1), - (2, 1), - (3, 9), - (5, 9), - (10,1); + (1, 9), + (1, 3), + (6, 9); INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) VALUES diff --git a/db/export-data.sh b/db/export-data.sh index 96a8754f9..97092da4f 100755 --- a/db/export-data.sh +++ b/db/export-data.sh @@ -16,8 +16,6 @@ TABLES=( config version versionLog - notification - notificationAcl ) dump_tables ${TABLES[@]} diff --git a/modules/worker/back/methods/operator/spec/operator.spec.js b/modules/worker/back/methods/operator/spec/operator.spec.js index 6a8b02e04..f57322f49 100644 --- a/modules/worker/back/methods/operator/spec/operator.spec.js +++ b/modules/worker/back/methods/operator/spec/operator.spec.js @@ -74,9 +74,15 @@ describe('Operator', () => { created: Date.vnNow(), }, options); - const notificationQueue = await createOperator(labeler, options); + let error; - expect(notificationQueue).toEqual(null); + try { + await createOperator(labeler, options); + } catch (e) { + error = e; + } + + expect(error.message).toEqual('Is already Notified'); await tx.rollback(); } catch (e) { diff --git a/modules/worker/back/models/operator.js b/modules/worker/back/models/operator.js index 51fd0bfa1..074179806 100644 --- a/modules/worker/back/models/operator.js +++ b/modules/worker/back/models/operator.js @@ -4,6 +4,7 @@ module.exports = function(Self) { const models = Self.app.models; const options = ctx.options; const notification = 'backup-printer-selected'; + const {userId} = ctx.options.accessToken; if (!instance?.sectorFk || !instance?.labelerFk) return; @@ -12,34 +13,17 @@ module.exports = function(Self) { }, options); if (sector.backupPrinterFk && sector.backupPrinterFk == instance.labelerFk) { - const {userId} = ctx.options.accessToken; - const {delay} = await models.Notification.findOne({ - where: {name: notification} + await models.NotificationQueue.create({ + notificationFk: notification, + authorFk: userId, + params: JSON.stringify( + { + 'labelerId': instance.labelerFk, + 'sectorId': instance.sectorFk, + 'workerId': userId + } + ) }, options); - const hasNotified = await models.NotificationQueue.findOne({ - where: { - notificationFk: notification, - and: [ - {params: {like: '%\"labelerId\":' + instance.labelerFk + '%'}}, - {params: {like: '%\"sectorId\":' + instance.sectorFk + '%'}} - ] - }, - order: 'created DESC', - }, options); - - if (hasNotified?.created - Date.now() > delay || !hasNotified?.created || !delay) { - await models.NotificationQueue.create({ - notificationFk: notification, - authorFk: userId, - params: JSON.stringify( - { - 'labelerId': instance.labelerFk, - 'sectorId': instance.sectorFk, - 'workerId': userId - } - ) - }, options); - } } }); }; From 88739542fec47a58c33e647d831a8ac6dec6cca1 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 19 Dec 2023 14:07:46 +0100 Subject: [PATCH 017/153] move(version): refs #6005 move backupLabeler --- db/changes/{235001 => 235201}/00-printerChangeIdType.sql | 0 db/changes/{235001 => 235201}/01-printerChangeIdType.sql | 0 db/changes/{235001 => 235201}/03-sectorBackUpLabelerFk.sql | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename db/changes/{235001 => 235201}/00-printerChangeIdType.sql (100%) rename db/changes/{235001 => 235201}/01-printerChangeIdType.sql (100%) rename db/changes/{235001 => 235201}/03-sectorBackUpLabelerFk.sql (100%) diff --git a/db/changes/235001/00-printerChangeIdType.sql b/db/changes/235201/00-printerChangeIdType.sql similarity index 100% rename from db/changes/235001/00-printerChangeIdType.sql rename to db/changes/235201/00-printerChangeIdType.sql diff --git a/db/changes/235001/01-printerChangeIdType.sql b/db/changes/235201/01-printerChangeIdType.sql similarity index 100% rename from db/changes/235001/01-printerChangeIdType.sql rename to db/changes/235201/01-printerChangeIdType.sql diff --git a/db/changes/235001/03-sectorBackUpLabelerFk.sql b/db/changes/235201/03-sectorBackUpLabelerFk.sql similarity index 100% rename from db/changes/235001/03-sectorBackUpLabelerFk.sql rename to db/changes/235201/03-sectorBackUpLabelerFk.sql From 1c40e01fcb0be13fa60ec05ed001657d8e92af68 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 20 Feb 2024 13:49:42 +0100 Subject: [PATCH 018/153] refactor: refs #6005 move the logic to the report --- back/models/notificationQueue.js | 29 ------------------- db/dump/fixtures.after.sql | 3 -- db/dump/fixtures.before.sql | 2 +- .../10895-pinkArborvitae/00-firstScript.sql | 11 +++++++ .../10895-pinkArborvitae/01-secondScript.sql | 28 ++++++++++++++++++ .../10895-pinkArborvitae/02-thirdScript.sql | 17 +++++++++++ .../03-insertBackUpNotification.sql | 12 ++++++++ .../backup-printer-selected.js | 21 ++++++++++++-- .../sql/previousNotifications.sql | 5 ++++ 9 files changed, 93 insertions(+), 35 deletions(-) delete mode 100644 back/models/notificationQueue.js create mode 100644 db/versions/10895-pinkArborvitae/00-firstScript.sql create mode 100644 db/versions/10895-pinkArborvitae/01-secondScript.sql create mode 100644 db/versions/10895-pinkArborvitae/02-thirdScript.sql create mode 100644 db/versions/10895-pinkArborvitae/03-insertBackUpNotification.sql create mode 100644 print/templates/email/backup-printer-selected/sql/previousNotifications.sql diff --git a/back/models/notificationQueue.js b/back/models/notificationQueue.js deleted file mode 100644 index a22bb6ce3..000000000 --- a/back/models/notificationQueue.js +++ /dev/null @@ -1,29 +0,0 @@ -module.exports = Self => { - Self.observe('before save', async ctx => { - const instance = ctx.data || ctx.instance; - const {notificationFk} = instance; - - if (!(notificationFk === 'backup-printer-selected')) return; - const {models} = Self.app; - const params = JSON.parse(instance.params); - const options = ctx.options; - const {delay} = await models.Notification.findOne({ - where: {name: notificationFk} - }, options); - - const hasNotified = await models.NotificationQueue.findOne({ - where: { - notificationFk: notificationFk, - and: [ - {params: {like: '%\"labelerId\":' + params.labelerId + '%'}}, - {params: {like: '%\"sectorId\":' + params.sectorId + '%'}} - ] - }, - order: 'created DESC', - }, options); - - if (hasNotified?.created - Date.now() > delay || !hasNotified?.created || !delay) return; - - throw new Error('Is already Notified'); - }); -}; diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 4c5f89d97..661b92d9c 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -113,9 +113,6 @@ INSERT INTO vn.ticket (clientFk, warehouseFk, shipped, nickname, refFk, addressF (100, 4, '2022-07-12 00:00:00', 'root', NULL, 195, NULL, NULL, 0, 0, 0, 0, NULL, 0, '2022-07-12 16:18:58', 1, NULL, 4, NULL, 1, 567, 1, '2022-07-12', 0, 0, 6, NULL, NULL, NULL, NULL, NULL), (100, 5, '2022-07-12 00:00:00', 'root', NULL, 195, NULL, NULL, 0, 0, 0, 0, NULL, 0, '2022-07-12 16:18:58', 1, NULL, 5, NULL, 1, 567, 1, '2022-07-12', 0, 0, 1, NULL, NULL, NULL, NULL, NULL); */ -INSERT INTO vn.sector (description,warehouseFk) VALUES - ('Sector One',1); - INSERT INTO vn.saleGroup (userFk,parkingFk,sectorFk) VALUES (100,1,1); diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 43293c9ea..de5b8fbf6 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -198,7 +198,7 @@ INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAd (2, 'printer2', 'path2', 1, 1 , NULL), (4, 'printer4', 'path4', 0, NULL, '10.1.10.4'); -UPDATE `vn`.`sector` SET mainPrinterFk = 1 WHERE id = 1; +UPDATE `vn`.`sector` SET `backupPrinterFk` = 1 WHERE id = 1; INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`,`bossFk`, `phone`) diff --git a/db/versions/10895-pinkArborvitae/00-firstScript.sql b/db/versions/10895-pinkArborvitae/00-firstScript.sql new file mode 100644 index 000000000..2387fda08 --- /dev/null +++ b/db/versions/10895-pinkArborvitae/00-firstScript.sql @@ -0,0 +1,11 @@ +ALTER TABLE `vn`.`packingSite` DROP FOREIGN KEY IF EXISTS `packingSite_FK_4`; +ALTER TABLE `vn`.`arcRead` DROP FOREIGN KEY IF EXISTS `worker_printer_FK`; +ALTER TABLE `vn`.`host` DROP FOREIGN KEY IF EXISTS `configHost_FK`; +ALTER TABLE `vn`.`operator` DROP FOREIGN KEY IF EXISTS `operator_FK_5`; +ALTER TABLE `vn`.`packingSite` DROP FOREIGN KEY IF EXISTS `packingSite_FK_1`; +ALTER TABLE `vn`.`printQueue` DROP FOREIGN KEY IF EXISTS `printQueue_printerFk`; +ALTER TABLE `vn`.`sector` DROP FOREIGN KEY IF EXISTS `sector_FK_1`; +ALTER TABLE `vn`.`worker` DROP FOREIGN KEY IF EXISTS `worker_FK`; +ALTER TABLE dipole.printer DROP FOREIGN KEY IF EXISTS printer_FK; +ALTER TABLE dipole.expedition_PrintOut DROP FOREIGN KEY IF EXISTS expedition_PrintOut_FK; + diff --git a/db/versions/10895-pinkArborvitae/01-secondScript.sql b/db/versions/10895-pinkArborvitae/01-secondScript.sql new file mode 100644 index 000000000..4397bcf01 --- /dev/null +++ b/db/versions/10895-pinkArborvitae/01-secondScript.sql @@ -0,0 +1,28 @@ +ALTER TABLE `vn`.`printer` MODIFY COLUMN IF EXISTS `id` int unsigned auto_increment NOT NULL; + +ALTER TABLE `vn`.`arcRead` MODIFY COLUMN IF EXISTS `printerFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`arcRead` ADD CONSTRAINT `arcRead_FK` FOREIGN KEY IF NOT EXISTS (printerFk) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE `vn`.`host` MODIFY COLUMN IF EXISTS `printerFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`host` ADD CONSTRAINT `host_FK` FOREIGN KEY IF NOT EXISTS (printerFk) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE CASCADE; + +ALTER TABLE `vn`.`operator` MODIFY COLUMN IF EXISTS `labelerFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`operator` ADD CONSTRAINT `operator_FK_4` FOREIGN KEY IF NOT EXISTS (labelerFk) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE `vn`.`packingSite` MODIFY COLUMN IF EXISTS `printerFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`packingSite` ADD CONSTRAINT `packingSite_FK_1` FOREIGN KEY IF NOT EXISTS (printerFk) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE RESTRICT; + +ALTER TABLE `vn`.`packingSite` MODIFY COLUMN IF EXISTS `printerRfidFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`packingSite` ADD CONSTRAINT `packingSite_FK_4` FOREIGN KEY IF NOT EXISTS(printerRfidFk) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE CASCADE; + +ALTER TABLE `vn`.`printQueue` MODIFY COLUMN IF EXISTS `printerFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`printQueue` ADD CONSTRAINT `printQueue_FK` FOREIGN KEY IF NOT EXISTS (id) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE CASCADE; + +ALTER TABLE `vn`.`sector` MODIFY COLUMN IF EXISTS `mainPrinterFk` int unsigned DEFAULT NULL NULL; +ALTER TABLE `vn`.`sector` ADD CONSTRAINT `sector_FK` FOREIGN KEY IF NOT EXISTS (mainPrinterFk) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE `dipole`.`printer` MODIFY COLUMN IF EXISTS `id` int unsigned DEFAULT NULL NULL; +ALTER TABLE `dipole`.`printer` ADD CONSTRAINT `vnPrinter_FK` FOREIGN KEY IF NOT EXISTS (id) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE; + +ALTER TABLE `dipole`.`expedition_PrintOut` MODIFY COLUMN IF EXISTS `printerFk` int unsigned DEFAULT 0 NOT NULL; +ALTER TABLE `dipole`.`expedition_PrintOut` ADD CONSTRAINT `expedition_PrintOut_FK` FOREIGN KEY IF NOT EXISTS (printerFk) REFERENCES printer(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/10895-pinkArborvitae/02-thirdScript.sql b/db/versions/10895-pinkArborvitae/02-thirdScript.sql new file mode 100644 index 000000000..21e97580f --- /dev/null +++ b/db/versions/10895-pinkArborvitae/02-thirdScript.sql @@ -0,0 +1,17 @@ + +ALTER TABLE `util`.`notification` ADD IF NOT EXISTS delay int unsigned NULL + COMMENT 'Minimum seconds Interval to Prevent Spam from Same-Type Notifications'; + +ALTER TABLE vn.sector DROP FOREIGN KEY IF EXISTS sector_FK; + +ALTER TABLE `vn`.`sector` CHANGE IF EXISTS `mainPrinterFk` `backupPrinterFk` int unsigned DEFAULT NULL NULL; + +ALTER TABLE `util`.`notificationSubscription` DROP FOREIGN KEY IF EXISTS `notificationSubscription_ibfk_1`; +ALTER TABLE `util`.`notificationQueue` DROP FOREIGN KEY IF EXISTS `nnotificationQueue_ibfk_1`; +ALTER TABLE `util`.`notificationAcl` DROP FOREIGN KEY IF EXISTS `notificationAcl_ibfk_1`; + +ALTER TABLE `util`.`notification` MODIFY COLUMN IF EXISTS `id` int(11) auto_increment NOT NULL; + +ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_Fk` FOREIGN KEY IF NOT EXISTS (`notificationFk`) REFERENCES `util`.`notification`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_Fk` FOREIGN KEY IF NOT EXISTS (`notificationFk`) REFERENCES `util`.`notification`(`name`) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_Fk` FOREIGN KEY IF NOT EXISTS (`notificationFk`) REFERENCES `util`.`notification`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/10895-pinkArborvitae/03-insertBackUpNotification.sql b/db/versions/10895-pinkArborvitae/03-insertBackUpNotification.sql new file mode 100644 index 000000000..b6558e6d4 --- /dev/null +++ b/db/versions/10895-pinkArborvitae/03-insertBackUpNotification.sql @@ -0,0 +1,12 @@ +INSERT IGNORE INTO util.notification (name, description, delay) + VALUES ('backup-printer-selected','A backup printer has been selected', 3600); + +INSERT IGNORE INTO util.notificationSubscription (notificationFk, userFk) + SELECT id, 10435 + FROM util.notification + WHERE name = 'backup-printer-selected'; + +INSERT IGNORE INTO util.notificationAcl (notificationFk, roleFk) + SELECT id, 66 + FROM util.notification + WHERE name = 'backup-printer-selected'; \ No newline at end of file diff --git a/print/templates/email/backup-printer-selected/backup-printer-selected.js b/print/templates/email/backup-printer-selected/backup-printer-selected.js index 0e56396db..099124286 100755 --- a/print/templates/email/backup-printer-selected/backup-printer-selected.js +++ b/print/templates/email/backup-printer-selected/backup-printer-selected.js @@ -1,11 +1,15 @@ const Component = require(`vn-print/core/component`); const emailBody = new Component('email-body'); +const name = 'backup-printer-selected'; module.exports = { - name: 'backup-printer-selected', + name: name, async serverPrefetch() { - this.sector = await this.findOneFromDef('sector', [this.sectorId]); + const notifications = await this.rawSqlFromDef('previousNotifications', [name]); + if (notifications && checkDuplicates(notifications, this.labelerId, this.sectorId)) + throw new Error('Previous notification sended with the same parameters'); + this.sector = await this.findOneFromDef('sector', [this.sectorId]); if (!this.sector) throw new Error('Something went wrong'); @@ -31,3 +35,16 @@ module.exports = { } } }; + +function checkDuplicates(notifications, labelerFk, printerFk) { + const criteria = { + labelerId: labelerFk, + sectorId: printerFk + }; + const filteredNotifications = notifications.filter(notification => { + const paramsObj = JSON.parse(notification.params); + return Object.keys(criteria).every(key => criteria[key] === paramsObj[key]); + }); + + return filteredNotifications.size > 1; +} diff --git a/print/templates/email/backup-printer-selected/sql/previousNotifications.sql b/print/templates/email/backup-printer-selected/sql/previousNotifications.sql new file mode 100644 index 000000000..bd44b05e4 --- /dev/null +++ b/print/templates/email/backup-printer-selected/sql/previousNotifications.sql @@ -0,0 +1,5 @@ +SELECT nq.params + FROM util.notificationQueue nq + JOIN util.notification n ON n.name = nq.notificationFk + WHERE n.name = ? + AND TIMESTAMPDIFF(SECOND, nq.created, util.VN_NOW()) <= n.delay \ No newline at end of file From 5e97f820a224625c361ceeb3d304f0f15ec6e36f Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 21 Feb 2024 12:59:42 +0100 Subject: [PATCH 019/153] feat(spec): refs #6005 add spec --- back/methods/notification/getList.js | 2 +- .../notification/specs/getList.spec.js | 7 ++++--- db/dump/fixtures.before.sql | 21 +++++++++++-------- ...sql => 03-insertBackUpNotification.vn.sql} | 0 .../methods/operator/spec/operator.spec.js | 16 +++++++------- .../backup-printer-selected.js | 7 ++++--- .../sql/previousNotificationscopy.sql | 4 ++++ 7 files changed, 32 insertions(+), 25 deletions(-) rename db/versions/10895-pinkArborvitae/{03-insertBackUpNotification.sql => 03-insertBackUpNotification.vn.sql} (100%) create mode 100644 print/templates/email/backup-printer-selected/sql/previousNotificationscopy.sql diff --git a/back/methods/notification/getList.js b/back/methods/notification/getList.js index 3881f0f63..49e88e093 100644 --- a/back/methods/notification/getList.js +++ b/back/methods/notification/getList.js @@ -45,7 +45,7 @@ module.exports = Self => { }); availableNotificationsMap.delete(active.notificationFk); } - + console.log(activeNotificationsMap); return { active: [...activeNotificationsMap.entries()], available: [...availableNotificationsMap.entries()] diff --git a/back/methods/notification/specs/getList.spec.js b/back/methods/notification/specs/getList.spec.js index 8f8c9e5e3..c43a3c6de 100644 --- a/back/methods/notification/specs/getList.spec.js +++ b/back/methods/notification/specs/getList.spec.js @@ -2,9 +2,10 @@ const models = require('vn-loopback/server/server').models; describe('NotificationSubscription getList()', () => { it('should return a list of available and active notifications of a user', async() => { - const {active, available} = await models.NotificationSubscription.getList(9); - const notifications = await models.Notification.find({}); - const totalAvailable = notifications.length - active.length; + const userId = 9; + const {active, available} = await models.NotificationSubscription.getList(userId); + const notifications = await models.NotificationSubscription.getAvailable(userId); + const totalAvailable = notifications.size - active.length; expect(active.length).toEqual(2); expect(available.length).toEqual(totalAvailable); diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index de5b8fbf6..f59065935 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2810,14 +2810,15 @@ INSERT INTO `vn`.`packingSiteConfig` (`shinobiUrl`, `shinobiToken`, `shinobiGrou INSERT INTO `util`.`notificationConfig` SET `cleanDays` = 90; -INSERT INTO `util`.`notification` (`id`, `name`, `description`) +INSERT INTO `util`.`notification` (`id`, `name`, `description`, `delay`) VALUES - (1, 'print-email', 'notification fixture one'), - (2, 'invoice-electronic', 'A electronic invoice has been generated'), - (3, 'not-main-printer-configured', 'A printer distinct than main has been configured'), - (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'), - (5, 'modified-entry', 'An entry has been modified'), - (6, 'book-entry-deleted', 'accounting entries deleted'); + (1, 'print-email', 'notification fixture one', NULL), + (2, 'invoice-electronic', 'A electronic invoice has been generated', NULL), + (3, 'not-main-printer-configured', 'A printer distinct than main has been configured', NULL), + (4, 'supplier-pay-method-update', 'A supplier pay method has been updated', NULL), + (5, 'modified-entry', 'An entry has been modified', NULL), + (6, 'book-entry-deleted', 'accounting entries deleted', NULL), + (7, 'backup-printer-selected','A backup printer has been selected', 3600); INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) VALUES @@ -2827,7 +2828,8 @@ INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) (3, 9), (4, 1), (5, 9), - (6, 9); + (6, 9), + (7, 66); INSERT INTO `util`.`notificationQueue` (`id`, `notificationFk`, `params`, `authorFk`, `status`, `created`) VALUES @@ -2844,7 +2846,8 @@ INSERT INTO `util`.`notificationSubscription` (`notificationFk`, `userFk`) (2, 1109), (1, 9), (1, 3), - (6, 9); + (6, 9), + (7, 66); INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) diff --git a/db/versions/10895-pinkArborvitae/03-insertBackUpNotification.sql b/db/versions/10895-pinkArborvitae/03-insertBackUpNotification.vn.sql similarity index 100% rename from db/versions/10895-pinkArborvitae/03-insertBackUpNotification.sql rename to db/versions/10895-pinkArborvitae/03-insertBackUpNotification.vn.sql diff --git a/modules/worker/back/methods/operator/spec/operator.spec.js b/modules/worker/back/methods/operator/spec/operator.spec.js index f57322f49..a39fcf791 100644 --- a/modules/worker/back/methods/operator/spec/operator.spec.js +++ b/modules/worker/back/methods/operator/spec/operator.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -describe('Operator', () => { +fdescribe('Operator', () => { const authorFk = 9; const sectorId = 1; const labeler = 1; @@ -62,7 +62,7 @@ describe('Operator', () => { } }); - it('should not create notification when is already notified by another worker', async() => { + fit('should not create notification when is already notified by another worker', async() => { const tx = await models.Operator.beginTransaction({}); try { @@ -74,15 +74,13 @@ describe('Operator', () => { created: Date.vnNow(), }, options); - let error; + await createOperator(labeler, options); + await models.Notification.send(options); + const lastNotification = await models.NotificationQueue.find({order: 'id DESC'}, options); - try { - await createOperator(labeler, options); - } catch (e) { - error = e; - } + console.log('lastNotification: ', lastNotification); - expect(error.message).toEqual('Is already Notified'); + expect(1).toEqual('Is already Notified'); await tx.rollback(); } catch (e) { diff --git a/print/templates/email/backup-printer-selected/backup-printer-selected.js b/print/templates/email/backup-printer-selected/backup-printer-selected.js index 099124286..04a82b0c7 100755 --- a/print/templates/email/backup-printer-selected/backup-printer-selected.js +++ b/print/templates/email/backup-printer-selected/backup-printer-selected.js @@ -5,8 +5,10 @@ const name = 'backup-printer-selected'; module.exports = { name: name, async serverPrefetch() { + const notifications1 = await this.rawSqlFromDef('previousNotificationscopy', [name]); + console.log('notifications: ', notifications1); const notifications = await this.rawSqlFromDef('previousNotifications', [name]); - if (notifications && checkDuplicates(notifications, this.labelerId, this.sectorId)) + if (!notifications.length && checkDuplicates(notifications, this.labelerId, this.sectorId)) throw new Error('Previous notification sended with the same parameters'); this.sector = await this.findOneFromDef('sector', [this.sectorId]); @@ -45,6 +47,5 @@ function checkDuplicates(notifications, labelerFk, printerFk) { const paramsObj = JSON.parse(notification.params); return Object.keys(criteria).every(key => criteria[key] === paramsObj[key]); }); - - return filteredNotifications.size > 1; + return filteredNotifications.length > 1; } diff --git a/print/templates/email/backup-printer-selected/sql/previousNotificationscopy.sql b/print/templates/email/backup-printer-selected/sql/previousNotificationscopy.sql new file mode 100644 index 000000000..f8f30e7f1 --- /dev/null +++ b/print/templates/email/backup-printer-selected/sql/previousNotificationscopy.sql @@ -0,0 +1,4 @@ +SELECT nq.params + FROM util.notificationQueue nq + JOIN util.notification n ON n.name = nq.notificationFk + WHERE n.name = ? \ No newline at end of file From 48310d24c7c900a28b86e13235a36ca868f7ed86 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 21 Feb 2024 14:36:12 +0100 Subject: [PATCH 020/153] refs #6732 change name supplier.isSerious to supplier.isReal --- db/routines/vn2008/views/Proveedores.sql | 2 +- db/versions/10900-redOak/00-firstScript.sql | 1 + modules/supplier/back/methods/supplier/getSummary.js | 2 +- modules/supplier/back/models/supplier.json | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 db/versions/10900-redOak/00-firstScript.sql diff --git a/db/routines/vn2008/views/Proveedores.sql b/db/routines/vn2008/views/Proveedores.sql index 0b7ee89f8..e26e9c829 100644 --- a/db/routines/vn2008/views/Proveedores.sql +++ b/db/routines/vn2008/views/Proveedores.sql @@ -23,7 +23,7 @@ AS SELECT `s`.`id` AS `Id_Proveedor`, `s`.`isOfficial` AS `oficial`, `s`.`workerFk` AS `workerFk`, `s`.`payDay` AS `pay_day`, - `s`.`isSerious` AS `serious`, + `s`.`isReal` AS `real`, `s`.`note` AS `notas`, `s`.`taxTypeSageFk` AS `taxTypeSageFk`, `s`.`withholdingSageFk` AS `withholdingSageFk`, diff --git a/db/versions/10900-redOak/00-firstScript.sql b/db/versions/10900-redOak/00-firstScript.sql new file mode 100644 index 000000000..8609ddc7e --- /dev/null +++ b/db/versions/10900-redOak/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.supplier CHANGE COLUMN isSerious isReal tinyint(1) unsigned NOT NULL DEFAULT 0; diff --git a/modules/supplier/back/methods/supplier/getSummary.js b/modules/supplier/back/methods/supplier/getSummary.js index bc869725c..699233386 100644 --- a/modules/supplier/back/methods/supplier/getSummary.js +++ b/modules/supplier/back/methods/supplier/getSummary.js @@ -25,7 +25,7 @@ module.exports = Self => { 'id', 'name', 'nickname', - 'isSerious', + 'isReal', 'isActive', 'note', 'nif', diff --git a/modules/supplier/back/models/supplier.json b/modules/supplier/back/models/supplier.json index 59d23f106..90b266ba9 100644 --- a/modules/supplier/back/models/supplier.json +++ b/modules/supplier/back/models/supplier.json @@ -48,7 +48,7 @@ "isOfficial": { "type": "boolean" }, - "isSerious": { + "isReal": { "type": "boolean" }, "isTrucker": { From 10a89cb7900c84a76f92f63c1f92edb4e13912cb Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 28 Feb 2024 13:32:17 +0100 Subject: [PATCH 021/153] refs #6827 Check usernames special characters --- back/methods/chat/spec/send.spec.js | 4 +-- db/dump/fixtures.before.sql | 26 +++++++++---------- .../account/procedures/user_checkName.sql | 2 +- .../10917-aquaPhormium/00-firstScript.sql | 9 +++++++ e2e/paths/02-client/01_create_client.spec.js | 2 +- .../02-client/07_edit_web_access.spec.js | 4 +-- e2e/paths/02-client/09_add_credit.spec.js | 2 +- e2e/paths/02-client/19_summary.spec.js | 2 +- e2e/paths/05-ticket/05_tracking_state.spec.js | 2 +- .../01_create_and_basic_data.spec.js | 4 +-- .../client/specs/createWithUser.spec.js | 6 ++--- .../client/back/models/specs/client.spec.js | 8 +++--- .../specs/activeWithInheritedRole.spec.js | 2 +- .../back/methods/worker/specs/new.spec.js | 2 +- 14 files changed, 42 insertions(+), 33 deletions(-) create mode 100644 db/versions/10917-aquaPhormium/00-firstScript.sql diff --git a/back/methods/chat/spec/send.spec.js b/back/methods/chat/spec/send.spec.js index e910f3fab..511f5fe80 100644 --- a/back/methods/chat/spec/send.spec.js +++ b/back/methods/chat/spec/send.spec.js @@ -3,14 +3,14 @@ const {models} = require('vn-loopback/server/server'); describe('Chat send()', () => { it('should return true as response', async() => { let ctx = {req: {accessToken: {userId: 1}}}; - let response = await models.Chat.send(ctx, '@salesPerson', 'I changed something'); + let response = await models.Chat.send(ctx, '@salesperson', 'I changed something'); expect(response).toEqual(true); }); it('should return false as response', async() => { let ctx = {req: {accessToken: {userId: 18}}}; - let response = await models.Chat.send(ctx, '@salesPerson', 'I changed something'); + let response = await models.Chat.send(ctx, '@salesperson', 'I changed something'); expect(response).toEqual(false); }); diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 1d59c7ac0..1c20b46c1 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -81,7 +81,7 @@ INSERT INTO `account`.`roleConfig`(`id`, `mysqlPassword`, `rolePrefix`, `userPre CALL `account`.`role_sync`; INSERT INTO `account`.`user`(`id`,`name`, `nickname`, `role`,`active`,`email`, `lang`, `image`, `password`) - SELECT id, name, CONCAT(name, 'Nick'), id, 1, CONCAT(name, '@mydomain.com'), 'en', '4fa3ada0-3ac4-11eb-9ab8-27f6fc3b85fd', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2' + SELECT id, LOWER(name), CONCAT(name, 'Nick'), id, 1, CONCAT(name, '@mydomain.com'), 'en', '4fa3ada0-3ac4-11eb-9ab8-27f6fc3b85fd', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2' FROM `account`.`role` ORDER BY id; @@ -118,18 +118,18 @@ INSERT INTO `hedera`.`tpvConfig`(`id`, `currency`, `terminal`, `transactionType` INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`,`email`,`lang`, `image`) VALUES - (1101, 'BruceWayne', 'Bruce Wayne', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'BruceWayne@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1102, 'PetterParker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'PetterParker@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1103, 'ClarkKent', 'Clark Kent', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'ClarkKent@mydomain.com', 'fr', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1104, 'TonyStark', 'Tony Stark', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'TonyStark@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1105, 'MaxEisenhardt', 'Max Eisenhardt', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1106, 'DavidCharlesHaller', 'David Charles Haller', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'DavidCharlesHaller@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1107, 'HankPym', 'Hank Pym', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'HankPym@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1108, 'CharlesXavier', 'Charles Xavier', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'CharlesXavier@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1109, 'BruceBanner', 'Bruce Banner', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'BruceBanner@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), - (1110, 'JessicaJones', 'Jessica Jones', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'JessicaJones@mydomain.com', 'en', NULL), - (1111, 'Missing', 'Missing', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL), - (1112, 'Trash', 'Trash', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL); + (1101, 'brucewayne', 'Bruce Wayne', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'BruceWayne@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1102, 'petterparker', 'Petter Parker', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'PetterParker@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1103, 'clarkkent', 'Clark Kent', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'ClarkKent@mydomain.com', 'fr', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1104, 'tonystark', 'Tony Stark', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'TonyStark@mydomain.com', 'es', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1105, 'maxeisenhardt', 'Max Eisenhardt', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 1, 'MaxEisenhardt@mydomain.com', 'pt', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1106, 'davidcharleshaller', 'David Charles Haller', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'DavidCharlesHaller@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1107, 'hankpym', 'Hank Pym', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'HankPym@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1108, 'charlesxavier', 'Charles Xavier', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'CharlesXavier@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1109, 'brucebanner', 'Bruce Banner', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'BruceBanner@mydomain.com', 'en', 'e7723f0b24ff05b32ed09d95196f2f29'), + (1110, 'jessicajones', 'Jessica Jones', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 1, 1, 'JessicaJones@mydomain.com', 'en', NULL), + (1111, 'missing', 'Missing', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL), + (1112, 'trash', 'Trash', '$2b$10$UzQHth.9UUQ1T5aiQJ21lOU0oVlbxoqH4PFM9V8T90KNSAcg0eEL2', 2, 0, NULL, 'en', NULL); UPDATE account.`user` SET passExpired = DATE_SUB(util.VN_CURDATE(), INTERVAL 1 YEAR) diff --git a/db/routines/account/procedures/user_checkName.sql b/db/routines/account/procedures/user_checkName.sql index 4f954ad00..6fab17361 100644 --- a/db/routines/account/procedures/user_checkName.sql +++ b/db/routines/account/procedures/user_checkName.sql @@ -7,7 +7,7 @@ BEGIN * The user name must only contain lowercase letters or, starting with second * character, numbers or underscores. */ - IF vUserName NOT REGEXP '^[a-z0-9_-]*$' THEN + IF vUserName NOT REGEXP BINARY '^[a-z0-9_-]+$' THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'INVALID_USER_NAME'; END IF; diff --git a/db/versions/10917-aquaPhormium/00-firstScript.sql b/db/versions/10917-aquaPhormium/00-firstScript.sql new file mode 100644 index 000000000..436243ba5 --- /dev/null +++ b/db/versions/10917-aquaPhormium/00-firstScript.sql @@ -0,0 +1,9 @@ +UPDATE account.user +SET name = LOWER(name), + name = REPLACE(name, ' ', ''), + name = REPLACE(name, '.', ''), + name = REPLACE(name, 'ñ', 'n'), + name = REPLACE(name, '*', ''), + name = REPLACE(name, 'ç', 'z'), + name = REPLACE(name, 'ã', 'a') +WHERE NOT active; diff --git a/e2e/paths/02-client/01_create_client.spec.js b/e2e/paths/02-client/01_create_client.spec.js index 744b11a72..e951ec784 100644 --- a/e2e/paths/02-client/01_create_client.spec.js +++ b/e2e/paths/02-client/01_create_client.spec.js @@ -32,7 +32,7 @@ describe('Client create path', () => { await page.autocompleteSearch(selectors.createClientView.salesPerson, 'salesPerson'); await page.autocompleteSearch(selectors.createClientView.businessType, 'florist'); await page.write(selectors.createClientView.taxNumber, '74451390E'); - await page.write(selectors.createClientView.userName, 'CaptainMarvel'); + await page.write(selectors.createClientView.userName, 'captainmarvel'); await page.write(selectors.createClientView.email, 'CarolDanvers@verdnatura.es'); await page.waitToClick(selectors.createClientView.createButton); const message = await page.waitForSnackbar(); diff --git a/e2e/paths/02-client/07_edit_web_access.spec.js b/e2e/paths/02-client/07_edit_web_access.spec.js index c5e132ab7..8758c3b05 100644 --- a/e2e/paths/02-client/07_edit_web_access.spec.js +++ b/e2e/paths/02-client/07_edit_web_access.spec.js @@ -29,7 +29,7 @@ describe('Client web access path', () => { await page.click($.enableWebAccess); await page.click($.saveButton); const enableMessage = await page.waitForSnackbar(); - await page.overwrite($.userName, 'Legion'); + await page.overwrite($.userName, 'legion'); await page.overwrite($.email, 'legion@marvel.com'); await page.click($.saveButton); const modifyMessage = await page.waitForSnackbar(); @@ -47,7 +47,7 @@ describe('Client web access path', () => { expect(modifyMessage.type).toBe('success'); expect(hasAccess).toBe('unchecked'); - expect(userName).toEqual('Legion'); + expect(userName).toEqual('legion'); expect(email).toEqual('legion@marvel.com'); // expect(logName).toEqual('Legion'); diff --git a/e2e/paths/02-client/09_add_credit.spec.js b/e2e/paths/02-client/09_add_credit.spec.js index 2365f0635..179265b0f 100644 --- a/e2e/paths/02-client/09_add_credit.spec.js +++ b/e2e/paths/02-client/09_add_credit.spec.js @@ -34,6 +34,6 @@ describe('Client Add credit path', () => { const result = await page.waitToGetProperty(selectors.clientCredit.firstCreditText, 'innerText'); expect(result).toContain(999); - expect(result).toContain('salesAssistant'); + expect(result).toContain('salesassistant'); }); }); diff --git a/e2e/paths/02-client/19_summary.spec.js b/e2e/paths/02-client/19_summary.spec.js index b3bf43c5c..dec8d505c 100644 --- a/e2e/paths/02-client/19_summary.spec.js +++ b/e2e/paths/02-client/19_summary.spec.js @@ -61,7 +61,7 @@ describe('Client summary path', () => { it('should display web access details', async() => { const result = await page.waitToGetProperty(selectors.clientSummary.userName, 'innerText'); - expect(result).toContain('PetterParker'); + expect(result).toContain('petterparker'); }); it('should display business data', async() => { diff --git a/e2e/paths/05-ticket/05_tracking_state.spec.js b/e2e/paths/05-ticket/05_tracking_state.spec.js index 9ac373287..5cfc1c9d4 100644 --- a/e2e/paths/05-ticket/05_tracking_state.spec.js +++ b/e2e/paths/05-ticket/05_tracking_state.spec.js @@ -59,7 +59,7 @@ describe('Ticket Create new tracking state path', () => { const result = await page .waitToGetProperty(selectors.createStateView.worker, 'value'); - expect(result).toEqual('salesPerson'); + expect(result).toEqual('salesperson'); }); it(`should succesfully create a valid state`, async() => { diff --git a/e2e/paths/14-account/01_create_and_basic_data.spec.js b/e2e/paths/14-account/01_create_and_basic_data.spec.js index e38d1aeec..e2c069d80 100644 --- a/e2e/paths/14-account/01_create_and_basic_data.spec.js +++ b/e2e/paths/14-account/01_create_and_basic_data.spec.js @@ -21,7 +21,7 @@ describe('Account create and basic data path', () => { }); it('should fill the form and then save it by clicking the create button', async() => { - await page.write(selectors.accountIndex.newName, 'Remy'); + await page.write(selectors.accountIndex.newName, 'remy'); await page.write(selectors.accountIndex.newNickname, 'Gambit'); await page.write(selectors.accountIndex.newEmail, 'RemyEtienneLeBeau@verdnatura.es'); await page.autocompleteSearch(selectors.accountIndex.newRole, 'Trainee'); @@ -39,7 +39,7 @@ describe('Account create and basic data path', () => { it('should check the name is as expected', async() => { const result = await page.waitToGetProperty(selectors.accountBasicData.name, 'value'); - expect(result).toEqual('Remy'); + expect(result).toEqual('remy'); }); it('should check the nickname is as expected', async() => { diff --git a/modules/client/back/methods/client/specs/createWithUser.spec.js b/modules/client/back/methods/client/specs/createWithUser.spec.js index 074cb289a..04fc51a26 100644 --- a/modules/client/back/methods/client/specs/createWithUser.spec.js +++ b/modules/client/back/methods/client/specs/createWithUser.spec.js @@ -3,8 +3,8 @@ const LoopBackContext = require('loopback-context'); describe('Client Create', () => { const newAccount = { - userName: 'Deadpool', - email: 'Deadpool@marvel.com', + userName: 'deadpool', + email: 'deadpool@marvel.com', fi: '16195279J', name: 'Wade', socialName: 'DEADPOOL MARVEL', @@ -31,7 +31,7 @@ describe('Client Create', () => { }); }); - it(`should not find Deadpool as he's not created yet`, async() => { + it(`should not find deadpool as he's not created yet`, async() => { const tx = await models.Client.beginTransaction({}); try { diff --git a/modules/client/back/models/specs/client.spec.js b/modules/client/back/models/specs/client.spec.js index bf134fbf9..1b5132304 100644 --- a/modules/client/back/models/specs/client.spec.js +++ b/modules/client/back/models/specs/client.spec.js @@ -31,8 +31,8 @@ describe('Client Model', () => { await models.Client.notifyAssignment(instance, previousWorkerId, currentWorkerId); - expect(chatModel.send).toHaveBeenCalledWith(ctx, '@DavidCharlesHaller', `Client assignment has changed`); - expect(chatModel.send).toHaveBeenCalledWith(ctx, '@HankPym', `Client assignment has changed`); + expect(chatModel.send).toHaveBeenCalledWith(ctx, '@davidcharleshaller', `Client assignment has changed`); + expect(chatModel.send).toHaveBeenCalledWith(ctx, '@hankpym', `Client assignment has changed`); }); it('should call to the Chat send() method for the previous worker', async() => { @@ -40,7 +40,7 @@ describe('Client Model', () => { await models.Client.notifyAssignment(instance, null, currentWorkerId); - expect(chatModel.send).toHaveBeenCalledWith(ctx, '@HankPym', `Client assignment has changed`); + expect(chatModel.send).toHaveBeenCalledWith(ctx, '@hankpym', `Client assignment has changed`); }); it('should call to the Chat send() method for the current worker', async() => { @@ -48,7 +48,7 @@ describe('Client Model', () => { await models.Client.notifyAssignment(instance, previousWorkerId, null); - expect(chatModel.send).toHaveBeenCalledWith(ctx, '@DavidCharlesHaller', `Client assignment has changed`); + expect(chatModel.send).toHaveBeenCalledWith(ctx, '@davidcharleshaller', `Client assignment has changed`); }); }); diff --git a/modules/worker/back/methods/worker/specs/activeWithInheritedRole.spec.js b/modules/worker/back/methods/worker/specs/activeWithInheritedRole.spec.js index 580e07351..cf1eafa23 100644 --- a/modules/worker/back/methods/worker/specs/activeWithInheritedRole.spec.js +++ b/modules/worker/back/methods/worker/specs/activeWithInheritedRole.spec.js @@ -6,7 +6,7 @@ describe('Worker activeWithInheritedRole', () => { allRolesCount = await app.models.VnRole.count(); }); - it('should return the workers with an inherited role of salesPerson', async() => { + it('should return the workers with an inherited role of salesperson', async() => { const filter = {where: {role: 'salesPerson'}}; const result = await app.models.Worker.activeWithInheritedRole(filter); diff --git a/modules/worker/back/methods/worker/specs/new.spec.js b/modules/worker/back/methods/worker/specs/new.spec.js index d3e9cb9d0..66959e0a7 100644 --- a/modules/worker/back/methods/worker/specs/new.spec.js +++ b/modules/worker/back/methods/worker/specs/new.spec.js @@ -20,7 +20,7 @@ describe('Worker new', () => { const employeeId = 1; const defaultWorker = { fi: '78457139E', - name: 'DEFAULTERWORKER', + name: 'defaulterworker', firstName: 'DEFAULT', lastNames: 'WORKER', email: 'defaultWorker@mydomain.com', From 9aad1dd6e843cfb20f3d7494937e1cebe4aae41a Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 5 Mar 2024 12:41:54 +0100 Subject: [PATCH 022/153] feat: refs #6500 procRefactor8 --- db/routines/vn/events/raidUpdate.sql | 8 ++++ db/routines/vn/procedures/creditRecovery.sql | 49 ++++++++++++++++++++ db/routines/vn/procedures/raidUpdate.sql | 30 ++++++++++++ db/routines/vn/procedures/rateView.sql | 42 +++++++++++++++++ 4 files changed, 129 insertions(+) create mode 100644 db/routines/vn/events/raidUpdate.sql create mode 100644 db/routines/vn/procedures/creditRecovery.sql create mode 100644 db/routines/vn/procedures/raidUpdate.sql create mode 100644 db/routines/vn/procedures/rateView.sql diff --git a/db/routines/vn/events/raidUpdate.sql b/db/routines/vn/events/raidUpdate.sql new file mode 100644 index 000000000..619dadb48 --- /dev/null +++ b/db/routines/vn/events/raidUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`raidUpdate` + ON SCHEDULE EVERY 1 DAY + STARTS '2017-12-29 00:05:00.000' + ON COMPLETION PRESERVE + ENABLE +DO CALL raidUpdate$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/creditRecovery.sql b/db/routines/vn/procedures/creditRecovery.sql new file mode 100644 index 000000000..5a32a87f8 --- /dev/null +++ b/db/routines/vn/procedures/creditRecovery.sql @@ -0,0 +1,49 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditRecovery`() +BEGIN + DECLARE EXIT HANDLER FOR SQLSTATE '45000' + BEGIN + ROLLBACK; + RESIGNAL; + END; + + START TRANSACTION; + + UPDATE `client` c + JOIN payMethod pm ON pm.id = c.payMethodFk + SET c.credit = 0 + WHERE pm.`code` = 'card'; + + DROP TEMPORARY TABLE IF EXISTS tCreditClients; + CREATE TEMPORARY TABLE tCreditClients + SELECT clientFk, IF (credit > recovery ,credit - recovery,0) newCredit + FROM ( + SELECT r.clientFk, + r.amount recovery, + timestampadd(DAY, r.period, sub2.created) deadLine, + sub2.amount credit + FROM recovery r + JOIN ( + SELECT clientFk, amount , created + FROM ( + SELECT * FROM clientCredit + ORDER BY created DESC + LIMIT 10000000000000000000 + ) sub + GROUP BY clientFk + ) sub2 ON sub2.clientFk = r.clientFk + WHERE r.finished IS NULL OR r.finished >= util.VN_CURDATE() + GROUP BY r.clientFk + HAVING deadLine <= util.VN_CURDATE() + ) sub3 + WHERE credit > 0; + + UPDATE client c + JOIN tCreditClients cc ON cc.clientFk = c.clientFk + SET Clientes.Credito = newCredit; + + DROP TEMPORARY TABLE tCreditClients; + COMMIT; + +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/raidUpdate.sql b/db/routines/vn/procedures/raidUpdate.sql new file mode 100644 index 000000000..214974350 --- /dev/null +++ b/db/routines/vn/procedures/raidUpdate.sql @@ -0,0 +1,30 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`raidUpdate`() +BEGIN + + UPDATE entry e + JOIN entryVirtual ev ON ev.entryFk = e.id + JOIN travel t ON t.id = e.travelFk + JOIN ( + SELECT * + FROM ( + SELECT id, landed, tt.warehouseInFk, tt.warehouseOutFk + FROM travel t + JOIN ( + SELECT t.warehouseInFk, t.warehouseOutFk + FROM entryVirtual ev + JOIN entry e ON e.id = ev.entryFk + JOIN travel t ON t.id = e.travelFk + GROUP BY t.warehouseInFk, t.warehouseOutFk + ) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk + + WHERE shipped > util.VN_CURDATE() AND isDelivered = FALSE + ORDER BY t.landed + LIMIT 10000000000000000000 + ) t + GROUP BY warehouseInFk, warehouseOutFk + ) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk + SET e.travelFk = t.id; + +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/rateView.sql b/db/routines/vn/procedures/rateView.sql new file mode 100644 index 000000000..6da1ea017 --- /dev/null +++ b/db/routines/vn/procedures/rateView.sql @@ -0,0 +1,42 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`rateView`() +BEGIN + + DECLARE v10Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 10 YEAR; + + SELECT + t.year, + t.month, + pagos.dollars, + pagos.changePractical, + CAST(SUM(iit.foreignValue ) / SUM(iit.taxableBase) AS DECIMAL(5,4)) cambioTeorico, + pagos.changeOfficial + FROM invoiceIn ii + JOIN time t ON t.dated = ii.issued + JOIN invoiceInTax iit ON ii.id = iit.invoiceInFk + JOIN + ( + SELECT + t.year, + t.month, + CAST(SUM(divisa) AS DECIMAL(10,2)) dollars, + CAST(SUM(divisa) / SUM(amount) AS DECIMAL(5,4)) changePractical, + CAST(rr.value * 0.998 AS DECIMAL(5,4)) changeOfficial + FROM payment p + JOIN time t ON t.dated = p.received + JOIN referenceRate rr ON rr.dated = p.received + JOIN currency c ON c.id = rr.currencyFk + WHERE divisa + AND p.received >= v10Years + AND c.code = 'USD' + GROUP BY t.year, t.month + ) pagos ON t.year = pagos.year AND t.month = pagos.MONTH + JOIN currency c ON c.id = ii.currencyFk + WHERE c.code = 'USD' + AND ii.issued >= v10Years + AND iit.foreignValue + AND iit.taxableBase + GROUP BY t.year, t.month; + +END$$ +DELIMITER ; From e83b0622cfb893c8294a042ee7dc37e0211a4b96 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 5 Mar 2024 13:21:53 +0100 Subject: [PATCH 023/153] refs 6500 rateView --- db/routines/vn/procedures/rateView.sql | 34 +++++++++++--------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/db/routines/vn/procedures/rateView.sql b/db/routines/vn/procedures/rateView.sql index 6da1ea017..fb03c192a 100644 --- a/db/routines/vn/procedures/rateView.sql +++ b/db/routines/vn/procedures/rateView.sql @@ -2,9 +2,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`rateView`() BEGIN - DECLARE v10Years DATE DEFAULT util.VN_CURDATE() - INTERVAL 10 YEAR; - - SELECT + SELECT t.year, t.month, pagos.dollars, @@ -15,28 +13,24 @@ BEGIN JOIN time t ON t.dated = ii.issued JOIN invoiceInTax iit ON ii.id = iit.invoiceInFk JOIN - ( - SELECT - t.year, - t.month, - CAST(SUM(divisa) AS DECIMAL(10,2)) dollars, - CAST(SUM(divisa) / SUM(amount) AS DECIMAL(5,4)) changePractical, - CAST(rr.value * 0.998 AS DECIMAL(5,4)) changeOfficial - FROM payment p - JOIN time t ON t.dated = p.received - JOIN referenceRate rr ON rr.dated = p.received - JOIN currency c ON c.id = rr.currencyFk - WHERE divisa - AND p.received >= v10Years - AND c.code = 'USD' - GROUP BY t.year, t.month + ( SELECT + t.year, + t.month, + CAST(SUM(divisa) AS DECIMAL(10,2)) dollars, + CAST(SUM(divisa) / SUM(amount) AS DECIMAL(5,4)) changePractical, + CAST(rr.value * 0.998 AS DECIMAL(5,4)) changeOfficial + FROM payment p + JOIN time t ON t.dated = p.received + JOIN referenceRate rr ON rr.dated = p.received + JOIN currency c ON c.id = rr.currencyFk + WHERE divisa + AND c.code = 'USD' + GROUP BY t.year, t.month ) pagos ON t.year = pagos.year AND t.month = pagos.MONTH JOIN currency c ON c.id = ii.currencyFk WHERE c.code = 'USD' - AND ii.issued >= v10Years AND iit.foreignValue AND iit.taxableBase GROUP BY t.year, t.month; - END$$ DELIMITER ; From 2f0c1612c2770fd300090e45fe84ff7446c911e7 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 6 Mar 2024 12:02:34 +0100 Subject: [PATCH 024/153] feat: refs #6500 delete procedure --- db/routines/vn/procedures/riskAllClients.sql | 24 +++--- .../vn/procedures/solunionRiskRequest.sql | 16 ++-- db/routines/vn2008/events/raidUpdate.sql | 8 -- db/routines/vn2008/procedures/raidUpdate.sql | 28 ------- db/routines/vn2008/procedures/rateView.sql | 37 -------- .../vn2008/procedures/recobro_credito.sql | 45 ---------- .../vn2008/procedures/risk_vs_client_list.sql | 84 ------------------- 7 files changed, 20 insertions(+), 222 deletions(-) delete mode 100644 db/routines/vn2008/events/raidUpdate.sql delete mode 100644 db/routines/vn2008/procedures/raidUpdate.sql delete mode 100644 db/routines/vn2008/procedures/rateView.sql delete mode 100644 db/routines/vn2008/procedures/recobro_credito.sql delete mode 100644 db/routines/vn2008/procedures/risk_vs_client_list.sql diff --git a/db/routines/vn/procedures/riskAllClients.sql b/db/routines/vn/procedures/riskAllClients.sql index 66c0a0dd5..621d047ae 100644 --- a/db/routines/vn/procedures/riskAllClients.sql +++ b/db/routines/vn/procedures/riskAllClients.sql @@ -3,27 +3,27 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`riskAllClients`(max BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.client_list; - CREATE TEMPORARY TABLE tmp.client_list - (PRIMARY KEY (Id_Cliente)) + CREATE TEMPORARY TABLE tmp.client_list + (PRIMARY KEY (Id_Cliente)) ENGINE = MEMORY SELECT id Id_Cliente, null grade FROM vn.client; - - CALL vn2008.risk_vs_client_list(maxRiskDate); - + + CALL client_getDebt (maxRiskDate); + SELECT c.RazonSocial, - c.Id_Cliente, - c.Credito, - CAST(r.risk as DECIMAL (10,2)) risk, - CAST(c.Credito - r.risk as DECIMAL (10,2)) Diferencia, - c.Id_Pais + c.Id_Cliente, + c.Credito, + CAST(r.risk as DECIMAL (10,2)) risk, + CAST(c.Credito - r.risk as DECIMAL (10,2)) Diferencia, + c.Id_Pais FROM vn2008.Clientes c JOIN tmp.risk r ON r.Id_Cliente = c.Id_Cliente JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente GROUP BY c.Id_cliente; - + DROP TEMPORARY TABLE IF EXISTS tmp.risk; - DROP TEMPORARY TABLE IF EXISTS tmp.client_list; + DROP TEMPORARY TABLE IF EXISTS tmp.client_list; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/solunionRiskRequest.sql b/db/routines/vn/procedures/solunionRiskRequest.sql index b735bea33..7a7102782 100644 --- a/db/routines/vn/procedures/solunionRiskRequest.sql +++ b/db/routines/vn/procedures/solunionRiskRequest.sql @@ -8,15 +8,15 @@ BEGIN ENGINE = MEMORY SELECT * FROM (SELECT cc.client Id_Cliente, ci.grade FROM vn.creditClassification cc JOIN vn.creditInsurance ci ON cc.id = ci.creditClassification - WHERE dateEnd IS NULL - ORDER BY ci.creationDate DESC + WHERE dateEnd IS NULL + ORDER BY ci.creationDate DESC LIMIT 10000000000000000000) t1 GROUP BY Id_Cliente; - - CALL vn2008.risk_vs_client_list(util.VN_CURDATE()); - + + CALL client_getDebt (util.VN_CURDATE()); + SELECT c.Id_Cliente, c.Cliente, c.Credito credito_vn, c.creditInsurance solunion, cast(r.risk as DECIMAL(10,0)) riesgo_vivo, - cast(c.creditInsurance - r.risk as decimal(10,0)) margen_vivo, + cast(c.creditInsurance - r.risk as decimal(10,0)) margen_vivo, f.Consumo consumo_anual, c.Vencimiento, ci.grade FROM vn2008.Clientes c @@ -24,8 +24,8 @@ BEGIN JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente JOIN bi.facturacion_media_anual f ON c.Id_Cliente = f.Id_Cliente GROUP BY Id_cliente; - + DROP TEMPORARY TABLE IF EXISTS tmp.risk; - DROP TEMPORARY TABLE IF EXISTS tmp.client_list; + DROP TEMPORARY TABLE IF EXISTS tmp.client_list; END$$ DELIMITER ; diff --git a/db/routines/vn2008/events/raidUpdate.sql b/db/routines/vn2008/events/raidUpdate.sql deleted file mode 100644 index aacfd6dcd..000000000 --- a/db/routines/vn2008/events/raidUpdate.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn2008`.`raidUpdate` - ON SCHEDULE EVERY 1 DAY - STARTS '2017-12-29 00:05:00.000' - ON COMPLETION PRESERVE - ENABLE -DO CALL raidUpdate$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/raidUpdate.sql b/db/routines/vn2008/procedures/raidUpdate.sql deleted file mode 100644 index 9746f3cf9..000000000 --- a/db/routines/vn2008/procedures/raidUpdate.sql +++ /dev/null @@ -1,28 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`raidUpdate`() -BEGIN - - UPDATE Entradas e - JOIN Entradas_Auto ea USING (Id_Entrada) - JOIN travel t ON t.id = e.travel_id - JOIN ( - SELECT * - FROM ( - SELECT id, landing, warehouse_id, warehouse_id_out - FROM travel - JOIN ( - SELECT warehouse_id, warehouse_id_out - FROM Entradas_Auto ea - JOIN Entradas e USING(Id_Entrada) - JOIN travel t ON t.id = e.travel_id - GROUP BY warehouse_id, warehouse_id_out - ) t USING (warehouse_id, warehouse_id_out) - WHERE shipment > util.VN_CURDATE() AND delivered = FALSE - ORDER BY landing - LIMIT 10000000000000000000 - ) t - GROUP BY warehouse_id, warehouse_id_out - ) t USING (warehouse_id, warehouse_id_out) - SET e.travel_id = t.id; -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/rateView.sql b/db/routines/vn2008/procedures/rateView.sql deleted file mode 100644 index 91e317be6..000000000 --- a/db/routines/vn2008/procedures/rateView.sql +++ /dev/null @@ -1,37 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`rateView`() -BEGIN - - SELECT - t.year as año, - t.month as mes, - pagos.dolares, - pagos.cambioPractico, - CAST(sum(divisa) / sum(bi) as DECIMAL(5,4)) as cambioTeorico, - pagos.cambioOficial - FROM recibida r - JOIN time t ON t.date = r.fecha - JOIN recibida_iva ri ON r.id = ri.recibida_id - JOIN - ( - SELECT - t.year as Año, - t.month as Mes, - cast(sum(divisa) as DECIMAL(10,2)) as dolares, - cast(sum(divisa) / sum(importe) as DECIMAL(5,4)) as cambioPractico, - cast(rr.rate * 0.998 as DECIMAL(5,4)) as cambioOficial - FROM pago p - JOIN time t ON t.date = p.fecha - JOIN reference_rate rr ON rr.date = p.fecha AND moneda_id = 2 - WHERE divisa - AND fecha >= '2015-01-11' - GROUP BY t.year, t.month - ) pagos ON t.year = pagos.Año AND t.month = pagos.Mes - WHERE moneda_id = 2 - AND fecha >= '2015-01-01' - AND divisa - AND bi - GROUP BY t.year, t.month; - -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/recobro_credito.sql b/db/routines/vn2008/procedures/recobro_credito.sql deleted file mode 100644 index 3657f2b9b..000000000 --- a/db/routines/vn2008/procedures/recobro_credito.sql +++ /dev/null @@ -1,45 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`recobro_credito`() -BEGIN - DECLARE EXIT HANDLER FOR SQLSTATE '45000' - BEGIN - ROLLBACK; - RESIGNAL; - END; - - START TRANSACTION; - UPDATE vn.`client` c - JOIN vn.payMethod pm ON pm.id = c.payMethodFk - SET credit = 0 - WHERE pm.`code` = 'card'; - - DROP TEMPORARY TABLE IF EXISTS clientes_credit; - CREATE TEMPORARY TABLE clientes_credit - SELECT Id_Cliente, if (Credito > Recobro ,Credito - Recobro,0) AS newCredit - FROM ( - SELECT r.Id_Cliente, r.amount AS Recobro, - timestampadd(DAY, period, UltimaFecha) AS Deadline, sub2.amount AS Credito - FROM vn2008.recovery r - JOIN ( - SELECT Id_Cliente, amount , odbc_date AS UltimaFecha - FROM ( - SELECT * FROM credit - ORDER BY odbc_date DESC - LIMIT 10000000000000000000 - ) sub - GROUP BY Id_Cliente - ) sub2 USING(Id_Cliente) - WHERE dend IS NULL or dend >= util.VN_CURDATE() - GROUP BY Id_Cliente - HAVING Deadline <= util.VN_CURDATE() - ) sub3 - WHERE Credito > 0; - - UPDATE Clientes - JOIN clientes_credit USING(Id_Cliente) - SET Clientes.Credito = newCredit; - - DROP TEMPORARY TABLE clientes_credit; - COMMIT; -END$$ -DELIMITER ; diff --git a/db/routines/vn2008/procedures/risk_vs_client_list.sql b/db/routines/vn2008/procedures/risk_vs_client_list.sql deleted file mode 100644 index 92f94eb9f..000000000 --- a/db/routines/vn2008/procedures/risk_vs_client_list.sql +++ /dev/null @@ -1,84 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`risk_vs_client_list`(maxRiskDate DATE) -BEGIN -/** - * Calcula el riesgo para los clientes activos de la tabla temporal tmp.client_list - * - * @deprecated usar vn.client_getDebt - * @param maxRiskDate Fecha maxima de los registros - * @return table tmp.risk - */ - DECLARE startingDate DATETIME DEFAULT TIMESTAMPADD(DAY, - DAYOFMONTH(util.VN_CURDATE()) - 60, util.VN_CURDATE()); - DECLARE endingDate DATETIME; - DECLARE MAX_RISK_ALLOWED INT DEFAULT 200; - - SET maxRiskDate = IFNULL(maxRiskDate, util.VN_CURDATE()); - SET endingDate = TIMESTAMP(maxRiskDate, '23:59:59'); - - DROP TEMPORARY TABLE IF EXISTS tmp.client_list_2; - CREATE TEMPORARY TABLE tmp.client_list_2 - (PRIMARY KEY (Id_Cliente)) - ENGINE = MEMORY - SELECT * - FROM tmp.client_list; - - DROP TEMPORARY TABLE IF EXISTS tmp.client_list_3; - CREATE TEMPORARY TABLE tmp.client_list_3 - (PRIMARY KEY (Id_Cliente)) - ENGINE = MEMORY - SELECT * - FROM tmp.client_list; - - DROP TEMPORARY TABLE IF EXISTS tmp.tickets_sin_facturar; - CREATE TEMPORARY TABLE tmp.tickets_sin_facturar - (PRIMARY KEY (Id_Cliente)) - ENGINE = MEMORY - SELECT t.Id_Cliente, floor(IF(cl.isVies, 1, 1.1) * sum(Cantidad * Preu * (100 - Descuento) / 100)) as total - FROM Movimientos m - JOIN Tickets t on m.Id_Ticket = t.Id_Ticket - JOIN tmp.client_list c on c.Id_Cliente = t.Id_Cliente - JOIN vn.client cl ON cl.id = t.Id_Cliente - WHERE Factura IS NULL - AND Fecha BETWEEN startingDate AND endingDate - GROUP BY t.Id_Cliente; - - DROP TEMPORARY TABLE IF EXISTS tmp.risk; - CREATE TEMPORARY TABLE tmp.risk - (PRIMARY KEY (Id_Cliente)) - ENGINE = MEMORY - SELECT Id_Cliente, SUM(amount) risk, sum(saldo) saldo - FROM Clientes c - JOIN ( - SELECT clientFk, SUM(amount) amount,SUM(amount) saldo - FROM vn.clientRisk - JOIN tmp.client_list on Id_Cliente = clientFk - GROUP BY clientFk - UNION ALL - SELECT Id_Cliente, SUM(Entregado),SUM(Entregado) - FROM Recibos - JOIN tmp.client_list_2 using(Id_Cliente) - WHERE Fechacobro > endingDate - GROUP BY Id_Cliente - UNION ALL - SELECT Id_Cliente, total,0 - FROM tmp.tickets_sin_facturar - UNION ALL - SELECT t.clientFk, CAST(-SUM(t.amount) / 100 AS DECIMAL(10,2)), CAST(-SUM(t.amount) / 100 AS DECIMAL(10,2)) - FROM hedera.tpvTransaction t - JOIN tmp.client_list_3 on Id_Cliente = t.clientFk - WHERE t.receiptFk IS NULL - AND t.status = 'ok' - GROUP BY t.clientFk - ) t ON c.Id_Cliente = t.clientFk - WHERE c.activo != FALSE - GROUP BY c.Id_Cliente; - - DELETE r.* - FROM tmp.risk r - JOIN vn2008.Clientes c on c.Id_Cliente = r.Id_Cliente - JOIN vn2008.pay_met pm on pm.id = c.pay_met_id - WHERE IFNULL(r.saldo,0) < 10 - AND r.risk <= MAX_RISK_ALLOWED - AND pm.`name` = 'TARJETA'; -END$$ -DELIMITER ; From 194947dc9a0cf3dccd0bb9ed69acd357e6fb41a4 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 6 Mar 2024 14:11:07 +0100 Subject: [PATCH 025/153] feat: refs #6500 procRefactor8 --- db/routines/vn/procedures/client_getDebt.sql | 6 ++-- db/routines/vn/procedures/creditRecovery.sql | 2 +- db/routines/vn/procedures/riskAllClients.sql | 32 +++++++++---------- .../vn/procedures/solunionRiskRequest.sql | 25 ++++++++------- 4 files changed, 34 insertions(+), 31 deletions(-) diff --git a/db/routines/vn/procedures/client_getDebt.sql b/db/routines/vn/procedures/client_getDebt.sql index ad7b5b7d2..3eaace4e9 100644 --- a/db/routines/vn/procedures/client_getDebt.sql +++ b/db/routines/vn/procedures/client_getDebt.sql @@ -17,15 +17,15 @@ BEGIN SET vEnded = util.dayEnd(IFNULL(vDate, util.VN_CURDATE())); - CREATE OR REPLACE TEMPORARY TABLE tClientRisk + CREATE OR REPLACE TEMPORARY TABLE tClientRisk ENGINE = MEMORY - SELECT cr.clientFk, SUM(cr.amount) amount + SELECT cr.clientFk, SUM(cr.amount) amount FROM clientRisk cr JOIN tmp.clientGetDebt c ON c.clientFk = cr.clientFk GROUP BY cr.clientFk; INSERT INTO tClientRisk - SELECT c.clientFk, SUM(r.amountPaid) + SELECT c.clientFk, SUM(r.amountPaid) FROM receipt r JOIN tmp.clientGetDebt c ON c.clientFk = r.clientFk WHERE r.payed > vEnded diff --git a/db/routines/vn/procedures/creditRecovery.sql b/db/routines/vn/procedures/creditRecovery.sql index 5a32a87f8..e598661af 100644 --- a/db/routines/vn/procedures/creditRecovery.sql +++ b/db/routines/vn/procedures/creditRecovery.sql @@ -40,7 +40,7 @@ BEGIN UPDATE client c JOIN tCreditClients cc ON cc.clientFk = c.clientFk - SET Clientes.Credito = newCredit; + SET c.credit = newCredit; DROP TEMPORARY TABLE tCreditClients; COMMIT; diff --git a/db/routines/vn/procedures/riskAllClients.sql b/db/routines/vn/procedures/riskAllClients.sql index 621d047ae..c818c715c 100644 --- a/db/routines/vn/procedures/riskAllClients.sql +++ b/db/routines/vn/procedures/riskAllClients.sql @@ -2,28 +2,28 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`riskAllClients`(maxRiskDate DATE) BEGIN - DROP TEMPORARY TABLE IF EXISTS tmp.client_list; - CREATE TEMPORARY TABLE tmp.client_list - (PRIMARY KEY (Id_Cliente)) + DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; + CREATE TEMPORARY TABLE tmp.clientGetDebt + (PRIMARY KEY (clientFk)) ENGINE = MEMORY - SELECT id Id_Cliente, null grade FROM vn.client; + SELECT id clientFk, null grade FROM client; CALL client_getDebt (maxRiskDate); SELECT - c.RazonSocial, - c.Id_Cliente, - c.Credito, - CAST(r.risk as DECIMAL (10,2)) risk, - CAST(c.Credito - r.risk as DECIMAL (10,2)) Diferencia, - c.Id_Pais - FROM - vn2008.Clientes c - JOIN tmp.risk r ON r.Id_Cliente = c.Id_Cliente - JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente - GROUP BY c.Id_cliente; + c.RazonSocial, + c.Id_Cliente, + c.Credito, + CAST(r.risk as DECIMAL (10,2)) risk, + CAST(c.Credito - r.risk as DECIMAL (10,2)) Diferencia, + c.Id_Pais + FROM + vn2008.Clientes c + JOIN tmp.risk r ON r.clientFk = c.Id_Cliente + JOIN tmp.clientGetDebt ci ON c.Id_Cliente = ci.clientFk + GROUP BY c.Id_cliente; DROP TEMPORARY TABLE IF EXISTS tmp.risk; - DROP TEMPORARY TABLE IF EXISTS tmp.client_list; + DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/solunionRiskRequest.sql b/db/routines/vn/procedures/solunionRiskRequest.sql index 7a7102782..f5af4d0ad 100644 --- a/db/routines/vn/procedures/solunionRiskRequest.sql +++ b/db/routines/vn/procedures/solunionRiskRequest.sql @@ -2,15 +2,18 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`solunionRiskRequest`() BEGIN - DROP TEMPORARY TABLE IF EXISTS tmp.client_list; - CREATE TEMPORARY TABLE tmp.client_list - (PRIMARY KEY (Id_Cliente)) + DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; + CREATE TEMPORARY TABLE tmp.clientGetDebt + (PRIMARY KEY (clientFk)) ENGINE = MEMORY - SELECT * FROM (SELECT cc.client Id_Cliente, ci.grade FROM vn.creditClassification cc - JOIN vn.creditInsurance ci ON cc.id = ci.creditClassification - WHERE dateEnd IS NULL - ORDER BY ci.creationDate DESC - LIMIT 10000000000000000000) t1 GROUP BY Id_Cliente; + SELECT * + FROM (SELECT cc.client clientFk, ci.grade + FROM vn.creditClassification cc + JOIN vn.creditInsurance ci ON cc.id = ci.creditClassification + WHERE dateEnd IS NULL + ORDER BY ci.creationDate DESC + LIMIT 10000000000000000000) t1 + GROUP BY clientFk; CALL client_getDebt (util.VN_CURDATE()); @@ -20,12 +23,12 @@ BEGIN f.Consumo consumo_anual, c.Vencimiento, ci.grade FROM vn2008.Clientes c - JOIN tmp.risk r ON r.Id_Cliente = c.Id_Cliente - JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente + JOIN tmp.risk r ON r.clientFk = c.Id_Cliente + JOIN tmp.clientGetDebt ci ON c.Id_Cliente = ci.clientFk JOIN bi.facturacion_media_anual f ON c.Id_Cliente = f.Id_Cliente GROUP BY Id_cliente; DROP TEMPORARY TABLE IF EXISTS tmp.risk; - DROP TEMPORARY TABLE IF EXISTS tmp.client_list; + DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; END$$ DELIMITER ; From a44359762b188ac5b223b3fe26499dab4db2fb5b Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 6 Mar 2024 14:51:34 +0100 Subject: [PATCH 026/153] feat(delay): refs #6005 add new restriction --- .../email/backup-printer-selected/backup-printer-selected.js | 4 +--- .../backup-printer-selected/sql/previousNotifications.sql | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/print/templates/email/backup-printer-selected/backup-printer-selected.js b/print/templates/email/backup-printer-selected/backup-printer-selected.js index 04a82b0c7..3578d0476 100755 --- a/print/templates/email/backup-printer-selected/backup-printer-selected.js +++ b/print/templates/email/backup-printer-selected/backup-printer-selected.js @@ -5,10 +5,8 @@ const name = 'backup-printer-selected'; module.exports = { name: name, async serverPrefetch() { - const notifications1 = await this.rawSqlFromDef('previousNotificationscopy', [name]); - console.log('notifications: ', notifications1); const notifications = await this.rawSqlFromDef('previousNotifications', [name]); - if (!notifications.length && checkDuplicates(notifications, this.labelerId, this.sectorId)) + if (!notifications.length || checkDuplicates(notifications, this.labelerId, this.sectorId)) throw new Error('Previous notification sended with the same parameters'); this.sector = await this.findOneFromDef('sector', [this.sectorId]); diff --git a/print/templates/email/backup-printer-selected/sql/previousNotifications.sql b/print/templates/email/backup-printer-selected/sql/previousNotifications.sql index bd44b05e4..2e2a8b93f 100644 --- a/print/templates/email/backup-printer-selected/sql/previousNotifications.sql +++ b/print/templates/email/backup-printer-selected/sql/previousNotifications.sql @@ -1,4 +1,4 @@ -SELECT nq.params +SELECT nq.params, created, status FROM util.notificationQueue nq JOIN util.notification n ON n.name = nq.notificationFk WHERE n.name = ? From 45bcf8043f03cb4eea2a621abb5c59af38661e3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 7 Mar 2024 19:03:57 +0100 Subject: [PATCH 027/153] feat: permissions to vn.entry.isBooked refs#6724 --- db/versions/10944-tealLaurel/00-firstScript.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 db/versions/10944-tealLaurel/00-firstScript.sql diff --git a/db/versions/10944-tealLaurel/00-firstScript.sql b/db/versions/10944-tealLaurel/00-firstScript.sql new file mode 100644 index 000000000..d11bcb333 --- /dev/null +++ b/db/versions/10944-tealLaurel/00-firstScript.sql @@ -0,0 +1,10 @@ + + REVOKE UPDATE ON vn.entry FROM entryEditor; + GRANT UPDATE ON vn.entry TO administrative; + + GRANT UPDATE (id, supplierFk, dated, invoiceNumber, isExcludedFromAvailable, + isConfirmed, isOrdered, isRaid,commission, created, evaNotes, travelFk, + currencyFk,companyFk, gestDocFk, invoiceInFk, isBlocked, loadPriority, + kop, sub, pro, auction, invoiceAmount, buyerFk, typeFk, reference, + observationEditorFk, clonedFrom, editorFk, lockerUserFk, locked + ) ON vn.entry TO entryEditor; From ae25ba3fb6b2d827de39345f41e18d9d8608ef02 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 8 Mar 2024 13:44:19 +0100 Subject: [PATCH 028/153] feat(notify): refs #6005 add restriction on created notification time --- back/methods/notification/send.js | 2 +- .../back/methods/operator/spec/operator.spec.js | 2 -- .../backup-printer-selected.js | 13 ++++++++----- .../sql/previousNotifications.sql | 4 +++- .../sql/previousNotificationscopy.sql | 4 ---- 5 files changed, 12 insertions(+), 13 deletions(-) delete mode 100644 print/templates/email/backup-printer-selected/sql/previousNotificationscopy.sql diff --git a/back/methods/notification/send.js b/back/methods/notification/send.js index b2748477d..0232c59bd 100644 --- a/back/methods/notification/send.js +++ b/back/methods/notification/send.js @@ -67,7 +67,7 @@ module.exports = Self => { continue; } - const newParams = Object.assign({}, queueParams, sendParams); + const newParams = Object.assign({}, queueParams, sendParams, {created: queue.created}); const email = new Email(queueName, newParams); if (process.env.NODE_ENV != 'test') diff --git a/modules/worker/back/methods/operator/spec/operator.spec.js b/modules/worker/back/methods/operator/spec/operator.spec.js index a39fcf791..0a8fc5b5d 100644 --- a/modules/worker/back/methods/operator/spec/operator.spec.js +++ b/modules/worker/back/methods/operator/spec/operator.spec.js @@ -80,8 +80,6 @@ fdescribe('Operator', () => { console.log('lastNotification: ', lastNotification); - expect(1).toEqual('Is already Notified'); - await tx.rollback(); } catch (e) { await tx.rollback(); diff --git a/print/templates/email/backup-printer-selected/backup-printer-selected.js b/print/templates/email/backup-printer-selected/backup-printer-selected.js index 3578d0476..0e20ed0d8 100755 --- a/print/templates/email/backup-printer-selected/backup-printer-selected.js +++ b/print/templates/email/backup-printer-selected/backup-printer-selected.js @@ -5,7 +5,7 @@ const name = 'backup-printer-selected'; module.exports = { name: name, async serverPrefetch() { - const notifications = await this.rawSqlFromDef('previousNotifications', [name]); + const notifications = await this.rawSqlFromDef('previousNotifications', [name, this.created, this.created]); if (!notifications.length || checkDuplicates(notifications, this.labelerId, this.sectorId)) throw new Error('Previous notification sended with the same parameters'); @@ -32,18 +32,21 @@ module.exports = { workerId: { type: Number, required: true + }, + created: { + type: Date, + required: true } + } }; function checkDuplicates(notifications, labelerFk, printerFk) { - const criteria = { - labelerId: labelerFk, - sectorId: printerFk - }; + const criteria = {labelerId: labelerFk, sectorId: printerFk}; const filteredNotifications = notifications.filter(notification => { const paramsObj = JSON.parse(notification.params); return Object.keys(criteria).every(key => criteria[key] === paramsObj[key]); }); + return filteredNotifications.length > 1; } diff --git a/print/templates/email/backup-printer-selected/sql/previousNotifications.sql b/print/templates/email/backup-printer-selected/sql/previousNotifications.sql index 2e2a8b93f..312daacbb 100644 --- a/print/templates/email/backup-printer-selected/sql/previousNotifications.sql +++ b/print/templates/email/backup-printer-selected/sql/previousNotifications.sql @@ -2,4 +2,6 @@ SELECT nq.params, created, status FROM util.notificationQueue nq JOIN util.notification n ON n.name = nq.notificationFk WHERE n.name = ? - AND TIMESTAMPDIFF(SECOND, nq.created, util.VN_NOW()) <= n.delay \ No newline at end of file + AND nq.created BETWEEN ? - INTERVAL IFNULL(n.delay, 0) SECOND AND ? + AND nq.status <> 'error' + ORDER BY created \ No newline at end of file diff --git a/print/templates/email/backup-printer-selected/sql/previousNotificationscopy.sql b/print/templates/email/backup-printer-selected/sql/previousNotificationscopy.sql deleted file mode 100644 index f8f30e7f1..000000000 --- a/print/templates/email/backup-printer-selected/sql/previousNotificationscopy.sql +++ /dev/null @@ -1,4 +0,0 @@ -SELECT nq.params - FROM util.notificationQueue nq - JOIN util.notification n ON n.name = nq.notificationFk - WHERE n.name = ? \ No newline at end of file From 8815f078505f87c2765799d5d8fdb1b096dcd463 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 11 Mar 2024 12:18:03 +0100 Subject: [PATCH 029/153] feat(spec): refs #6005 add spec to backup Notify --- back/methods/notification/getList.js | 1 - back/methods/notification/specs/send.spec.js | 32 +++++ .../methods/operator/spec/operator.spec.js | 124 ++++++++++++++---- 3 files changed, 129 insertions(+), 28 deletions(-) diff --git a/back/methods/notification/getList.js b/back/methods/notification/getList.js index 49e88e093..cd9cfcd1d 100644 --- a/back/methods/notification/getList.js +++ b/back/methods/notification/getList.js @@ -45,7 +45,6 @@ module.exports = Self => { }); availableNotificationsMap.delete(active.notificationFk); } - console.log(activeNotificationsMap); return { active: [...activeNotificationsMap.entries()], available: [...availableNotificationsMap.entries()] diff --git a/back/methods/notification/specs/send.spec.js b/back/methods/notification/specs/send.spec.js index f0b186e06..c506dc4b0 100644 --- a/back/methods/notification/specs/send.spec.js +++ b/back/methods/notification/specs/send.spec.js @@ -1,6 +1,38 @@ const models = require('vn-loopback/server/server').models; describe('Notification Send()', () => { + beforeAll(async() => { + await models.NotificationQueue.destroyAll(); + await models.NotificationQueue.create( + [ + { + id: 1, + params: '{"id": "1"}', + status: 'pending', + created: '2000-12-31T23:00:00.000Z', + notificationFk: 'print-email', + authorFk: 9 + }, + { + id: 2, + params: '{"id": "2"}', + status: 'pending', + created: '2000-12-31T23:00:00.000Z', + notificationFk: 'print-email', + authorFk: null + }, + { + id: 3, + params: null, + status: 'pending', + created: '2000-12-31T23:00:00.000Z', + notificationFk: 'print-email', + authorFk: null + } + ] + ); + }); + it('should send notification', async() => { const statusPending = 'pending'; const tx = await models.NotificationQueue.beginTransaction({}); diff --git a/modules/worker/back/methods/operator/spec/operator.spec.js b/modules/worker/back/methods/operator/spec/operator.spec.js index 0a8fc5b5d..39a473a38 100644 --- a/modules/worker/back/methods/operator/spec/operator.spec.js +++ b/modules/worker/back/methods/operator/spec/operator.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('Operator', () => { +describe('Operator', () => { const authorFk = 9; const sectorId = 1; const labeler = 1; @@ -13,6 +13,8 @@ fdescribe('Operator', () => { sectorFk: sectorId }; + const errorStatus = 'error'; + async function createOperator(labelerFk, options) { operator.labelerFk = labelerFk; await models.Operator.create(operator, options); @@ -62,31 +64,6 @@ fdescribe('Operator', () => { } }); - fit('should not create notification when is already notified by another worker', async() => { - const tx = await models.Operator.beginTransaction({}); - - try { - const options = {transaction: tx, accessToken: {userId: authorFk}}; - await models.NotificationQueue.create({ - authorFk: 1, - notificationFk: notificationName, - params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 10}), - created: Date.vnNow(), - }, options); - - await createOperator(labeler, options); - await models.Notification.send(options); - const lastNotification = await models.NotificationQueue.find({order: 'id DESC'}, options); - - console.log('lastNotification: ', lastNotification); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } - }); - it('should create notification when delay is null', async() => { const tx = await models.Operator.beginTransaction({}); @@ -96,7 +73,7 @@ fdescribe('Operator', () => { await models.NotificationQueue.create({ authorFk: 1, notificationFk: notificationName, - params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 10}), + params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 1}), created: Date.vnNow(), }, options); @@ -118,4 +95,97 @@ fdescribe('Operator', () => { throw e; } }); + + it('should not sent notification when is already notified by another worker', async() => { + await models.NotificationQueue.create({ + authorFk: 2, + notificationFk: notificationName, + params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 2}), + created: '2001-01-01 12:30:00', + }); + + await models.NotificationQueue.create({ + authorFk: 1, + notificationFk: notificationName, + params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 1}), + created: '2001-01-01 12:31:00', + }); + await models.Notification.send(); + + const lastNotification = await models.NotificationQueue.findOne({order: 'id DESC'}); + + await models.NotificationQueue.destroyAll({notificationFk: notificationName}); + + expect(lastNotification.status).toEqual(errorStatus); + }); + + it('should send a notification when the previous one is on errorStatus status', async() => { + await models.NotificationQueue.create({ + authorFk: 2, + notificationFk: notificationName, + params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 2}), + created: '2001-01-01 12:30:00', + status: errorStatus + }); + + await models.NotificationQueue.create({ + authorFk: 1, + notificationFk: notificationName, + params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 1}), + created: '2001-01-01 12:31:00', + }); + await models.Notification.send(); + + const lastNotification = await models.NotificationQueue.findOne({order: 'id DESC'}); + + await models.NotificationQueue.destroyAll({notificationFk: notificationName}); + + expect(lastNotification.status).toEqual('sent'); + }); + + it('should send a notification when the previous one has distinct params', async() => { + await models.NotificationQueue.create({ + authorFk: 2, + notificationFk: notificationName, + params: JSON.stringify({'labelerId': labeler, 'sectorId': 2, 'workerId': 1}), + created: '2001-01-01 12:30:00', + }); + + await models.NotificationQueue.create({ + authorFk: 1, + notificationFk: notificationName, + params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 1}), + created: '2001-01-01 12:31:00', + }); + await models.Notification.send(); + + const lastNotification = await models.NotificationQueue.findOne({order: 'id DESC'}); + + await models.NotificationQueue.destroyAll({notificationFk: notificationName}); + + expect(lastNotification.status).toEqual('sent'); + }); + + it('should respect de configured delay for the notification', async() => { + await models.NotificationQueue.create({ + authorFk: 2, + notificationFk: notificationName, + params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 2}), + created: '2001-01-01 12:30:00', + }); + + await models.NotificationQueue.create({ + authorFk: 1, + notificationFk: notificationName, + params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 1}), + created: '2001-01-01 13:29:00', + }); + await models.Notification.send(); + + const lastNotification = await models.NotificationQueue.findOne({order: 'id DESC'}); + + await models.NotificationQueue.destroyAll({notificationFk: notificationName}); + + expect(lastNotification.status).toEqual('error'); + }); }); From 421ca8654da847a07d3c80da645b2ddb9368712c Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 11 Mar 2024 13:39:03 +0100 Subject: [PATCH 030/153] fix(changes): refs #6005 remove changes files --- back/methods/notification/send.js | 2 +- db/changes/235201/00-printerChangeIdType.sql | 10 --------- db/changes/235201/01-printerChangeIdType.sql | 21 ------------------- .../235201/03-sectorBackUpLabelerFk.sql | 18 ---------------- .../backup-printer-selected.js | 10 ++++++--- 5 files changed, 8 insertions(+), 53 deletions(-) delete mode 100644 db/changes/235201/00-printerChangeIdType.sql delete mode 100644 db/changes/235201/01-printerChangeIdType.sql delete mode 100644 db/changes/235201/03-sectorBackUpLabelerFk.sql diff --git a/back/methods/notification/send.js b/back/methods/notification/send.js index 0232c59bd..ee3127631 100644 --- a/back/methods/notification/send.js +++ b/back/methods/notification/send.js @@ -67,7 +67,7 @@ module.exports = Self => { continue; } - const newParams = Object.assign({}, queueParams, sendParams, {created: queue.created}); + const newParams = Object.assign({}, queueParams, sendParams, {queueCreated: queue.created}); const email = new Email(queueName, newParams); if (process.env.NODE_ENV != 'test') diff --git a/db/changes/235201/00-printerChangeIdType.sql b/db/changes/235201/00-printerChangeIdType.sql deleted file mode 100644 index 759ac7939..000000000 --- a/db/changes/235201/00-printerChangeIdType.sql +++ /dev/null @@ -1,10 +0,0 @@ -ALTER TABLE `vn`.`packingSite` DROP FOREIGN KEY `packingSite_FK_4`; -ALTER TABLE `vn`.`arcRead` DROP FOREIGN KEY `worker_printer_FK`; -ALTER TABLE `vn`.`host` DROP FOREIGN KEY `configHost_FK`; -ALTER TABLE `vn`.`operator` DROP FOREIGN KEY `operator_FK_5`; -ALTER TABLE `vn`.`packingSite` DROP FOREIGN KEY `packingSite_FK_1`; -ALTER TABLE `vn`.`printQueue` DROP FOREIGN KEY `printQueue_printerFk`; -ALTER TABLE `vn`.`sector` DROP FOREIGN KEY `sector_FK_1`; -ALTER TABLE `vn`.`worker` DROP FOREIGN KEY `worker_FK`; - - diff --git a/db/changes/235201/01-printerChangeIdType.sql b/db/changes/235201/01-printerChangeIdType.sql deleted file mode 100644 index 3fd7d3798..000000000 --- a/db/changes/235201/01-printerChangeIdType.sql +++ /dev/null @@ -1,21 +0,0 @@ -ALTER TABLE `vn`.`printer` MODIFY COLUMN `id` int unsigned auto_increment NOT NULL; - -ALTER TABLE `vn`.`arcRead` MODIFY COLUMN `printerFk` int unsigned DEFAULT NULL NULL; -ALTER TABLE `vn`.`arcRead` ADD CONSTRAINT `arcRead_FK` FOREIGN KEY (printerFk) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE; - -ALTER TABLE `vn`.`host` MODIFY COLUMN `printerFk` int unsigned DEFAULT NULL NULL; -ALTER TABLE `vn`.`host` ADD CONSTRAINT `host_FK` FOREIGN KEY (printerFk) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE CASCADE; - -ALTER TABLE `vn`.`operator` MODIFY COLUMN `labelerFk` int unsigned DEFAULT NULL NULL; -ALTER TABLE `vn`.`operator` ADD CONSTRAINT `operator_FK_4` FOREIGN KEY (labelerFk) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE; - -ALTER TABLE `vn`.`packingSite` MODIFY COLUMN `printerRfidFk` int unsigned DEFAULT NULL NULL; -ALTER TABLE `vn`.`packingSite` MODIFY COLUMN `printerFk` int unsigned DEFAULT NULL NULL; -ALTER TABLE `vn`.`packingSite` ADD CONSTRAINT `packingSite_FK_1` FOREIGN KEY (printerFk) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE RESTRICT; -ALTER TABLE `vn`.`packingSite` ADD CONSTRAINT `packingSite_FK_4` FOREIGN KEY (printerRfidFk) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE CASCADE; - -ALTER TABLE `vn`.`printQueue` MODIFY COLUMN `printerFk` int unsigned DEFAULT NULL NULL; -ALTER TABLE `vn`.`printQueue` ADD CONSTRAINT `printQueue_FK` FOREIGN KEY (id) REFERENCES vn.printer(id) ON DELETE RESTRICT ON UPDATE CASCADE; - -ALTER TABLE `vn`.`sector` MODIFY COLUMN `mainPrinterFk` int unsigned DEFAULT NULL NULL; -ALTER TABLE `vn`.`sector` ADD CONSTRAINT `sector_FK` FOREIGN KEY (mainPrinterFk) REFERENCES vn.printer(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/changes/235201/03-sectorBackUpLabelerFk.sql b/db/changes/235201/03-sectorBackUpLabelerFk.sql deleted file mode 100644 index 8ca12e7e4..000000000 --- a/db/changes/235201/03-sectorBackUpLabelerFk.sql +++ /dev/null @@ -1,18 +0,0 @@ -ALTER TABLE `util`.`notification` ADD delay INT NULL - COMMENT 'Minimum Milliseconds Interval to Prevent Spam from Same-Type Notifications'; - -ALTER TABLE vn.sector DROP FOREIGN KEY sector_FK; - -ALTER TABLE `vn`.`sector` CHANGE `mainPrinterFk` `backupPrinterFk` int unsigned DEFAULT NULL NULL; - -ALTER TABLE `util`.`notificationSubscription` DROP FOREIGN KEY `notificationSubscription_ibfk_1`; -ALTER TABLE `util`.`notificationQueue` DROP FOREIGN KEY `nnotificationQueue_ibfk_1`; -ALTER TABLE `util`.`notificationAcl` DROP FOREIGN KEY `notificationAcl_ibfk_1`; - -ALTER TABLE `util`.`notification` MODIFY COLUMN `id` int(11) auto_increment NOT NULL; - -ALTER TABLE `util`.`notificationSubscription` ADD CONSTRAINT `notificationSubscription_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `util`.`notificationQueue` ADD CONSTRAINT `notificationQueue_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`name`) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE `util`.`notificationAcl` ADD CONSTRAINT `notificationAcl_Fk` FOREIGN KEY (`notificationFk`) REFERENCES `util`.`notification`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; - - diff --git a/print/templates/email/backup-printer-selected/backup-printer-selected.js b/print/templates/email/backup-printer-selected/backup-printer-selected.js index 0e20ed0d8..edce70344 100755 --- a/print/templates/email/backup-printer-selected/backup-printer-selected.js +++ b/print/templates/email/backup-printer-selected/backup-printer-selected.js @@ -5,8 +5,12 @@ const name = 'backup-printer-selected'; module.exports = { name: name, async serverPrefetch() { - const notifications = await this.rawSqlFromDef('previousNotifications', [name, this.created, this.created]); - if (!notifications.length || checkDuplicates(notifications, this.labelerId, this.sectorId)) + const notifications = await this.rawSqlFromDef( + 'previousNotifications', + [name, this.queueCreated, this.queueCreated] + ); + + if (checkDuplicates(notifications, this.labelerId, this.sectorId)) throw new Error('Previous notification sended with the same parameters'); this.sector = await this.findOneFromDef('sector', [this.sectorId]); @@ -33,7 +37,7 @@ module.exports = { type: Number, required: true }, - created: { + queueCreated: { type: Date, required: true } From 562dd4034f2a9311fb45afaed6954ca73d0d1fc4 Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 27 Mar 2024 07:58:35 +0100 Subject: [PATCH 031/153] feat: #7130 added "served" field to RouteList table(Salix). --- modules/route/back/methods/route/filter.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/route/back/methods/route/filter.js b/modules/route/back/methods/route/filter.js index 7c2225dc9..5b13a9004 100644 --- a/modules/route/back/methods/route/filter.js +++ b/modules/route/back/methods/route/filter.js @@ -67,6 +67,12 @@ module.exports = Self => { type: 'string', description: 'The description filter', http: {source: 'query'} + }, + { + arg: 'isOk', + type: 'boolean', + description: 'The isOk filter', + http: {source: 'query'} } ], returns: { @@ -102,6 +108,8 @@ module.exports = Self => { case 'agencyModeFk': param = `r.${param}`; return {[param]: value}; + case 'isOk': + return {'r.isOk': value}; } }); From a62e189e470a2cfa8f0ff3e5e032e1de4835525f Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 28 Mar 2024 16:10:52 +0100 Subject: [PATCH 032/153] feat: refs #6724 hook added --- modules/entry/back/models/entry.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 6148ae559..9d5cd4e1f 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -46,4 +46,15 @@ module.exports = Self => { } } }); + + Self.observe('before delete', async function(ctx) { + let isBooked = ctx.instance && ctx.instance.isBooked; + + if (isBooked === undefined) { + const entryInstance = await Self.findById(ctx.where.id); + isBooked = entryInstance.isBooked; + } + + if (isBooked) throw new Error('Booked entry cannot be deleted'); + }); }; From 52457b964230af1eac10f328785d6c1c48f4deb8 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 3 Apr 2024 07:09:07 +0200 Subject: [PATCH 033/153] feat: sin concatenar en el nombre --- db/routines/vn/procedures/itemTrash.sql | 56 ------------------- .../vn/procedures/item_setVisibleDiscard.sql | 8 +-- 2 files changed, 4 insertions(+), 60 deletions(-) delete mode 100644 db/routines/vn/procedures/itemTrash.sql diff --git a/db/routines/vn/procedures/itemTrash.sql b/db/routines/vn/procedures/itemTrash.sql deleted file mode 100644 index bbb30b78a..000000000 --- a/db/routines/vn/procedures/itemTrash.sql +++ /dev/null @@ -1,56 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemTrash`( - vItemFk INT, - vWarehouseFk INT, - vQuantity INT, - vIsTrash BOOLEAN) -BEGIN - DECLARE vTicketFk INT; - DECLARE vClientFk INT; - DECLARE vCompanyVnlFk INT DEFAULT 442; - DECLARE vCalc INT; - - SELECT barcodeToItem(vItemFk) INTO vItemFk; - - SELECT IF(vIsTrash, 200, 400) INTO vClientFk; - - SELECT t.id INTO vTicketFk - FROM ticket t - JOIN address a ON a.id=t.addressFk - WHERE t.warehouseFk = vWarehouseFk - AND t.clientFk = vClientFk - AND DATE(t.shipped) = util.VN_CURDATE() - AND a.isDefaultAddress - LIMIT 1; - - CALL cache.visible_refresh(vCalc, TRUE, vWarehouseFk); - - IF vTicketFk IS NULL THEN - CALL ticket_add( - vClientFk, - util.VN_CURDATE(), - vWarehouseFk, - vCompanyVnlFk, - NULL, - NULL, - NULL, - util.VN_CURDATE(), - account.myUser_getId(), - FALSE, - vTicketFk); - END IF; - - INSERT INTO sale(ticketFk, itemFk, concept, quantity) - SELECT vTicketFk, - vItemFk, - CONCAT(longName,' ',worker_getCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)), - vQuantity - FROM item - WHERE id = vItemFk; - - UPDATE cache.visible - SET visible = visible - vQuantity - WHERE calc_id = vCalc - AND item_id = vItemFk; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/item_setVisibleDiscard.sql b/db/routines/vn/procedures/item_setVisibleDiscard.sql index 1cc2a8871..c1792dbb9 100644 --- a/db/routines/vn/procedures/item_setVisibleDiscard.sql +++ b/db/routines/vn/procedures/item_setVisibleDiscard.sql @@ -23,11 +23,11 @@ BEGIN SELECT DEFAULT(companyFk) INTO vDefaultCompanyFk FROM vn.ticket LIMIT 1; - - IF vAddressFk IS NULL THEN + + IF vAddressFk IS NULL THEN SELECT pc.shortageAddressFk INTO vAddressShortage FROM productionConfig pc ; - ELSE + ELSE SET vAddressShortage = vAddressFk; END IF; @@ -65,7 +65,7 @@ BEGIN INSERT INTO sale(ticketFk, itemFk, concept, quantity) SELECT vTicketFk, vItemFk, - CONCAT(longName,' ', worker_getCode(), ' ', LEFT(CAST(util.VN_NOW() AS TIME),5)), + longName, vQuantity FROM item WHERE id = vItemFk; From d71f3e0818e38a978a01ccb508ead3b409755cb1 Mon Sep 17 00:00:00 2001 From: jgallego Date: Wed, 3 Apr 2024 09:02:34 +0200 Subject: [PATCH 034/153] test --- db/routines/vn/procedures/item_setVisibleDiscard.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/routines/vn/procedures/item_setVisibleDiscard.sql b/db/routines/vn/procedures/item_setVisibleDiscard.sql index c1792dbb9..59ffa0f66 100644 --- a/db/routines/vn/procedures/item_setVisibleDiscard.sql +++ b/db/routines/vn/procedures/item_setVisibleDiscard.sql @@ -13,6 +13,7 @@ BEGIN * @param vQuantity a dar de alta/baja * @param vAddressFk id address */ + DECLARE vTicketFk INT; DECLARE vClientFk INT; DECLARE vDefaultCompanyFk INT; From 642d2803866979b4c9f2424eb248a303cbf2f223 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 3 Apr 2024 09:30:18 +0200 Subject: [PATCH 035/153] refs #6497:rdirect --- win/README.md | 18 ++++++++++++++++++ win/addRule.ps1 | 26 ++++++++++++++++++++++++++ win/powershellAddRule.lnk | Bin 0 -> 2708 bytes win/powershellRedirect.lnk | Bin 0 -> 3144 bytes win/redirect.ps1 | 5 +++++ 5 files changed, 49 insertions(+) create mode 100644 win/README.md create mode 100644 win/addRule.ps1 create mode 100644 win/powershellAddRule.lnk create mode 100644 win/powershellRedirect.lnk create mode 100644 win/redirect.ps1 diff --git a/win/README.md b/win/README.md new file mode 100644 index 000000000..4cdc43b2c --- /dev/null +++ b/win/README.md @@ -0,0 +1,18 @@ +# win + +In this folder, there are two scripts: +1- 'addRule' : adds a rule to the Windows firewall to accept requests on ports 3000 and 5000. +2- 'redirect' : allows redirecting ports 3000 and 5000 so that our machine processes them with our local Salix server. + + +## Run + +Two ways: + +1-Search the project of Salix in WSL with the explorer of windows, for example: \\wsl.localhost\Debian\home\your_user\projects\salix and with a terminal with administrator permissions execute addRule only one time and execute redirect.ps1 every time you need redirect ports. + +2-Search the project of Salix in WSL with the explorer of windows and edit the .lnk with the path of your installation of Salix. So , you will have a direct link for execute. + +## Server + +To access your Salix server, you can directly enter the IP or name of your computer along with the corresponding port \ No newline at end of file diff --git a/win/addRule.ps1 b/win/addRule.ps1 new file mode 100644 index 000000000..363f4fee4 --- /dev/null +++ b/win/addRule.ps1 @@ -0,0 +1,26 @@ +# Definir las propiedades de la nueva regla +# Define el nombre de la regla +$ruleName = "salixRule" + +# Define el perfil de la regla (Dominio, Privado, P�blico) +$profile = "Domain,Private,Public" + +# Define la acción (Permitir/Bloquear) +$action = "Allow" + +# Define el protocolo (TCP/UDP) +$protocol = "TCP" + +# Define el puerto local +$port = 3000, 5000 + +# Define una descripción (opcional) +$description = "Permitir tráfico HTTP.Frontend y backend Salix." + +# Crea la regla de firewall +New-NetFirewallRule -DisplayName $ruleName -Profile $profile -Action $action -Protocol $protocol -LocalPort $port -Description $description + +# Imprime un mensaje de confirmación +Write-Host "Regla de firewall creada exitosamente: $ruleName" + +pause diff --git a/win/powershellAddRule.lnk b/win/powershellAddRule.lnk new file mode 100644 index 0000000000000000000000000000000000000000..bb462149a5028d8930aead9e7facb65ec02842d3 GIT binary patch literal 2708 zcmds3Z){Ul6#sRi3=wIel8FdSla3kFx4uo>T%63cY@LC%P?Z<*7FgEGy0&ZGn{>l10PI`AIM@1%814g;~$I=;!OBp)Zclp?Xub+B>S}c za_&9%-qUk__ngyn??wPNXBm6ooY|vg!d(s*`Dea)X!q*vQ?{31Z|xX1rfh$nUuDiQ zeUB+=v*Zi?k}@aOgntN4x~?|F?eBhDjz@jIqYt9m-=G(SW|-%pnv-trYt@de@!n`U zYoG~>umIOT+Z)OT6WZaY6v}*Q+AB8KeBdy)B92}}kwz8V(CCk) zYHNVzS$fs=qPJ(M04UabW?>~F7^J>_#E?QQ_;XZnX5rl%y4+U48%}3qeUa{1GKpsk z7B06Xv{xI&g2P$L!sxZBBIIH71Tpl{ayP9e`GG-b&)E!X?+n?oOI3V8!z?@2NtTtg zv!|lcwu>4R@MmyRCr`rQwQD`iE@T9{A<&iBKn%2Hd0uuC+6fc?kXIBhl0)F8*-N*$ zX00t#Kx`BcD?~m(0#=i{NvlZWUm3k5X*)>{(p{vWXa6!gM=(Wl8KCE5mS320u`UkK zi*YyedEl5&g^Zb$2OS$?7~aT zzBoPJ3(1ru`7UOti&;HLRGrLKgEKE$xRYcAT>RYdGgovx$34j`gS^GCH#R zWp4+GF(1)5N=tTT`qPy1|Rmn~Nv-Y>qt<~aS)nOCC6 zf86wc`%Wsi36?BNNxaW<$BC2&G7rYN&c)JsG4p?)2QHhJM;PPH&gwm~kEc^3;mGg4 zPpACY*Lw2iSSzsGnpd)cd$5#C3+$2rz>wT`PI zQ%6#Bk}5g5%j?99+0L>TFuog}@$0QC?eEt<8 literal 0 HcmV?d00001 diff --git a/win/powershellRedirect.lnk b/win/powershellRedirect.lnk new file mode 100644 index 0000000000000000000000000000000000000000..e5cc78862d98f99708510ea1d7684a6dfef49236 GIT binary patch literal 3144 zcmds3e@xV682=oaV4~g$5t_+GJH$1PJ4hi4BM#wk2B&9oYsZwqCCAT;BMwHbBe8Y-#zd9ywCf5 zpXYg>_j#Z9SqDHD8^Inpqk81`Bu2qVeC_#1-dMJIQ1|M)1*L8NLEWw1rD~3mIf_%K z@rV2Q5wS>c{8HR+yq@LNfAnJ%p0HRBE=H;?%N=GKLpH&xCY7!qta_Aq>niF4e&k>- zX5;4R?Zp9mwQJvMGkLyM`X;N(eP%roEQ2(=S;JAd+~+Bu)U7@fTzJ(>8Yu~#;}G9 zh1IS%vqgg;b}9{BHwGtJ?od1Mpn;kzskMe5cnC#7oetN5Ry~@mW($xtL65eRMN{h8 z7N4YRq69Pe8)7MwJK^CKxvFxF@QLYuG2QHG_JF!H&&z7Ht5ezEnj(Vd$|i7I_0r8t zTdwnkE%t{kHq-KE0b{3la3kbFH}1CQWSAI(S~PljjwV_(Ig0L2-+Fp%jq+zX zUSafk>G3*9q|^{EXM`FV)h)EDjIrwHECu;oso@D2kq8?j#f=xZB5~y>u3=l1qzX!O zBadr-R1>eKoT+!{=HDLPG1--edK>9!AOEsahn(F5K!=IrMS`63JkA3}y-Th}looa8 znNJ*B-`*{2TL?V!4i`shHD$iWdf!S3P1P>1NsK&~_j~c@N6+qgufTe3!*xT-H)TN3Ri<3t2pjvK-!cq{mPf(J@EE!r1!+b zjo8c&_-c>*QfgQz}<{xAydEnJ<AcXk@$w;aRL6tf}7$u7kn7%ZQ5FttkG19RKhq~0`WjrV=;|c14lwU^K zb=1^=QwcOnpLGY6V*{5a5)P1vHiT?0V#Fkx${`h1C>B^)8BBJOy zrep0%C}Vo|;x8sKX;y+VRTw3G-R=G2G9Dr*Lj?&{d4eyHc@7~|0t!(jL?L3twoU3p zL3a?u=szu|25s0;aO8G>Oqc(q#9GoTgh6bPN+9&A8j&1)sixz#7T;*Cje{6+d8aG? z%XOKyo_}KAPin6{_cG~W@1=6$q&Zf?N`(# zxYxQxw1dWL2A+tk&HJ>?XFp=kF?VG*?|PJUspDWLT Date: Wed, 3 Apr 2024 09:31:15 +0200 Subject: [PATCH 036/153] refs #6497:redirect --- win/{README.md => Content.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename win/{README.md => Content.md} (100%) diff --git a/win/README.md b/win/Content.md similarity index 100% rename from win/README.md rename to win/Content.md From 53015d1c67eda14d54313160df7e2bd6b207c05a Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 3 Apr 2024 09:33:50 +0200 Subject: [PATCH 037/153] refs #6497:redirect --- win/Content.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/Content.md b/win/Content.md index 4cdc43b2c..6a13c22e5 100644 --- a/win/Content.md +++ b/win/Content.md @@ -9,7 +9,7 @@ In this folder, there are two scripts: Two ways: -1-Search the project of Salix in WSL with the explorer of windows, for example: \\wsl.localhost\Debian\home\your_user\projects\salix and with a terminal with administrator permissions execute addRule only one time and execute redirect.ps1 every time you need redirect ports. +1-Search the project of Salix in WSL with the explorer of windows, for example: \\wsl.localhost\Debian\home\your_user\projects\salix and with a terminal Powershell with administrator permissions execute addRule.ps1 only one time and execute redirect.ps1 every time you need redirect ports. 2-Search the project of Salix in WSL with the explorer of windows and edit the .lnk with the path of your installation of Salix. So , you will have a direct link for execute. From 11991ed5a1b81d07e92d20ded12644ad8b692e99 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 3 Apr 2024 09:36:03 +0200 Subject: [PATCH 038/153] refs #6497:redirect --- win/Content.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/win/Content.md b/win/Content.md index 6a13c22e5..eea5b123c 100644 --- a/win/Content.md +++ b/win/Content.md @@ -9,9 +9,9 @@ In this folder, there are two scripts: Two ways: -1-Search the project of Salix in WSL with the explorer of windows, for example: \\wsl.localhost\Debian\home\your_user\projects\salix and with a terminal Powershell with administrator permissions execute addRule.ps1 only one time and execute redirect.ps1 every time you need redirect ports. +1-Search the project of Salix in WSL with the explorer of windows, for example: \\wsl.localhost\Debian\home\your_user\projects\salix and with a terminal Powershell with administrator permissions execute addRule.ps1 only one time and execute redirect.ps1 every time you need redirect ports when the project is running. -2-Search the project of Salix in WSL with the explorer of windows and edit the .lnk with the path of your installation of Salix. So , you will have a direct link for execute. +2-Search the project of Salix in WSL with the explorer of windows and edit the files with .lnk with the path of your installation of Salix. So , you will have a direct link for execute. ## Server From 5acef1fcc0ea544941d642b0dcce17ac3bea2e44 Mon Sep 17 00:00:00 2001 From: jcasado Date: Thu, 4 Apr 2024 13:53:23 +0200 Subject: [PATCH 039/153] refs #6641 add button my team --- modules/claim/front/search-panel/index.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/claim/front/search-panel/index.html b/modules/claim/front/search-panel/index.html index fbc527d60..6465eb621 100644 --- a/modules/claim/front/search-panel/index.html +++ b/modules/claim/front/search-panel/index.html @@ -73,5 +73,12 @@ + + + From 1c6d9139261ebf507251194077880bfd0a080947 Mon Sep 17 00:00:00 2001 From: jcasado Date: Thu, 4 Apr 2024 14:28:39 +0200 Subject: [PATCH 040/153] refs #6641 addFilterCollegues --- modules/claim/back/methods/claim/filter.js | 29 ++++++++++++++++++- .../back/methods/claim/specs/filter.spec.js | 19 ++++++++++++ modules/claim/front/search-panel/index.html | 8 ++--- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/modules/claim/back/methods/claim/filter.js b/modules/claim/back/methods/claim/filter.js index 2daee6413..b1d1cb3a7 100644 --- a/modules/claim/back/methods/claim/filter.js +++ b/modules/claim/back/methods/claim/filter.js @@ -79,7 +79,12 @@ module.exports = Self => { type: 'number', description: 'The claimResponsible id', http: {source: 'query'} - } + }, + { + arg: 'myTeam', + type: 'boolean', + description: `Team partners` + }, ], returns: { type: ['object'], @@ -92,6 +97,7 @@ module.exports = Self => { }); Self.filter = async(ctx, filter, options) => { + const userId = ctx.req.accessToken.userId; const models = Self.app.models; const conn = Self.dataSource.connector; const args = ctx.args; @@ -121,6 +127,22 @@ module.exports = Self => { claimIdsByClaimResponsibleFk = claims.map(claim => claim.claimFk); } + // Apply filter by team + const teamMembersId = []; + if (args.myTeam != null) { + const worker = await models.Worker.findById(userId, { + include: { + relation: 'collegues' + } + }, myOptions); + const collegues = worker.collegues() || []; + for (let collegue of collegues) + teamMembersId.push(collegue.collegueFk); + + if (teamMembersId.length == 0) + teamMembersId.push(userId); + } + const where = buildFilter(args, (param, value) => { switch (param) { case 'search': @@ -152,6 +174,11 @@ module.exports = Self => { to.setHours(23, 59, 59, 999); return {'cl.created': {between: [value, to]}}; + case 'myTeam': + if (value) + return {'cl.workerFk': {inq: teamMembersId}}; + else + return {'cl.workerFk': {nin: teamMembersId}}; } }); diff --git a/modules/claim/back/methods/claim/specs/filter.spec.js b/modules/claim/back/methods/claim/specs/filter.spec.js index 49e258505..a25ec8d27 100644 --- a/modules/claim/back/methods/claim/specs/filter.spec.js +++ b/modules/claim/back/methods/claim/specs/filter.spec.js @@ -97,4 +97,23 @@ describe('claim filter()', () => { throw e; } }); + + it('should now return the tickets from the worker team', async() => { + const tx = await models.Claim.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const ctx = {req: {accessToken: {userId: 18}}, args: {myTeam: true}}; + const filter = {}; + const result = await models.SalesMonitor.salesFilter(ctx, filter, options); + + expect(result.length).toBeGreaterThan(20); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); diff --git a/modules/claim/front/search-panel/index.html b/modules/claim/front/search-panel/index.html index 6465eb621..260f86801 100644 --- a/modules/claim/front/search-panel/index.html +++ b/modules/claim/front/search-panel/index.html @@ -70,15 +70,15 @@ label="Responsible"> - - - - + + + + From 84e6e7f7bf740cd2b551d43bbd3d988be32834f2 Mon Sep 17 00:00:00 2001 From: jcasado Date: Thu, 4 Apr 2024 14:53:26 +0200 Subject: [PATCH 041/153] refs #6641 test fixtures --- db/dump/fixtures.before.sql | 10 +++++++--- modules/claim/back/methods/claim/filter.js | 15 ++++++++++++--- .../claim/back/methods/claim/specs/filter.spec.js | 9 +++++---- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 1dad68b2c..f874c8aee 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1827,9 +1827,9 @@ INSERT INTO `vn`.`claimState`(`id`, `code`, `description`, `roleFk`, `priority`, INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `clientFk`, `workerFk`, `responsibility`, `isChargedToMana`, `created`, `packages`, `ticketFk`) VALUES - (1, util.VN_CURDATE(), 1, 1101, 18, 3, 0, util.VN_CURDATE(), 0, 11), + (1, util.VN_CURDATE(), 1, 1101, 19, 3, 0, util.VN_CURDATE(), 0, 11), (2, util.VN_CURDATE(), 4, 1101, 18, 3, 0, util.VN_CURDATE(), 1, 16), - (3, util.VN_CURDATE(), 3, 1101, 18, 1, 1, util.VN_CURDATE(), 5, 7), + (3, util.VN_CURDATE(), 3, 1101, 19, 1, 1, util.VN_CURDATE(), 5, 7), (4, util.VN_CURDATE(), 3, 1104, 18, 5, 0, util.VN_CURDATE(), 10, 8); INSERT INTO `vn`.`claimObservation` (`claimFk`, `workerFk`, `text`, `created`) @@ -3745,4 +3745,8 @@ INSERT INTO vn.ticketLog (originFk,userFk,`action`,creationDate,changedModel,new INSERT INTO `vn`.`supplierDms`(`supplierFk`, `dmsFk`, `editorFk`) VALUES - (1, 10, 9); \ No newline at end of file + (1, 10, 9); + +INSERT INTO vn.workerTeam +(id, team, workerFk) +VALUES(8, 1, 19); diff --git a/modules/claim/back/methods/claim/filter.js b/modules/claim/back/methods/claim/filter.js index b1d1cb3a7..21d6ff80f 100644 --- a/modules/claim/back/methods/claim/filter.js +++ b/modules/claim/back/methods/claim/filter.js @@ -4,10 +4,15 @@ const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; module.exports = Self => { - Self.remoteMethodCtx('filter', { + Self.remoteMethod('filter', { description: 'Find all instances of the model matched by filter from the data source.', accessType: 'READ', accepts: [ + { + arg: 'ctx', + type: 'object', + http: {source: 'context'} + }, { arg: 'filter', type: 'object', @@ -97,7 +102,11 @@ module.exports = Self => { }); Self.filter = async(ctx, filter, options) => { - const userId = ctx.req.accessToken.userId; + const userId = ctx?.req?.accessToken?.userId; + console.log('ctx', ctx); + console.log('ctx.req', ctx.req); + console.log('ctx.req.accessToken', ctx.req.accessToken); + console.log('ctx.req.accessToken.userId', ctx.req.accessToken.userId); const models = Self.app.models; const conn = Self.dataSource.connector; const args = ctx.args; @@ -143,7 +152,7 @@ module.exports = Self => { teamMembersId.push(userId); } - const where = buildFilter(args, (param, value) => { + const where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': return /^\d+$/.test(value) diff --git a/modules/claim/back/methods/claim/specs/filter.spec.js b/modules/claim/back/methods/claim/specs/filter.spec.js index a25ec8d27..677015c4d 100644 --- a/modules/claim/back/methods/claim/specs/filter.spec.js +++ b/modules/claim/back/methods/claim/specs/filter.spec.js @@ -1,6 +1,7 @@ const app = require('vn-loopback/server/server'); +const models = require('vn-loopback/server/server').models; -describe('claim filter()', () => { +fdescribe('claim filter()', () => { it('should return 1 result filtering by id', async() => { const tx = await app.models.Claim.beginTransaction({}); @@ -104,11 +105,11 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 18}}, args: {myTeam: true}}; + const ctx = {req: {accessToken: {userId: 9}}, args: {myTeam: true}}; const filter = {}; - const result = await models.SalesMonitor.salesFilter(ctx, filter, options); + const result = await models.Claim.filter(ctx, filter, options); - expect(result.length).toBeGreaterThan(20); + expect(result.length).toEqual(2); await tx.rollback(); } catch (e) { From bd661befb6b2c0cfa2f8c05f711cd59c18384fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 4 Apr 2024 15:04:23 +0200 Subject: [PATCH 042/153] feat: bloquear facturas recibidas contabilizadas refs #7173 --- .../vn/procedures/invoiceIn_checkBooked.sql | 22 +++++++++++++++++++ .../invoiceInCorrection_beforeDelete.sql | 8 +++++++ .../invoiceInCorrection_beforeUpdate.sql | 8 +++++++ .../triggers/invoiceInDueDay_beforeDelete.sql | 8 +++++++ .../triggers/invoiceInDueDay_beforeInsert.sql | 1 + .../invoiceInIntrastat_beforeDelete.sql | 8 +++++++ .../invoiceInIntrastat_beforeUpdatesql | 8 +++++++ .../vn/triggers/invoiceInTax_beforeDelete.sql | 8 +++++++ .../vn/triggers/invoiceInTax_beforeUpdate.sql | 2 ++ .../vn/triggers/invoiceIn_afterDelete.sql | 2 ++ .../vn/triggers/invoiceIn_beforeUpdate.sql | 2 ++ 11 files changed, 77 insertions(+) create mode 100644 db/routines/vn/procedures/invoiceIn_checkBooked.sql create mode 100644 db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql create mode 100644 db/routines/vn/triggers/invoiceInCorrection_beforeUpdate.sql create mode 100644 db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql create mode 100644 db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql create mode 100644 db/routines/vn/triggers/invoiceInIntrastat_beforeUpdatesql create mode 100644 db/routines/vn/triggers/invoiceInTax_beforeDelete.sql diff --git a/db/routines/vn/procedures/invoiceIn_checkBooked.sql b/db/routines/vn/procedures/invoiceIn_checkBooked.sql new file mode 100644 index 000000000..862870eb4 --- /dev/null +++ b/db/routines/vn/procedures/invoiceIn_checkBooked.sql @@ -0,0 +1,22 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_checkBooked`( + vSelf INT +) +BEGIN +/** + * Comprueba si una factura recibida está contabilizada, + * y si lo está retorna un throw. + * + * @param vSelf Id invoiceIn + */ + DECLARE vIsBooked BOOL; + + SELECT isBooked INTO vIsBooked + FROM invoiceIn + WHERE id = vSelf; + + IF vIsBooked THEN + CALL util.throw('InvoiceIn is already booked'); + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql new file mode 100644 index 000000000..f4df48dcd --- /dev/null +++ b/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_beforeDelete` + BEFORE DELETE ON `invoiceInCorrection` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(OLD.correctingFk); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeUpdate.sql new file mode 100644 index 000000000..bd324863b --- /dev/null +++ b/db/routines/vn/triggers/invoiceInCorrection_beforeUpdate.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_beforeUpdate` + BEFORE UPDATE ON `invoiceInCorrection` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(OLD.correctingFk); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql new file mode 100644 index 000000000..3b0f90d0d --- /dev/null +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_beforeDelete` + BEFORE DELETE ON `invoiceInDueDay` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(OLD.id); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql index f7e4265a7..c23ead0e4 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql @@ -5,6 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor BEGIN DECLARE vIsNotified BOOLEAN; + CALL invoiceIn_checkBooked(OLD.invoiceInFk); SET NEW.editorFk = account.myUser_getId(); SELECT isNotified INTO vIsNotified diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql b/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql new file mode 100644 index 000000000..412b091f4 --- /dev/null +++ b/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_beforeDelete` + BEFORE DELETE ON `invoiceInIntrastat` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(OLD.invoiceInFk); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdatesql b/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdatesql new file mode 100644 index 000000000..649c9ef30 --- /dev/null +++ b/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdatesql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_beforeUpdate` + BEFORE UPDATE ON `invoiceInIntrastat` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(OLD.invoiceInFk); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql b/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql new file mode 100644 index 000000000..a43f602b4 --- /dev/null +++ b/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeDelete` + BEFORE DELETE ON `invoiceInTax` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(OLD.invoiceInFk); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql index 30918b7c5..3e5ecf030 100644 --- a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql @@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeUp BEFORE UPDATE ON `invoiceInTax` FOR EACH ROW BEGIN + CALL invoiceIn_checkBooked(OLD.invoiceInFk); + IF NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) THEN CALL invoiceInTax_afterUpsert(NEW.invoiceInFk); END IF; diff --git a/db/routines/vn/triggers/invoiceIn_afterDelete.sql b/db/routines/vn/triggers/invoiceIn_afterDelete.sql index c088f6492..90fac193d 100644 --- a/db/routines/vn/triggers/invoiceIn_afterDelete.sql +++ b/db/routines/vn/triggers/invoiceIn_afterDelete.sql @@ -3,6 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_afterDelete AFTER DELETE ON `invoiceIn` FOR EACH ROW BEGIN + CALL invoiceIn_checkBooked(OLD.id); + INSERT INTO invoiceInLog SET `action` = 'delete', `changedModel` = 'InvoiceIn', diff --git a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql index 4503c7dbd..688a3af92 100644 --- a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql @@ -5,6 +5,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdat BEGIN DECLARE vWithholdingSageFk INT; + CALL invoiceIn_checkBooked(OLD.id); + IF NOT (NEW.supplierRef <=> OLD.supplierRef) AND NOT util.checkPrintableChars(NEW.supplierRef) THEN CALL util.throw('The invoiceIn reference contains invalid characters'); END IF; From d18721f50d23534c366b8b79aee8f5d1e441ca66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Thu, 4 Apr 2024 18:05:45 +0200 Subject: [PATCH 043/153] feat: bloquear facturas recibidas contabilizadas refs #7173 --- ...{invoiceIn_checkBooked.sql => invoiceIn_checkIsBooked.sql} | 2 +- db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql | 2 +- db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql | 4 ++-- db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql | 1 - db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql | 1 + db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql | 2 +- db/routines/vn/triggers/invoiceInTax_beforeDelete.sql | 2 +- db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql | 2 +- db/routines/vn/triggers/invoiceIn_afterDelete.sql | 2 +- db/routines/vn/triggers/invoiceIn_afterUpdate.sql | 1 + 10 files changed, 10 insertions(+), 9 deletions(-) rename db/routines/vn/procedures/{invoiceIn_checkBooked.sql => invoiceIn_checkIsBooked.sql} (94%) diff --git a/db/routines/vn/procedures/invoiceIn_checkBooked.sql b/db/routines/vn/procedures/invoiceIn_checkIsBooked.sql similarity index 94% rename from db/routines/vn/procedures/invoiceIn_checkBooked.sql rename to db/routines/vn/procedures/invoiceIn_checkIsBooked.sql index 862870eb4..35008fcd5 100644 --- a/db/routines/vn/procedures/invoiceIn_checkBooked.sql +++ b/db/routines/vn/procedures/invoiceIn_checkIsBooked.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_checkBooked`( +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_checkIsBooked`( vSelf INT ) BEGIN diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql index f4df48dcd..309d53af2 100644 --- a/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql +++ b/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql @@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_b BEFORE DELETE ON `invoiceInCorrection` FOR EACH ROW BEGIN - CALL invoiceIn_checkBooked(OLD.correctingFk); + CALL invoiceIn_checkIsBooked(OLD.correctingFk); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql index 3b0f90d0d..eed070950 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeDelete.sql @@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor BEFORE DELETE ON `invoiceInDueDay` FOR EACH ROW BEGIN - CALL invoiceIn_checkBooked(OLD.id); + CALL invoiceIn_checkIsBooked(OLD.id); END$$ -DELIMITER ; +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql index c23ead0e4..f7e4265a7 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql @@ -5,7 +5,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor BEGIN DECLARE vIsNotified BOOLEAN; - CALL invoiceIn_checkBooked(OLD.invoiceInFk); SET NEW.editorFk = account.myUser_getId(); SELECT isNotified INTO vIsNotified diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql index 2452ff0d1..5d58ef28b 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeUpdate.sql @@ -5,6 +5,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor BEGIN DECLARE vIsNotified BOOLEAN; + CALL invoiceIn_checkBooked(OLD.invoiceInFk); SET NEW.editorFk = account.myUser_getId(); SELECT isNotified INTO vIsNotified diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql b/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql index 412b091f4..e3dfc769c 100644 --- a/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql +++ b/db/routines/vn/triggers/invoiceInIntrastat_beforeDelete.sql @@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_be BEFORE DELETE ON `invoiceInIntrastat` FOR EACH ROW BEGIN - CALL invoiceIn_checkBooked(OLD.invoiceInFk); + CALL invoiceIn_checkIsBooked(OLD.invoiceInFk); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql b/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql index a43f602b4..c48e7a227 100644 --- a/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql +++ b/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql @@ -3,6 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeDe BEFORE DELETE ON `invoiceInTax` FOR EACH ROW BEGIN - CALL invoiceIn_checkBooked(OLD.invoiceInFk); + CALL invoiceIn_checkIsBooked(OLD.invoiceInFk); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql index 3e5ecf030..99ccd2c1d 100644 --- a/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceInTax_beforeUpdate.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInTax_beforeUp BEFORE UPDATE ON `invoiceInTax` FOR EACH ROW BEGIN - CALL invoiceIn_checkBooked(OLD.invoiceInFk); + CALL invoiceIn_checkIsBooked(OLD.invoiceInFk); IF NOT (NEW.invoiceInFk <=> OLD.invoiceInFk) THEN CALL invoiceInTax_afterUpsert(NEW.invoiceInFk); diff --git a/db/routines/vn/triggers/invoiceIn_afterDelete.sql b/db/routines/vn/triggers/invoiceIn_afterDelete.sql index 90fac193d..62a01ebc2 100644 --- a/db/routines/vn/triggers/invoiceIn_afterDelete.sql +++ b/db/routines/vn/triggers/invoiceIn_afterDelete.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_afterDelete AFTER DELETE ON `invoiceIn` FOR EACH ROW BEGIN - CALL invoiceIn_checkBooked(OLD.id); + CALL invoiceIn_checkIsBooked(OLD.id); INSERT INTO invoiceInLog SET `action` = 'delete', diff --git a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql index b1308393c..8d3df4ed5 100644 --- a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql @@ -3,6 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_afterUpdate AFTER UPDATE ON `invoiceIn` FOR EACH ROW BEGIN + CALL invoiceIn_checkIsBooked(OLD.id); IF NEW.issued != OLD.issued OR NEW.currencyFk != OLD.currencyFk THEN From 4b4aaa9e1034a7beb05490b68d59f5b32e17cfb0 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 5 Apr 2024 08:04:53 +0200 Subject: [PATCH 044/153] feat: refs #6005 move logic from report to hook --- back/methods/notification/send.js | 2 +- .../methods/operator/spec/operator.spec.js | 42 +++++-------------- modules/worker/back/models/operator.js | 38 ++++++++++++++--- .../backup-printer-selected.js | 25 +---------- .../sql/previousNotifications.sql | 7 ---- 5 files changed, 44 insertions(+), 70 deletions(-) delete mode 100644 print/templates/email/backup-printer-selected/sql/previousNotifications.sql diff --git a/back/methods/notification/send.js b/back/methods/notification/send.js index ee3127631..b2748477d 100644 --- a/back/methods/notification/send.js +++ b/back/methods/notification/send.js @@ -67,7 +67,7 @@ module.exports = Self => { continue; } - const newParams = Object.assign({}, queueParams, sendParams, {queueCreated: queue.created}); + const newParams = Object.assign({}, queueParams, sendParams); const email = new Email(queueName, newParams); if (process.env.NODE_ENV != 'test') diff --git a/modules/worker/back/methods/operator/spec/operator.spec.js b/modules/worker/back/methods/operator/spec/operator.spec.js index 39a473a38..016d90a30 100644 --- a/modules/worker/back/methods/operator/spec/operator.spec.js +++ b/modules/worker/back/methods/operator/spec/operator.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -describe('Operator', () => { +fdescribe('Operator', () => { const authorFk = 9; const sectorId = 1; const labeler = 1; @@ -53,6 +53,7 @@ describe('Operator', () => { try { const options = {transaction: tx, accessToken: {userId: authorFk}}; + await models.NotificationQueue.destroyAll({notificationFk: notificationName}, options); const notificationQueue = await createOperator(2, options); expect(notificationQueue).toEqual(null); @@ -70,25 +71,12 @@ describe('Operator', () => { try { const options = {transaction: tx, accessToken: {userId: authorFk}}; - await models.NotificationQueue.create({ - authorFk: 1, - notificationFk: notificationName, - params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 1}), - created: Date.vnNow(), - }, options); - - const notification = await models.Notification.findOne({where: {name: notificationName}}, options); - await notification.updateAttributes({delay: null}, options); + const notifiation = await models.Notification.findOne({where: {name: notificationName}}, options); + await notifiation.updateAttributes({delay: null}, options); const notificationQueue = await createOperator(labeler, options); - const params = JSON.parse(notificationQueue.params); expect(notificationQueue.notificationFk).toEqual(notificationName); - expect(notificationQueue.authorFk).toEqual(authorFk); - expect(params.labelerId).toEqual(1); - expect(params.sectorId).toEqual(1); - expect(params.workerId).toEqual(9); - await tx.rollback(); } catch (e) { await tx.rollback(); @@ -96,23 +84,12 @@ describe('Operator', () => { } }); - it('should not sent notification when is already notified by another worker', async() => { - await models.NotificationQueue.create({ - authorFk: 2, - notificationFk: notificationName, - params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 2}), - created: '2001-01-01 12:30:00', - }); + fit('should not sent notification when is already notified by another worker', async() => { + await models.Operator.updateAll({id: 1}, {labelerFk: labeler, sectorFk: sectorId}, null); + await models.Operator.updateAll({id: 1}, {labelerFk: labeler, sectorFk: sectorId}, null); - await models.NotificationQueue.create({ - authorFk: 1, - notificationFk: notificationName, - params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 1}), - created: '2001-01-01 12:31:00', - }); - await models.Notification.send(); - - const lastNotification = await models.NotificationQueue.findOne({order: 'id DESC'}); + const lastNotification = await models.NotificationQueue.find({order: 'id DESC', limit: 2}); + console.log('lastNotification: ', lastNotification); await models.NotificationQueue.destroyAll({notificationFk: notificationName}); @@ -183,6 +160,7 @@ describe('Operator', () => { await models.Notification.send(); const lastNotification = await models.NotificationQueue.findOne({order: 'id DESC'}); + console.log('lastNotification: ', lastNotification); await models.NotificationQueue.destroyAll({notificationFk: notificationName}); diff --git a/modules/worker/back/models/operator.js b/modules/worker/back/models/operator.js index 2583bfc4b..f7a57e255 100644 --- a/modules/worker/back/models/operator.js +++ b/modules/worker/back/models/operator.js @@ -1,20 +1,44 @@ module.exports = Self => { Self.observe('after save', async ctx => { + console.log('entra en after save'); const instance = ctx.data || ctx.instance; const models = Self.app.models; const options = ctx.options; - const notification = 'backup-printer-selected'; - const {userId} = ctx.options.accessToken; + const notificationName = 'backup-printer-selected'; + const userId = ctx.options.accessToken?.userId; if (!instance?.sectorFk || !instance?.labelerFk) return; - + console.log('instance.sectorFk: ', instance.sectorFk); const sector = await models.Sector.findById(instance.sectorFk, { fields: ['backupPrinterFk'] }, options); + console.log('sector.backupPrinterFk == instance.labelerFk: ', sector.backupPrinterFk == instance.labelerFk); if (sector.backupPrinterFk && sector.backupPrinterFk == instance.labelerFk) { - await models.NotificationQueue.create({ - notificationFk: notification, + console.log('entra'); + const {labelerFk, sectorFk} = instance; + + const [{delay}] = await models.Notification.find({where: {name: notificationName}}, options); + if (delay) { + const now = Date.vnNow(); + const filter = {where: {created: {between: [now - (delay * 1000), now]}}}; + const notifications = await models.NotificationQueue.find(filter, options); + console.log('notifications: ', notifications); + + const criteria = {labelerId: labelerFk, sectorId: sectorFk}; + const filteredNotifications = notifications.filter(notification => { + const paramsObj = JSON.parse(notification.params); + console.log('paramsObj: ', paramsObj); + return Object.keys(criteria).every(key => criteria[key] === paramsObj[key]); + }); + + console.log('filteredNotifications.length: ', filteredNotifications.length); + if (filteredNotifications.length > 1) + throw new Error('Previous notification sended with the same parameters'); + } + + const created = await models.NotificationQueue.create({ + notificationFk: notificationName, authorFk: userId, params: JSON.stringify( { @@ -23,7 +47,9 @@ module.exports = Self => { 'workerId': userId } ) - }, options); + }); + console.log('created: ', created); } }); }; + diff --git a/print/templates/email/backup-printer-selected/backup-printer-selected.js b/print/templates/email/backup-printer-selected/backup-printer-selected.js index edce70344..6372d52c0 100755 --- a/print/templates/email/backup-printer-selected/backup-printer-selected.js +++ b/print/templates/email/backup-printer-selected/backup-printer-selected.js @@ -1,18 +1,9 @@ const Component = require(`vn-print/core/component`); const emailBody = new Component('email-body'); -const name = 'backup-printer-selected'; module.exports = { - name: name, + name: 'backup-printer-selected', async serverPrefetch() { - const notifications = await this.rawSqlFromDef( - 'previousNotifications', - [name, this.queueCreated, this.queueCreated] - ); - - if (checkDuplicates(notifications, this.labelerId, this.sectorId)) - throw new Error('Previous notification sended with the same parameters'); - this.sector = await this.findOneFromDef('sector', [this.sectorId]); if (!this.sector) throw new Error('Something went wrong'); @@ -36,21 +27,7 @@ module.exports = { workerId: { type: Number, required: true - }, - queueCreated: { - type: Date, - required: true } } }; - -function checkDuplicates(notifications, labelerFk, printerFk) { - const criteria = {labelerId: labelerFk, sectorId: printerFk}; - const filteredNotifications = notifications.filter(notification => { - const paramsObj = JSON.parse(notification.params); - return Object.keys(criteria).every(key => criteria[key] === paramsObj[key]); - }); - - return filteredNotifications.length > 1; -} diff --git a/print/templates/email/backup-printer-selected/sql/previousNotifications.sql b/print/templates/email/backup-printer-selected/sql/previousNotifications.sql deleted file mode 100644 index 312daacbb..000000000 --- a/print/templates/email/backup-printer-selected/sql/previousNotifications.sql +++ /dev/null @@ -1,7 +0,0 @@ -SELECT nq.params, created, status - FROM util.notificationQueue nq - JOIN util.notification n ON n.name = nq.notificationFk - WHERE n.name = ? - AND nq.created BETWEEN ? - INTERVAL IFNULL(n.delay, 0) SECOND AND ? - AND nq.status <> 'error' - ORDER BY created \ No newline at end of file From d9a3cc95918af4158c8e3d3535689f282d2ed9a9 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 5 Apr 2024 09:07:01 +0200 Subject: [PATCH 045/153] commit --- pnpm-lock.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3f0473929..afc546a7c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -208,6 +208,9 @@ devDependencies: html-webpack-plugin: specifier: ^5.5.1 version: 5.6.0(webpack@5.90.1) + husky: + specifier: ^8.0.3 + version: 8.0.3 identity-obj-proxy: specifier: ^3.0.0 version: 3.0.0 @@ -7388,6 +7391,12 @@ packages: ms: 2.1.3 dev: true + /husky@8.0.3: + resolution: {integrity: sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg==} + engines: {node: '>=14'} + hasBin: true + dev: true + /i18n@0.8.6: resolution: {integrity: sha512-aMsJq8i1XXrb+BBsgmJBwak9mr69zPEIAUPb6c5yw2G/O4k1Q52lBxL+agZdQDN/RGf1ylQzrCswsOOgIiC1FA==} engines: {node: '>=0.10.0'} From 71a333786e2684a540211a735e3473555f55938e Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 5 Apr 2024 09:08:20 +0200 Subject: [PATCH 046/153] commit --- .husky/commit-msg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/commit-msg b/.husky/commit-msg index 482222a2b..8816a6ae6 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1,4 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -npm run commitlint ${1} +pnpm run commitlint ${1} From a30cc3b660a1310155c863f989bfcbc16a9e233d Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 5 Apr 2024 09:32:07 +0200 Subject: [PATCH 047/153] feat: commit --- .husky/.commitlintrc.json | 6 + package.json | 7 +- pnpm-lock.yaml | 454 +++++++++++++++++++++++++++++++++++++- 3 files changed, 457 insertions(+), 10 deletions(-) create mode 100644 .husky/.commitlintrc.json diff --git a/.husky/.commitlintrc.json b/.husky/.commitlintrc.json new file mode 100644 index 000000000..f38108778 --- /dev/null +++ b/.husky/.commitlintrc.json @@ -0,0 +1,6 @@ +{ + "extends": ["@commitlint/config-conventional"], + "rules": { + "type-enum": [2, "always", ["ci", "chore", "docs", "ticket","feat", "fix", "perf", "refactor", "revert", "style"]] + } +} \ No newline at end of file diff --git a/package.json b/package.json index 3b367f876..5aa1cfb7f 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,8 @@ "@babel/plugin-syntax-dynamic-import": "^7.7.4", "@babel/preset-env": "^7.11.0", "@babel/register": "^7.7.7", + "@commitlint/cli": "^19.2.1", + "@commitlint/config-conventional": "^19.1.0", "@verdnatura/myt": "^1.6.9", "angular-mocks": "^1.7.9", "babel-jest": "^26.0.1", @@ -82,7 +84,7 @@ "html-loader": "^0.4.5", "html-loader-jest": "^0.2.1", "html-webpack-plugin": "^5.5.1", - "husky": "^8.0.3", + "husky": "^8.0.0", "identity-obj-proxy": "^3.0.0", "jasmine": "^5.0.2", "jasmine-reporters": "^2.4.0", @@ -112,7 +114,8 @@ "test:front": "jest --watch", "back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back", "lint": "eslint ./ --cache --ignore-pattern .gitignore", - "commitlint": "commitlint --edit" + "commitlint": "commitlint --edit", + "prepare": "husky install" }, "jest": { "projects": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index afc546a7c..d3959ac03 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -94,7 +94,7 @@ dependencies: version: 1.3.0 puppeteer: specifier: 21.11.0 - version: 21.11.0 + version: 21.11.0(typescript@5.4.4) read-chunk: specifier: ^3.2.0 version: 3.2.0 @@ -130,6 +130,12 @@ devDependencies: '@babel/register': specifier: ^7.7.7 version: 7.23.7(@babel/core@7.23.9) + '@commitlint/cli': + specifier: ^19.2.1 + version: 19.2.1(@types/node@20.11.16)(typescript@5.4.4) + '@commitlint/config-conventional': + specifier: ^19.1.0 + version: 19.1.0 '@verdnatura/myt': specifier: ^1.6.9 version: 1.6.9 @@ -209,7 +215,7 @@ devDependencies: specifier: ^5.5.1 version: 5.6.0(webpack@5.90.1) husky: - specifier: ^8.0.3 + specifier: ^8.0.0 version: 8.0.3 identity-obj-proxy: specifier: ^3.0.0 @@ -1505,6 +1511,169 @@ packages: minimist: 1.2.8 dev: true + /@commitlint/cli@19.2.1(@types/node@20.11.16)(typescript@5.4.4): + resolution: {integrity: sha512-cbkYUJsLqRomccNxvoJTyv5yn0bSy05BBizVyIcLACkRbVUqYorC351Diw/XFSWC/GtpwiwT2eOvQgFZa374bg==} + engines: {node: '>=v18'} + hasBin: true + dependencies: + '@commitlint/format': 19.0.3 + '@commitlint/lint': 19.1.0 + '@commitlint/load': 19.2.0(@types/node@20.11.16)(typescript@5.4.4) + '@commitlint/read': 19.2.1 + '@commitlint/types': 19.0.3 + execa: 8.0.1 + yargs: 17.7.2 + transitivePeerDependencies: + - '@types/node' + - typescript + dev: true + + /@commitlint/config-conventional@19.1.0: + resolution: {integrity: sha512-KIKD2xrp6Uuk+dcZVj3++MlzIr/Su6zLE8crEDQCZNvWHNQSeeGbzOlNtsR32TUy6H3JbP7nWgduAHCaiGQ6EA==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/types': 19.0.3 + conventional-changelog-conventionalcommits: 7.0.2 + dev: true + + /@commitlint/config-validator@19.0.3: + resolution: {integrity: sha512-2D3r4PKjoo59zBc2auodrSCaUnCSALCx54yveOFwwP/i2kfEAQrygwOleFWswLqK0UL/F9r07MFi5ev2ohyM4Q==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/types': 19.0.3 + ajv: 8.12.0 + dev: true + + /@commitlint/ensure@19.0.3: + resolution: {integrity: sha512-SZEpa/VvBLoT+EFZVb91YWbmaZ/9rPH3ESrINOl0HD2kMYsjvl0tF7nMHh0EpTcv4+gTtZBAe1y/SS6/OhfZzQ==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/types': 19.0.3 + lodash.camelcase: 4.3.0 + lodash.kebabcase: 4.1.1 + lodash.snakecase: 4.1.1 + lodash.startcase: 4.4.0 + lodash.upperfirst: 4.3.1 + dev: true + + /@commitlint/execute-rule@19.0.0: + resolution: {integrity: sha512-mtsdpY1qyWgAO/iOK0L6gSGeR7GFcdW7tIjcNFxcWkfLDF5qVbPHKuGATFqRMsxcO8OUKNj0+3WOHB7EHm4Jdw==} + engines: {node: '>=v18'} + dev: true + + /@commitlint/format@19.0.3: + resolution: {integrity: sha512-QjjyGyoiVWzx1f5xOteKHNLFyhyweVifMgopozSgx1fGNrGV8+wp7k6n1t6StHdJ6maQJ+UUtO2TcEiBFRyR6Q==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/types': 19.0.3 + chalk: 5.3.0 + dev: true + + /@commitlint/is-ignored@19.0.3: + resolution: {integrity: sha512-MqDrxJaRSVSzCbPsV6iOKG/Lt52Y+PVwFVexqImmYYFhe51iVJjK2hRhOG2jUAGiUHk4jpdFr0cZPzcBkSzXDQ==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/types': 19.0.3 + semver: 7.6.0 + dev: true + + /@commitlint/lint@19.1.0: + resolution: {integrity: sha512-ESjaBmL/9cxm+eePyEr6SFlBUIYlYpI80n+Ltm7IA3MAcrmiP05UMhJdAD66sO8jvo8O4xdGn/1Mt2G5VzfZKw==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/is-ignored': 19.0.3 + '@commitlint/parse': 19.0.3 + '@commitlint/rules': 19.0.3 + '@commitlint/types': 19.0.3 + dev: true + + /@commitlint/load@19.2.0(@types/node@20.11.16)(typescript@5.4.4): + resolution: {integrity: sha512-XvxxLJTKqZojCxaBQ7u92qQLFMMZc4+p9qrIq/9kJDy8DOrEa7P1yx7Tjdc2u2JxIalqT4KOGraVgCE7eCYJyQ==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/config-validator': 19.0.3 + '@commitlint/execute-rule': 19.0.0 + '@commitlint/resolve-extends': 19.1.0 + '@commitlint/types': 19.0.3 + chalk: 5.3.0 + cosmiconfig: 9.0.0(typescript@5.4.4) + cosmiconfig-typescript-loader: 5.0.0(@types/node@20.11.16)(cosmiconfig@9.0.0)(typescript@5.4.4) + lodash.isplainobject: 4.0.6 + lodash.merge: 4.6.2 + lodash.uniq: 4.5.0 + transitivePeerDependencies: + - '@types/node' + - typescript + dev: true + + /@commitlint/message@19.0.0: + resolution: {integrity: sha512-c9czf6lU+9oF9gVVa2lmKaOARJvt4soRsVmbR7Njwp9FpbBgste5i7l/2l5o8MmbwGh4yE1snfnsy2qyA2r/Fw==} + engines: {node: '>=v18'} + dev: true + + /@commitlint/parse@19.0.3: + resolution: {integrity: sha512-Il+tNyOb8VDxN3P6XoBBwWJtKKGzHlitEuXA5BP6ir/3loWlsSqDr5aecl6hZcC/spjq4pHqNh0qPlfeWu38QA==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/types': 19.0.3 + conventional-changelog-angular: 7.0.0 + conventional-commits-parser: 5.0.0 + dev: true + + /@commitlint/read@19.2.1: + resolution: {integrity: sha512-qETc4+PL0EUv7Q36lJbPG+NJiBOGg7SSC7B5BsPWOmei+Dyif80ErfWQ0qXoW9oCh7GTpTNRoaVhiI8RbhuaNw==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/top-level': 19.0.0 + '@commitlint/types': 19.0.3 + execa: 8.0.1 + git-raw-commits: 4.0.0 + minimist: 1.2.8 + dev: true + + /@commitlint/resolve-extends@19.1.0: + resolution: {integrity: sha512-z2riI+8G3CET5CPgXJPlzftH+RiWYLMYv4C9tSLdLXdr6pBNimSKukYP9MS27ejmscqCTVA4almdLh0ODD2KYg==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/config-validator': 19.0.3 + '@commitlint/types': 19.0.3 + global-directory: 4.0.1 + import-meta-resolve: 4.0.0 + lodash.mergewith: 4.6.2 + resolve-from: 5.0.0 + dev: true + + /@commitlint/rules@19.0.3: + resolution: {integrity: sha512-TspKb9VB6svklxNCKKwxhELn7qhtY1rFF8ls58DcFd0F97XoG07xugPjjbVnLqmMkRjZDbDIwBKt9bddOfLaPw==} + engines: {node: '>=v18'} + dependencies: + '@commitlint/ensure': 19.0.3 + '@commitlint/message': 19.0.0 + '@commitlint/to-lines': 19.0.0 + '@commitlint/types': 19.0.3 + execa: 8.0.1 + dev: true + + /@commitlint/to-lines@19.0.0: + resolution: {integrity: sha512-vkxWo+VQU5wFhiP9Ub9Sre0FYe019JxFikrALVoD5UGa8/t3yOJEpEhxC5xKiENKKhUkTpEItMTRAjHw2SCpZw==} + engines: {node: '>=v18'} + dev: true + + /@commitlint/top-level@19.0.0: + resolution: {integrity: sha512-KKjShd6u1aMGNkCkaX4aG1jOGdn7f8ZI8TR1VEuNqUOjWTOdcDSsmglinglJ18JTjuBX5I1PtjrhQCRcixRVFQ==} + engines: {node: '>=v18'} + dependencies: + find-up: 7.0.0 + dev: true + + /@commitlint/types@19.0.3: + resolution: {integrity: sha512-tpyc+7i6bPG9mvaBbtKUeghfyZSDgWquIDfMgqYtTbmZ9Y9VzEm2je9EYcQ0aoz5o7NvGS+rcDec93yO08MHYA==} + engines: {node: '>=v18'} + dependencies: + '@types/conventional-commits-parser': 5.0.0 + chalk: 5.3.0 + dev: true + /@discoveryjs/json-ext@0.5.7: resolution: {integrity: sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==} engines: {node: '>=10.0.0'} @@ -2436,6 +2605,12 @@ packages: '@types/node': 20.11.16 dev: false + /@types/conventional-commits-parser@5.0.0: + resolution: {integrity: sha512-loB369iXNmAZglwWATL+WRe+CRMmmBPtpolYzIebFaX4YA3x+BEfLqhUAV9WanycKI3TG1IMr5bMJDajDKLlUQ==} + dependencies: + '@types/node': 20.11.16 + dev: true + /@types/eslint-scope@3.7.7: resolution: {integrity: sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg==} dependencies: @@ -2817,7 +2992,6 @@ packages: dependencies: jsonparse: 1.3.1 through: 2.3.8 - dev: false /abab@2.0.6: resolution: {integrity: sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==} @@ -3164,6 +3338,10 @@ packages: resolution: {integrity: sha512-hNfzcOV8W4NdualtqBFPyVO+54DSJuZGY9qT4pRroB6S9e3iiido2ISIC5h9R2sPJ8H3FHCIiEnsv1lPXO3KtQ==} dev: true + /array-ify@1.0.0: + resolution: {integrity: sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==} + dev: true + /array-initial@1.1.0: resolution: {integrity: sha512-BC4Yl89vneCYfpLrs5JU2aAu9/a+xWbeKhvISg9PT7eWFB9UlRvI+rKEtk6mgxWr3dSkk9gQ8hCrdqt06NXPdw==} engines: {node: '>=0.10.0'} @@ -4005,6 +4183,11 @@ packages: ansi-styles: 4.3.0 supports-color: 7.2.0 + /chalk@5.3.0: + resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==} + engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + dev: true + /char-regex@1.0.2: resolution: {integrity: sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==} engines: {node: '>=10'} @@ -4302,6 +4485,13 @@ packages: /commondir@1.0.1: resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} + /compare-func@2.0.0: + resolution: {integrity: sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==} + dependencies: + array-ify: 1.0.0 + dot-prop: 5.3.0 + dev: true + /component-emitter@1.3.1: resolution: {integrity: sha512-T0+barUSQRTUQASh8bx02dl+DhF54GtIDY13Y3m9oWTklKbb3Wv974meRpeZ3lp1JpLVECWWNHC4vaG2XHXouQ==} dev: true @@ -4562,6 +4752,31 @@ packages: resolution: {integrity: sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==} engines: {node: '>= 0.6'} + /conventional-changelog-angular@7.0.0: + resolution: {integrity: sha512-ROjNchA9LgfNMTTFSIWPzebCwOGFdgkEq45EnvvrmSLvCtAw0HSmrCs7/ty+wAeYUZyNay0YMUNYFTRL72PkBQ==} + engines: {node: '>=16'} + dependencies: + compare-func: 2.0.0 + dev: true + + /conventional-changelog-conventionalcommits@7.0.2: + resolution: {integrity: sha512-NKXYmMR/Hr1DevQegFB4MwfM5Vv0m4UIxKZTTYuD98lpTknaZlSRrDOG4X7wIXpGkfsYxZTghUN+Qq+T0YQI7w==} + engines: {node: '>=16'} + dependencies: + compare-func: 2.0.0 + dev: true + + /conventional-commits-parser@5.0.0: + resolution: {integrity: sha512-ZPMl0ZJbw74iS9LuX9YIAiW8pfM5p3yh2o/NbXHbkFuZzY5jvdi5jFycEOkmBW5H5I7nA+D6f3UcsCLP2vvSEA==} + engines: {node: '>=16'} + hasBin: true + dependencies: + JSONStream: 1.3.5 + is-text-path: 2.0.0 + meow: 12.1.1 + split2: 4.2.0 + dev: true + /convert-source-map@1.9.0: resolution: {integrity: sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==} dev: true @@ -4616,7 +4831,21 @@ packages: /core-util-is@1.0.3: resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} - /cosmiconfig@9.0.0: + /cosmiconfig-typescript-loader@5.0.0(@types/node@20.11.16)(cosmiconfig@9.0.0)(typescript@5.4.4): + resolution: {integrity: sha512-+8cK7jRAReYkMwMiG+bxhcNKiHJDM6bR9FD/nGBXOWdMLuYawjF5cGrtLilJ+LGd3ZjCXnJjR5DkfWPoIVlqJA==} + engines: {node: '>=v16'} + peerDependencies: + '@types/node': '*' + cosmiconfig: '>=8.2' + typescript: '>=4' + dependencies: + '@types/node': 20.11.16 + cosmiconfig: 9.0.0(typescript@5.4.4) + jiti: 1.21.0 + typescript: 5.4.4 + dev: true + + /cosmiconfig@9.0.0(typescript@5.4.4): resolution: {integrity: sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==} engines: {node: '>=14'} peerDependencies: @@ -4629,7 +4858,7 @@ packages: import-fresh: 3.3.0 js-yaml: 4.1.0 parse-json: 5.2.0 - dev: false + typescript: 5.4.4 /cross-fetch@4.0.0: resolution: {integrity: sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==} @@ -4749,6 +4978,11 @@ packages: engines: {node: '>=4'} dev: true + /dargs@8.1.0: + resolution: {integrity: sha512-wAV9QHOsNbwnWdNW2FYvE1P56wtgSbM+3SZcdGiWQILwVjACCXDCI3Ai8QlCjMDB8YK5zySiXZYBiwGmNY3lnw==} + engines: {node: '>=12'} + dev: true + /dashdash@1.14.1: resolution: {integrity: sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==} engines: {node: '>=0.10'} @@ -5173,6 +5407,13 @@ packages: is-obj: 1.0.1 dev: false + /dot-prop@5.3.0: + resolution: {integrity: sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==} + engines: {node: '>=8'} + dependencies: + is-obj: 2.0.0 + dev: true + /duplex-child-process@0.0.5: resolution: {integrity: sha512-3WVvFnyEYmFYXi2VB9z9XG8y4MbCMEPYrSGYROY3Pp7TT5qsyrdv+rZS6ydjQvTegHMc00pbrl4V/OOwrzo1KQ==} dev: false @@ -5651,6 +5892,21 @@ packages: signal-exit: 3.0.7 strip-final-newline: 2.0.0 + /execa@8.0.1: + resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==} + engines: {node: '>=16.17'} + dependencies: + cross-spawn: 7.0.3 + get-stream: 8.0.1 + human-signals: 5.0.0 + is-stream: 3.0.0 + merge-stream: 2.0.0 + npm-run-path: 5.3.0 + onetime: 6.0.0 + signal-exit: 4.1.0 + strip-final-newline: 3.0.0 + dev: true + /exit@0.1.2: resolution: {integrity: sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==} engines: {node: '>= 0.8.0'} @@ -5993,6 +6249,15 @@ packages: path-exists: 4.0.0 dev: true + /find-up@7.0.0: + resolution: {integrity: sha512-YyZM99iHrqLKjmt4LJDj58KI+fYyufRLBSYcqycxf//KpBk9FoewoGX0450m9nB44qrZnovzC2oeP5hUibxc/g==} + engines: {node: '>=18'} + dependencies: + locate-path: 7.2.0 + path-exists: 5.0.0 + unicorn-magic: 0.1.0 + dev: true + /findup-sync@2.0.0: resolution: {integrity: sha512-vs+3unmJT45eczmcAZ6zMJtxN3l/QXeccaXQx5cu/MeJMhewVfoWZqibRkOxPnmoR59+Zy5hjabfQc6JLSah4g==} engines: {node: '>= 0.10'} @@ -6409,6 +6674,11 @@ packages: dependencies: pump: 3.0.0 + /get-stream@8.0.1: + resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} + engines: {node: '>=16'} + dev: true + /get-uri@6.0.2: resolution: {integrity: sha512-5KLucCJobh8vBY1K07EFV4+cPZH3mrV9YeAruUseCQKHB58SGjjT2l9/eA9LD082IiuMjSlFJEcdJ27TXvbZNw==} engines: {node: '>= 14'} @@ -6435,6 +6705,16 @@ packages: dependencies: assert-plus: 1.0.0 + /git-raw-commits@4.0.0: + resolution: {integrity: sha512-ICsMM1Wk8xSGMowkOmPrzo2Fgmfo4bMHLNX6ytHjajRJUqvHOw/TFapQ+QG75c3X/tTDDhOSRPGC52dDbNM8FQ==} + engines: {node: '>=16'} + hasBin: true + dependencies: + dargs: 8.1.0 + meow: 12.1.1 + split2: 4.2.0 + dev: true + /github-from-package@0.0.0: resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==} requiresBuild: true @@ -6541,6 +6821,13 @@ packages: once: 1.4.0 dev: true + /global-directory@4.0.1: + resolution: {integrity: sha512-wHTUcDUoZ1H5/0iVqEudYW4/kAlN5cZ3j/bXn0Dpbizl9iaUVeWSHqiOjsgk6OW2bkLclbBjzewBz6weQ1zA2Q==} + engines: {node: '>=18'} + dependencies: + ini: 4.1.1 + dev: true + /global-modules@1.0.0: resolution: {integrity: sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==} engines: {node: '>=0.10.0'} @@ -7385,6 +7672,11 @@ packages: resolution: {integrity: sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==} engines: {node: '>=8.12.0'} + /human-signals@5.0.0: + resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} + engines: {node: '>=16.17.0'} + dev: true + /humanize-ms@1.2.1: resolution: {integrity: sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==} dependencies: @@ -7504,6 +7796,10 @@ packages: resolve-cwd: 3.0.0 dev: true + /import-meta-resolve@4.0.0: + resolution: {integrity: sha512-okYUR7ZQPH+efeuMJGlq4f8ubUgO50kByRPyt/Cy1Io4PSRsPjxME+YlVaCOx+NIToW7hCsZNFJyTPFFKepRSA==} + dev: true + /imurmurhash@0.1.4: resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} engines: {node: '>=0.8.19'} @@ -7783,6 +8079,11 @@ packages: engines: {node: '>=0.10.0'} dev: false + /is-obj@2.0.0: + resolution: {integrity: sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==} + engines: {node: '>=8'} + dev: true + /is-path-cwd@1.0.0: resolution: {integrity: sha512-cnS56eR9SPAscL77ik76ATVqoPARTqPIVkMDVxRaWH06zT+6+CzIroYRJ0VVvm0Z1zfAvxvz9i/D3Ppjaqt5Nw==} engines: {node: '>=0.10.0'} @@ -7871,6 +8172,18 @@ packages: resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} engines: {node: '>=8'} + /is-stream@3.0.0: + resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dev: true + + /is-text-path@2.0.0: + resolution: {integrity: sha512-+oDTluR6WEjdXEJMnC2z6A4FRwFoYuvShVVEGsS7ewc0UTi2QtAKMDJuL4BDEVt+5T7MjFo12RP8ghOM75oKJw==} + engines: {node: '>=8'} + dependencies: + text-extensions: 2.4.0 + dev: true + /is-typed-array@1.1.13: resolution: {integrity: sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw==} engines: {node: '>= 0.4'} @@ -8545,6 +8858,11 @@ packages: - utf-8-validate dev: true + /jiti@1.21.0: + resolution: {integrity: sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q==} + hasBin: true + dev: true + /jmespath@0.16.0: resolution: {integrity: sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw==} engines: {node: '>= 0.6.0'} @@ -8704,7 +9022,6 @@ packages: /jsonparse@1.3.1: resolution: {integrity: sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==} engines: {'0': node >= 0.2.0} - dev: false /jsprim@1.4.2: resolution: {integrity: sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==} @@ -8938,6 +9255,13 @@ packages: p-locate: 4.1.0 dev: true + /locate-path@7.2.0: + resolution: {integrity: sha512-gvVijfZvn7R+2qyPX8mAuKcFGDf6Nc61GdvGafQsHL0sBIxfKzA+usWn4GFC/bk+QdwPUD4kWFJLhElipq+0VA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + p-locate: 6.0.0 + dev: true + /lodash._basecopy@3.0.1: resolution: {integrity: sha512-rFR6Vpm4HeCK1WPGvjZSJ+7yik8d8PVUdCJx5rT2pogG4Ve/2ZS7kfmO5l5T2o5V2mqlNIfSF5MZlr1+xOoYQQ==} dev: true @@ -8974,6 +9298,10 @@ packages: resolution: {integrity: sha512-O0pWuFSK6x4EXhM1dhZ8gchNtG7JMqBtrHdoUFUWXD7dJnNSUze1GuyQr5sOs0aCvgGeI3o/OJW8f4ca7FDxmQ==} dev: true + /lodash.camelcase@4.3.0: + resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} + dev: true + /lodash.debounce@4.0.8: resolution: {integrity: sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==} dev: true @@ -8996,6 +9324,14 @@ packages: resolution: {integrity: sha512-JwObCrNJuT0Nnbuecmqr5DgtuBppuCvGD9lxjFpAzwnVtdGoDQ1zig+5W8k5/6Gcn0gZ3936HDAlGd28i7sOGQ==} dev: true + /lodash.isplainobject@4.0.6: + resolution: {integrity: sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==} + dev: true + + /lodash.kebabcase@4.1.1: + resolution: {integrity: sha512-N8XRTIMMqqDgSy4VLKPnJ/+hpGZN+PHQiJnSenYqPaVV/NCqEogTnAdZLQiGKhxX+JCs8waWq2t1XHWKOmlY8g==} + dev: true + /lodash.keys@3.1.2: resolution: {integrity: sha512-CuBsapFjcubOGMn3VD+24HOAPxM79tH+V6ivJL3CHYjtrawauDJHUk//Yew9Hvc6e9rbCrURGk8z6PC+8WJBfQ==} dependencies: @@ -9016,6 +9352,14 @@ packages: resolution: {integrity: sha512-L4/arjjuq4noiUJpt3yS6KIKDtJwNe2fIYgMqyYYKoeIfV1iEqvPwhCx23o+R9dzouGihDAPN1dTIRWa7zk8tw==} dev: true + /lodash.snakecase@4.1.1: + resolution: {integrity: sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==} + dev: true + + /lodash.startcase@4.4.0: + resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} + dev: true + /lodash.template@3.6.2: resolution: {integrity: sha512-0B4Y53I0OgHUJkt+7RmlDFWKjVAI/YUpWNiL9GQz5ORDr4ttgfQGo+phBWKFLJbBdtOwgMuUkdOHOnPg45jKmQ==} dependencies: @@ -9041,6 +9385,14 @@ packages: resolution: {integrity: sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==} dev: true + /lodash.uniq@4.5.0: + resolution: {integrity: sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==} + dev: true + + /lodash.upperfirst@4.3.1: + resolution: {integrity: sha512-sReKOYJIJf74dhJONhU4e0/shzi1trVbSWDOhKYE5XV2O+H7Sb2Dihwuc7xWxVl+DgFPyTqIN3zMfT9cq5iWDg==} + dev: true + /lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} @@ -9493,6 +9845,11 @@ packages: readable-stream: 2.3.8 dev: true + /meow@12.1.1: + resolution: {integrity: sha512-BhXM0Au22RwUneMPwSCnyhTOizdWoIEPU9sp0Aqa1PnDMR5Wv2FGXYDjuzJEIX+Eo2Rb8xuYe5jrnm5QowQFkw==} + engines: {node: '>=16.10'} + dev: true + /meow@9.0.0: resolution: {integrity: sha512-+obSblOQmRhcyBt62furQqRAQpNyWXo8BuQ5bN7dG8wmwQ+vwHKp/rCFD4CrTP8CsDQD1sjoZ94K417XEUk8IQ==} engines: {node: '>=10'} @@ -9602,6 +9959,11 @@ packages: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} engines: {node: '>=6'} + /mimic-fn@4.0.0: + resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} + engines: {node: '>=12'} + dev: true + /mimic-response@1.0.1: resolution: {integrity: sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==} engines: {node: '>=4'} @@ -10370,6 +10732,13 @@ packages: dependencies: path-key: 3.1.1 + /npm-run-path@5.3.0: + resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + path-key: 4.0.0 + dev: true + /npmlog@4.1.2: resolution: {integrity: sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==} dependencies: @@ -10526,6 +10895,13 @@ packages: dependencies: mimic-fn: 2.1.0 + /onetime@6.0.0: + resolution: {integrity: sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==} + engines: {node: '>=12'} + dependencies: + mimic-fn: 4.0.0 + dev: true + /opn@5.5.0: resolution: {integrity: sha512-PqHpggC9bLV0VeWcdKhkpxY+3JTzetLSqTCWL/z/tFIbI6G8JCjondXklT1JinczLz2Xib62sSp0T/gKT4KksA==} engines: {node: '>=4'} @@ -10647,6 +11023,13 @@ packages: p-try: 2.2.0 dev: true + /p-limit@4.0.0: + resolution: {integrity: sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + yocto-queue: 1.0.0 + dev: true + /p-locate@3.0.0: resolution: {integrity: sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==} engines: {node: '>=6'} @@ -10661,6 +11044,13 @@ packages: p-limit: 2.3.0 dev: true + /p-locate@6.0.0: + resolution: {integrity: sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + p-limit: 4.0.0 + dev: true + /p-map@2.1.0: resolution: {integrity: sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==} engines: {node: '>=6'} @@ -10818,6 +11208,11 @@ packages: engines: {node: '>=8'} dev: true + /path-exists@5.0.0: + resolution: {integrity: sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dev: true + /path-is-absolute@1.0.1: resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} engines: {node: '>=0.10.0'} @@ -10834,6 +11229,11 @@ packages: resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} engines: {node: '>=8'} + /path-key@4.0.0: + resolution: {integrity: sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==} + engines: {node: '>=12'} + dev: true + /path-parse@1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} dev: true @@ -11250,14 +11650,14 @@ packages: - utf-8-validate dev: false - /puppeteer@21.11.0: + /puppeteer@21.11.0(typescript@5.4.4): resolution: {integrity: sha512-9jTHuYe22TD3sNxy0nEIzC7ZrlRnDgeX3xPkbS7PnbdwYjl2o/z/YuCrRBwezdKpbTDTJ4VqIggzNyeRcKq3cg==} engines: {node: '>=16.13.2'} hasBin: true requiresBuild: true dependencies: '@puppeteer/browsers': 1.9.1 - cosmiconfig: 9.0.0 + cosmiconfig: 9.0.0(typescript@5.4.4) puppeteer-core: 21.11.0 transitivePeerDependencies: - bufferutil @@ -11999,6 +12399,14 @@ packages: dependencies: lru-cache: 6.0.0 + /semver@7.6.0: + resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==} + engines: {node: '>=10'} + hasBin: true + dependencies: + lru-cache: 6.0.0 + dev: true + /send@0.18.0(supports-color@6.1.0): resolution: {integrity: sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==} engines: {node: '>= 0.8.0'} @@ -12454,6 +12862,11 @@ packages: extend-shallow: 3.0.2 dev: true + /split2@4.2.0: + resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==} + engines: {node: '>= 10.x'} + dev: true + /sprintf-js@1.0.3: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} @@ -12714,6 +13127,11 @@ packages: resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} engines: {node: '>=6'} + /strip-final-newline@3.0.0: + resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} + engines: {node: '>=12'} + dev: true + /strip-indent@3.0.0: resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} engines: {node: '>=8'} @@ -13129,6 +13547,11 @@ packages: minimatch: 3.1.2 dev: true + /text-extensions@2.4.0: + resolution: {integrity: sha512-te/NtwBwfiNRLf9Ijqx3T0nlqZiQ2XrrtBvu+cLL8ZRrGkO0NHTug8MYFKyoSrv/sHTaSKfilUkizV6XhxMJ3g==} + engines: {node: '>=8'} + dev: true + /text-table@0.2.0: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} dev: true @@ -13429,6 +13852,11 @@ packages: ts-toolbelt: 9.6.0 dev: false + /typescript@5.4.4: + resolution: {integrity: sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==} + engines: {node: '>=14.17'} + hasBin: true + /uglify-js@3.4.10: resolution: {integrity: sha512-Y2VsbPVs0FIshJztycsO2SfPk7/KAF/T72qzv9u5EpQ4kB2hQoHlhNQTsNyy6ul7lQtqJN/AoWeS23OzEiEFxw==} engines: {node: '>=0.8.0'} @@ -13523,6 +13951,11 @@ packages: engines: {node: '>=4'} dev: true + /unicorn-magic@0.1.0: + resolution: {integrity: sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==} + engines: {node: '>=18'} + dev: true + /union-value@1.0.1: resolution: {integrity: sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==} engines: {node: '>=0.10.0'} @@ -14462,3 +14895,8 @@ packages: buffer-crc32: 0.2.13 fd-slicer: 1.1.0 dev: false + + /yocto-queue@1.0.0: + resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==} + engines: {node: '>=12.20'} + dev: true From 0004d1da239f7a6acd49543ab0791feb2e255220 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 5 Apr 2024 09:34:10 +0200 Subject: [PATCH 048/153] test: commit --- .husky/.commitlintrc.json | 2 +- .husky/commit-msg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.husky/.commitlintrc.json b/.husky/.commitlintrc.json index f38108778..fae9c3c80 100644 --- a/.husky/.commitlintrc.json +++ b/.husky/.commitlintrc.json @@ -1,6 +1,6 @@ { "extends": ["@commitlint/config-conventional"], "rules": { - "type-enum": [2, "always", ["ci", "chore", "docs", "ticket","feat", "fix", "perf", "refactor", "revert", "style"]] + "type-enum": [2, "always", ["ci", "chore", "docs", "ticket","feat", "fix", "perf", "refactor", "revert", "style", "test"]] } } \ No newline at end of file diff --git a/.husky/commit-msg b/.husky/commit-msg index 8816a6ae6..5e563eba5 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1,4 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -pnpm run commitlint ${1} +npx --no-install commitlint --edit From 42e21eb6025acd4ef76f0241cb7a4e6eb9b9261d Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 5 Apr 2024 14:13:17 +0200 Subject: [PATCH 049/153] feat(githook) add reference --- .husky/.commitlintrc.json | 6 ------ .husky/addReferenceTag.js | 36 ++++++++++++++++++++++++++++++++++++ .husky/commit-msg | 4 ++++ package.json | 3 ++- 4 files changed, 42 insertions(+), 7 deletions(-) delete mode 100644 .husky/.commitlintrc.json create mode 100644 .husky/addReferenceTag.js diff --git a/.husky/.commitlintrc.json b/.husky/.commitlintrc.json deleted file mode 100644 index fae9c3c80..000000000 --- a/.husky/.commitlintrc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": ["@commitlint/config-conventional"], - "rules": { - "type-enum": [2, "always", ["ci", "chore", "docs", "ticket","feat", "fix", "perf", "refactor", "revert", "style", "test"]] - } -} \ No newline at end of file diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js new file mode 100644 index 000000000..2eab2b8c5 --- /dev/null +++ b/.husky/addReferenceTag.js @@ -0,0 +1,36 @@ + + +const fs = require('fs'); +const path = require('path'); + +async function getCurrentBranchName(p = process.cwd()) { + while (p !== path.parse(p).root) { + const gitHeadPath = path.join(p, '.git', 'HEAD'); + try { + const headContent = await fs.readFile(gitHeadPath, 'utf-8'); + return headContent.trim().split('/')[2]; + } catch (err) { + p = path.resolve(p, '..'); + } + } + return false; +} +const branchName = getCurrentBranchName(); +if (branchName) { + const msgPath = `.git/COMMIT_EDITMSG`; + const msg = fs.readFileSync(msgPath, "utf-8"); + + const referenceTag = `refs #${branchName.match(/^\d+/)}`; + console.log('referenceTag: ', referenceTag); + console.log(msg); + + if (!msg.includes(referenceTag)) { + const splitedMsg = msg.split(':'); + + if (splitedMsg.length > 1) { + const finalMsg = splitedMsg[0] + splitedMsg.slice(1).join(':'); + fs.writeFileSync(msgPath, finalMsg); + } + } +} + diff --git a/.husky/commit-msg b/.husky/commit-msg index 5e563eba5..b813583c2 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1,8 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" +echo "Running husky commit-msg hook" npx --no-install commitlint --edit +echo "Adding reference tag to commit message" +pnpm run addReferenceTag + diff --git a/package.json b/package.json index 5aa1cfb7f..c6bafb510 100644 --- a/package.json +++ b/package.json @@ -115,7 +115,8 @@ "back": "nodemon --inspect -w modules ./node_modules/gulp/bin/gulp.js back", "lint": "eslint ./ --cache --ignore-pattern .gitignore", "commitlint": "commitlint --edit", - "prepare": "husky install" + "prepare": "husky install", + "addReferenceTag": "node .husky/addReferenceTag.js" }, "jest": { "projects": [ From 021280c53cd30c3350e18d7b1bfe4806b70ab9ff Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 5 Apr 2024 14:14:10 +0200 Subject: [PATCH 050/153] fix commit code --- .husky/addReferenceTag.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index 2eab2b8c5..b50a0342b 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -3,17 +3,14 @@ const fs = require('fs'); const path = require('path'); -async function getCurrentBranchName(p = process.cwd()) { - while (p !== path.parse(p).root) { - const gitHeadPath = path.join(p, '.git', 'HEAD'); - try { - const headContent = await fs.readFile(gitHeadPath, 'utf-8'); - return headContent.trim().split('/')[2]; - } catch (err) { - p = path.resolve(p, '..'); - } - } - return false; +function getCurrentBranchName(p = process.cwd()) { + const gitHeadPath = `${p}/.git/HEAD`; + + return fs.existsSync(p) ? + fs.existsSync(gitHeadPath) ? + fs.readFileSync(gitHeadPath, 'utf-8').trim().split('/')[2] : + getCurrentBranchName(path.resolve(p, '..')) : + false } const branchName = getCurrentBranchName(); if (branchName) { @@ -29,6 +26,7 @@ if (branchName) { if (splitedMsg.length > 1) { const finalMsg = splitedMsg[0] + splitedMsg.slice(1).join(':'); + console.log('finalMsg: ', finalMsg); fs.writeFileSync(msgPath, finalMsg); } } From 11dea43da26c47fe4da0cb874716b3c87c5c3fb8 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 5 Apr 2024 14:53:06 +0200 Subject: [PATCH 051/153] fix:refs #6130 code --- .husky/addReferenceTag.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index b50a0342b..1361851a6 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -25,7 +25,7 @@ if (branchName) { const splitedMsg = msg.split(':'); if (splitedMsg.length > 1) { - const finalMsg = splitedMsg[0] + splitedMsg.slice(1).join(':'); + const finalMsg = splitedMsg[0] + ':' + referenceTag + splitedMsg.slice(1).join(':'); console.log('finalMsg: ', finalMsg); fs.writeFileSync(msgPath, finalMsg); } From 70bdb523718ea3faac209393d74060993608854d Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 5 Apr 2024 14:57:52 +0200 Subject: [PATCH 052/153] fix: refs #6130 code --- .husky/addReferenceTag.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index 1361851a6..a51d47683 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -1,21 +1,10 @@ - - const fs = require('fs'); const path = require('path'); -function getCurrentBranchName(p = process.cwd()) { - const gitHeadPath = `${p}/.git/HEAD`; - - return fs.existsSync(p) ? - fs.existsSync(gitHeadPath) ? - fs.readFileSync(gitHeadPath, 'utf-8').trim().split('/')[2] : - getCurrentBranchName(path.resolve(p, '..')) : - false -} const branchName = getCurrentBranchName(); if (branchName) { const msgPath = `.git/COMMIT_EDITMSG`; - const msg = fs.readFileSync(msgPath, "utf-8"); + const msg = fs.readFileSync(msgPath, 'utf-8'); const referenceTag = `refs #${branchName.match(/^\d+/)}`; console.log('referenceTag: ', referenceTag); @@ -25,10 +14,21 @@ if (branchName) { const splitedMsg = msg.split(':'); if (splitedMsg.length > 1) { - const finalMsg = splitedMsg[0] + ':' + referenceTag + splitedMsg.slice(1).join(':'); + const finalMsg = splitedMsg[0] + ': ' + referenceTag + splitedMsg.slice(1).join(':'); console.log('finalMsg: ', finalMsg); fs.writeFileSync(msgPath, finalMsg); } } } +function getCurrentBranchName(p = process.cwd()) { + if (!fs.existsSync(p)) return false; + + const gitHeadPath = path.join(p, '.git', 'HEAD'); + + if (!fs.existsSync(gitHeadPath)) + return getCurrentBranchName(path.resolve(p, '..')); + + const headContent = fs.readFileSync(gitHeadPath, 'utf-8'); + return headContent.trim().split('/')[2]; +} From 1e669e99f89e83da697d4d8b5a90a3944673ed04 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 5 Apr 2024 14:58:20 +0200 Subject: [PATCH 053/153] fix: refs #6130 code:code --- .husky/addReferenceTag.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index a51d47683..64b713c48 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -21,7 +21,7 @@ if (branchName) { } } -function getCurrentBranchName(p = process.cwd()) { +function getCurrentBranchName(p = process.cwd()) { if (!fs.existsSync(p)) return false; const gitHeadPath = path.join(p, '.git', 'HEAD'); From 29f952308f0d952c4140e0e00048eeb63e8c13bb Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 5 Apr 2024 14:58:43 +0200 Subject: [PATCH 054/153] #code: refs #6130 code@ --- .husky/addReferenceTag.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index 64b713c48..a51d47683 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -21,7 +21,7 @@ if (branchName) { } } -function getCurrentBranchName(p = process.cwd()) { +function getCurrentBranchName(p = process.cwd()) { if (!fs.existsSync(p)) return false; const gitHeadPath = path.join(p, '.git', 'HEAD'); From 2084d047b2f99c8956d3ea85aa8c505fea7c3703 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 5 Apr 2024 15:01:12 +0200 Subject: [PATCH 055/153] fix: refs #6130 code --- .husky/addReferenceTag.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index a51d47683..64b713c48 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -21,7 +21,7 @@ if (branchName) { } } -function getCurrentBranchName(p = process.cwd()) { +function getCurrentBranchName(p = process.cwd()) { if (!fs.existsSync(p)) return false; const gitHeadPath = path.join(p, '.git', 'HEAD'); From 7acb4ee52366f995187fde25ef48b033b7c1c121 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 5 Apr 2024 15:01:29 +0200 Subject: [PATCH 056/153] fix: refs #6130 code --- .husky/addReferenceTag.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index 64b713c48..a51d47683 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -21,7 +21,7 @@ if (branchName) { } } -function getCurrentBranchName(p = process.cwd()) { +function getCurrentBranchName(p = process.cwd()) { if (!fs.existsSync(p)) return false; const gitHeadPath = path.join(p, '.git', 'HEAD'); From 0dcd1518b93e37196e525d5c1d5e190bd832a006 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 8 Apr 2024 08:08:17 +0200 Subject: [PATCH 058/153] feat: refs #6130 add commit --- .husky/addReferenceTag.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index a51d47683..eb1d80d8b 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -1,5 +1,5 @@ const fs = require('fs'); -const path = require('path'); +const path = require('path'); const branchName = getCurrentBranchName(); if (branchName) { From f7170309d26db47739b89d035687ae92978416e4 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 8 Apr 2024 08:09:21 +0200 Subject: [PATCH 059/153] test: refs #6130 89 add commit --- .husky/addReferenceTag.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index eb1d80d8b..ce4134e1a 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -1,4 +1,4 @@ -const fs = require('fs'); +const fs = require('fs'); const path = require('path'); const branchName = getCurrentBranchName(); From 1728ed955bd8fb9175bf490b3dddcfb85ccd18f3 Mon Sep 17 00:00:00 2001 From: pablone Date: Mon, 8 Apr 2024 08:51:13 +0200 Subject: [PATCH 060/153] fix: refs #6130 code remove console.log --- .husky/addReferenceTag.js | 40 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index ce4134e1a..399c69301 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -1,26 +1,6 @@ -const fs = require('fs'); +const fs = require('fs'); const path = require('path'); -const branchName = getCurrentBranchName(); -if (branchName) { - const msgPath = `.git/COMMIT_EDITMSG`; - const msg = fs.readFileSync(msgPath, 'utf-8'); - - const referenceTag = `refs #${branchName.match(/^\d+/)}`; - console.log('referenceTag: ', referenceTag); - console.log(msg); - - if (!msg.includes(referenceTag)) { - const splitedMsg = msg.split(':'); - - if (splitedMsg.length > 1) { - const finalMsg = splitedMsg[0] + ': ' + referenceTag + splitedMsg.slice(1).join(':'); - console.log('finalMsg: ', finalMsg); - fs.writeFileSync(msgPath, finalMsg); - } - } -} - function getCurrentBranchName(p = process.cwd()) { if (!fs.existsSync(p)) return false; @@ -32,3 +12,21 @@ function getCurrentBranchName(p = process.cwd()) { const headContent = fs.readFileSync(gitHeadPath, 'utf-8'); return headContent.trim().split('/')[2]; } + +const branchName = getCurrentBranchName(); + +if (branchName) { + const msgPath = `.git/COMMIT_EDITMSG`; + const msg = fs.readFileSync(msgPath, 'utf-8'); + + const referenceTag = `refs #${branchName.match(/^\d+/)}`; + if (!msg.includes(referenceTag)) { + const splitedMsg = msg.split(':'); + + if (splitedMsg.length > 1) { + const finalMsg = splitedMsg[0] + ': ' + referenceTag + splitedMsg.slice(1).join(':'); + fs.writeFileSync(msgPath, finalMsg); + } + } +} + From dddcacee7a417fddb9dd712d4b02e3b9424b9668 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 8 Apr 2024 12:01:27 +0200 Subject: [PATCH 061/153] feat: refs #6500 --- db/routines/vn/procedures/riskAllClients.sql | 34 ++++---- .../vn2008/procedures/risk_vs_client_list.sql | 84 +++++++++++++++++++ 2 files changed, 101 insertions(+), 17 deletions(-) create mode 100644 db/routines/vn2008/procedures/risk_vs_client_list.sql diff --git a/db/routines/vn/procedures/riskAllClients.sql b/db/routines/vn/procedures/riskAllClients.sql index c818c715c..f007247f3 100644 --- a/db/routines/vn/procedures/riskAllClients.sql +++ b/db/routines/vn/procedures/riskAllClients.sql @@ -2,28 +2,28 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`riskAllClients`(maxRiskDate DATE) BEGIN - DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; - CREATE TEMPORARY TABLE tmp.clientGetDebt - (PRIMARY KEY (clientFk)) + DROP TEMPORARY TABLE IF EXISTS tmp.client_list; + CREATE TEMPORARY TABLE tmp.client_list + (PRIMARY KEY (Id_Cliente)) ENGINE = MEMORY - SELECT id clientFk, null grade FROM client; + SELECT id Id_Cliente, null grade FROM vn.client; - CALL client_getDebt (maxRiskDate); + CALL vn2008.risk_vs_client_list(maxRiskDate); SELECT - c.RazonSocial, - c.Id_Cliente, - c.Credito, - CAST(r.risk as DECIMAL (10,2)) risk, - CAST(c.Credito - r.risk as DECIMAL (10,2)) Diferencia, - c.Id_Pais - FROM - vn2008.Clientes c - JOIN tmp.risk r ON r.clientFk = c.Id_Cliente - JOIN tmp.clientGetDebt ci ON c.Id_Cliente = ci.clientFk - GROUP BY c.Id_cliente; + c.RazonSocial, + c.Id_Cliente, + c.Credito, + CAST(r.risk as DECIMAL (10,2)) risk, + CAST(c.Credito - r.risk as DECIMAL (10,2)) Diferencia, + c.Id_Pais + FROM + vn2008.Clientes c + JOIN tmp.risk r ON r.Id_Cliente = c.Id_Cliente + JOIN tmp.client_list ci ON c.Id_Cliente = ci.Id_Cliente + GROUP BY c.Id_cliente; DROP TEMPORARY TABLE IF EXISTS tmp.risk; - DROP TEMPORARY TABLE IF EXISTS tmp.clientGetDebt; + DROP TEMPORARY TABLE IF EXISTS tmp.client_list; END$$ DELIMITER ; diff --git a/db/routines/vn2008/procedures/risk_vs_client_list.sql b/db/routines/vn2008/procedures/risk_vs_client_list.sql new file mode 100644 index 000000000..92f94eb9f --- /dev/null +++ b/db/routines/vn2008/procedures/risk_vs_client_list.sql @@ -0,0 +1,84 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`risk_vs_client_list`(maxRiskDate DATE) +BEGIN +/** + * Calcula el riesgo para los clientes activos de la tabla temporal tmp.client_list + * + * @deprecated usar vn.client_getDebt + * @param maxRiskDate Fecha maxima de los registros + * @return table tmp.risk + */ + DECLARE startingDate DATETIME DEFAULT TIMESTAMPADD(DAY, - DAYOFMONTH(util.VN_CURDATE()) - 60, util.VN_CURDATE()); + DECLARE endingDate DATETIME; + DECLARE MAX_RISK_ALLOWED INT DEFAULT 200; + + SET maxRiskDate = IFNULL(maxRiskDate, util.VN_CURDATE()); + SET endingDate = TIMESTAMP(maxRiskDate, '23:59:59'); + + DROP TEMPORARY TABLE IF EXISTS tmp.client_list_2; + CREATE TEMPORARY TABLE tmp.client_list_2 + (PRIMARY KEY (Id_Cliente)) + ENGINE = MEMORY + SELECT * + FROM tmp.client_list; + + DROP TEMPORARY TABLE IF EXISTS tmp.client_list_3; + CREATE TEMPORARY TABLE tmp.client_list_3 + (PRIMARY KEY (Id_Cliente)) + ENGINE = MEMORY + SELECT * + FROM tmp.client_list; + + DROP TEMPORARY TABLE IF EXISTS tmp.tickets_sin_facturar; + CREATE TEMPORARY TABLE tmp.tickets_sin_facturar + (PRIMARY KEY (Id_Cliente)) + ENGINE = MEMORY + SELECT t.Id_Cliente, floor(IF(cl.isVies, 1, 1.1) * sum(Cantidad * Preu * (100 - Descuento) / 100)) as total + FROM Movimientos m + JOIN Tickets t on m.Id_Ticket = t.Id_Ticket + JOIN tmp.client_list c on c.Id_Cliente = t.Id_Cliente + JOIN vn.client cl ON cl.id = t.Id_Cliente + WHERE Factura IS NULL + AND Fecha BETWEEN startingDate AND endingDate + GROUP BY t.Id_Cliente; + + DROP TEMPORARY TABLE IF EXISTS tmp.risk; + CREATE TEMPORARY TABLE tmp.risk + (PRIMARY KEY (Id_Cliente)) + ENGINE = MEMORY + SELECT Id_Cliente, SUM(amount) risk, sum(saldo) saldo + FROM Clientes c + JOIN ( + SELECT clientFk, SUM(amount) amount,SUM(amount) saldo + FROM vn.clientRisk + JOIN tmp.client_list on Id_Cliente = clientFk + GROUP BY clientFk + UNION ALL + SELECT Id_Cliente, SUM(Entregado),SUM(Entregado) + FROM Recibos + JOIN tmp.client_list_2 using(Id_Cliente) + WHERE Fechacobro > endingDate + GROUP BY Id_Cliente + UNION ALL + SELECT Id_Cliente, total,0 + FROM tmp.tickets_sin_facturar + UNION ALL + SELECT t.clientFk, CAST(-SUM(t.amount) / 100 AS DECIMAL(10,2)), CAST(-SUM(t.amount) / 100 AS DECIMAL(10,2)) + FROM hedera.tpvTransaction t + JOIN tmp.client_list_3 on Id_Cliente = t.clientFk + WHERE t.receiptFk IS NULL + AND t.status = 'ok' + GROUP BY t.clientFk + ) t ON c.Id_Cliente = t.clientFk + WHERE c.activo != FALSE + GROUP BY c.Id_Cliente; + + DELETE r.* + FROM tmp.risk r + JOIN vn2008.Clientes c on c.Id_Cliente = r.Id_Cliente + JOIN vn2008.pay_met pm on pm.id = c.pay_met_id + WHERE IFNULL(r.saldo,0) < 10 + AND r.risk <= MAX_RISK_ALLOWED + AND pm.`name` = 'TARJETA'; +END$$ +DELIMITER ; From 2d18f01a15be29e49d7382ba7f15bea77c2bd385 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 8 Apr 2024 12:18:13 +0200 Subject: [PATCH 062/153] feat: refs #6500 --- db/routines/vn/procedures/creditRecovery.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/creditRecovery.sql b/db/routines/vn/procedures/creditRecovery.sql index e598661af..a57e08063 100644 --- a/db/routines/vn/procedures/creditRecovery.sql +++ b/db/routines/vn/procedures/creditRecovery.sql @@ -39,7 +39,7 @@ BEGIN WHERE credit > 0; UPDATE client c - JOIN tCreditClients cc ON cc.clientFk = c.clientFk + JOIN tCreditClients cc ON cc.clientFk = c.id SET c.credit = newCredit; DROP TEMPORARY TABLE tCreditClients; From d595a7b2fabc01b6f0dd86df99fe908114c467e0 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 8 Apr 2024 12:22:15 +0200 Subject: [PATCH 063/153] feat: refs #6500 --- db/versions/10984-navyDendro/00-firstScript.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 db/versions/10984-navyDendro/00-firstScript.sql diff --git a/db/versions/10984-navyDendro/00-firstScript.sql b/db/versions/10984-navyDendro/00-firstScript.sql new file mode 100644 index 000000000..136625a34 --- /dev/null +++ b/db/versions/10984-navyDendro/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here +UPDATE bs.nightTask SET `schema`='vn' WHERE id=22; + +UPDATE bs.nightTask SET `schema`='vn',`procedure`='creditRecovery' WHERE id=30; \ No newline at end of file From 26c74a3e71b321bb0c5d35768dcb47581a95860f Mon Sep 17 00:00:00 2001 From: jcasado Date: Mon, 8 Apr 2024 13:03:15 +0200 Subject: [PATCH 064/153] refs #6641 fix test --- modules/claim/back/methods/claim/filter.js | 6 +---- .../back/methods/claim/specs/filter.spec.js | 27 ++++++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/modules/claim/back/methods/claim/filter.js b/modules/claim/back/methods/claim/filter.js index 21d6ff80f..56d4fdfed 100644 --- a/modules/claim/back/methods/claim/filter.js +++ b/modules/claim/back/methods/claim/filter.js @@ -102,11 +102,7 @@ module.exports = Self => { }); Self.filter = async(ctx, filter, options) => { - const userId = ctx?.req?.accessToken?.userId; - console.log('ctx', ctx); - console.log('ctx.req', ctx.req); - console.log('ctx.req.accessToken', ctx.req.accessToken); - console.log('ctx.req.accessToken.userId', ctx.req.accessToken.userId); + const userId = ctx.req.accessToken.userId; const models = Self.app.models; const conn = Self.dataSource.connector; const args = ctx.args; diff --git a/modules/claim/back/methods/claim/specs/filter.spec.js b/modules/claim/back/methods/claim/specs/filter.spec.js index 677015c4d..08e680e97 100644 --- a/modules/claim/back/methods/claim/specs/filter.spec.js +++ b/modules/claim/back/methods/claim/specs/filter.spec.js @@ -1,14 +1,24 @@ const app = require('vn-loopback/server/server'); const models = require('vn-loopback/server/server').models; -fdescribe('claim filter()', () => { +describe('claim filter()', () => { + let ctx; + beforeEach(() => { + ctx = { + req: { + accessToken: {userId: 9}, + headers: {origin: 'http://localhost'} + } + }; + }); + it('should return 1 result filtering by id', async() => { const tx = await app.models.Claim.beginTransaction({}); try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({args: {filter: {}, search: 1}}, null, options); + const result = await app.models.Claim.filter({...ctx, args: {filter: {}, search: 1}}, null, options); expect(result.length).toEqual(1); expect(result[0].id).toEqual(1); @@ -26,7 +36,7 @@ fdescribe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({args: {filter: {}, search: 'Tony Stark'}}, null, options); + const result = await app.models.Claim.filter({...ctx, args: {filter: {}, search: 'Tony Stark'}}, null, options); expect(result.length).toEqual(1); expect(result[0].id).toEqual(4); @@ -44,7 +54,7 @@ fdescribe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({args: {filter: {}, workerFk: 18}}, null, options); + const result = await app.models.Claim.filter({...ctx, args: {filter: {}, workerFk: 18}}, null, options); expect(result.length).toEqual(4); expect(result[0].id).toEqual(1); @@ -65,7 +75,7 @@ fdescribe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({args: {filter: {}, itemFk: 2}}, null, options); + const result = await app.models.Claim.filter({...ctx, args: {filter: {}, itemFk: 2}}, null, options); expect(result.length).toEqual(3); expect(result[0].id).toEqual(1); @@ -85,7 +95,7 @@ fdescribe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({args: {filter: {}, claimResponsibleFk: 7}}, null, options); + const result = await app.models.Claim.filter({...ctx, args: {filter: {}, claimResponsibleFk: 7}}, null, options); expect(result.length).toEqual(3); expect(result[0].id).toEqual(2); @@ -99,15 +109,14 @@ fdescribe('claim filter()', () => { } }); - it('should now return the tickets from the worker team', async() => { + it('should now return claims from the worker team', async() => { const tx = await models.Claim.beginTransaction({}); try { const options = {transaction: tx}; - const ctx = {req: {accessToken: {userId: 9}}, args: {myTeam: true}}; const filter = {}; - const result = await models.Claim.filter(ctx, filter, options); + const result = await models.Claim.filter({...ctx, args: {filter: {}, itemFk: null, myTeam: true}}, filter, options); expect(result.length).toEqual(2); From 2c0c346a7bebf58566274751d5067cd5ca33c560 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 9 Apr 2024 07:34:43 +0200 Subject: [PATCH 065/153] feat: refs #6500 --- db/routines/vn/procedures/creditRecovery.sql | 23 ++++++++++--------- .../10984-navyDendro/00-firstScript.sql | 4 ++-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/db/routines/vn/procedures/creditRecovery.sql b/db/routines/vn/procedures/creditRecovery.sql index a57e08063..0a02f611f 100644 --- a/db/routines/vn/procedures/creditRecovery.sql +++ b/db/routines/vn/procedures/creditRecovery.sql @@ -16,31 +16,32 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tCreditClients; CREATE TEMPORARY TABLE tCreditClients - SELECT clientFk, IF (credit > recovery ,credit - recovery,0) newCredit + SELECT clientFk, IF(credit > recovery, credit - recovery, 0) newCredit FROM ( SELECT r.clientFk, r.amount recovery, - timestampadd(DAY, r.period, sub2.created) deadLine, + (sub2.created + INTERVAL r.period DAY) deadLine, sub2.amount credit FROM recovery r JOIN ( - SELECT clientFk, amount , created - FROM ( - SELECT * FROM clientCredit - ORDER BY created DESC - LIMIT 10000000000000000000 - ) sub + SELECT clientFk, amount, created + FROM ( + SELECT clientFk, amount, created + FROM clientCredit + ORDER BY created DESC + LIMIT 10000000000000000000 + ) sub GROUP BY clientFk ) sub2 ON sub2.clientFk = r.clientFk WHERE r.finished IS NULL OR r.finished >= util.VN_CURDATE() GROUP BY r.clientFk - HAVING deadLine <= util.VN_CURDATE() + HAVING deadLine <= util.VN_CURDATE() ) sub3 WHERE credit > 0; UPDATE client c - JOIN tCreditClients cc ON cc.clientFk = c.id - SET c.credit = newCredit; + JOIN tCreditClients cc ON cc.clientFk = c.id + SET c.credit = newCredit; DROP TEMPORARY TABLE tCreditClients; COMMIT; diff --git a/db/versions/10984-navyDendro/00-firstScript.sql b/db/versions/10984-navyDendro/00-firstScript.sql index 136625a34..c08462d75 100644 --- a/db/versions/10984-navyDendro/00-firstScript.sql +++ b/db/versions/10984-navyDendro/00-firstScript.sql @@ -1,4 +1,4 @@ -- Place your SQL code here -UPDATE bs.nightTask SET `schema`='vn' WHERE id=22; +UPDATE bs.nightTask SET `schema`='vn' WHERE `procedure`='raidUpdate'; -UPDATE bs.nightTask SET `schema`='vn',`procedure`='creditRecovery' WHERE id=30; \ No newline at end of file +UPDATE bs.nightTask SET `schema`='vn',`procedure`='creditRecovery' WHERE `procedure` ='recobro_credito'; \ No newline at end of file From 638b715ee51adb3551284aed9f4826cc2d679fbf Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 9 Apr 2024 09:30:28 +0200 Subject: [PATCH 066/153] fix: refs #6005 move logic to hook --- loopback/locale/es.json | 697 +++++++++--------- .../methods/operator/spec/operator.spec.js | 166 ++--- modules/worker/back/models/operator.js | 31 +- 3 files changed, 406 insertions(+), 488 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 3748b6eaf..56b4bdc1c 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -1,350 +1,351 @@ { - "Phone format is invalid": "El formato del teléfono no es correcto", - "You are not allowed to change the credit": "No tienes privilegios para modificar el crédito", - "Unable to mark the equivalence surcharge": "No se puede marcar el recargo de equivalencia", - "The default consignee can not be unchecked": "No se puede desmarcar el consignatario predeterminado", - "Unable to default a disabled consignee": "No se puede poner predeterminado un consignatario desactivado", - "Can't be blank": "No puede estar en blanco", - "Invalid TIN": "NIF/CIF inválido", - "TIN must be unique": "El NIF/CIF debe ser único", - "A client with that Web User name already exists": "Ya existe un cliente con ese Usuario Web", - "Is invalid": "Es inválido", - "Quantity cannot be zero": "La cantidad no puede ser cero", - "Enter an integer different to zero": "Introduce un entero distinto de cero", - "Package cannot be blank": "El embalaje no puede estar en blanco", - "The company name must be unique": "La razón social debe ser única", - "Invalid email": "Correo electrónico inválido", - "The IBAN does not have the correct format": "El IBAN no tiene el formato correcto", - "That payment method requires an IBAN": "El método de pago seleccionado requiere un IBAN", - "That payment method requires a BIC": "El método de pago seleccionado requiere un BIC", - "State cannot be blank": "El estado no puede estar en blanco", - "Worker cannot be blank": "El trabajador no puede estar en blanco", - "Cannot change the payment method if no salesperson": "No se puede cambiar la forma de pago si no hay comercial asignado", - "can't be blank": "El campo no puede estar vacío", - "Observation type must be unique": "El tipo de observación no puede repetirse", - "The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero", - "The grade must be similar to the last one": "El grade debe ser similar al último", - "Only manager can change the credit": "Solo el gerente puede cambiar el credito de este cliente", - "Name cannot be blank": "El nombre no puede estar en blanco", - "Phone cannot be blank": "El teléfono no puede estar en blanco", - "Period cannot be blank": "El periodo no puede estar en blanco", - "Choose a company": "Selecciona una empresa", - "Se debe rellenar el campo de texto": "Se debe rellenar el campo de texto", - "Description should have maximum of 45 characters": "La descripción debe tener maximo 45 caracteres", - "Cannot be blank": "El campo no puede estar en blanco", - "The grade must be an integer greater than or equal to zero": "El grade debe ser un entero mayor o igual a cero", - "Sample type cannot be blank": "El tipo de plantilla no puede quedar en blanco", - "Description cannot be blank": "Se debe rellenar el campo de texto", - "The price of the item changed": "El precio del artículo cambió", - "The value should not be greater than 100%": "El valor no debe de ser mayor de 100%", - "The value should be a number": "El valor debe ser un numero", - "This order is not editable": "Esta orden no se puede modificar", - "You can't create an order for a frozen client": "No puedes crear una orden para un cliente congelado", - "You can't create an order for a client that has a debt": "No puedes crear una orden para un cliente con deuda", - "is not a valid date": "No es una fecha valida", - "Barcode must be unique": "El código de barras debe ser único", - "The warehouse can't be repeated": "El almacén no puede repetirse", - "The tag or priority can't be repeated for an item": "El tag o prioridad no puede repetirse para un item", - "The observation type can't be repeated": "El tipo de observación no puede repetirse", - "A claim with that sale already exists": "Ya existe una reclamación para esta línea", - "You don't have enough privileges to change that field": "No tienes permisos para cambiar ese campo", - "Warehouse cannot be blank": "El almacén no puede quedar en blanco", - "Agency cannot be blank": "La agencia no puede quedar en blanco", - "Not enough privileges to edit a client with verified data": "No tienes permisos para hacer cambios en un cliente con datos comprobados", - "This address doesn't exist": "Este consignatario no existe", - "You must delete the claim id %d first": "Antes debes borrar la reclamación %d", - "You don't have enough privileges": "No tienes suficientes permisos", - "Cannot check Equalization Tax in this NIF/CIF": "No se puede marcar RE en este NIF/CIF", - "You can't make changes on the basic data of an confirmed order or with rows": "No puedes cambiar los datos básicos de una orden con artículos", - "INVALID_USER_NAME": "El nombre de usuario solo debe contener letras minúsculas o, a partir del segundo carácter, números o subguiones, no está permitido el uso de la letra ñ", - "You can't create a ticket for a frozen client": "No puedes crear un ticket para un cliente congelado", - "You can't create a ticket for an inactive client": "No puedes crear un ticket para un cliente inactivo", - "Tag value cannot be blank": "El valor del tag no puede quedar en blanco", - "ORDER_EMPTY": "Cesta vacía", - "You don't have enough privileges to do that": "No tienes permisos para cambiar esto", - "NO SE PUEDE DESACTIVAR EL CONSIGNAT": "NO SE PUEDE DESACTIVAR EL CONSIGNAT", - "Error. El NIF/CIF está repetido": "Error. El NIF/CIF está repetido", - "Street cannot be empty": "Dirección no puede estar en blanco", - "City cannot be empty": "Ciudad no puede estar en blanco", - "Code cannot be blank": "Código no puede estar en blanco", - "You cannot remove this department": "No puedes eliminar este departamento", - "The extension must be unique": "La extensión debe ser unica", - "The secret can't be blank": "La contraseña no puede estar en blanco", - "We weren't able to send this SMS": "No hemos podido enviar el SMS", - "This client can't be invoiced": "Este cliente no puede ser facturado", - "You must provide the correction information to generate a corrective invoice": "Debes informar la información de corrección para generar una factura rectificativa", - "This ticket can't be invoiced": "Este ticket no puede ser facturado", - "You cannot add or modify services to an invoiced ticket": "No puedes añadir o modificar servicios a un ticket facturado", - "This ticket can not be modified": "Este ticket no puede ser modificado", - "The introduced hour already exists": "Esta hora ya ha sido introducida", - "INFINITE_LOOP": "Existe una dependencia entre dos Jefes", - "The sales of the receiver ticket can't be modified": "Las lineas del ticket al que envias no pueden ser modificadas", - "NO_AGENCY_AVAILABLE": "No hay una zona de reparto disponible con estos parámetros", - "ERROR_PAST_SHIPMENT": "No puedes seleccionar una fecha de envío en pasado", - "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", - "The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)", - "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", - "This item doesn't exists": "El artículo no existe", - "NOT_ZONE_WITH_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada", - "Extension format is invalid": "El formato de la extensión es inválido", - "Invalid parameters to create a new ticket": "Parámetros inválidos para crear un nuevo ticket", - "This item is not available": "Este artículo no está disponible", - "This postcode already exists": "Este código postal ya existe", - "Concept cannot be blank": "El concepto no puede quedar en blanco", - "File doesn't exists": "El archivo no existe", - "You don't have privileges to change the zone": "No tienes permisos para cambiar la zona o para esos parámetros hay más de una opción de envío, hable con las agencias", - "This ticket is already on weekly tickets": "Este ticket ya está en tickets programados", - "Ticket id cannot be blank": "El id de ticket no puede quedar en blanco", - "Weekday cannot be blank": "El día de la semana no puede quedar en blanco", - "You can't delete a confirmed order": "No puedes borrar un pedido confirmado", - "The social name has an invalid format": "El nombre fiscal tiene un formato incorrecto", - "Invalid quantity": "Cantidad invalida", - "This postal code is not valid": "Este código postal no es válido", - "is invalid": "es inválido", - "The postcode doesn't exist. Please enter a correct one": "El código postal no existe. Por favor, introduce uno correcto", - "The department name can't be repeated": "El nombre del departamento no puede repetirse", - "This phone already exists": "Este teléfono ya existe", - "You cannot move a parent to its own sons": "No puedes mover un elemento padre a uno de sus hijos", - "You can't create a claim for a removed ticket": "No puedes crear una reclamación para un ticket eliminado", - "You cannot delete a ticket that part of it is being prepared": "No puedes eliminar un ticket en el que una parte que está siendo preparada", - "You must delete all the buy requests first": "Debes eliminar todas las peticiones de compra primero", - "You should specify a date": "Debes especificar una fecha", - "You should specify at least a start or end date": "Debes especificar al menos una fecha de inicio o de fin", - "Start date should be lower than end date": "La fecha de inicio debe ser menor que la fecha de fin", - "You should mark at least one week day": "Debes marcar al menos un día de la semana", - "Swift / BIC can't be empty": "Swift / BIC no puede estar vacío", - "Customs agent is required for a non UEE member": "El agente de aduanas es requerido para los clientes extracomunitarios", - "Incoterms is required for a non UEE member": "El incoterms es requerido para los clientes extracomunitarios", - "Deleted sales from ticket": "He eliminado las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", - "Added sale to ticket": "He añadido la siguiente linea al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", - "Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale quantity": "He cambiado la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* del ticket [{{ticketId}}]({{{ticketUrl}}})", - "State": "Estado", - "regular": "normal", - "reserved": "reservado", - "Changed sale reserved state": "He cambiado el estado reservado de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Bought units from buy request": "Se ha comprado {{quantity}} unidades de [{{itemId}} {{concept}}]({{{urlItem}}}) para el ticket id [{{ticketId}}]({{{url}}})", - "Deny buy request": "Se ha rechazado la petición de compra para el ticket id [{{ticketId}}]({{{url}}}). Motivo: {{observation}}", - "MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} ({{clientId}})]({{{url}}}) a *{{credit}} €*", - "Changed client paymethod": "He cambiado la forma de pago del cliente [{{clientName}} ({{clientId}})]({{{url}}})", - "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} ({{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})", - "Change quantity": "{{concept}} cambia de {{oldQuantity}} a {{newQuantity}}", - "Claim will be picked": "Se recogerá el género de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*", - "Claim state has changed to": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *{{newState}}*", - "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", - "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", - "Distance must be lesser than 4000": "La distancia debe ser inferior a 4000", - "This ticket is deleted": "Este ticket está eliminado", - "Unable to clone this travel": "No ha sido posible clonar este travel", - "This thermograph id already exists": "La id del termógrafo ya existe", - "Choose a date range or days forward": "Selecciona un rango de fechas o días en adelante", - "ORDER_ALREADY_CONFIRMED": "ORDEN YA CONFIRMADA", - "Invalid password": "Invalid password", - "Password does not meet requirements": "La contraseña no cumple los requisitos", - "Role already assigned": "Rol ya asignado", - "Invalid role name": "Nombre de rol no válido", - "Role name must be written in camelCase": "El nombre del rol debe escribirse en camelCase", - "Email already exists": "El correo ya existe", - "User already exists": "El/La usuario/a ya existe", - "Absence change notification on the labour calendar": "Notificación de cambio de ausencia en el calendario laboral", - "Record of hours week": "Registro de horas semana {{week}} año {{year}} ", - "Created absence": "El empleado {{author}} ha añadido una ausencia de tipo '{{absenceType}}' a {{employee}} para el día {{dated}}.", - "Deleted absence": "El empleado {{author}} ha eliminado una ausencia de tipo '{{absenceType}}' a {{employee}} del día {{dated}}.", - "I have deleted the ticket id": "He eliminado el ticket id [{{id}}]({{{url}}})", - "I have restored the ticket id": "He restaurado el ticket id [{{id}}]({{{url}}})", - "You can only restore a ticket within the first hour after deletion": "Únicamente puedes restaurar el ticket dentro de la primera hora después de su eliminación", - "Changed this data from the ticket": "He cambiado estos datos del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "agencyModeFk": "Agencia", - "clientFk": "Cliente", - "zoneFk": "Zona", - "warehouseFk": "Almacén", - "shipped": "F. envío", - "landed": "F. entrega", - "addressFk": "Consignatario", - "companyFk": "Empresa", - "The social name cannot be empty": "La razón social no puede quedar en blanco", - "The nif cannot be empty": "El NIF no puede quedar en blanco", - "You need to fill sage information before you check verified data": "Debes rellenar la información de sage antes de marcar datos comprobados", - "ASSIGN_ZONE_FIRST": "Asigna una zona primero", - "Amount cannot be zero": "El importe no puede ser cero", - "Company has to be official": "Empresa inválida", - "You can not select this payment method without a registered bankery account": "No se puede utilizar este método de pago si no has registrado una cuenta bancaria", - "Action not allowed on the test environment": "Esta acción no está permitida en el entorno de pruebas", - "The selected ticket is not suitable for this route": "El ticket seleccionado no es apto para esta ruta", - "New ticket request has been created with price": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}* y un precio de *{{price}} €*", - "New ticket request has been created": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}*", - "Swift / BIC cannot be empty": "Swift / BIC no puede estar vacío", - "This BIC already exist.": "Este BIC ya existe.", - "That item doesn't exists": "Ese artículo no existe", - "There's a new urgent ticket:": "Hay un nuevo ticket urgente:", - "Invalid account": "Cuenta inválida", - "Compensation account is empty": "La cuenta para compensar está vacia", - "This genus already exist": "Este genus ya existe", - "This specie already exist": "Esta especie ya existe", - "Client assignment has changed": "He cambiado el comercial ~*\"<{{previousWorkerName}}>\"*~ por *\"<{{currentWorkerName}}>\"* del cliente [{{clientName}} ({{clientId}})]({{{url}}})", - "None": "Ninguno", - "The contract was not active during the selected date": "El contrato no estaba activo durante la fecha seleccionada", - "Cannot add more than one '1/2 day vacation'": "No puedes añadir más de un 'Vacaciones 1/2 dia'", - "This document already exists on this ticket": "Este documento ya existe en el ticket", - "Some of the selected tickets are not billable": "Algunos de los tickets seleccionados no son facturables", - "You can't invoice tickets from multiple clients": "No puedes facturar tickets de multiples clientes", - "nickname": "nickname", - "INACTIVE_PROVIDER": "Proveedor inactivo", - "This client is not invoiceable": "Este cliente no es facturable", - "serial non editable": "Esta serie no permite asignar la referencia", - "Max shipped required": "La fecha límite es requerida", - "Can't invoice to future": "No se puede facturar a futuro", - "Can't invoice to past": "No se puede facturar a pasado", - "This ticket is already invoiced": "Este ticket ya está facturado", - "A ticket with an amount of zero can't be invoiced": "No se puede facturar un ticket con importe cero", - "A ticket with a negative base can't be invoiced": "No se puede facturar un ticket con una base negativa", - "Global invoicing failed": "[Facturación global] No se han podido facturar algunos clientes", - "Wasn't able to invoice the following clients": "No se han podido facturar los siguientes clientes", - "Can't verify data unless the client has a business type": "No se puede verificar datos de un cliente que no tiene tipo de negocio", - "You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito", - "You can't change the credit set to zero from a financialBoss": "No puedes cambiar el cŕedito establecido a cero por un jefe de finanzas", - "Amounts do not match": "Las cantidades no coinciden", - "The PDF document does not exist": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'", - "The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos", - "You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días", - "The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día", - "The worker has a marked absence that day": "El trabajador tiene marcada una ausencia ese día", - "You can not modify is pay method checked": "No se puede modificar el campo método de pago validado", - "The account size must be exactly 10 characters": "El tamaño de la cuenta debe ser exactamente de 10 caracteres", - "Can't transfer claimed sales": "No puedes transferir lineas reclamadas", - "You don't have privileges to create refund": "No tienes permisos para crear un abono", - "The item is required": "El artículo es requerido", - "The agency is already assigned to another autonomous": "La agencia ya está asignada a otro autónomo", - "date in the future": "Fecha en el futuro", - "reference duplicated": "Referencia duplicada", - "This ticket is already a refund": "Este ticket ya es un abono", - "isWithoutNegatives": "Sin negativos", - "routeFk": "routeFk", - "Can't change the password of another worker": "No se puede cambiar la contraseña de otro trabajador", - "No hay un contrato en vigor": "No hay un contrato en vigor", - "No se permite fichar a futuro": "No se permite fichar a futuro", - "No está permitido trabajar": "No está permitido trabajar", - "Fichadas impares": "Fichadas impares", - "Descanso diario 12h.": "Descanso diario 12h.", - "Descanso semanal 36h. / 72h.": "Descanso semanal 36h. / 72h.", - "Dirección incorrecta": "Dirección incorrecta", - "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador", - "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador", - "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", - "This route does not exists": "Esta ruta no existe", - "Claim pickup order sent": "Reclamación Orden de recogida enviada [{{claimId}}]({{{claimUrl}}}) al cliente *{{clientName}}*", - "You don't have grant privilege": "No tienes privilegios para dar privilegios", - "You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario", - "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) fusionado con [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})", - "Already has this status": "Ya tiene este estado", - "There aren't records for this week": "No existen registros para esta semana", - "Empty data source": "Origen de datos vacio", - "App locked": "Aplicación bloqueada por el usuario {{userId}}", - "Email verify": "Correo de verificación", - "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment", - "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", - "Negative basis": "Base negativa", - "This worker code already exists": "Este codigo de trabajador ya existe", - "This personal mail already exists": "Este correo personal ya existe", - "This worker already exists": "Este trabajador ya existe", - "App name does not exist": "El nombre de aplicación no es válido", - "Try again": "Vuelve a intentarlo", - "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9", - "Failed to upload delivery note": "Error al subir albarán {{id}}", - "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 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", - "A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.", - "There is no assigned email for this client": "No hay correo asignado para este cliente", - "Exists an invoice with a future date": "Existe una factura con fecha posterior", - "Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite", - "Warehouse inventory not set": "El almacén inventario no está establecido", - "This locker has already been assigned": "Esta taquilla ya ha sido asignada", - "Tickets with associated refunds": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº %d", - "Not exist this branch": "La rama no existe", - "This ticket cannot be signed because it has not been boxed": "Este ticket no puede firmarse porque no ha sido encajado", - "Collection does not exist": "La colección no existe", - "Cannot obtain exclusive lock": "No se puede obtener un bloqueo exclusivo", - "Insert a date range": "Inserte un rango de fechas", - "Added observation": "{{user}} añadió esta observacion: {{text}}", - "Comment added to client": "Observación añadida al cliente {{clientFk}}", - "Invalid auth code": "Código de verificación incorrecto", - "Invalid or expired verification code": "Código de verificación incorrecto o expirado", - "Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen", - "company": "Compañía", - "country": "País", - "clientId": "Id cliente", - "clientSocialName": "Cliente", - "amount": "Importe", - "taxableBase": "Base", - "ticketFk": "Id ticket", - "isActive": "Activo", - "hasToInvoice": "Facturar", - "isTaxDataChecked": "Datos comprobados", - "comercialId": "Id comercial", - "comercialName": "Comercial", - "Pass expired": "La contraseña ha caducado, cambiela desde Salix", - "Invalid NIF for VIES": "Invalid NIF for VIES", - "Ticket does not exist": "Este ticket no existe", - "Ticket is already signed": "Este ticket ya ha sido firmado", - "Authentication failed": "Autenticación fallida", - "You can't use the same password": "No puedes usar la misma contraseña", - "You can only add negative amounts in refund tickets": "Solo se puede añadir cantidades negativas en tickets abono", - "Fecha fuera de rango": "Fecha fuera de rango", - "Error while generating PDF": "Error al generar PDF", - "Error when sending mail to client": "Error al enviar el correo al cliente", - "Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico", - "The renew period has not been exceeded": "El periodo de renovación no ha sido superado", - "Valid priorities": "Prioridades válidas: %d", - "hasAnyNegativeBase": "Base negativa para los tickets: {{ticketsIds}}", - "hasAnyPositiveBase": "Base positivas para los tickets: {{ticketsIds}}", - "You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado", - "This ticket cannot be left empty.": "Este ticket no se puede dejar vacío. %s", - "The company has not informed the supplier account for bank transfers": "La empresa no tiene informado la cuenta de proveedor para transferencias bancarias", - "You cannot assign/remove an alias that you are not assigned to": "No puede asignar/eliminar un alias que no tenga asignado", - "This invoice has a linked vehicle.": "Esta factura tiene un vehiculo vinculado", - "You don't have enough privileges.": "No tienes suficientes permisos.", - "This ticket is locked": "Este ticket está bloqueado.", - "This ticket is not editable.": "Este ticket no es editable.", - "The ticket doesn't exist.": "No existe el ticket.", - "Social name should be uppercase": "La razón social debe ir en mayúscula", - "Street should be uppercase": "La dirección fiscal debe ir en mayúscula", - "Ticket without Route": "Ticket sin ruta", - "Select a different client": "Seleccione un cliente distinto", - "Fill all the fields": "Rellene todos los campos", - "The response is not a PDF": "La respuesta no es un PDF", - "Booking completed": "Reserva completada", - "The ticket is in preparation": "El ticket [{{ticketId}}]({{{ticketUrl}}}) del comercial {{salesPersonId}} está en preparación", - "The notification subscription of this worker cant be modified": "La subscripción a la notificación de este trabajador no puede ser modificada", - "User disabled": "Usuario desactivado", - "The amount cannot be less than the minimum": "La cantidad no puede ser menor que la cantidad mínima", - "quantityLessThanMin": "La cantidad no puede ser menor que la cantidad mínima", - "Cannot past travels with entries": "No se pueden pasar envíos con entradas", - "It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}", - "This claim has been updated": "La reclamación con Id: {{claimId}}, ha sido actualizada", - "This user does not have an assigned tablet": "Este usuario no tiene tablet asignada", - "Field are invalid": "El campo '{{tag}}' no es válido", - "Incorrect pin": "Pin incorrecto.", - "You already have the mailAlias": "Ya tienes este alias de correo", - "The alias cant be modified": "Este alias de correo no puede ser modificado", - "No tickets to invoice": "No hay tickets para facturar", - "this warehouse has not dms": "El Almacén no acepta documentos", - "This ticket already has a cmr saved": "Este ticket ya tiene un cmr guardado", - "Name should be uppercase": "El nombre debe ir en mayúscula", - "Bank entity must be specified": "La entidad bancaria es obligatoria", - "An email is necessary": "Es necesario un email", - "You cannot update these fields": "No puedes actualizar estos campos", - "CountryFK cannot be empty": "El país no puede estar vacío", - "Cmr file does not exist": "El archivo del cmr no existe", - "You are not allowed to modify the alias": "No estás autorizado a modificar el alias", - "The address of the customer must have information about Incoterms and Customs Agent": "El consignatario del cliente debe tener informado Incoterms y Agente de aduanas" + "Phone format is invalid": "El formato del teléfono no es correcto", + "You are not allowed to change the credit": "No tienes privilegios para modificar el crédito", + "Unable to mark the equivalence surcharge": "No se puede marcar el recargo de equivalencia", + "The default consignee can not be unchecked": "No se puede desmarcar el consignatario predeterminado", + "Unable to default a disabled consignee": "No se puede poner predeterminado un consignatario desactivado", + "Can't be blank": "No puede estar en blanco", + "Invalid TIN": "NIF/CIF inválido", + "TIN must be unique": "El NIF/CIF debe ser único", + "A client with that Web User name already exists": "Ya existe un cliente con ese Usuario Web", + "Is invalid": "Es inválido", + "Quantity cannot be zero": "La cantidad no puede ser cero", + "Enter an integer different to zero": "Introduce un entero distinto de cero", + "Package cannot be blank": "El embalaje no puede estar en blanco", + "The company name must be unique": "La razón social debe ser única", + "Invalid email": "Correo electrónico inválido", + "The IBAN does not have the correct format": "El IBAN no tiene el formato correcto", + "That payment method requires an IBAN": "El método de pago seleccionado requiere un IBAN", + "That payment method requires a BIC": "El método de pago seleccionado requiere un BIC", + "State cannot be blank": "El estado no puede estar en blanco", + "Worker cannot be blank": "El trabajador no puede estar en blanco", + "Cannot change the payment method if no salesperson": "No se puede cambiar la forma de pago si no hay comercial asignado", + "can't be blank": "El campo no puede estar vacío", + "Observation type must be unique": "El tipo de observación no puede repetirse", + "The credit must be an integer greater than or equal to zero": "The credit must be an integer greater than or equal to zero", + "The grade must be similar to the last one": "El grade debe ser similar al último", + "Only manager can change the credit": "Solo el gerente puede cambiar el credito de este cliente", + "Name cannot be blank": "El nombre no puede estar en blanco", + "Phone cannot be blank": "El teléfono no puede estar en blanco", + "Period cannot be blank": "El periodo no puede estar en blanco", + "Choose a company": "Selecciona una empresa", + "Se debe rellenar el campo de texto": "Se debe rellenar el campo de texto", + "Description should have maximum of 45 characters": "La descripción debe tener maximo 45 caracteres", + "Cannot be blank": "El campo no puede estar en blanco", + "The grade must be an integer greater than or equal to zero": "El grade debe ser un entero mayor o igual a cero", + "Sample type cannot be blank": "El tipo de plantilla no puede quedar en blanco", + "Description cannot be blank": "Se debe rellenar el campo de texto", + "The price of the item changed": "El precio del artículo cambió", + "The value should not be greater than 100%": "El valor no debe de ser mayor de 100%", + "The value should be a number": "El valor debe ser un numero", + "This order is not editable": "Esta orden no se puede modificar", + "You can't create an order for a frozen client": "No puedes crear una orden para un cliente congelado", + "You can't create an order for a client that has a debt": "No puedes crear una orden para un cliente con deuda", + "is not a valid date": "No es una fecha valida", + "Barcode must be unique": "El código de barras debe ser único", + "The warehouse can't be repeated": "El almacén no puede repetirse", + "The tag or priority can't be repeated for an item": "El tag o prioridad no puede repetirse para un item", + "The observation type can't be repeated": "El tipo de observación no puede repetirse", + "A claim with that sale already exists": "Ya existe una reclamación para esta línea", + "You don't have enough privileges to change that field": "No tienes permisos para cambiar ese campo", + "Warehouse cannot be blank": "El almacén no puede quedar en blanco", + "Agency cannot be blank": "La agencia no puede quedar en blanco", + "Not enough privileges to edit a client with verified data": "No tienes permisos para hacer cambios en un cliente con datos comprobados", + "This address doesn't exist": "Este consignatario no existe", + "You must delete the claim id %d first": "Antes debes borrar la reclamación %d", + "You don't have enough privileges": "No tienes suficientes permisos", + "Cannot check Equalization Tax in this NIF/CIF": "No se puede marcar RE en este NIF/CIF", + "You can't make changes on the basic data of an confirmed order or with rows": "No puedes cambiar los datos básicos de una orden con artículos", + "INVALID_USER_NAME": "El nombre de usuario solo debe contener letras minúsculas o, a partir del segundo carácter, números o subguiones, no está permitido el uso de la letra ñ", + "You can't create a ticket for a frozen client": "No puedes crear un ticket para un cliente congelado", + "You can't create a ticket for an inactive client": "No puedes crear un ticket para un cliente inactivo", + "Tag value cannot be blank": "El valor del tag no puede quedar en blanco", + "ORDER_EMPTY": "Cesta vacía", + "You don't have enough privileges to do that": "No tienes permisos para cambiar esto", + "NO SE PUEDE DESACTIVAR EL CONSIGNAT": "NO SE PUEDE DESACTIVAR EL CONSIGNAT", + "Error. El NIF/CIF está repetido": "Error. El NIF/CIF está repetido", + "Street cannot be empty": "Dirección no puede estar en blanco", + "City cannot be empty": "Ciudad no puede estar en blanco", + "Code cannot be blank": "Código no puede estar en blanco", + "You cannot remove this department": "No puedes eliminar este departamento", + "The extension must be unique": "La extensión debe ser unica", + "The secret can't be blank": "La contraseña no puede estar en blanco", + "We weren't able to send this SMS": "No hemos podido enviar el SMS", + "This client can't be invoiced": "Este cliente no puede ser facturado", + "You must provide the correction information to generate a corrective invoice": "Debes informar la información de corrección para generar una factura rectificativa", + "This ticket can't be invoiced": "Este ticket no puede ser facturado", + "You cannot add or modify services to an invoiced ticket": "No puedes añadir o modificar servicios a un ticket facturado", + "This ticket can not be modified": "Este ticket no puede ser modificado", + "The introduced hour already exists": "Esta hora ya ha sido introducida", + "INFINITE_LOOP": "Existe una dependencia entre dos Jefes", + "The sales of the receiver ticket can't be modified": "Las lineas del ticket al que envias no pueden ser modificadas", + "NO_AGENCY_AVAILABLE": "No hay una zona de reparto disponible con estos parámetros", + "ERROR_PAST_SHIPMENT": "No puedes seleccionar una fecha de envío en pasado", + "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", + "The sales do not exists": "La(s) línea(s) seleccionada(s) no existe(n)", + "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", + "This item doesn't exists": "El artículo no existe", + "NOT_ZONE_WITH_THIS_PARAMETERS": "Para este día no hay ninguna zona configurada", + "Extension format is invalid": "El formato de la extensión es inválido", + "Invalid parameters to create a new ticket": "Parámetros inválidos para crear un nuevo ticket", + "This item is not available": "Este artículo no está disponible", + "This postcode already exists": "Este código postal ya existe", + "Concept cannot be blank": "El concepto no puede quedar en blanco", + "File doesn't exists": "El archivo no existe", + "You don't have privileges to change the zone": "No tienes permisos para cambiar la zona o para esos parámetros hay más de una opción de envío, hable con las agencias", + "This ticket is already on weekly tickets": "Este ticket ya está en tickets programados", + "Ticket id cannot be blank": "El id de ticket no puede quedar en blanco", + "Weekday cannot be blank": "El día de la semana no puede quedar en blanco", + "You can't delete a confirmed order": "No puedes borrar un pedido confirmado", + "The social name has an invalid format": "El nombre fiscal tiene un formato incorrecto", + "Invalid quantity": "Cantidad invalida", + "This postal code is not valid": "Este código postal no es válido", + "is invalid": "es inválido", + "The postcode doesn't exist. Please enter a correct one": "El código postal no existe. Por favor, introduce uno correcto", + "The department name can't be repeated": "El nombre del departamento no puede repetirse", + "This phone already exists": "Este teléfono ya existe", + "You cannot move a parent to its own sons": "No puedes mover un elemento padre a uno de sus hijos", + "You can't create a claim for a removed ticket": "No puedes crear una reclamación para un ticket eliminado", + "You cannot delete a ticket that part of it is being prepared": "No puedes eliminar un ticket en el que una parte que está siendo preparada", + "You must delete all the buy requests first": "Debes eliminar todas las peticiones de compra primero", + "You should specify a date": "Debes especificar una fecha", + "You should specify at least a start or end date": "Debes especificar al menos una fecha de inicio o de fin", + "Start date should be lower than end date": "La fecha de inicio debe ser menor que la fecha de fin", + "You should mark at least one week day": "Debes marcar al menos un día de la semana", + "Swift / BIC can't be empty": "Swift / BIC no puede estar vacío", + "Customs agent is required for a non UEE member": "El agente de aduanas es requerido para los clientes extracomunitarios", + "Incoterms is required for a non UEE member": "El incoterms es requerido para los clientes extracomunitarios", + "Deleted sales from ticket": "He eliminado las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", + "Added sale to ticket": "He añadido la siguiente linea al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", + "Changed sale discount": "He cambiado el descuento de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Created claim": "He creado la reclamación [{{claimId}}]({{{claimUrl}}}) de las siguientes lineas del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Changed sale price": "He cambiado el precio de [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) de {{oldPrice}}€ ➔ *{{newPrice}}€* del ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale quantity": "He cambiado la cantidad de [{{itemId}} {{concept}}]({{{itemUrl}}}) de {{oldQuantity}} ➔ *{{newQuantity}}* del ticket [{{ticketId}}]({{{ticketUrl}}})", + "State": "Estado", + "regular": "normal", + "reserved": "reservado", + "Changed sale reserved state": "He cambiado el estado reservado de las siguientes lineas al ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Bought units from buy request": "Se ha comprado {{quantity}} unidades de [{{itemId}} {{concept}}]({{{urlItem}}}) para el ticket id [{{ticketId}}]({{{url}}})", + "Deny buy request": "Se ha rechazado la petición de compra para el ticket id [{{ticketId}}]({{{url}}}). Motivo: {{observation}}", + "MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} ({{clientId}})]({{{url}}}) a *{{credit}} €*", + "Changed client paymethod": "He cambiado la forma de pago del cliente [{{clientName}} ({{clientId}})]({{{url}}})", + "Sent units from ticket": "Envio *{{quantity}}* unidades de [{{concept}} ({{itemId}})]({{{itemUrl}}}) a *\"{{nickname}}\"* provenientes del ticket id [{{ticketId}}]({{{ticketUrl}}})", + "Change quantity": "{{concept}} cambia de {{oldQuantity}} a {{newQuantity}}", + "Claim will be picked": "Se recogerá el género de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}*", + "Claim state has changed to": "Se ha cambiado el estado de la reclamación [({{claimId}})]({{{claimUrl}}}) del cliente *{{clientName}}* a *{{newState}}*", + "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}", + "ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto", + "Distance must be lesser than 4000": "La distancia debe ser inferior a 4000", + "This ticket is deleted": "Este ticket está eliminado", + "Unable to clone this travel": "No ha sido posible clonar este travel", + "This thermograph id already exists": "La id del termógrafo ya existe", + "Choose a date range or days forward": "Selecciona un rango de fechas o días en adelante", + "ORDER_ALREADY_CONFIRMED": "ORDEN YA CONFIRMADA", + "Invalid password": "Invalid password", + "Password does not meet requirements": "La contraseña no cumple los requisitos", + "Role already assigned": "Rol ya asignado", + "Invalid role name": "Nombre de rol no válido", + "Role name must be written in camelCase": "El nombre del rol debe escribirse en camelCase", + "Email already exists": "El correo ya existe", + "User already exists": "El/La usuario/a ya existe", + "Absence change notification on the labour calendar": "Notificación de cambio de ausencia en el calendario laboral", + "Record of hours week": "Registro de horas semana {{week}} año {{year}} ", + "Created absence": "El empleado {{author}} ha añadido una ausencia de tipo '{{absenceType}}' a {{employee}} para el día {{dated}}.", + "Deleted absence": "El empleado {{author}} ha eliminado una ausencia de tipo '{{absenceType}}' a {{employee}} del día {{dated}}.", + "I have deleted the ticket id": "He eliminado el ticket id [{{id}}]({{{url}}})", + "I have restored the ticket id": "He restaurado el ticket id [{{id}}]({{{url}}})", + "You can only restore a ticket within the first hour after deletion": "Únicamente puedes restaurar el ticket dentro de la primera hora después de su eliminación", + "Changed this data from the ticket": "He cambiado estos datos del ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "agencyModeFk": "Agencia", + "clientFk": "Cliente", + "zoneFk": "Zona", + "warehouseFk": "Almacén", + "shipped": "F. envío", + "landed": "F. entrega", + "addressFk": "Consignatario", + "companyFk": "Empresa", + "The social name cannot be empty": "La razón social no puede quedar en blanco", + "The nif cannot be empty": "El NIF no puede quedar en blanco", + "You need to fill sage information before you check verified data": "Debes rellenar la información de sage antes de marcar datos comprobados", + "ASSIGN_ZONE_FIRST": "Asigna una zona primero", + "Amount cannot be zero": "El importe no puede ser cero", + "Company has to be official": "Empresa inválida", + "You can not select this payment method without a registered bankery account": "No se puede utilizar este método de pago si no has registrado una cuenta bancaria", + "Action not allowed on the test environment": "Esta acción no está permitida en el entorno de pruebas", + "The selected ticket is not suitable for this route": "El ticket seleccionado no es apto para esta ruta", + "New ticket request has been created with price": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}* y un precio de *{{price}} €*", + "New ticket request has been created": "Se ha creado una nueva petición de compra '{{description}}' para el día *{{shipped}}*, con una cantidad de *{{quantity}}*", + "Swift / BIC cannot be empty": "Swift / BIC no puede estar vacío", + "This BIC already exist.": "Este BIC ya existe.", + "That item doesn't exists": "Ese artículo no existe", + "There's a new urgent ticket:": "Hay un nuevo ticket urgente:", + "Invalid account": "Cuenta inválida", + "Compensation account is empty": "La cuenta para compensar está vacia", + "This genus already exist": "Este genus ya existe", + "This specie already exist": "Esta especie ya existe", + "Client assignment has changed": "He cambiado el comercial ~*\"<{{previousWorkerName}}>\"*~ por *\"<{{currentWorkerName}}>\"* del cliente [{{clientName}} ({{clientId}})]({{{url}}})", + "None": "Ninguno", + "The contract was not active during the selected date": "El contrato no estaba activo durante la fecha seleccionada", + "Cannot add more than one '1/2 day vacation'": "No puedes añadir más de un 'Vacaciones 1/2 dia'", + "This document already exists on this ticket": "Este documento ya existe en el ticket", + "Some of the selected tickets are not billable": "Algunos de los tickets seleccionados no son facturables", + "You can't invoice tickets from multiple clients": "No puedes facturar tickets de multiples clientes", + "nickname": "nickname", + "INACTIVE_PROVIDER": "Proveedor inactivo", + "This client is not invoiceable": "Este cliente no es facturable", + "serial non editable": "Esta serie no permite asignar la referencia", + "Max shipped required": "La fecha límite es requerida", + "Can't invoice to future": "No se puede facturar a futuro", + "Can't invoice to past": "No se puede facturar a pasado", + "This ticket is already invoiced": "Este ticket ya está facturado", + "A ticket with an amount of zero can't be invoiced": "No se puede facturar un ticket con importe cero", + "A ticket with a negative base can't be invoiced": "No se puede facturar un ticket con una base negativa", + "Global invoicing failed": "[Facturación global] No se han podido facturar algunos clientes", + "Wasn't able to invoice the following clients": "No se han podido facturar los siguientes clientes", + "Can't verify data unless the client has a business type": "No se puede verificar datos de un cliente que no tiene tipo de negocio", + "You don't have enough privileges to set this credit amount": "No tienes suficientes privilegios para establecer esta cantidad de crédito", + "You can't change the credit set to zero from a financialBoss": "No puedes cambiar el cŕedito establecido a cero por un jefe de finanzas", + "Amounts do not match": "Las cantidades no coinciden", + "The PDF document does not exist": "El documento PDF no existe. Prueba a regenerarlo desde la opción 'Regenerar PDF factura'", + "The type of business must be filled in basic data": "El tipo de negocio debe estar rellenado en datos básicos", + "You can't create a claim from a ticket delivered more than seven days ago": "No puedes crear una reclamación de un ticket entregado hace más de siete días", + "The worker has hours recorded that day": "El trabajador tiene horas fichadas ese día", + "The worker has a marked absence that day": "El trabajador tiene marcada una ausencia ese día", + "You can not modify is pay method checked": "No se puede modificar el campo método de pago validado", + "The account size must be exactly 10 characters": "El tamaño de la cuenta debe ser exactamente de 10 caracteres", + "Can't transfer claimed sales": "No puedes transferir lineas reclamadas", + "You don't have privileges to create refund": "No tienes permisos para crear un abono", + "The item is required": "El artículo es requerido", + "The agency is already assigned to another autonomous": "La agencia ya está asignada a otro autónomo", + "date in the future": "Fecha en el futuro", + "reference duplicated": "Referencia duplicada", + "This ticket is already a refund": "Este ticket ya es un abono", + "isWithoutNegatives": "Sin negativos", + "routeFk": "routeFk", + "Can't change the password of another worker": "No se puede cambiar la contraseña de otro trabajador", + "No hay un contrato en vigor": "No hay un contrato en vigor", + "No se permite fichar a futuro": "No se permite fichar a futuro", + "No está permitido trabajar": "No está permitido trabajar", + "Fichadas impares": "Fichadas impares", + "Descanso diario 12h.": "Descanso diario 12h.", + "Descanso semanal 36h. / 72h.": "Descanso semanal 36h. / 72h.", + "Dirección incorrecta": "Dirección incorrecta", + "Modifiable user details only by an administrator": "Detalles de usuario modificables solo por un administrador", + "Modifiable password only via recovery or by an administrator": "Contraseña modificable solo a través de la recuperación o por un administrador", + "Not enough privileges to edit a client": "No tienes suficientes privilegios para editar un cliente", + "This route does not exists": "Esta ruta no existe", + "Claim pickup order sent": "Reclamación Orden de recogida enviada [{{claimId}}]({{{claimUrl}}}) al cliente *{{clientName}}*", + "You don't have grant privilege": "No tienes privilegios para dar privilegios", + "You don't own the role and you can't assign it to another user": "No eres el propietario del rol y no puedes asignarlo a otro usuario", + "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) fusionado con [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})", + "Already has this status": "Ya tiene este estado", + "There aren't records for this week": "No existen registros para esta semana", + "Empty data source": "Origen de datos vacio", + "App locked": "Aplicación bloqueada por el usuario {{userId}}", + "Email verify": "Correo de verificación", + "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment", + "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", + "Negative basis": "Base negativa", + "This worker code already exists": "Este codigo de trabajador ya existe", + "This personal mail already exists": "Este correo personal ya existe", + "This worker already exists": "Este trabajador ya existe", + "App name does not exist": "El nombre de aplicación no es válido", + "Try again": "Vuelve a intentarlo", + "Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9", + "Failed to upload delivery note": "Error al subir albarán {{id}}", + "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 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", + "A supplier with the same name already exists. Change the country.": "Un proveedor con el mismo nombre ya existe. Cambie el país.", + "There is no assigned email for this client": "No hay correo asignado para este cliente", + "Exists an invoice with a future date": "Existe una factura con fecha posterior", + "Invoice date can't be less than max date": "La fecha de factura no puede ser inferior a la fecha límite", + "Warehouse inventory not set": "El almacén inventario no está establecido", + "This locker has already been assigned": "Esta taquilla ya ha sido asignada", + "Tickets with associated refunds": "No se pueden borrar tickets con abonos asociados. Este ticket está asociado al abono Nº %d", + "Not exist this branch": "La rama no existe", + "This ticket cannot be signed because it has not been boxed": "Este ticket no puede firmarse porque no ha sido encajado", + "Collection does not exist": "La colección no existe", + "Cannot obtain exclusive lock": "No se puede obtener un bloqueo exclusivo", + "Insert a date range": "Inserte un rango de fechas", + "Added observation": "{{user}} añadió esta observacion: {{text}}", + "Comment added to client": "Observación añadida al cliente {{clientFk}}", + "Invalid auth code": "Código de verificación incorrecto", + "Invalid or expired verification code": "Código de verificación incorrecto o expirado", + "Cannot create a new claimBeginning from a different ticket": "No se puede crear una línea de reclamación de un ticket diferente al origen", + "company": "Compañía", + "country": "País", + "clientId": "Id cliente", + "clientSocialName": "Cliente", + "amount": "Importe", + "taxableBase": "Base", + "ticketFk": "Id ticket", + "isActive": "Activo", + "hasToInvoice": "Facturar", + "isTaxDataChecked": "Datos comprobados", + "comercialId": "Id comercial", + "comercialName": "Comercial", + "Pass expired": "La contraseña ha caducado, cambiela desde Salix", + "Invalid NIF for VIES": "Invalid NIF for VIES", + "Ticket does not exist": "Este ticket no existe", + "Ticket is already signed": "Este ticket ya ha sido firmado", + "Authentication failed": "Autenticación fallida", + "You can't use the same password": "No puedes usar la misma contraseña", + "You can only add negative amounts in refund tickets": "Solo se puede añadir cantidades negativas en tickets abono", + "Fecha fuera de rango": "Fecha fuera de rango", + "Error while generating PDF": "Error al generar PDF", + "Error when sending mail to client": "Error al enviar el correo al cliente", + "Mail not sent": "Se ha producido un fallo al enviar la factura al cliente [{{clientId}}]({{{clientUrl}}}), por favor revisa la dirección de correo electrónico", + "The renew period has not been exceeded": "El periodo de renovación no ha sido superado", + "Valid priorities": "Prioridades válidas: %d", + "hasAnyNegativeBase": "Base negativa para los tickets: {{ticketsIds}}", + "hasAnyPositiveBase": "Base positivas para los tickets: {{ticketsIds}}", + "You cannot assign an alias that you are not assigned to": "No puede asignar un alias que no tenga asignado", + "This ticket cannot be left empty.": "Este ticket no se puede dejar vacío. %s", + "The company has not informed the supplier account for bank transfers": "La empresa no tiene informado la cuenta de proveedor para transferencias bancarias", + "You cannot assign/remove an alias that you are not assigned to": "No puede asignar/eliminar un alias que no tenga asignado", + "This invoice has a linked vehicle.": "Esta factura tiene un vehiculo vinculado", + "You don't have enough privileges.": "No tienes suficientes permisos.", + "This ticket is locked": "Este ticket está bloqueado.", + "This ticket is not editable.": "Este ticket no es editable.", + "The ticket doesn't exist.": "No existe el ticket.", + "Social name should be uppercase": "La razón social debe ir en mayúscula", + "Street should be uppercase": "La dirección fiscal debe ir en mayúscula", + "Ticket without Route": "Ticket sin ruta", + "Select a different client": "Seleccione un cliente distinto", + "Fill all the fields": "Rellene todos los campos", + "The response is not a PDF": "La respuesta no es un PDF", + "Booking completed": "Reserva completada", + "The ticket is in preparation": "El ticket [{{ticketId}}]({{{ticketUrl}}}) del comercial {{salesPersonId}} está en preparación", + "The notification subscription of this worker cant be modified": "La subscripción a la notificación de este trabajador no puede ser modificada", + "User disabled": "Usuario desactivado", + "The amount cannot be less than the minimum": "La cantidad no puede ser menor que la cantidad mínima", + "quantityLessThanMin": "La cantidad no puede ser menor que la cantidad mínima", + "Cannot past travels with entries": "No se pueden pasar envíos con entradas", + "It was not able to remove the next expeditions:": "No se pudo eliminar las siguientes expediciones: {{expeditions}}", + "This claim has been updated": "La reclamación con Id: {{claimId}}, ha sido actualizada", + "This user does not have an assigned tablet": "Este usuario no tiene tablet asignada", + "Field are invalid": "El campo '{{tag}}' no es válido", + "Incorrect pin": "Pin incorrecto.", + "You already have the mailAlias": "Ya tienes este alias de correo", + "The alias cant be modified": "Este alias de correo no puede ser modificado", + "No tickets to invoice": "No hay tickets para facturar", + "this warehouse has not dms": "El Almacén no acepta documentos", + "This ticket already has a cmr saved": "Este ticket ya tiene un cmr guardado", + "Name should be uppercase": "El nombre debe ir en mayúscula", + "Bank entity must be specified": "La entidad bancaria es obligatoria", + "An email is necessary": "Es necesario un email", + "You cannot update these fields": "No puedes actualizar estos campos", + "CountryFK cannot be empty": "El país no puede estar vacío", + "Cmr file does not exist": "El archivo del cmr no existe", + "You are not allowed to modify the alias": "No estás autorizado a modificar el alias", + "The address of the customer must have information about Incoterms and Customs Agent": "El consignatario del cliente debe tener informado Incoterms y Agente de aduanas", + "PrinterNotInSameSector": "PrinterNotInSameSector" } \ No newline at end of file diff --git a/modules/worker/back/methods/operator/spec/operator.spec.js b/modules/worker/back/methods/operator/spec/operator.spec.js index 016d90a30..6a4a5cff1 100644 --- a/modules/worker/back/methods/operator/spec/operator.spec.js +++ b/modules/worker/back/methods/operator/spec/operator.spec.js @@ -1,99 +1,61 @@ const models = require('vn-loopback/server/server').models; -fdescribe('Operator', () => { +describe('Operator', () => { const authorFk = 9; const sectorId = 1; const labeler = 1; const notificationName = 'backup-printer-selected'; - const operator = { - workerFk: 1, - trainFk: 1, - itemPackingTypeFk: 'H', - warehouseFk: 1, - sectorFk: sectorId - }; - const errorStatus = 'error'; + const sentStatus = 'sent'; - async function createOperator(labelerFk, options) { - operator.labelerFk = labelerFk; - await models.Operator.create(operator, options); - return models.NotificationQueue.findOne({ - where: { - notificationFk: notificationName, - authorFk: authorFk, - }, - order: 'created DESC', - }, options); + beforeEach(async() => { + await models.NotificationQueue.destroyAll({notificationFk: notificationName}); + }); + + async function updateOperatorAndFindNotification(labelerFk = labeler) { + await models.Operator.updateAll({id: authorFk}, {workerFk: authorFk, labelerFk: labelerFk, sectorFk: sectorId}); + return models.NotificationQueue.findOne({order: 'id DESC'}); } it('should create notification when configured a backup printer in the sector', async() => { - const tx = await models.Operator.beginTransaction({}); + const notificationQueue = await updateOperatorAndFindNotification(); + const params = JSON.parse(notificationQueue.params); - try { - const options = {transaction: tx, accessToken: {userId: authorFk}}; - const notificationQueue = await createOperator(labeler, options); - const params = JSON.parse(notificationQueue.params); - - expect(notificationQueue.notificationFk).toEqual(notificationName); - expect(notificationQueue.authorFk).toEqual(authorFk); - expect(params.labelerId).toEqual(1); - expect(params.sectorId).toEqual(1); - expect(params.workerId).toEqual(9); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(notificationQueue.notificationFk).toEqual(notificationName); + expect(notificationQueue.authorFk).toEqual(authorFk); + expect(params.labelerId).toEqual(1); + expect(params.sectorId).toEqual(1); + expect(params.workerId).toEqual(9); }); it('should not create notification when configured a non backup printer in the sector', async() => { - const tx = await models.Operator.beginTransaction({}); + const notificationQueue = await updateOperatorAndFindNotification(2); - try { - const options = {transaction: tx, accessToken: {userId: authorFk}}; - await models.NotificationQueue.destroyAll({notificationFk: notificationName}, options); - const notificationQueue = await createOperator(2, options); - - expect(notificationQueue).toEqual(null); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(notificationQueue?.notificationFk).not.toEqual(notificationName); }); it('should create notification when delay is null', async() => { - const tx = await models.Operator.beginTransaction({}); + const notification = await models.Notification.findOne({where: {name: notificationName}}); + const {delay} = notification; + const lastNotification = await updateOperatorAndFindNotification(); + await notification.updateAttributes({delay}); - try { - const options = {transaction: tx, accessToken: {userId: authorFk}}; - - const notifiation = await models.Notification.findOne({where: {name: notificationName}}, options); - await notifiation.updateAttributes({delay: null}, options); - - const notificationQueue = await createOperator(labeler, options); - - expect(notificationQueue.notificationFk).toEqual(notificationName); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(lastNotification.notificationFk).toEqual(notificationName); }); - fit('should not sent notification when is already notified by another worker', async() => { - await models.Operator.updateAll({id: 1}, {labelerFk: labeler, sectorFk: sectorId}, null); - await models.Operator.updateAll({id: 1}, {labelerFk: labeler, sectorFk: sectorId}, null); - - const lastNotification = await models.NotificationQueue.find({order: 'id DESC', limit: 2}); - console.log('lastNotification: ', lastNotification); - - await models.NotificationQueue.destroyAll({notificationFk: notificationName}); - - expect(lastNotification.status).toEqual(errorStatus); + it('should not sent notification when is already notified by another worker', async() => { + try { + await models.NotificationQueue.create({ + authorFk: 2, + notificationFk: notificationName, + params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 2}), + created: '2001-01-01 12:30:00', + status: sentStatus + }); + await models.Operator.updateAll({id: 1}, {labelerFk: labeler, sectorFk: sectorId}); + } catch (e) { + expect(e.message).toEqual('Previous notification sended with the same parameters'); + } }); it('should send a notification when the previous one is on errorStatus status', async() => { @@ -104,20 +66,9 @@ fdescribe('Operator', () => { created: '2001-01-01 12:30:00', status: errorStatus }); + const lastNotification = await updateOperatorAndFindNotification(); - await models.NotificationQueue.create({ - authorFk: 1, - notificationFk: notificationName, - params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 1}), - created: '2001-01-01 12:31:00', - }); - await models.Notification.send(); - - const lastNotification = await models.NotificationQueue.findOne({order: 'id DESC'}); - - await models.NotificationQueue.destroyAll({notificationFk: notificationName}); - - expect(lastNotification.status).toEqual('sent'); + expect(lastNotification.notificationFk).toEqual(notificationName); }); it('should send a notification when the previous one has distinct params', async() => { @@ -126,44 +77,11 @@ fdescribe('Operator', () => { notificationFk: notificationName, params: JSON.stringify({'labelerId': labeler, 'sectorId': 2, 'workerId': 1}), created: '2001-01-01 12:30:00', + status: sentStatus }); + const lastNotification = await updateOperatorAndFindNotification(); - await models.NotificationQueue.create({ - authorFk: 1, - notificationFk: notificationName, - params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 1}), - created: '2001-01-01 12:31:00', - }); - await models.Notification.send(); - - const lastNotification = await models.NotificationQueue.findOne({order: 'id DESC'}); - - await models.NotificationQueue.destroyAll({notificationFk: notificationName}); - - expect(lastNotification.status).toEqual('sent'); - }); - - it('should respect de configured delay for the notification', async() => { - await models.NotificationQueue.create({ - authorFk: 2, - notificationFk: notificationName, - params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 2}), - created: '2001-01-01 12:30:00', - }); - - await models.NotificationQueue.create({ - authorFk: 1, - notificationFk: notificationName, - params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 1}), - created: '2001-01-01 13:29:00', - }); - await models.Notification.send(); - - const lastNotification = await models.NotificationQueue.findOne({order: 'id DESC'}); - console.log('lastNotification: ', lastNotification); - - await models.NotificationQueue.destroyAll({notificationFk: notificationName}); - - expect(lastNotification.status).toEqual('error'); + expect(lastNotification.notificationFk).toEqual(notificationName); }); }); + diff --git a/modules/worker/back/models/operator.js b/modules/worker/back/models/operator.js index f7a57e255..d123a1493 100644 --- a/modules/worker/back/models/operator.js +++ b/modules/worker/back/models/operator.js @@ -1,43 +1,43 @@ module.exports = Self => { Self.observe('after save', async ctx => { - console.log('entra en after save'); const instance = ctx.data || ctx.instance; const models = Self.app.models; const options = ctx.options; const notificationName = 'backup-printer-selected'; - const userId = ctx.options.accessToken?.userId; + const userId = ctx.options.accessToken?.userId || instance.workerFk; if (!instance?.sectorFk || !instance?.labelerFk) return; - console.log('instance.sectorFk: ', instance.sectorFk); + const sector = await models.Sector.findById(instance.sectorFk, { fields: ['backupPrinterFk'] }, options); - console.log('sector.backupPrinterFk == instance.labelerFk: ', sector.backupPrinterFk == instance.labelerFk); if (sector.backupPrinterFk && sector.backupPrinterFk == instance.labelerFk) { - console.log('entra'); const {labelerFk, sectorFk} = instance; + const [{delay}] = await models.Notification.find({where: {name: notificationName}}); - const [{delay}] = await models.Notification.find({where: {name: notificationName}}, options); if (delay) { - const now = Date.vnNow(); - const filter = {where: {created: {between: [now - (delay * 1000), now]}}}; - const notifications = await models.NotificationQueue.find(filter, options); - console.log('notifications: ', notifications); + const now = Date.vnNow() - (delay * 1000) + (3600 * 1000); + const notifications = await models.NotificationQueue.find( + {where: + + {created: {gte: now}, + notificationFk: notificationName, + status: 'sent' + } + }); const criteria = {labelerId: labelerFk, sectorId: sectorFk}; const filteredNotifications = notifications.filter(notification => { const paramsObj = JSON.parse(notification.params); - console.log('paramsObj: ', paramsObj); - return Object.keys(criteria).every(key => criteria[key] === paramsObj[key]); + return Object.keys(criteria).every(key => criteria[key] === paramsObj?.[key]); }); - console.log('filteredNotifications.length: ', filteredNotifications.length); - if (filteredNotifications.length > 1) + if (filteredNotifications.length >= 1) throw new Error('Previous notification sended with the same parameters'); } - const created = await models.NotificationQueue.create({ + await models.NotificationQueue.create({ notificationFk: notificationName, authorFk: userId, params: JSON.stringify( @@ -48,7 +48,6 @@ module.exports = Self => { } ) }); - console.log('created: ', created); } }); }; From c6ece4619fc37d0ac1270f4c225e29ad448fc324 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 9 Apr 2024 11:40:12 +0200 Subject: [PATCH 067/153] feat: refs #6500 --- db/routines/vn/procedures/creditRecovery.sql | 42 ++++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/db/routines/vn/procedures/creditRecovery.sql b/db/routines/vn/procedures/creditRecovery.sql index 0a02f611f..f61b1499a 100644 --- a/db/routines/vn/procedures/creditRecovery.sql +++ b/db/routines/vn/procedures/creditRecovery.sql @@ -17,27 +17,27 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tCreditClients; CREATE TEMPORARY TABLE tCreditClients SELECT clientFk, IF(credit > recovery, credit - recovery, 0) newCredit - FROM ( - SELECT r.clientFk, - r.amount recovery, - (sub2.created + INTERVAL r.period DAY) deadLine, - sub2.amount credit - FROM recovery r - JOIN ( - SELECT clientFk, amount, created - FROM ( - SELECT clientFk, amount, created - FROM clientCredit - ORDER BY created DESC - LIMIT 10000000000000000000 - ) sub - GROUP BY clientFk - ) sub2 ON sub2.clientFk = r.clientFk - WHERE r.finished IS NULL OR r.finished >= util.VN_CURDATE() - GROUP BY r.clientFk - HAVING deadLine <= util.VN_CURDATE() - ) sub3 - WHERE credit > 0; + FROM ( + SELECT r.clientFk, + r.amount recovery, + (sub2.created + INTERVAL r.period DAY) deadLine, + sub2.amount credit + FROM recovery r + JOIN ( + SELECT clientFk, amount, created + FROM ( + SELECT clientFk, amount, created + FROM clientCredit + ORDER BY created DESC + LIMIT 10000000000000000000 + ) sub + GROUP BY clientFk + ) sub2 ON sub2.clientFk = r.clientFk + WHERE r.finished IS NULL OR r.finished >= util.VN_CURDATE() + GROUP BY r.clientFk + HAVING deadLine <= util.VN_CURDATE() + ) sub3 + WHERE credit > 0; UPDATE client c JOIN tCreditClients cc ON cc.clientFk = c.id From da037c5235c956e924bb57fdfd2254f28e04bdbf Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 9 Apr 2024 13:34:33 +0200 Subject: [PATCH 068/153] refactor: refs #6005 delay on productionConfig --- back/model-config.json | 3 +++ back/models/production-config.json | 19 +++++++++++++++ db/dump/fixtures.after.sql | 10 -------- db/dump/fixtures.before.sql | 22 +++++++++--------- .../10895-pinkArborvitae/02-thirdScript.sql | 2 +- .../03-insertBackUpNotification.vn.sql | 4 ++-- .../methods/operator/spec/operator.spec.js | 23 ++++--------------- modules/worker/back/models/operator.js | 15 +++++------- 8 files changed, 47 insertions(+), 51 deletions(-) create mode 100644 back/models/production-config.json diff --git a/back/model-config.json b/back/model-config.json index f48ec11e6..ebcdb7bce 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -174,5 +174,8 @@ }, "WorkerActivityType": { "dataSource": "vn" + }, + "ProductionConfig": { + "dataSource": "vn" } } \ No newline at end of file diff --git a/back/models/production-config.json b/back/models/production-config.json new file mode 100644 index 000000000..3800dbbf2 --- /dev/null +++ b/back/models/production-config.json @@ -0,0 +1,19 @@ +{ + "name": "ProductionConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "productionConfig" + } + }, + "properties": { + "id": { + "type": "number", + "required": true, + "id": true + }, + "backupPrinterNotificationDelay": { + "type": "string" + } + } +} diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 896642005..fade82c3e 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -153,16 +153,6 @@ INSERT INTO `vn`.`occupationCode` (`code`, `name`) ('b', 'Representantes de comercio'), ('c', 'Personal de oficios en trabajos de construcción en general, y en instalac.,edificios y obras'); -INSERT INTO `vn2008`.`payroll_employee` (`CodTrabajador`,`codempresa`) - VALUES - (36,20), - (43,20), - (76,20), - (1106,20), - (1107,20), - (1108,20), - (1109,20), - (1110,20); INSERT INTO `vn`.`trainingCourseType` (`id`, `name`) VALUES diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 8c2f0a5d4..25a2ee8fb 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2805,16 +2805,16 @@ INSERT INTO `util`.`notificationConfig` SET `id` = 1, `cleanDays` = 90; TRUNCATE `util`.`notification`; -INSERT INTO `util`.`notification` (`id`, `name`, `description`, `delay`) +INSERT INTO `util`.`notification` (`id`, `name`, `description`) VALUES - (1, 'print-email', 'notification fixture one', NULL), - (2, 'invoice-electronic', 'A electronic invoice has been generated', NULL), - (3, 'not-main-printer-configured', 'A printer distinct than main has been configured', NULL), - (4, 'supplier-pay-method-update', 'A supplier pay method has been updated', NULL), - (5, 'modified-entry', 'An entry has been modified', NULL), - (6, 'book-entry-deleted', 'accounting entries deleted', NULL), - (7, 'zone-included','An email to notify zoneCollisions'); - (8, 'backup-printer-selected','A backup printer has been selected', 3600), + (1, 'print-email', 'notification fixture one'), + (2, 'invoice-electronic', 'A electronic invoice has been generated'), + (3, 'not-main-printer-configured', 'A printer distinct than main has been configured'), + (4, 'supplier-pay-method-update', 'A supplier pay method has been updated'), + (5, 'modified-entry', 'An entry has been modified'), + (6, 'book-entry-deleted', 'accounting entries deleted'), + (7, 'zone-included','An email to notify zoneCollisions'), + (8, 'backup-printer-selected','A backup printer has been selected'); TRUNCATE `util`.`notificationAcl`; INSERT INTO `util`.`notificationAcl` (`notificationFk`, `roleFk`) @@ -2854,9 +2854,9 @@ INSERT INTO `vn`.`routeConfig` (`id`, `defaultWorkCenterFk`) VALUES (1, 9); -INSERT INTO `vn`.`productionConfig` (`isPreviousPreparationRequired`, `ticketPrintedMax`, `ticketTrolleyMax`, `rookieDays`, `notBuyingMonths`, `id`, `isZoneClosedByExpeditionActivated`, `maxNotReadyCollections`, `minTicketsToCloseZone`, `movingTicketDelRoute`, `defaultZone`, `defautlAgencyMode`, `hasUniqueCollectionTime`, `maxCollectionWithoutUser`, `pendingCollectionsOrder`, `pendingCollectionsAge`) +INSERT INTO `vn`.`productionConfig` (`isPreviousPreparationRequired`, `ticketPrintedMax`, `ticketTrolleyMax`, `rookieDays`, `notBuyingMonths`, `id`, `isZoneClosedByExpeditionActivated`, `maxNotReadyCollections`, `minTicketsToCloseZone`, `movingTicketDelRoute`, `defaultZone`, `defautlAgencyMode`, `hasUniqueCollectionTime`, `maxCollectionWithoutUser`, `pendingCollectionsOrder`, `pendingCollectionsAge`, `backupPrinterNotificationDelay`) VALUES - (0, 8, 80, 0, 0, 1, 0, 15, 25, -1, 697, 1328, 0, 1, 8, 6); + (0, 8, 80, 0, 0, 1, 0, 15, 25, -1, 697, 1328, 0, 1, 8, 6, 3600); INSERT INTO `vn`.`collection` (`id`, `created`, `workerFk`, `stateFk`, `itemPackingTypeFk`, `saleTotalCount`, `salePickedCount`, `trainFk`, `sectorFk`, `wagons`) VALUES diff --git a/db/versions/10895-pinkArborvitae/02-thirdScript.sql b/db/versions/10895-pinkArborvitae/02-thirdScript.sql index 21e97580f..142ec06b1 100644 --- a/db/versions/10895-pinkArborvitae/02-thirdScript.sql +++ b/db/versions/10895-pinkArborvitae/02-thirdScript.sql @@ -1,5 +1,5 @@ -ALTER TABLE `util`.`notification` ADD IF NOT EXISTS delay int unsigned NULL +ALTER TABLE `vn`.`productionConfig` ADD IF NOT EXISTS backupPrinterNotificationDelay int unsigned NULL COMMENT 'Minimum seconds Interval to Prevent Spam from Same-Type Notifications'; ALTER TABLE vn.sector DROP FOREIGN KEY IF EXISTS sector_FK; diff --git a/db/versions/10895-pinkArborvitae/03-insertBackUpNotification.vn.sql b/db/versions/10895-pinkArborvitae/03-insertBackUpNotification.vn.sql index b6558e6d4..9dc3c0f60 100644 --- a/db/versions/10895-pinkArborvitae/03-insertBackUpNotification.vn.sql +++ b/db/versions/10895-pinkArborvitae/03-insertBackUpNotification.vn.sql @@ -1,5 +1,5 @@ -INSERT IGNORE INTO util.notification (name, description, delay) - VALUES ('backup-printer-selected','A backup printer has been selected', 3600); +INSERT IGNORE INTO util.notification (name, description) + VALUES ('backup-printer-selected','A backup printer has been selected'); INSERT IGNORE INTO util.notificationSubscription (notificationFk, userFk) SELECT id, 10435 diff --git a/modules/worker/back/methods/operator/spec/operator.spec.js b/modules/worker/back/methods/operator/spec/operator.spec.js index 6a4a5cff1..5a3528641 100644 --- a/modules/worker/back/methods/operator/spec/operator.spec.js +++ b/modules/worker/back/methods/operator/spec/operator.spec.js @@ -1,11 +1,10 @@ const models = require('vn-loopback/server/server').models; -describe('Operator', () => { +fdescribe('Operator', () => { const authorFk = 9; const sectorId = 1; const labeler = 1; const notificationName = 'backup-printer-selected'; - const errorStatus = 'error'; const sentStatus = 'sent'; beforeEach(async() => { @@ -35,10 +34,11 @@ describe('Operator', () => { }); it('should create notification when delay is null', async() => { - const notification = await models.Notification.findOne({where: {name: notificationName}}); - const {delay} = notification; + const config = await models.ProductionConfig.findOne(); + const delay = config.backupPrinterNotificationDelay; + await config.updateAttributes({backupPrinterNotificationDelay: null}); const lastNotification = await updateOperatorAndFindNotification(); - await notification.updateAttributes({delay}); + await config.updateAttributes({backupPrinterNotificationDelay: delay}); expect(lastNotification.notificationFk).toEqual(notificationName); }); @@ -58,19 +58,6 @@ describe('Operator', () => { } }); - it('should send a notification when the previous one is on errorStatus status', async() => { - await models.NotificationQueue.create({ - authorFk: 2, - notificationFk: notificationName, - params: JSON.stringify({'labelerId': labeler, 'sectorId': sectorId, 'workerId': 2}), - created: '2001-01-01 12:30:00', - status: errorStatus - }); - const lastNotification = await updateOperatorAndFindNotification(); - - expect(lastNotification.notificationFk).toEqual(notificationName); - }); - it('should send a notification when the previous one has distinct params', async() => { await models.NotificationQueue.create({ authorFk: 2, diff --git a/modules/worker/back/models/operator.js b/modules/worker/back/models/operator.js index d123a1493..1ebc1643c 100644 --- a/modules/worker/back/models/operator.js +++ b/modules/worker/back/models/operator.js @@ -14,17 +14,14 @@ module.exports = Self => { if (sector.backupPrinterFk && sector.backupPrinterFk == instance.labelerFk) { const {labelerFk, sectorFk} = instance; - const [{delay}] = await models.Notification.find({where: {name: notificationName}}); - if (delay) { - const now = Date.vnNow() - (delay * 1000) + (3600 * 1000); + const {backupPrinterNotificationDelay} = await models.ProductionConfig.findOne(); + if (backupPrinterNotificationDelay) { const notifications = await models.NotificationQueue.find( - {where: - - {created: {gte: now}, - notificationFk: notificationName, - status: 'sent' - } + {where: {created: {gte: Date.vnNow() - (backupPrinterNotificationDelay * 1000) + (3600 * 1000)}, + notificationFk: notificationName, + status: 'sent' + } }); const criteria = {labelerId: labelerFk, sectorId: sectorFk}; From aff73a179e2d77dd60f7fb740b476a5f4db94a74 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 9 Apr 2024 13:36:50 +0200 Subject: [PATCH 069/153] remove: refs #6005 remove delay from notification model --- back/models/notification.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/back/models/notification.json b/back/models/notification.json index 07702d99d..56f66bf1d 100644 --- a/back/models/notification.json +++ b/back/models/notification.json @@ -18,9 +18,6 @@ }, "description": { "type": "string" - }, - "delay": { - "type": "number" } }, "relations": { From 90c26959af27b5c7abe43c20abbcd665ac50260f Mon Sep 17 00:00:00 2001 From: ivanm Date: Tue, 9 Apr 2024 13:39:33 +0200 Subject: [PATCH 070/153] refs #7161 change longName to name --- db/routines/vn/procedures/item_setVisibleDiscard.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/item_setVisibleDiscard.sql b/db/routines/vn/procedures/item_setVisibleDiscard.sql index 59ffa0f66..1f2dbee93 100644 --- a/db/routines/vn/procedures/item_setVisibleDiscard.sql +++ b/db/routines/vn/procedures/item_setVisibleDiscard.sql @@ -66,7 +66,7 @@ BEGIN INSERT INTO sale(ticketFk, itemFk, concept, quantity) SELECT vTicketFk, vItemFk, - longName, + name, vQuantity FROM item WHERE id = vItemFk; From ac9732606c980a8adb807988325d23fb826df499 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 9 Apr 2024 14:55:29 +0200 Subject: [PATCH 071/153] remove(focus): refs #6005 from spec --- modules/worker/back/methods/operator/spec/operator.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/methods/operator/spec/operator.spec.js b/modules/worker/back/methods/operator/spec/operator.spec.js index 5a3528641..cf0b1e4b8 100644 --- a/modules/worker/back/methods/operator/spec/operator.spec.js +++ b/modules/worker/back/methods/operator/spec/operator.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('Operator', () => { +describe('Operator', () => { const authorFk = 9; const sectorId = 1; const labeler = 1; From d85562b090236f51d1dfdfe97dc36eacc4f1cc65 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 9 Apr 2024 15:06:05 +0200 Subject: [PATCH 072/153] refs #7188 fix: bug tokenMultimedia --- front/core/services/auth.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/front/core/services/auth.js b/front/core/services/auth.js index 753bc3fba..d77966aca 100644 --- a/front/core/services/auth.js +++ b/front/core/services/auth.js @@ -86,7 +86,8 @@ export default class Auth { return this.$http.get('VnUsers/ShareToken', { headers: {Authorization: json.data.token} }).then(({data}) => { - this.vnToken.set(json.data.token, data.multimediaToken.id, now, json.data.ttl, remember); + // Usar data.multimediaToken.id cuando el resto de sistemas lo tengan completado + this.vnToken.set(json.data.token, json.data.token, now, json.data.ttl, remember); this.loadAcls().then(() => { let continueHash = this.$state.params.continue; if (continueHash) From eedf30a2dd7eb1d9d492a0f4ed7dbc80202a5878 Mon Sep 17 00:00:00 2001 From: ivanm Date: Tue, 9 Apr 2024 17:31:34 +0200 Subject: [PATCH 073/153] refs #6732 salix dependencies and undo changes Proveedores --- db/routines/vn2008/views/Proveedores.sql | 2 +- e2e/helpers/selectors.js | 2 +- e2e/paths/13-supplier/02_basic_data.spec.js | 6 +++--- modules/supplier/back/locale/supplier/en.yml | 2 +- modules/supplier/back/locale/supplier/es.yml | 2 +- modules/supplier/front/basic-data/index.html | 2 +- modules/supplier/front/descriptor/index.html | 2 +- modules/supplier/front/descriptor/index.js | 2 +- modules/supplier/front/descriptor/index.spec.js | 2 +- modules/supplier/front/summary/index.html | 6 +++--- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/db/routines/vn2008/views/Proveedores.sql b/db/routines/vn2008/views/Proveedores.sql index e26e9c829..0b7ee89f8 100644 --- a/db/routines/vn2008/views/Proveedores.sql +++ b/db/routines/vn2008/views/Proveedores.sql @@ -23,7 +23,7 @@ AS SELECT `s`.`id` AS `Id_Proveedor`, `s`.`isOfficial` AS `oficial`, `s`.`workerFk` AS `workerFk`, `s`.`payDay` AS `pay_day`, - `s`.`isReal` AS `real`, + `s`.`isSerious` AS `serious`, `s`.`note` AS `notas`, `s`.`taxTypeSageFk` AS `taxTypeSageFk`, `s`.`withholdingSageFk` AS `withholdingSageFk`, diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index daaa17c71..685345273 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -1258,7 +1258,7 @@ export default { }, supplierBasicData: { alias: 'vn-supplier-basic-data vn-textfield[ng-model="$ctrl.supplier.nickname"]', - isSerious: 'vn-supplier-basic-data vn-check[ng-model="$ctrl.supplier.isSerious"]', + isReal: 'vn-supplier-basic-data vn-check[ng-model="$ctrl.supplier.isReal"]', isActive: 'vn-supplier-basic-data vn-check[ng-model="$ctrl.supplier.isActive"]', isPayMethodChecked: 'vn-supplier-basic-data vn-check[ng-model="$ctrl.supplier.isPayMethodChecked"]', notes: 'vn-supplier-basic-data vn-textarea[ng-model="$ctrl.supplier.note"]', diff --git a/e2e/paths/13-supplier/02_basic_data.spec.js b/e2e/paths/13-supplier/02_basic_data.spec.js index 79a9898ca..710ebd8df 100644 --- a/e2e/paths/13-supplier/02_basic_data.spec.js +++ b/e2e/paths/13-supplier/02_basic_data.spec.js @@ -20,7 +20,7 @@ describe('Supplier basic data path', () => { it('should edit the basic data', async() => { await page.clearInput(selectors.supplierBasicData.alias); await page.write(selectors.supplierBasicData.alias, 'Plants Nick SL'); - await page.waitToClick(selectors.supplierBasicData.isSerious); + await page.waitToClick(selectors.supplierBasicData.isReal); await page.waitToClick(selectors.supplierBasicData.isActive); await page.waitToClick(selectors.supplierBasicData.isPayMethodChecked); await page.write(selectors.supplierBasicData.notes, 'Some notes'); @@ -41,8 +41,8 @@ describe('Supplier basic data path', () => { expect(result).toEqual('Plants Nick SL'); }); - it('should check the isSerious checkbox is now checked', async() => { - const result = await page.checkboxState(selectors.supplierBasicData.isSerious); + it('should check the isReal checkbox is now checked', async() => { + const result = await page.checkboxState(selectors.supplierBasicData.isReal); expect(result).toBe('checked'); }); diff --git a/modules/supplier/back/locale/supplier/en.yml b/modules/supplier/back/locale/supplier/en.yml index 25bcae1e3..626d78ff8 100644 --- a/modules/supplier/back/locale/supplier/en.yml +++ b/modules/supplier/back/locale/supplier/en.yml @@ -11,7 +11,7 @@ columns: postcodeFk: postcode isActive: active isOfficial: official - isSerious: serious + isReal: real isTrucker: trucker note: note street: street diff --git a/modules/supplier/back/locale/supplier/es.yml b/modules/supplier/back/locale/supplier/es.yml index 678c384a9..ed57d357a 100644 --- a/modules/supplier/back/locale/supplier/es.yml +++ b/modules/supplier/back/locale/supplier/es.yml @@ -11,7 +11,7 @@ columns: postcodeFk: código postal isActive: activo isOfficial: oficial - isSerious: serio + isReal: real isTrucker: camionero note: nota street: calle diff --git a/modules/supplier/front/basic-data/index.html b/modules/supplier/front/basic-data/index.html index 68e635a06..fcdb2a522 100644 --- a/modules/supplier/front/basic-data/index.html +++ b/modules/supplier/front/basic-data/index.html @@ -26,7 +26,7 @@ + ng-model="$ctrl.supplier.isReal"> + ng-if="$ctrl.supplier.isReal == false">