From 42df7114640289156b9416778e608fc716247431 Mon Sep 17 00:00:00 2001 From: pablone Date: Sun, 15 Oct 2023 11:15:07 +0200 Subject: [PATCH 001/161] 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/161] 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/161] 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/161] 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/161] 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/161] 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/161] =?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/161] 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/161] 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/161] 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/161] 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/161] 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/161] 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/161] 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/161] 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/161] 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/161] 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 01512c7d36f2cdce1fa36010ecd79460316626d5 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 5 Feb 2024 13:52:28 +0100 Subject: [PATCH 018/161] feat: refs #6777 change dependecies vn2008 to vn --- .../bi/procedures/Greuge_Evolution_Add.sql | 10 ++-- .../bi/procedures/analisis_ventas_update.sql | 52 +++++++++---------- .../bi/procedures/claim_ratio_routine.sql | 24 ++++----- db/routines/bi/procedures/comparativa_add.sql | 10 ++-- .../bi/procedures/comparativa_add_manual.sql | 10 ++-- .../bs/procedures/comercialesCompleto.sql | 18 +++---- .../bs/procedures/manaCustomerUpdate.sql | 8 +-- .../bs/procedures/ventas_contables_add.sql | 20 +++---- .../ventas_contables_por_cliente.sql | 30 +++++------ .../vn/functions/getAlert3StateTest.sql | 14 ++--- .../vn/functions/isPalletHomogeneus.sql | 6 +-- .../vn/functions/ticketPositionInPath.sql | 6 +-- .../vn/procedures/invoiceFromAddress.sql | 11 ++-- .../vn2008/procedures/availableTraslate.sql | 2 +- db/routines/vn2008/procedures/clean.sql | 12 ++--- .../procedures/confection_control_source.sql | 26 +++++----- .../vn2008/procedures/historico_multiple.sql | 2 +- db/routines/vn2008/views/Tickets_state.sql | 7 --- db/routines/vn2008/views/Tickets_turno.sql | 6 --- 19 files changed, 132 insertions(+), 142 deletions(-) delete mode 100644 db/routines/vn2008/views/Tickets_state.sql delete mode 100644 db/routines/vn2008/views/Tickets_turno.sql diff --git a/db/routines/bi/procedures/Greuge_Evolution_Add.sql b/db/routines/bi/procedures/Greuge_Evolution_Add.sql index 83033cbf8..36491cbab 100644 --- a/db/routines/bi/procedures/Greuge_Evolution_Add.sql +++ b/db/routines/bi/procedures/Greuge_Evolution_Add.sql @@ -92,12 +92,12 @@ BEGIN UPDATE bi.Greuge_Evolution ge JOIN ( SELECT cs.Id_Cliente, sum(Valor * Cantidad) as Importe - FROM vn2008.Tickets t - JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna - JOIN vn2008.Movimientos m on m.Id_Ticket = t.Id_Ticket + FROM vn.ticket t + JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.addressFk + JOIN vn2008.Movimientos m on m.Id_Ticket = t.id JOIN vn2008.Movimientos_componentes mc on mc.Id_Movimiento = m.Id_Movimiento - WHERE t.Fecha >= datFEC - AND t.Fecha < datFEC_TOMORROW + WHERE t.shipped >= datFEC + AND t.shipped < datFEC_TOMORROW AND mc.Id_Componente = 17 -- Recobro GROUP BY cs.Id_Cliente ) sub using(Id_Cliente) diff --git a/db/routines/bi/procedures/analisis_ventas_update.sql b/db/routines/bi/procedures/analisis_ventas_update.sql index 4f6a448ed..228660d07 100644 --- a/db/routines/bi/procedures/analisis_ventas_update.sql +++ b/db/routines/bi/procedures/analisis_ventas_update.sql @@ -10,18 +10,18 @@ BEGIN OR (Año = YEAR(vLastMonth) AND Mes >= MONTH(vLastMonth)); INSERT INTO analisis_ventas ( - Familia, - Reino, - Comercial, - Comprador, - Provincia, - almacen, - Año, - Mes, - Semana, - Vista, - Importe - ) + Familia, + Reino, + Comercial, + Comprador, + Provincia, + almacen, + Año, + Mes, + Semana, + Vista, + Importe + ) SELECT tp.Tipo AS Familia, r.reino AS Reino, @@ -35,19 +35,19 @@ BEGIN dm.description AS Vista, bt.importe AS Importe FROM bs.ventas bt - LEFT JOIN vn2008.Tipos tp ON tp.tipo_id = bt.tipo_id - LEFT JOIN vn2008.reinos r ON r.id = tp.reino_id - LEFT JOIN vn2008.Clientes c on c.Id_Cliente = bt.Id_Cliente - LEFT JOIN vn2008.Trabajadores tr ON tr.Id_Trabajador = c.Id_Trabajador - LEFT JOIN vn2008.Trabajadores tr2 ON tr2.Id_Trabajador = tp.Id_Trabajador - JOIN vn2008.time tm ON tm.date = bt.fecha - JOIN vn2008.Movimientos m ON m.Id_Movimiento = bt.Id_Movimiento - LEFT JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia - LEFT JOIN vn.deliveryMethod dm ON dm.id = a.Vista - LEFT JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.Id_Consigna - LEFT JOIN vn2008.province p ON p.province_id = cs.province_id - LEFT JOIN vn.warehouse w ON w.id = t.warehouse_id - WHERE bt.fecha >= vLastMonth AND r.mercancia; + LEFT JOIN vn2008.Tipos tp ON tp.tipo_id = bt.tipo_id + LEFT JOIN vn2008.reinos r ON r.id = tp.reino_id + LEFT JOIN vn2008.Clientes c on c.Id_Cliente = bt.Id_Cliente + LEFT JOIN vn2008.Trabajadores tr ON tr.Id_Trabajador = c.Id_Trabajador + LEFT JOIN vn2008.Trabajadores tr2 ON tr2.Id_Trabajador = tp.Id_Trabajador + JOIN vn2008.time tm ON tm.date = bt.fecha + JOIN vn2008.Movimientos m ON m.Id_Movimiento = bt.Id_Movimiento + LEFT JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk + LEFT JOIN vn.deliveryMethod dm ON dm.id = a.Vista + LEFT JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.addressFk + LEFT JOIN vn2008.province p ON p.province_id = cs.province_id + LEFT JOIN vn.warehouse w ON w.id = t.warehouseFk + WHERE bt.fecha >= vLastMonth AND r.mercancia; END$$ DELIMITER ; diff --git a/db/routines/bi/procedures/claim_ratio_routine.sql b/db/routines/bi/procedures/claim_ratio_routine.sql index 4616bcb9e..dce098e2d 100644 --- a/db/routines/bi/procedures/claim_ratio_routine.sql +++ b/db/routines/bi/procedures/claim_ratio_routine.sql @@ -59,18 +59,18 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list (PRIMARY KEY (Id_Ticket)) - SELECT DISTINCT t.Id_Ticket + SELECT DISTINCT t.id FROM vn2008.Movimientos_componentes mc JOIN vn2008.Movimientos m ON mc.Id_Movimiento = m.Id_Movimiento - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Tickets_state ts ON ts.Id_Ticket = t.Id_Ticket - JOIN vn.ticketTracking tt ON tt.id = ts.inter_id - JOIN vn2008.state s ON s.id = tt.stateFk + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN vn.ticketLastState ts ON ts.ticketFk = t.id + JOIN vn.ticketTracking tt ON tt.id = ts.ticketTrackingFk + JOIN vn.state s ON s.id = tt.stateFk WHERE mc.Id_Componente = 17 AND mc.greuge = 0 - AND t.Fecha >= '2016-10-01' - AND t.Fecha < util.VN_CURDATE() - AND s.alert_level >= 3; + AND t.shipped >= '2016-10-01' + AND t.shipped < util.VN_CURDATE() + AND s.alertLevel >= 3; DELETE g.* FROM vn2008.Greuges g @@ -82,15 +82,15 @@ BEGIN SELECT Id_Cliente ,concat('recobro ', m.Id_Ticket), - round(SUM(mc.Valor*Cantidad),2) AS dif - ,date(t.Fecha) + ,date(t.shipped) , 2 ,tt.Id_Ticket FROM vn2008.Movimientos m - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket - JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.Id_Ticket + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.id JOIN vn2008.Movimientos_componentes mc ON mc.Id_Movimiento = m.Id_Movimiento AND mc.Id_Componente = 17 - GROUP BY t.Id_Ticket + GROUP BY t.id HAVING ABS(dif) > 1; UPDATE vn2008.Movimientos_componentes mc diff --git a/db/routines/bi/procedures/comparativa_add.sql b/db/routines/bi/procedures/comparativa_add.sql index 4297c8aff..ac06798db 100644 --- a/db/routines/bi/procedures/comparativa_add.sql +++ b/db/routines/bi/procedures/comparativa_add.sql @@ -15,17 +15,17 @@ BEGIN IF lastCOMP < vMaxPeriod - 3 AND vMaxWeek > 3 THEN REPLACE vn2008.Comparativa(Periodo, Id_Article, warehouse_id, Cantidad,price) - SELECT tm.period as Periodo, m.Id_Article, t.warehouse_id, sum(m.Cantidad), sum(v.importe) + SELECT tm.period as Periodo, m.Id_Article, t.warehouseFk, sum(m.Cantidad), sum(v.importe) FROM bs.ventas v JOIN vn2008.time tm ON tm.date = v.fecha JOIN vn2008.Movimientos m ON m.Id_Movimiento = v.Id_Movimiento JOIN vn2008.Tipos tp ON tp.tipo_id = v.tipo_id JOIN vn2008.reinos r ON r.id = tp.reino_id - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket + JOIN vn.ticket t ON t.id = m.Id_Ticket WHERE tm.period BETWEEN lastCOMP AND vMaxPeriod - 3 - AND t.Id_Cliente NOT IN(400,200) - AND t.warehouse_id NOT IN (0,13) - GROUP BY m.Id_Article, Periodo, t.warehouse_id; + AND t.clientFk NOT IN(400,200) + AND t.warehouseFk NOT IN (0,13) + GROUP BY m.Id_Article, Periodo, t.warehouseFk; END IF; END$$ diff --git a/db/routines/bi/procedures/comparativa_add_manual.sql b/db/routines/bi/procedures/comparativa_add_manual.sql index 281e15b23..2b05b1277 100644 --- a/db/routines/bi/procedures/comparativa_add_manual.sql +++ b/db/routines/bi/procedures/comparativa_add_manual.sql @@ -25,16 +25,16 @@ BEGIN WHERE Periodo BETWEEN periodStart AND periodEnd; INSERT INTO vn2008.Comparativa(Periodo, Id_Article, warehouse_id, Cantidad,price) - SELECT tm.period as Periodo, m.Id_Article, t.warehouse_id, sum(m.Cantidad), sum(v.importe) + SELECT tm.period as Periodo, m.Id_Article, t.warehouseFk, sum(m.Cantidad), sum(v.importe) FROM bs.ventas v JOIN vn2008.time tm ON tm.date = v.fecha JOIN vn2008.Movimientos m ON m.Id_Movimiento = v.Id_Movimiento JOIN vn2008.Tipos tp ON tp.tipo_id = v.tipo_id JOIN vn2008.reinos r ON r.id = tp.reino_id - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket + JOIN vn.ticket t ON t.id = m.Id_Ticket WHERE tm.period BETWEEN periodStart AND periodEnd - AND t.Id_Cliente NOT IN(400,200) - AND t.warehouse_id NOT IN (0,13) - GROUP BY m.Id_Article, Periodo, t.warehouse_id; + AND t.clientFk NOT IN(400,200) + AND t.warehouseFk NOT IN (0,13) + GROUP BY m.Id_Article, Periodo, t.warehouseFk; END$$ DELIMITER ; diff --git a/db/routines/bs/procedures/comercialesCompleto.sql b/db/routines/bs/procedures/comercialesCompleto.sql index 323d5cd00..8f519b6ca 100644 --- a/db/routines/bs/procedures/comercialesCompleto.sql +++ b/db/routines/bs/procedures/comercialesCompleto.sql @@ -70,23 +70,23 @@ BEGIN AND (v.fecha BETWEEN TIMESTAMPADD(DAY, - DAY(vDate) + 1, vDate) AND TIMESTAMPADD(DAY, - 1, vDate)) GROUP BY Id_Cliente) mes_actual ON mes_actual.Id_Cliente = c.Id_Cliente LEFT JOIN - (SELECT t.Id_Cliente, SUM(m.preu * m.Cantidad * (1 - m.Descuento / 100)) futur - FROM vn2008.Tickets t - JOIN vn2008.Clientes c ON c.Id_Cliente = t.Id_Cliente - JOIN vn2008.Movimientos m ON m.Id_Ticket = t.Id_Ticket + (SELECT t.clientFk, SUM(m.preu * m.Cantidad * (1 - m.Descuento / 100)) futur + FROM vn.ticket t + JOIN vn2008.Clientes c ON c.Id_Cliente = t.clientFk + JOIN vn2008.Movimientos m ON m.Id_Ticket = t.id LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador WHERE (c.Id_Trabajador = vWorker OR tr.boss = vWorker) - AND t.Fecha BETWEEN vDate AND util.dayEnd(LAST_DAY(vDate)) + AND t.shipped BETWEEN vDate AND util.dayEnd(LAST_DAY(vDate)) GROUP BY Id_Cliente) f ON c.Id_Cliente = f.Id_Cliente LEFT JOIN - (SELECT MAX(t.Fecha) LastTicket, c.Id_Cliente - FROM vn2008.Tickets t - JOIN vn2008.Clientes c ON c.Id_cliente = t.Id_Cliente + (SELECT MAX(t.shipped) LastTicket, c.Id_Cliente + FROM vn.ticket t + JOIN vn2008.Clientes c ON c.Id_cliente = t.clientFk LEFT JOIN vn2008.Trabajadores tr ON c.Id_Trabajador = tr.Id_Trabajador WHERE (c.Id_Trabajador = vWorker OR tr.boss = vWorker) - GROUP BY t.Id_Cliente) LastTicket ON LastTicket.Id_Cliente = c.Id_Cliente + GROUP BY t.clientFk) LastTicket ON LastTicket.Id_Cliente = c.Id_Cliente LEFT JOIN ( SELECT SUM(importe) peso, c.Id_Cliente diff --git a/db/routines/bs/procedures/manaCustomerUpdate.sql b/db/routines/bs/procedures/manaCustomerUpdate.sql index 1e9cb8429..7a4ee6dba 100644 --- a/db/routines/bs/procedures/manaCustomerUpdate.sql +++ b/db/routines/bs/procedures/manaCustomerUpdate.sql @@ -68,13 +68,13 @@ BEGIN FROM ( SELECT cs.Id_Cliente, Cantidad * Valor as mana - FROM vn2008.Tickets t + FROM vn.ticket t JOIN vn2008.Consignatarios cs using(Id_Consigna) - JOIN vn2008.Movimientos m on m.Id_Ticket = t.Id_Ticket + JOIN vn2008.Movimientos m on m.Id_Ticket = t.id JOIN vn2008.Movimientos_componentes mc on mc.Id_Movimiento = m.Id_Movimiento WHERE Id_Componente IN (vManaAutoId, vManaId, vClaimManaId) - AND t.Fecha > vFromDated - AND date(t.Fecha) <= vToDated + AND t.shipped > vFromDated + AND date(t.shipped) <= vToDated UNION ALL SELECT r.Id_Cliente, - Entregado FROM vn2008.Recibos r diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index d8e963e3e..554972e4c 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -19,11 +19,11 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (Id_Ticket)) + (PRIMARY KEY (id)) ENGINE = MEMORY - SELECT Id_Ticket - FROM vn2008.Tickets t - JOIN vn2008.Facturas f ON f.Id_Factura = t.Factura + SELECT id + FROM vn.ticket t + JOIN vn2008.Facturas f ON f.Id_Factura = t.refFk WHERE year(f.Fecha) = vYear AND month(f.Fecha) = vMonth; @@ -46,7 +46,7 @@ BEGIN ) as grupo , tp.reino_id , a.tipo_id - , t.empresa_id + , t.companyFk , 7000000000 + IF(e.empresa_grupo = e2.empresa_grupo ,1 @@ -54,12 +54,12 @@ BEGIN ) * 1000000 + tp.reino_id * 10000 as Gasto FROM vn2008.Movimientos m - JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna + JOIN vn.ticket t on t.id = m.Id_Ticket + JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.addressFk JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente - JOIN tmp.ticket_list tt on tt.Id_Ticket = t.Id_Ticket + JOIN tmp.ticket_list tt on tt.id = t.id JOIN vn2008.Articles a on m.Id_Article = a.Id_Article - JOIN vn2008.empresa e on e.id = t.empresa_id + JOIN vn2008.empresa e on e.id = t.companyFk LEFT JOIN vn2008.empresa e2 on e2.Id_Cliente = c.Id_Cliente JOIN vn2008.Tipos tp on tp.tipo_id = a.tipo_id WHERE Cantidad <> 0 @@ -92,7 +92,7 @@ BEGIN JOIN vn.ticket t ON ts.ticketFk = t.id JOIN vn.address a on a.id = t.addressFk JOIN vn.client cl on cl.id = a.clientFk - JOIN tmp.ticket_list tt on tt.Id_Ticket = t.id + JOIN tmp.ticket_list tt on tt.id = t.id JOIN vn.company c on c.id = t.companyFk LEFT JOIN vn.company c2 on c2.clientFk = cl.id GROUP BY grupo, t.companyFk ; diff --git a/db/routines/bs/procedures/ventas_contables_por_cliente.sql b/db/routines/bs/procedures/ventas_contables_por_cliente.sql index 9f1399025..26da1b870 100644 --- a/db/routines/bs/procedures/ventas_contables_por_cliente.sql +++ b/db/routines/bs/procedures/ventas_contables_por_cliente.sql @@ -10,38 +10,38 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (Id_Ticket)) - SELECT Id_Ticket - FROM vn2008.Tickets t - JOIN vn2008.Facturas f ON f.Id_Factura = t.Factura - WHERE year(f.Fecha) = vYear - AND month(f.Fecha) = vMonth; - + (PRIMARY KEY (id)) + SELECT id + FROM vn.ticket t + JOIN vn2008.Facturas f ON f.Id_Factura = t.refFk + WHERE year(f.shipped) = vYear + AND month(f.shipped) = vMonth; + SELECT vYear Año, vMonth Mes, - t.Id_Cliente, + t.clientFk, round(sum(Cantidad * Preu * (100 - m.Descuento)/100)) Venta, IF(e.empresa_grupo = e2.empresa_grupo, 1, IF(e2.empresa_grupo,2,0)) AS grupo, - t.empresa_id empresa + t.companyFk empresa FROM vn2008.Movimientos m - JOIN vn2008.Tickets t ON t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.Id_Consigna + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN vn2008.Consignatarios cs ON cs.Id_Consigna = t.addressFk JOIN vn2008.Clientes c ON c.Id_Cliente = cs.Id_Cliente - JOIN tmp.ticket_list tt ON tt.Id_Ticket = t.Id_Ticket + JOIN tmp.ticket_list tt ON tt.id = t.id JOIN vn2008.Articles a ON m.Id_Article = a.Id_Article - JOIN vn2008.empresa e ON e.id = t.empresa_id + JOIN vn2008.empresa e ON e.id = t.companyFk LEFT JOIN vn2008.empresa e2 ON e2.Id_Cliente = c.Id_Cliente JOIN vn2008.Tipos tp ON tp.tipo_id = a.tipo_id WHERE Cantidad <> 0 AND Preu <> 0 AND m.Descuento <> 100 AND a.tipo_id != 188 - GROUP BY t.Id_Cliente, grupo,t.empresa_id; + GROUP BY t.clientFk, grupo,t.companyFk; DROP TEMPORARY TABLE tmp.ticket_list; - + END$$ DELIMITER ; diff --git a/db/routines/vn/functions/getAlert3StateTest.sql b/db/routines/vn/functions/getAlert3StateTest.sql index 6a14d80d4..beba0948c 100644 --- a/db/routines/vn/functions/getAlert3StateTest.sql +++ b/db/routines/vn/functions/getAlert3StateTest.sql @@ -11,9 +11,9 @@ BEGIN SELECT a.Vista INTO vDeliveryType - FROM vn2008.Tickets t - JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia - WHERE Id_Ticket = vTicket; + FROM ticket t + JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk + WHERE id = vTicket; CASE vDeliveryType WHEN 1 THEN -- AGENCIAS @@ -23,11 +23,11 @@ BEGIN SET vCode = 'ON_DELIVERY'; ELSE -- MERCADO, OTROS - SELECT t.warehouse_id <> w.warehouse_id INTO isWaitingForPickUp - FROM vn2008.Tickets t + SELECT t.warehouseFk <> w.warehouse_id INTO isWaitingForPickUp + FROM ticket t LEFT JOIN vn2008.warehouse_pickup w - ON w.agency_id = t.Id_Agencia AND w.warehouse_id = t.warehouse_id - WHERE t.Id_Ticket = vTicket; + ON w.agency_id = t.agencyModeFk AND w.warehouse_id = t.warehouseFk + WHERE t.id = vTicket; IF isWaitingForPickUp THEN SET vCode = 'WAITING_FOR_PICKUP'; diff --git a/db/routines/vn/functions/isPalletHomogeneus.sql b/db/routines/vn/functions/isPalletHomogeneus.sql index 39c6461ae..05c20a71b 100644 --- a/db/routines/vn/functions/isPalletHomogeneus.sql +++ b/db/routines/vn/functions/isPalletHomogeneus.sql @@ -14,12 +14,12 @@ BEGIN SELECT COUNT(*) INTO vDistinctRoutesInThePallet FROM ( - SELECT DISTINCT t.Id_Ruta + SELECT DISTINCT t.routeFk FROM vn2008.scan_line sl JOIN vn2008.expeditions e ON e.expeditions_id = sl.code - JOIN vn2008.Tickets t ON t.Id_Ticket = e.ticket_id + JOIN ticket t ON t.id = e.ticket_id WHERE sl.scan_id = vScanId - AND t.Id_Ruta + AND t.routeFk ) t1; RETURN vDistinctRoutesInThePallet = 1; diff --git a/db/routines/vn/functions/ticketPositionInPath.sql b/db/routines/vn/functions/ticketPositionInPath.sql index 9bd2c110e..9a3bb4a0e 100644 --- a/db/routines/vn/functions/ticketPositionInPath.sql +++ b/db/routines/vn/functions/ticketPositionInPath.sql @@ -28,10 +28,10 @@ SELECT t.routeFk, t.warehouseFk, IFNULL(ts.productionOrder,0) SELECT (ag.`name` = 'VN_VALENCIA') INTO vIsValenciaPath - FROM vn2008.Rutas r - JOIN vn2008.Agencias a on a.Id_Agencia = r.Id_Agencia + FROM `route` r + JOIN vn2008.Agencias a on a.Id_Agencia = r.agencyModeFk JOIN vn2008.agency ag on ag.agency_id = a.agency_id - WHERE r.Id_Ruta = vMyPath; + WHERE r.id = vMyPath; IF vIsValenciaPath THEN -- Rutas Valencia diff --git a/db/routines/vn/procedures/invoiceFromAddress.sql b/db/routines/vn/procedures/invoiceFromAddress.sql index bde7afd8c..bea49e747 100644 --- a/db/routines/vn/procedures/invoiceFromAddress.sql +++ b/db/routines/vn/procedures/invoiceFromAddress.sql @@ -10,10 +10,13 @@ BEGIN CREATE TEMPORARY TABLE `tmp.``ticketToInvoice` (PRIMARY KEY (`id`)) - ENGINE = MEMORY - SELECT Id_Ticket id FROM vn2008.Tickets WHERE (Fecha BETWEEN vMinDateTicket - AND vMaxTicketDate) AND Id_Consigna = vAddress - AND Factura IS NULL AND empresa_id = vCompany; + ENGINE = MEMORY + SELECT id id + FROM ticket + WHERE (shipped BETWEEN vMinDateTicket AND vMaxTicketDate) + AND addressFk = vAddress + AND refFk IS NULL + AND companyFk = vCompany; END$$ DELIMITER ; diff --git a/db/routines/vn2008/procedures/availableTraslate.sql b/db/routines/vn2008/procedures/availableTraslate.sql index 6328560c8..399302d7b 100644 --- a/db/routines/vn2008/procedures/availableTraslate.sql +++ b/db/routines/vn2008/procedures/availableTraslate.sql @@ -18,7 +18,7 @@ proc: BEGIN -- Calcula algunos parámetros necesarios SET vDatedFrom = TIMESTAMP(vDated, '00:00:00'); SET vDatedTo = TIMESTAMP(TIMESTAMPADD(DAY, 4, vDated), '23:59:59'); - SELECT FechaInventario INTO vDatedInventory FROM tblContadores; + SELECT inventoried INTO vDatedInventory FROM vn.config; SELECT SUBTIME(util.VN_NOW(), reserveTime) INTO vDatedReserve FROM hedera.orderConfig; diff --git a/db/routines/vn2008/procedures/clean.sql b/db/routines/vn2008/procedures/clean.sql index bd8a324c6..dba4799d9 100644 --- a/db/routines/vn2008/procedures/clean.sql +++ b/db/routines/vn2008/procedures/clean.sql @@ -34,8 +34,8 @@ proc: BEGIN WHERE t.Fecha < vDate; DELETE tobs - FROM ticket_observation tobs - JOIN Tickets t ON tobs.Id_Ticket = t.Id_Ticket + FROM ticketObservation tobs + JOIN Tickets t ON tobs.ticketFk = t.Id_Ticket WHERE t.Fecha < vDate; DELETE tobs @@ -45,10 +45,10 @@ proc: BEGIN DELETE FROM Remesas WHERE `Fecha Remesa` < vDate18; - DELETE tt.* - FROM Tickets_turno tt - LEFT JOIN Movimientos m USING(Id_Ticket) - WHERE m.Id_Article IS NULL; + DELETE tw.* + FROM vn.ticketWeekly tw + LEFT JOIN vn.sale s USING(ticketFk) + WHERE s.Id_Article IS NULL; DELETE FROM cl_main WHERE Fecha < vDate18; DELETE FROM hedera.`order` WHERE date_send < vDate18; diff --git a/db/routines/vn2008/procedures/confection_control_source.sql b/db/routines/vn2008/procedures/confection_control_source.sql index 77b4df5f3..2951e9c38 100644 --- a/db/routines/vn2008/procedures/confection_control_source.sql +++ b/db/routines/vn2008/procedures/confection_control_source.sql @@ -11,33 +11,33 @@ BEGIN CREATE TEMPORARY TABLE tmp.production_buffer ENGINE = MEMORY SELECT - date(t.Fecha) as Fecha, - hour(t.Fecha) as Hora, - hour(t.Fecha) as Departure, - t.Id_Ticket, + date(t.shipped) as Fecha, + hour(t.shipped) as Hora, + hour(t.shipped) as Departure, + t.id, m.Id_Movimiento, m.Cantidad, m.Concepte, ABS(m.Reservado) Reservado, i.Categoria, tp.Tipo, - t.Alias as Cliente, + t.nickname as Cliente, wh.name as Almacen, - t.warehouse_id, + t.warehouseFk, cs.province_id, a.agency_id, ct.description as Taller, stock.visible, stock.available - FROM vn2008.Tickets t - JOIN vn2008.Agencias a ON a.Id_Agencia = t.Id_Agencia - JOIN vn.warehouse wh ON wh.id = t.warehouse_id - JOIN vn2008.Movimientos m ON m.Id_Ticket = t.Id_Ticket + FROM vn.ticket t + JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk + JOIN vn.warehouse wh ON wh.id = t.warehouseFk + JOIN vn2008.Movimientos m ON m.Id_Ticket = t.id JOIN vn2008.Articles i ON i.Id_Article = m.Id_Article JOIN vn2008.Tipos tp ON tp.tipo_id = i.tipo_id JOIN vn.confectionType ct ON ct.id = tp.confeccion - JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna - LEFT JOIN vn.ticketState tls on tls.ticketFk = t.Id_Ticket + JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.addressFk + LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id LEFT JOIN ( SELECT item_id, sum(visible) visible, sum(available) available @@ -61,7 +61,7 @@ BEGIN WHERE tp.confeccion AND tls.alertLevel < maxAlertLevel AND wh.hasConfectionTeam - AND t.Fecha BETWEEN vDated AND vEndingDate + AND t.shipped BETWEEN vDated AND vEndingDate AND m.Cantidad > 0; -- Entradas diff --git a/db/routines/vn2008/procedures/historico_multiple.sql b/db/routines/vn2008/procedures/historico_multiple.sql index ae4045a34..c68fbf2ad 100644 --- a/db/routines/vn2008/procedures/historico_multiple.sql +++ b/db/routines/vn2008/procedures/historico_multiple.sql @@ -4,7 +4,7 @@ BEGIN DECLARE vDateInventory DATETIME; - SELECT Fechainventario INTO vDateInventory FROM tblContadores; + SELECT inventoried INTO vDateInventory FROM vn.config; SET @a = 0; diff --git a/db/routines/vn2008/views/Tickets_state.sql b/db/routines/vn2008/views/Tickets_state.sql deleted file mode 100644 index be59a750f..000000000 --- a/db/routines/vn2008/views/Tickets_state.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Tickets_state` -AS SELECT `t`.`ticketFk` AS `Id_Ticket`, - `t`.`ticketTrackingFk` AS `inter_id`, - `t`.`name` AS `state_name` -FROM `vn`.`ticketLastState` `t` diff --git a/db/routines/vn2008/views/Tickets_turno.sql b/db/routines/vn2008/views/Tickets_turno.sql deleted file mode 100644 index 28bc2d55f..000000000 --- a/db/routines/vn2008/views/Tickets_turno.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Tickets_turno` -AS SELECT `tw`.`ticketFk` AS `Id_Ticket`, - `tw`.`weekDay` AS `weekDay` -FROM `vn`.`ticketWeekly` `tw` From 350088614991bee0909b1ba54af10b14ff72ff6d Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 6 Feb 2024 08:37:28 +0100 Subject: [PATCH 019/161] feat: refs #6777 tabulacion --- .../procedures/confection_control_source.sql | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/db/routines/vn2008/procedures/confection_control_source.sql b/db/routines/vn2008/procedures/confection_control_source.sql index 2951e9c38..6833cd29d 100644 --- a/db/routines/vn2008/procedures/confection_control_source.sql +++ b/db/routines/vn2008/procedures/confection_control_source.sql @@ -15,31 +15,31 @@ BEGIN hour(t.shipped) as Hora, hour(t.shipped) as Departure, t.id, - m.Id_Movimiento, + m.Id_Movimiento, m.Cantidad, m.Concepte, - ABS(m.Reservado) Reservado, + ABS(m.Reservado) Reservado, i.Categoria, - tp.Tipo, + tp.Tipo, t.nickname as Cliente, wh.name as Almacen, t.warehouseFk, cs.province_id, a.agency_id, - ct.description as Taller, - stock.visible, - stock.available + ct.description as Taller, + stock.visible, + stock.available FROM vn.ticket t JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk JOIN vn.warehouse wh ON wh.id = t.warehouseFk JOIN vn2008.Movimientos m ON m.Id_Ticket = t.id - JOIN vn2008.Articles i ON i.Id_Article = m.Id_Article + JOIN vn2008.Articles i ON i.Id_Article = m.Id_Article JOIN vn2008.Tipos tp ON tp.tipo_id = i.tipo_id - JOIN vn.confectionType ct ON ct.id = tp.confeccion + JOIN vn.confectionType ct ON ct.id = tp.confeccion JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.addressFk LEFT JOIN vn.ticketState tls on tls.ticketFk = t.id - LEFT JOIN - ( + LEFT JOIN + ( SELECT item_id, sum(visible) visible, sum(available) available FROM ( @@ -57,12 +57,12 @@ BEGIN where cc.cache_id IN (2,8) and cc.params IN ("1","44") ) sub GROUP BY item_id - ) stock ON stock.item_id = m.Id_Article + ) stock ON stock.item_id = m.Id_Article WHERE tp.confeccion AND tls.alertLevel < maxAlertLevel AND wh.hasConfectionTeam AND t.shipped BETWEEN vDated AND vEndingDate - AND m.Cantidad > 0; + AND m.Cantidad > 0; -- Entradas @@ -74,9 +74,9 @@ BEGIN Categoria, Cliente, Almacen, - Taller + Taller ) - SELECT + SELECT tr.shipment AS Fecha, e.Id_Entrada AS Id_Ticket, c.Cantidad, @@ -96,10 +96,7 @@ BEGIN WHERE who.hasConfectionTeam AND tp.confeccion AND tr.shipment BETWEEN vDated AND vEndingDate; - - - SELECT * FROM tmp.production_buffer; - + SELECT * FROM tmp.production_buffer; END$$ DELIMITER ; From c598e62d1ecc50e77ef0662840ca1afff3d5acdc Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 6 Feb 2024 14:03:33 +0100 Subject: [PATCH 020/161] feat: refs #6777 change dependencies vn2008 to vn part7 --- db/routines/bi/views/v_ventas_contables.sql | 10 +- db/routines/vn/views/ticketMRW.sql | 16 +-- .../procedures/ListaTicketsEncajados.sql | 36 ++--- db/routines/vn2008/procedures/clean.sql | 19 +-- .../procedures/customerDebtEvolution.sql | 32 ++--- .../emailYesterdayPurchasesByConsigna.sql | 16 +-- .../vn2008/procedures/embalajes_stocks.sql | 74 +++++----- .../procedures/embalajes_stocks_detalle.sql | 135 +++++++++--------- .../vn2008/procedures/historico_absoluto.sql | 20 +-- .../vn2008/procedures/historico_multiple.sql | 12 +- .../vn2008/procedures/preOrdenarRuta.sql | 24 ++-- .../vn2008/procedures/prepare_ticket_list.sql | 12 +- .../vn2008/procedures/risk_vs_client_list.sql | 10 +- db/routines/vn2008/views/item_out.sql | 8 +- 14 files changed, 213 insertions(+), 211 deletions(-) diff --git a/db/routines/bi/views/v_ventas_contables.sql b/db/routines/bi/views/v_ventas_contables.sql index 373fcdd3f..82bbeeaac 100644 --- a/db/routines/bi/views/v_ventas_contables.sql +++ b/db/routines/bi/views/v_ventas_contables.sql @@ -11,13 +11,13 @@ AS SELECT `time`.`year` AS `year`, FROM ( ( ( - `vn2008`.`Tickets` `t` - JOIN `bi`.`f_tvc` ON(`t`.`Id_Ticket` = `bi`.`f_tvc`.`Id_Ticket`) + `vn`.`ticket` `t` + JOIN `bi`.`f_tvc` ON(`t`.`id` = `bi`.`f_tvc`.`Id_Ticket`) ) - JOIN `vn2008`.`Movimientos` `m` ON(`t`.`Id_Ticket` = `m`.`Id_Ticket`) + JOIN `vn2008`.`Movimientos` `m` ON(`t`.`id` = `m`.`Id_Ticket`) ) - JOIN `vn2008`.`time` ON(`time`.`date` = cast(`t`.`Fecha` AS date)) + JOIN `vn2008`.`time` ON(`time`.`date` = cast(`t`.`shipped` AS date)) ) -WHERE `t`.`Fecha` >= '2014-01-01' +WHERE `t`.`shipped` >= '2014-01-01' GROUP BY `time`.`year`, `time`.`month` diff --git a/db/routines/vn/views/ticketMRW.sql b/db/routines/vn/views/ticketMRW.sql index d612c8742..2677b41e7 100644 --- a/db/routines/vn/views/ticketMRW.sql +++ b/db/routines/vn/views/ticketMRW.sql @@ -1,8 +1,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn`.`ticketMRW` -AS SELECT `Tickets`.`Id_Agencia` AS `id_Agencia`, - `Tickets`.`empresa_id` AS `empresa_id`, +AS SELECT `ticket`.`agencyModeFk` AS `id_Agencia`, + `ticket`.`companyFk` AS `empresa_id`, `Consignatarios`.`consignatario` AS `Consignatario`, `Consignatarios`.`domicilio` AS `DOMICILIO`, `Consignatarios`.`poblacion` AS `POBLACION`, @@ -19,13 +19,13 @@ AS SELECT `Tickets`.`Id_Agencia` AS `id_Agencia`, 0 ) AS `movil`, `Clientes`.`if` AS `IF`, - `Tickets`.`Id_Ticket` AS `Id_Ticket`, - `Tickets`.`warehouse_id` AS `warehouse_id`, + `ticket`.`id` AS `Id_Ticket`, + `ticket`.`warehouseFk` AS `warehouse_id`, `Consignatarios`.`id_consigna` AS `Id_Consigna`, `Paises`.`Codigo` AS `CodigoPais`, - `Tickets`.`Fecha` AS `Fecha`, + `ticket`.`shipped` AS `Fecha`, `province`.`province_id` AS `province_id`, - `Tickets`.`landing` AS `landing` + `ticket`.`landed` AS `landing` FROM ( ( ( @@ -35,8 +35,8 @@ FROM ( `Clientes`.`id_cliente` = `Consignatarios`.`Id_cliente` ) ) - JOIN `vn2008`.`Tickets` ON( - `Consignatarios`.`id_consigna` = `Tickets`.`Id_Consigna` + JOIN `vn`.`ticket` ON( + `Consignatarios`.`id_consigna` = `ticket`.`addressFk` ) ) JOIN `vn2008`.`province` ON( diff --git a/db/routines/vn2008/procedures/ListaTicketsEncajados.sql b/db/routines/vn2008/procedures/ListaTicketsEncajados.sql index 3d3318c63..e220cd9ad 100644 --- a/db/routines/vn2008/procedures/ListaTicketsEncajados.sql +++ b/db/routines/vn2008/procedures/ListaTicketsEncajados.sql @@ -2,24 +2,24 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`ListaTicketsEncajados`(IN intId_Trabajador int) BEGIN -SELECT Agencia, - Consignatario, - ti.Id_Ticket, - ts.userFk Id_Trabajador, - IFNULL(ncajas,0) AS ncajas, - IFNULL(nbultos,0) AS nbultos, - IFNULL(notros,0) AS notros, - ts.code AS Estado - FROM Tickets ti - INNER JOIN Consignatarios ON ti.Id_Consigna = Consignatarios.Id_consigna - INNER JOIN Agencias ON ti.Id_Agencia = Agencias.Id_Agencia - LEFT JOIN (SELECT Ticket_Id,count(*) AS ncajas FROM expeditions WHERE Id_Article=94 GROUP BY ticket_id) sub1 ON ti.Id_Ticket=sub1.Ticket_Id - LEFT JOIN (SELECT Ticket_Id,count(*) AS nbultos FROM expeditions WHERE Id_Article IS NULL GROUP BY ticket_id) sub2 ON ti.Id_Ticket=sub2.Ticket_Id - LEFT JOIN (SELECT Ticket_Id,count(*) AS notros FROM expeditions WHERE Id_Article >0 GROUP BY ticket_id) sub3 ON ti.Id_Ticket=sub3.Ticket_Id - INNER JOIN vn.ticketState ts ON ti.Id_ticket = ts.ticketFk - WHERE ti.Fecha=util.VN_CURDATE() AND - ts.userFk=intId_Trabajador - GROUP BY ti.Id_Ticket; + SELECT Agencia, + Consignatario, + ti.id Id_Ticket, + ts.userFk Id_Trabajador, + IFNULL(ncajas,0) AS ncajas, + IFNULL(nbultos,0) AS nbultos, + IFNULL(notros,0) AS notros, + ts.code AS Estado + FROM Tickets ti + INNER JOIN Consignatarios ON ti.addressFk = Consignatarios.Id_consigna + INNER JOIN Agencias ON ti.agencyModeFk = Agencias.Id_Agencia + LEFT JOIN (SELECT Ticket_Id,count(*) AS ncajas FROM expeditions WHERE Id_Article=94 GROUP BY ticket_id) sub1 ON ti.id=sub1.Ticket_Id + LEFT JOIN (SELECT Ticket_Id,count(*) AS nbultos FROM expeditions WHERE Id_Article IS NULL GROUP BY ticket_id) sub2 ON ti.id=sub2.Ticket_Id + LEFT JOIN (SELECT Ticket_Id,count(*) AS notros FROM expeditions WHERE Id_Article >0 GROUP BY ticket_id) sub3 ON ti.id=sub3.Ticket_Id + INNER JOIN vn.ticketState ts ON ti.id = ts.ticketFk + WHERE ti.shipped=util.VN_CURDATE() AND + ts.userFk=intId_Trabajador + GROUP BY ti.id; END$$ DELIMITER ; diff --git a/db/routines/vn2008/procedures/clean.sql b/db/routines/vn2008/procedures/clean.sql index dba4799d9..00279c090 100644 --- a/db/routines/vn2008/procedures/clean.sql +++ b/db/routines/vn2008/procedures/clean.sql @@ -30,18 +30,19 @@ proc: BEGIN DELETE ts FROM Tickets_stack ts - JOIN Tickets t ON ts.Id_Ticket = t.Id_Ticket - WHERE t.Fecha < vDate; + JOIN vn.ticket t ON ts.Id_Ticket = t.id + WHERE t.shipped < vDate; DELETE tobs FROM ticketObservation tobs - JOIN Tickets t ON tobs.ticketFk = t.Id_Ticket - WHERE t.Fecha < vDate; + JOIN vn.ticket t ON tobs.ticketFk = t.id + WHERE t.shipped < vDate; DELETE tobs FROM movement_label tobs JOIN Movimientos m ON tobs.Id_Movimiento = m.Id_Movimiento - JOIN Tickets t ON m.Id_Ticket = t.Id_Ticket WHERE t.Fecha < vDate; + JOIN vn.ticket t ON m.Id_Ticket = t.id + WHERE t.shipped < vDate; DELETE FROM Remesas WHERE `Fecha Remesa` < vDate18; @@ -92,9 +93,9 @@ proc: BEGIN END IF; -- Tickets Nulos PAK 11/10/2016 - UPDATE Tickets - SET empresa_id = 965 - WHERE Id_Cliente = 31 - AND empresa_id != 965; + UPDATE vn.ticket + SET companyFk = 965 + WHERE clientFk = 31 + AND companyFk != 965; END$$ DELIMITER ; diff --git a/db/routines/vn2008/procedures/customerDebtEvolution.sql b/db/routines/vn2008/procedures/customerDebtEvolution.sql index e5d23f0ef..f6f81e2b0 100644 --- a/db/routines/vn2008/procedures/customerDebtEvolution.sql +++ b/db/routines/vn2008/procedures/customerDebtEvolution.sql @@ -13,28 +13,28 @@ SELECT * FROM LEFT JOIN (SELECT Euros, date(Fecha) as Fecha FROM ( - SELECT Fechacobro as Fecha, Entregado as Euros + SELECT Fechacobro as Fecha, Entregado as Euros FROM Recibos WHERE Id_Cliente = vCustomer - AND Fechacobro >= '2017-01-01' - UNION ALL - SELECT vn.getDueDate(f.Fecha,c.Vencimiento), - Importe + AND Fechacobro >= '2017-01-01' + UNION ALL + SELECT vn.getDueDate(f.Fecha,c.Vencimiento), - Importe FROM Facturas f - JOIN Clientes c ON f.Id_Cliente = c.Id_Cliente + JOIN Clientes c ON f.Id_Cliente = c.Id_Cliente WHERE f.Id_Cliente = vCustomer - AND Fecha >= '2017-01-01' - UNION ALL - SELECT '2016-12-31', Debt + AND Fecha >= '2017-01-01' + UNION ALL + SELECT '2016-12-31', Debt FROM bi.customerDebtInventory WHERE Id_Cliente = vCustomer - UNION ALL - SELECT Fecha, - SUM(Cantidad * Preu * (100 - Descuento ) * 1.10 / 100) - FROM Tickets t - JOIN Movimientos m on m.Id_Ticket = t.Id_Ticket - WHERE Id_Cliente = vCustomer - AND Factura IS NULL - AND Fecha >= '2017-01-01' - GROUP BY Fecha + UNION ALL + SELECT t.shipped, - SUM(m.Cantidad * m.Preu * (100 - m.Descuento ) * 1.10 / 100) + FROM vn.ticket t + JOIN Movimientos m on m.Id_Ticket = t.id + WHERE t.clientFk = vCustomer + AND t.refFk IS NULL + AND t.shipped >= '2017-01-01' + GROUP BY t.shipped ) sub2 ORDER BY Fecha )sub ON time.date = sub.Fecha diff --git a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql index 439eba5ad..2a753157d 100644 --- a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql +++ b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql @@ -14,8 +14,8 @@ BEGIN DECLARE txt TEXT; DECLARE rs CURSOR FOR - SELECT t.Id_Ticket, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION - FROM Tickets t + SELECT t.id, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION + FROM vn.ticket t JOIN Consignatarios cs ON t.Id_Consigna = cs.Id_Consigna JOIN ( SELECT `Movimientos`.`Id_Ticket` AS `Id_Ticket`, @@ -24,15 +24,15 @@ BEGIN ) AS `amount` FROM ( `vn2008`.`Movimientos` - JOIN `vn2008`.`Tickets` ON( - `Movimientos`.`Id_Ticket` = `Tickets`.`Id_Ticket` + JOIN `vn`.`ticket` ON( + `Movimientos`.`Id_Ticket` = `ticket`.`id` ) ) - WHERE `Tickets`.`Fecha` >= `util`.`VN_CURDATE`() + INTERVAL -6 MONTH + WHERE `ticket`.`shipped` >= `util`.`VN_CURDATE`() + INTERVAL -6 MONTH GROUP BY `Movimientos`.`Id_Ticket` - ) v ON v.Id_Ticket = t.Id_Ticket - WHERE t.Fecha BETWEEN v_Date AND util.dayEnd(v_Date) - AND t.Id_Cliente = v_Client_Id; + ) v ON v.Id_Ticket = t.id + WHERE t.shipped BETWEEN v_Date AND util.dayEnd(v_Date) + AND t.clientFk = v_Client_Id; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; diff --git a/db/routines/vn2008/procedures/embalajes_stocks.sql b/db/routines/vn2008/procedures/embalajes_stocks.sql index b20e44c79..f6b0d9b9a 100644 --- a/db/routines/vn2008/procedures/embalajes_stocks.sql +++ b/db/routines/vn2008/procedures/embalajes_stocks.sql @@ -2,50 +2,50 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`embalajes_stocks`(IN idPEOPLE INT, IN bolCLIENT BOOLEAN) BEGIN -if bolCLIENT then + IF bolCLIENT THEN - select m.Id_Article, Article, - cast(sum(m.Cantidad) as decimal) as Saldo - from Movimientos m - join Articles a on m.Id_Article = a.Id_Article - join Tipos tp on tp.tipo_id = a.tipo_id - join Tickets t using(Id_Ticket) - join Consignatarios cs using(Id_Consigna) - where cs.Id_Cliente = idPEOPLE - and Tipo = 'Contenedores' - and t.Fecha > '2010-01-01' - group by m.Id_Article; + SELECT m.Id_Article, Article, - cast(sum(m.Cantidad) as decimal) Saldo + FROM Movimientos m + JOIN Articles a ON m.Id_Article = a.Id_Article + JOIN Tipos tp ON tp.tipo_id = a.tipo_id + JOIN ticket t ON t.id = m.Id_Ticket + JOIN Consignatarios cs using(Id_Consigna) + WHERE cs.Id_Cliente = idPEOPLE + AND Tipo = 'Contenedores' + AND t.shipped > '2010-01-01' + GROUP BY m.Id_Article; -else + ELSE -select Id_Article, Article, sum(Cantidad) as Saldo -from -(select Id_Article, Cantidad -from Compres c -join Articles a using(Id_Article) -join Tipos tp using(tipo_id) -join Entradas e using(Id_Entrada) -join travel tr on tr.id = travel_id -where Id_Proveedor = idPEOPLE -and landing >= '2010-01-01' -and reino_id = 6 + SELECT Id_Article, Article, sum(Cantidad) Saldo + FROM + (SELECT Id_Article, Cantidad + FROM Compres c + JOIN Articles a using(Id_Article) + JOIN Tipos tp using(tipo_id) + JOIN Entradas e using(Id_Entrada) + JOIN travel tr ON tr.id = travel_id + WHERE Id_Proveedor = idPEOPLE + AND landing >= '2010-01-01' + AND reino_id = 6 -union all + union all -select Id_Article, - Cantidad -from Movimientos m -join Articles a using(Id_Article) -join Tipos tp using(tipo_id) -join Tickets t using(Id_Ticket) -join Consignatarios cs using(Id_Consigna) -join proveedores_clientes pc on pc.Id_Cliente = cs.Id_Cliente -where Id_Proveedor = idPEOPLE -and reino_id = 6 -and t.Fecha > '2010-01-01') mov + SELECT Id_Article, - Cantidad + FROM Movimientos m + JOIN Articles a using(Id_Article) + JOIN Tipos tp using(tipo_id) + JOIN ticket t ON t.id = m.Id_Ticket + JOIN Consignatarios cs using(Id_Consigna) + JOIN proveedores_clientes pc ON pc.Id_Cliente = cs.Id_Cliente + WHERE Id_Proveedor = idPEOPLE + AND reino_id = 6 + AND t.shipped > '2010-01-01') mov -join Articles a using(Id_Article) -group by Id_Article; + JOIN Articles a using(Id_Article) + GROUP BY Id_Article; -end if; + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql b/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql index c49d1b88a..0319e0f75 100644 --- a/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql +++ b/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql @@ -2,77 +2,78 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`embalajes_stocks_detalle`(IN idPEOPLE INT, IN idARTICLE INT, IN bolCLIENT BOOLEAN) BEGIN + IF bolCLIENT THEN -if bolCLIENT then + SELECT m.Id_Article + , Article + , IF(Cantidad < 0, - Cantidad, NULL) Entrada + , IF(Cantidad < 0, NULL, Cantidad) Salida + , 'T' Tabla + , t.id Registro + , t.shipped Fecha + , w.name Almacen + , cast(Preu as Decimal(5,2)) Precio + , c.Cliente Proveedor + , abbreviation Empresa + FROM Movimientos m + JOIN Articles a using(Id_Article) + JOIN ticket t ON t.id = m.Id_Ticket + JOIN empresa e ON e.id = t.companyFk + JOIN warehouse w ON w.id = t.warehouseFk + JOIN Consignatarios cs using(Id_Consigna) + JOIN Clientes c ON c.Id_Cliente = cs.Id_Cliente + WHERE cs.Id_Cliente = idPEOPLE + AND m.Id_Article = idARTICLE + AND t.shipped > '2010-01-01'; - select m.Id_Article - , Article - , IF(Cantidad < 0, - Cantidad, NULL) as Entrada - , IF(Cantidad < 0, NULL, Cantidad) as Salida - , 'T' as Tabla - , t.Id_Ticket as Registro - , t.Fecha - , w.name as Almacen - , cast(Preu as Decimal(5,2)) Precio - , c.Cliente as Proveedor - , abbreviation as Empresa - from Movimientos m - join Articles a using(Id_Article) - join Tickets t using(Id_Ticket) - join empresa e on e.id = t.empresa_id - join warehouse w on w.id = t.warehouse_id - join Consignatarios cs using(Id_Consigna) - join Clientes c on c.Id_Cliente = cs.Id_Cliente - where cs.Id_Cliente = idPEOPLE - and m.Id_Article = idARTICLE - and t.Fecha > '2010-01-01'; + ELSE -else + SELECT Id_Article, + Tabla, + Registro, + Fecha, + Article, + w.name Almacen, + Entrada, + Salida, + Proveedor, + cast(Precio as Decimal(5,2)) Precio + FROM + (SELECT Id_Article + , IF(Cantidad > 0, Cantidad, NULL) Entrada + , IF(Cantidad > 0, NULL,- Cantidad) Salida + , 'E' Tabla + , Id_Entrada Registro + , landing Fecha + , tr.warehouse_id + , Costefijo Precio + FROM Compres c + JOIN Entradas e using(Id_Entrada) + JOIN travel tr ON tr.id = travel_id + WHERE Id_Proveedor = idPEOPLE + AND Id_Article = idARTICLE + AND landing >= '2010-01-01' -select Id_Article, Tabla, Registro, Fecha, Article -, w.name as Almacen, Entrada, Salida, Proveedor, cast(Precio as Decimal(5,2)) Precio - -from - -(select Id_Article - , IF(Cantidad > 0, Cantidad, NULL) as Entrada - , IF(Cantidad > 0, NULL,- Cantidad) as Salida - , 'E' as Tabla - , Id_Entrada as Registro - , landing as Fecha - , tr.warehouse_id - , Costefijo as Precio -from Compres c -join Entradas e using(Id_Entrada) -join travel tr on tr.id = travel_id -where Id_Proveedor = idPEOPLE -and Id_Article = idARTICLE -and landing >= '2010-01-01' - -union all - -select Id_Article - , IF(Cantidad < 0, - Cantidad, NULL) as Entrada - , IF(Cantidad < 0, NULL, Cantidad) as Salida - , 'T' - , Id_Ticket - , Fecha - , t.warehouse_id - , Preu -from Movimientos m -join Tickets t using(Id_Ticket) -join Consignatarios cs using(Id_Consigna) -join proveedores_clientes pc on pc.Id_Cliente = cs.Id_Cliente -where Id_Proveedor = idPEOPLE -and Id_Article = idARTICLE -and t.Fecha > '2010-01-01') mov - -join Articles a using(Id_Article) -join Proveedores p on Id_Proveedor = idPEOPLE -join warehouse w on w.id = mov.warehouse_id -; - -end if; + union all + SELECT Id_Article + , IF(Cantidad < 0, - Cantidad, NULL) Entrada + , IF(Cantidad < 0, NULL, Cantidad) Salida + , 'T' + , Id_Ticket + , Fecha + , t.warehouseFk warehouse_id + , Preu + FROM Movimientos m + JOIN ticket t ON t.id = m.Id_Ticket + JOIN Consignatarios cs using(Id_Consigna) + JOIN proveedores_clientes pc ON pc.Id_Cliente = cs.Id_Cliente + WHERE Id_Proveedor = idPEOPLE + AND Id_Article = idARTICLE + AND t.shipped > '2010-01-01') mov + JOIN Articles a using(Id_Article) + JOIN Proveedores p ON Id_Proveedor = idPEOPLE + JOIN warehouse w ON w.id = mov.warehouse_id; + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn2008/procedures/historico_absoluto.sql b/db/routines/vn2008/procedures/historico_absoluto.sql index 1a7e1dbfa..55f33ee89 100644 --- a/db/routines/vn2008/procedures/historico_absoluto.sql +++ b/db/routines/vn2008/procedures/historico_absoluto.sql @@ -50,20 +50,20 @@ BEGIN AND E.Inventario = 0 AND E.Redada = 0 UNION ALL - SELECT T.Fecha Fecha, + SELECT t.shipped Fecha, NULL Entrada, M.Cantidad Salida, - (M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) OK, - T.Alias Alias, - T.Factura Referencia, - T.Id_Ticket, - T.PedidoImpreso + (M.OK <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) OK, + t.nickname Alias, + t.refFk Referencia, + t.id Id_Ticket, + t.isPrinted PedidoImpreso FROM Movimientos M - INNER JOIN Tickets T USING (Id_Ticket) - JOIN Clientes C ON C.Id_Cliente = T.Id_Cliente - WHERE T.Fecha >= '2001-01-01' + INNER JOIN ticket t USING (Id_Ticket) + JOIN Clientes C ON C.Id_Cliente = t.clientFk + WHERE t.shipped >= '2001-01-01' AND M.Id_Article = idART - AND wh IN (T.warehouse_id , 0) + AND wh IN (t.warehouseFk , 0) ) t1 ORDER BY Fecha, Entrada DESC, OK DESC; diff --git a/db/routines/vn2008/procedures/historico_multiple.sql b/db/routines/vn2008/procedures/historico_multiple.sql index c68fbf2ad..fbec7bb1d 100644 --- a/db/routines/vn2008/procedures/historico_multiple.sql +++ b/db/routines/vn2008/procedures/historico_multiple.sql @@ -66,17 +66,17 @@ BEGIN UNION ALL - SELECT T.Fecha as Fecha, + SELECT t.shipped as Fecha, NULL as Entrada, M.Cantidad as Salida, warehouse_id as wh, - (M.OK <> 0 OR T.Etiquetasemitidas <> 0 OR T.Factura IS NOT NULL) as OK, - T.Factura as Referencia, - T.Id_Ticket as id + (M.OK <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) as OK, + t.refFk as Referencia, + t.id as id FROM Movimientos M - INNER JOIN Tickets T USING (Id_Ticket) - WHERE T.Fecha >= vDateInventory + INNER JOIN ticket t ON t.id = M.Id_Ticket + WHERE t.shipped >= vDateInventory AND M.Id_Article = vItemFk ) AS Historia diff --git a/db/routines/vn2008/procedures/preOrdenarRuta.sql b/db/routines/vn2008/procedures/preOrdenarRuta.sql index b5fd2b24b..9bcf853bd 100644 --- a/db/routines/vn2008/procedures/preOrdenarRuta.sql +++ b/db/routines/vn2008/procedures/preOrdenarRuta.sql @@ -6,17 +6,17 @@ BEGIN * DEPRECATED use vn.routeGressPriority */ -UPDATE Tickets mt -JOIN ( - SELECT tt.Id_Consigna, round(ifnull(avg(t.Prioridad),0),0) as Prioridad - from Tickets t - JOIN Tickets tt on tt.Id_Consigna = t.Id_Consigna - where t.Fecha > TIMESTAMPADD(YEAR,-1,util.VN_CURDATE()) - AND tt.Id_Ruta = vRutaId - GROUP BY Id_Consigna - ) sub ON sub.Id_Consigna = mt.Id_Consigna - SET mt.Prioridad = sub.Prioridad - WHERE mt.Id_Ruta = vRutaId; - + UPDATE vn.ticket mt + JOIN ( + SELECT tt.addressFk Id_Consigna, round(ifnull(avg(t.priority),0),0) as Prioridad + FROM vn.ticket t + JOIN vn.ticket tt on tt.addressFk = t.addressFk + WHERE t.shipped > TIMESTAMPADD(YEAR,-1,util.VN_CURDATE()) + AND tt.routeFk = vRutaId + GROUP BY addressFk + ) sub ON sub.Id_Consigna = mt.Id_Consigna + SET mt.priority = sub.Prioridad + WHERE mt.routeFk = vRutaId; + END$$ DELIMITER ; diff --git a/db/routines/vn2008/procedures/prepare_ticket_list.sql b/db/routines/vn2008/procedures/prepare_ticket_list.sql index e407a91b7..07cff3ff5 100644 --- a/db/routines/vn2008/procedures/prepare_ticket_list.sql +++ b/db/routines/vn2008/procedures/prepare_ticket_list.sql @@ -5,17 +5,17 @@ BEGIN CREATE TEMPORARY TABLE tmp.ticket_list (PRIMARY KEY (Id_Ticket)) ENGINE = MEMORY - SELECT t.Id_Ticket, c.Id_Cliente - FROM Tickets t - LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.Id_Ticket - JOIN Clientes c ON c.Id_Cliente = t.Id_Cliente + SELECT t.id Id_Ticket, c.Id_Cliente + FROM vn.ticket t + LEFT JOIN vn.ticketState ts ON ts.ticketFk = t.id + JOIN Clientes c ON c.Id_Cliente = t.clientFk WHERE c.typeFk IN ('normal','handMaking','internalUse') AND ( Fecha BETWEEN util.today() AND vEndingDate OR ( ts.alertLevel < 3 - AND t.Fecha >= vStartingDate - AND t.Fecha < util.today() + AND t.shipped >= vStartingDate + AND t.shipped < util.today() ) ); END$$ diff --git a/db/routines/vn2008/procedures/risk_vs_client_list.sql b/db/routines/vn2008/procedures/risk_vs_client_list.sql index 92f94eb9f..bb3c1028c 100644 --- a/db/routines/vn2008/procedures/risk_vs_client_list.sql +++ b/db/routines/vn2008/procedures/risk_vs_client_list.sql @@ -33,14 +33,14 @@ BEGIN 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 + SELECT t.clientFk 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 + JOIN vn.ticket t on m.Id_Ticket = t.id + JOIN tmp.client_list c on c.Id_Cliente = t.clientFk + JOIN vn.client cl ON cl.id = t.clientFk WHERE Factura IS NULL AND Fecha BETWEEN startingDate AND endingDate - GROUP BY t.Id_Cliente; + GROUP BY t.clientFk; DROP TEMPORARY TABLE IF EXISTS tmp.risk; CREATE TEMPORARY TABLE tmp.risk diff --git a/db/routines/vn2008/views/item_out.sql b/db/routines/vn2008/views/item_out.sql index 57353a6d6..a1e714cb6 100644 --- a/db/routines/vn2008/views/item_out.sql +++ b/db/routines/vn2008/views/item_out.sql @@ -1,17 +1,17 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `vn2008`.`item_out` -AS SELECT `t`.`warehouse_id` AS `warehouse_id`, - `t`.`Fecha` AS `dat`, +AS SELECT `t`.`warehouseFk` AS `warehouse_id`, + `t`.`shipped` AS `dat`, `m`.`Id_Article` AS `item_id`, - `m`.`Cantidad` AS `amount`, `m`.`OK` AS `ok`, `m`.`Reservado` AS `Reservado`, - `t`.`Factura` AS `invoice`, + `t`.`refFk` AS `invoice`, `m`.`Id_Movimiento` AS `saleFk`, `m`.`Id_Ticket` AS `ticketFk` FROM ( `vn2008`.`Movimientos` `m` - JOIN `vn2008`.`Tickets` `t` ON(`m`.`Id_Ticket` = `t`.`Id_Ticket`) + JOIN `vn`.`ticket` `t` ON(`m`.`Id_Ticket` = `t`.`id`) ) WHERE `m`.`Cantidad` <> 0 From 714cd3c2c37f71bb4d83ccf07e83ac122f3f268c Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 6 Feb 2024 14:55:20 +0100 Subject: [PATCH 021/161] feat: refs #6777 --- db/routines/bi/procedures/claim_ratio_routine.sql | 2 +- db/routines/bs/procedures/comercialesCompleto.sql | 2 +- db/routines/bs/procedures/ventas_contables_por_cliente.sql | 6 +++--- db/routines/vn/procedures/invoiceFromAddress.sql | 2 +- db/routines/vn2008/procedures/confection_control_source.sql | 2 +- db/routines/vn2008/procedures/customerDebtEvolution.sql | 2 +- .../vn2008/procedures/emailYesterdayPurchasesByConsigna.sql | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/db/routines/bi/procedures/claim_ratio_routine.sql b/db/routines/bi/procedures/claim_ratio_routine.sql index dce098e2d..d7adbaba1 100644 --- a/db/routines/bi/procedures/claim_ratio_routine.sql +++ b/db/routines/bi/procedures/claim_ratio_routine.sql @@ -59,7 +59,7 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list (PRIMARY KEY (Id_Ticket)) - SELECT DISTINCT t.id + SELECT DISTINCT t.id Id_Ticket FROM vn2008.Movimientos_componentes mc JOIN vn2008.Movimientos m ON mc.Id_Movimiento = m.Id_Movimiento JOIN vn.ticket t ON t.id = m.Id_Ticket diff --git a/db/routines/bs/procedures/comercialesCompleto.sql b/db/routines/bs/procedures/comercialesCompleto.sql index 8f519b6ca..72b54656a 100644 --- a/db/routines/bs/procedures/comercialesCompleto.sql +++ b/db/routines/bs/procedures/comercialesCompleto.sql @@ -70,7 +70,7 @@ BEGIN AND (v.fecha BETWEEN TIMESTAMPADD(DAY, - DAY(vDate) + 1, vDate) AND TIMESTAMPADD(DAY, - 1, vDate)) GROUP BY Id_Cliente) mes_actual ON mes_actual.Id_Cliente = c.Id_Cliente LEFT JOIN - (SELECT t.clientFk, SUM(m.preu * m.Cantidad * (1 - m.Descuento / 100)) futur + (SELECT t.clientFk Id_Cliente, SUM(m.preu * m.Cantidad * (1 - m.Descuento / 100)) futur FROM vn.ticket t JOIN vn2008.Clientes c ON c.Id_Cliente = t.clientFk JOIN vn2008.Movimientos m ON m.Id_Ticket = t.id diff --git a/db/routines/bs/procedures/ventas_contables_por_cliente.sql b/db/routines/bs/procedures/ventas_contables_por_cliente.sql index 26da1b870..31e93adb7 100644 --- a/db/routines/bs/procedures/ventas_contables_por_cliente.sql +++ b/db/routines/bs/procedures/ventas_contables_por_cliente.sql @@ -14,12 +14,12 @@ BEGIN SELECT id FROM vn.ticket t JOIN vn2008.Facturas f ON f.Id_Factura = t.refFk - WHERE year(f.shipped) = vYear - AND month(f.shipped) = vMonth; + WHERE year(f.Fecha) = vYear + AND month(f.Fecha) = vMonth; SELECT vYear Año, vMonth Mes, - t.clientFk, + t.clientFk Id_Cliente, round(sum(Cantidad * Preu * (100 - m.Descuento)/100)) Venta, IF(e.empresa_grupo = e2.empresa_grupo, 1, diff --git a/db/routines/vn/procedures/invoiceFromAddress.sql b/db/routines/vn/procedures/invoiceFromAddress.sql index bea49e747..bf657a731 100644 --- a/db/routines/vn/procedures/invoiceFromAddress.sql +++ b/db/routines/vn/procedures/invoiceFromAddress.sql @@ -11,7 +11,7 @@ BEGIN CREATE TEMPORARY TABLE `tmp.``ticketToInvoice` (PRIMARY KEY (`id`)) ENGINE = MEMORY - SELECT id id + SELECT id FROM ticket WHERE (shipped BETWEEN vMinDateTicket AND vMaxTicketDate) AND addressFk = vAddress diff --git a/db/routines/vn2008/procedures/confection_control_source.sql b/db/routines/vn2008/procedures/confection_control_source.sql index 6833cd29d..4b60b041e 100644 --- a/db/routines/vn2008/procedures/confection_control_source.sql +++ b/db/routines/vn2008/procedures/confection_control_source.sql @@ -23,7 +23,7 @@ BEGIN tp.Tipo, t.nickname as Cliente, wh.name as Almacen, - t.warehouseFk, + t.warehouseFk warehouse_id, cs.province_id, a.agency_id, ct.description as Taller, diff --git a/db/routines/vn2008/procedures/customerDebtEvolution.sql b/db/routines/vn2008/procedures/customerDebtEvolution.sql index f6f81e2b0..fad1a8a59 100644 --- a/db/routines/vn2008/procedures/customerDebtEvolution.sql +++ b/db/routines/vn2008/procedures/customerDebtEvolution.sql @@ -28,7 +28,7 @@ SELECT * FROM FROM bi.customerDebtInventory WHERE Id_Cliente = vCustomer UNION ALL - SELECT t.shipped, - SUM(m.Cantidad * m.Preu * (100 - m.Descuento ) * 1.10 / 100) + SELECT t.shipped Fecha, - SUM(m.Cantidad * m.Preu * (100 - m.Descuento ) * 1.10 / 100) FROM vn.ticket t JOIN Movimientos m on m.Id_Ticket = t.id WHERE t.clientFk = vCustomer diff --git a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql index 2a753157d..7da510afa 100644 --- a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql +++ b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql @@ -14,7 +14,7 @@ BEGIN DECLARE txt TEXT; DECLARE rs CURSOR FOR - SELECT t.id, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION + SELECT t.id Id_Ticket, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION FROM vn.ticket t JOIN Consignatarios cs ON t.Id_Consigna = cs.Id_Consigna JOIN ( From 747dabd1544a3f22492129591a63f4768682e2ed Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 7 Feb 2024 11:41:22 +0100 Subject: [PATCH 022/161] feat: refs #6777 --- .../bi/procedures/claim_ratio_routine.sql | 2 +- .../bs/procedures/ventas_contables_add.sql | 2 +- .../vn/procedures/invoiceFromAddress.sql | 2 +- .../procedures/ListaTicketsEncajados.sql | 2 +- db/routines/vn2008/procedures/clean.sql | 18 ++---------------- .../procedures/confection_control_source.sql | 2 +- .../emailYesterdayPurchasesByConsigna.sql | 4 ++-- .../vn2008/procedures/embalajes_stocks.sql | 8 ++++---- .../procedures/embalajes_stocks_detalle.sql | 10 +++++----- .../vn2008/procedures/historico_absoluto.sql | 2 +- .../vn2008/procedures/historico_multiple.sql | 6 +++--- .../vn2008/procedures/preOrdenarRuta.sql | 4 ++-- .../vn2008/procedures/prepare_ticket_list.sql | 2 +- .../vn2008/procedures/risk_vs_client_list.sql | 4 ++-- 14 files changed, 27 insertions(+), 41 deletions(-) diff --git a/db/routines/bi/procedures/claim_ratio_routine.sql b/db/routines/bi/procedures/claim_ratio_routine.sql index d7adbaba1..833a1153a 100644 --- a/db/routines/bi/procedures/claim_ratio_routine.sql +++ b/db/routines/bi/procedures/claim_ratio_routine.sql @@ -79,7 +79,7 @@ BEGIN INSERT INTO vn2008.Greuges (Id_Cliente,Comentario,Importe,Fecha, Greuges_type_id, Id_Ticket) - SELECT Id_Cliente + SELECT t.clientFk ,concat('recobro ', m.Id_Ticket), - round(SUM(mc.Valor*Cantidad),2) AS dif ,date(t.shipped) diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index 554972e4c..955356d4e 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -86,7 +86,7 @@ BEGIN ) as grupo , NULL , NULL - , t.companyFk + , t.companyFk empresa_id , 7050000000 FROM vn.ticketService ts JOIN vn.ticket t ON ts.ticketFk = t.id diff --git a/db/routines/vn/procedures/invoiceFromAddress.sql b/db/routines/vn/procedures/invoiceFromAddress.sql index bf657a731..2879460ce 100644 --- a/db/routines/vn/procedures/invoiceFromAddress.sql +++ b/db/routines/vn/procedures/invoiceFromAddress.sql @@ -8,7 +8,7 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS `tmp`.`ticketToInvoice`; - CREATE TEMPORARY TABLE `tmp.``ticketToInvoice` + CREATE TEMPORARY TABLE `tmp`.`ticketToInvoice` (PRIMARY KEY (`id`)) ENGINE = MEMORY SELECT id diff --git a/db/routines/vn2008/procedures/ListaTicketsEncajados.sql b/db/routines/vn2008/procedures/ListaTicketsEncajados.sql index e220cd9ad..6a9838da3 100644 --- a/db/routines/vn2008/procedures/ListaTicketsEncajados.sql +++ b/db/routines/vn2008/procedures/ListaTicketsEncajados.sql @@ -10,7 +10,7 @@ BEGIN IFNULL(nbultos,0) AS nbultos, IFNULL(notros,0) AS notros, ts.code AS Estado - FROM Tickets ti + FROM vn.ticket ti INNER JOIN Consignatarios ON ti.addressFk = Consignatarios.Id_consigna INNER JOIN Agencias ON ti.agencyModeFk = Agencias.Id_Agencia LEFT JOIN (SELECT Ticket_Id,count(*) AS ncajas FROM expeditions WHERE Id_Article=94 GROUP BY ticket_id) sub1 ON ti.id=sub1.Ticket_Id diff --git a/db/routines/vn2008/procedures/clean.sql b/db/routines/vn2008/procedures/clean.sql index 00279c090..0ae70d648 100644 --- a/db/routines/vn2008/procedures/clean.sql +++ b/db/routines/vn2008/procedures/clean.sql @@ -22,19 +22,12 @@ proc: BEGIN DELETE FROM cdr WHERE calldate < vDate18; DELETE FROM Monitoring WHERE ODBC_TIME < vDate; - DELETE FROM Conteo WHERE Fecha < vDate; DELETE FROM mail WHERE DATE_ODBC < vDate; - DELETE FROM expeditions_deleted WHERE odbc_date < vDate26; DELETE FROM Movimientos_mark WHERE odbc_date < vDate; DELETE FROM Splits WHERE Fecha < vDate18; - DELETE ts - FROM Tickets_stack ts - JOIN vn.ticket t ON ts.Id_Ticket = t.id - WHERE t.shipped < vDate; - DELETE tobs - FROM ticketObservation tobs + FROM vn.ticketObservation tobs JOIN vn.ticket t ON tobs.ticketFk = t.id WHERE t.shipped < vDate; @@ -49,7 +42,7 @@ proc: BEGIN DELETE tw.* FROM vn.ticketWeekly tw LEFT JOIN vn.sale s USING(ticketFk) - WHERE s.Id_Article IS NULL; + WHERE s.id IS NULL; DELETE FROM cl_main WHERE Fecha < vDate18; DELETE FROM hedera.`order` WHERE date_send < vDate18; @@ -65,13 +58,6 @@ proc: BEGIN JOIN travel t ON t.id = e.travel_id WHERE t.landing <= vDate; - DELETE co - FROM Compres_ok co JOIN Compres c ON c.Id_Compra = co.Id_Compra - JOIN Entradas e ON e.Id_Entrada = c.Id_Entrada - JOIN travel t ON t.id = e.travel_id - WHERE t.landing <= vDate; - DELETE FROM scan WHERE odbc_date < vDate6 AND id <> 1; - IF v_full THEN CREATE OR REPLACE TEMPORARY TABLE tTicketDelete SELECT DISTINCT tl.originFk ticketFk diff --git a/db/routines/vn2008/procedures/confection_control_source.sql b/db/routines/vn2008/procedures/confection_control_source.sql index 4b60b041e..84126bc8c 100644 --- a/db/routines/vn2008/procedures/confection_control_source.sql +++ b/db/routines/vn2008/procedures/confection_control_source.sql @@ -14,7 +14,7 @@ BEGIN date(t.shipped) as Fecha, hour(t.shipped) as Hora, hour(t.shipped) as Departure, - t.id, + t.id Id_Ticket, m.Id_Movimiento, m.Cantidad, m.Concepte, diff --git a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql index 7da510afa..be2f01d1f 100644 --- a/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql +++ b/db/routines/vn2008/procedures/emailYesterdayPurchasesByConsigna.sql @@ -14,9 +14,9 @@ BEGIN DECLARE txt TEXT; DECLARE rs CURSOR FOR - SELECT t.id Id_Ticket, Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION + SELECT t.id Id_Ticket, nickname Alias, cast(amount as decimal(10,2)) Importe, Domicilio, POBLACION FROM vn.ticket t - JOIN Consignatarios cs ON t.Id_Consigna = cs.Id_Consigna + JOIN Consignatarios cs ON t.addressFk = cs.Id_Consigna JOIN ( SELECT `Movimientos`.`Id_Ticket` AS `Id_Ticket`, sum( diff --git a/db/routines/vn2008/procedures/embalajes_stocks.sql b/db/routines/vn2008/procedures/embalajes_stocks.sql index f6b0d9b9a..6479b19f8 100644 --- a/db/routines/vn2008/procedures/embalajes_stocks.sql +++ b/db/routines/vn2008/procedures/embalajes_stocks.sql @@ -8,8 +8,8 @@ BEGIN FROM Movimientos m JOIN Articles a ON m.Id_Article = a.Id_Article JOIN Tipos tp ON tp.tipo_id = a.tipo_id - JOIN ticket t ON t.id = m.Id_Ticket - JOIN Consignatarios cs using(Id_Consigna) + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN Consignatarios cs ON cs.Id_Consigna = t.addressFk WHERE cs.Id_Cliente = idPEOPLE AND Tipo = 'Contenedores' AND t.shipped > '2010-01-01' @@ -35,8 +35,8 @@ BEGIN FROM Movimientos m JOIN Articles a using(Id_Article) JOIN Tipos tp using(tipo_id) - JOIN ticket t ON t.id = m.Id_Ticket - JOIN Consignatarios cs using(Id_Consigna) + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN Consignatarios cs ON cs.Id_Consigna = t.addressFk JOIN proveedores_clientes pc ON pc.Id_Cliente = cs.Id_Cliente WHERE Id_Proveedor = idPEOPLE AND reino_id = 6 diff --git a/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql b/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql index 0319e0f75..2992e6029 100644 --- a/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql +++ b/db/routines/vn2008/procedures/embalajes_stocks_detalle.sql @@ -17,10 +17,10 @@ BEGIN , abbreviation Empresa FROM Movimientos m JOIN Articles a using(Id_Article) - JOIN ticket t ON t.id = m.Id_Ticket + JOIN vn.ticket t ON t.id = m.Id_Ticket JOIN empresa e ON e.id = t.companyFk - JOIN warehouse w ON w.id = t.warehouseFk - JOIN Consignatarios cs using(Id_Consigna) + JOIN vn.warehouse w ON w.id = t.warehouseFk + JOIN Consignatarios cs ON cs.Id_Consigna = t.addressFk JOIN Clientes c ON c.Id_Cliente = cs.Id_Cliente WHERE cs.Id_Cliente = idPEOPLE AND m.Id_Article = idARTICLE @@ -65,8 +65,8 @@ BEGIN , t.warehouseFk warehouse_id , Preu FROM Movimientos m - JOIN ticket t ON t.id = m.Id_Ticket - JOIN Consignatarios cs using(Id_Consigna) + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN Consignatarios cs ON cs.Id_Consigna = t.addressFk JOIN proveedores_clientes pc ON pc.Id_Cliente = cs.Id_Cliente WHERE Id_Proveedor = idPEOPLE AND Id_Article = idARTICLE diff --git a/db/routines/vn2008/procedures/historico_absoluto.sql b/db/routines/vn2008/procedures/historico_absoluto.sql index 55f33ee89..e11fb64d5 100644 --- a/db/routines/vn2008/procedures/historico_absoluto.sql +++ b/db/routines/vn2008/procedures/historico_absoluto.sql @@ -59,7 +59,7 @@ BEGIN t.id Id_Ticket, t.isPrinted PedidoImpreso FROM Movimientos M - INNER JOIN ticket t USING (Id_Ticket) + INNER JOIN vn.ticket t ON t.id = M.Id_Ticket JOIN Clientes C ON C.Id_Cliente = t.clientFk WHERE t.shipped >= '2001-01-01' AND M.Id_Article = idART diff --git a/db/routines/vn2008/procedures/historico_multiple.sql b/db/routines/vn2008/procedures/historico_multiple.sql index fbec7bb1d..b3ddc208a 100644 --- a/db/routines/vn2008/procedures/historico_multiple.sql +++ b/db/routines/vn2008/procedures/historico_multiple.sql @@ -69,19 +69,19 @@ BEGIN SELECT t.shipped as Fecha, NULL as Entrada, M.Cantidad as Salida, - warehouse_id as wh, + t.warehouseFk as wh, (M.OK <> 0 OR t.isLabeled <> 0 OR t.refFk IS NOT NULL) as OK, t.refFk as Referencia, t.id as id FROM Movimientos M - INNER JOIN ticket t ON t.id = M.Id_Ticket + INNER JOIN vn.ticket t ON t.id = M.Id_Ticket WHERE t.shipped >= vDateInventory AND M.Id_Article = vItemFk ) AS Historia - INNER JOIN warehouse ON warehouse.id = Historia.wh + INNER JOIN vn.warehouse ON warehouse.id = Historia.wh ORDER BY Fecha, Entrada DESC, OK DESC; diff --git a/db/routines/vn2008/procedures/preOrdenarRuta.sql b/db/routines/vn2008/procedures/preOrdenarRuta.sql index 9bcf853bd..d3e1862f6 100644 --- a/db/routines/vn2008/procedures/preOrdenarRuta.sql +++ b/db/routines/vn2008/procedures/preOrdenarRuta.sql @@ -13,8 +13,8 @@ BEGIN JOIN vn.ticket tt on tt.addressFk = t.addressFk WHERE t.shipped > TIMESTAMPADD(YEAR,-1,util.VN_CURDATE()) AND tt.routeFk = vRutaId - GROUP BY addressFk - ) sub ON sub.Id_Consigna = mt.Id_Consigna + GROUP BY t.addressFk + ) sub ON sub.Id_Consigna = mt.addressFk SET mt.priority = sub.Prioridad WHERE mt.routeFk = vRutaId; diff --git a/db/routines/vn2008/procedures/prepare_ticket_list.sql b/db/routines/vn2008/procedures/prepare_ticket_list.sql index 07cff3ff5..ea1dc8e7d 100644 --- a/db/routines/vn2008/procedures/prepare_ticket_list.sql +++ b/db/routines/vn2008/procedures/prepare_ticket_list.sql @@ -11,7 +11,7 @@ BEGIN JOIN Clientes c ON c.Id_Cliente = t.clientFk WHERE c.typeFk IN ('normal','handMaking','internalUse') AND ( - Fecha BETWEEN util.today() AND vEndingDate + t.shipped BETWEEN util.today() AND vEndingDate OR ( ts.alertLevel < 3 AND t.shipped >= vStartingDate diff --git a/db/routines/vn2008/procedures/risk_vs_client_list.sql b/db/routines/vn2008/procedures/risk_vs_client_list.sql index bb3c1028c..148379a64 100644 --- a/db/routines/vn2008/procedures/risk_vs_client_list.sql +++ b/db/routines/vn2008/procedures/risk_vs_client_list.sql @@ -38,8 +38,8 @@ BEGIN JOIN vn.ticket t on m.Id_Ticket = t.id JOIN tmp.client_list c on c.Id_Cliente = t.clientFk JOIN vn.client cl ON cl.id = t.clientFk - WHERE Factura IS NULL - AND Fecha BETWEEN startingDate AND endingDate + WHERE t.refFk IS NULL + AND t.shipped BETWEEN startingDate AND endingDate GROUP BY t.clientFk; DROP TEMPORARY TABLE IF EXISTS tmp.risk; From be4403819da7c94d8514b48e859422483b3175d2 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 7 Feb 2024 11:45:14 +0100 Subject: [PATCH 023/161] feat: refs #6777 --- db/routines/bs/procedures/ventas_contables_add.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index 955356d4e..7c8063e56 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -66,7 +66,7 @@ BEGIN AND Preu <> 0 AND m.Descuento <> 100 AND a.tipo_id != TIPO_PATRIMONIAL - GROUP BY grupo, reino_id, tipo_id, empresa_id, Gasto; + GROUP BY grupo, reino_id, tipo_id, t.companyFk, Gasto; INSERT INTO bs.ventas_contables(year , month From 1c40e01fcb0be13fa60ec05ed001657d8e92af68 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 20 Feb 2024 13:49:42 +0100 Subject: [PATCH 024/161] 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 025/161] 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 311401daba314635241aa7eed2513db509e767f5 Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 29 Feb 2024 08:59:25 +0100 Subject: [PATCH 026/161] fix: refs #6777 ticketMRW --- db/routines/vn/views/ticketMRW.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/views/ticketMRW.sql b/db/routines/vn/views/ticketMRW.sql index 2677b41e7..26b928ac4 100644 --- a/db/routines/vn/views/ticketMRW.sql +++ b/db/routines/vn/views/ticketMRW.sql @@ -44,4 +44,4 @@ FROM ( ) ) JOIN `vn2008`.`Paises` ON(`province`.`Paises_Id` = `Paises`.`Id`) - ) + ); From 624c214178c1c7671df2515388187b545f7c66da Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 29 Feb 2024 10:46:08 +0100 Subject: [PATCH 027/161] fix: refs #6777 Fixed version --- .../10921-bronzeAralia/00-firstScript.sql | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 db/versions/10921-bronzeAralia/00-firstScript.sql diff --git a/db/versions/10921-bronzeAralia/00-firstScript.sql b/db/versions/10921-bronzeAralia/00-firstScript.sql new file mode 100644 index 000000000..55aa03dca --- /dev/null +++ b/db/versions/10921-bronzeAralia/00-firstScript.sql @@ -0,0 +1,49 @@ +-- Para evitar el error al hacer myt run +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`Clientes` +AS SELECT `c`.`id` AS `id_cliente`, + `c`.`name` AS `cliente`, + `c`.`fi` AS `if`, + `c`.`socialName` AS `razonSocial`, + `c`.`contact` AS `contacto`, + `c`.`street` AS `domicilio`, + `c`.`city` AS `poblacion`, + `c`.`postcode` AS `codPostal`, + `c`.`phone` AS `telefono`, + `c`.`mobile` AS `movil`, + `c`.`isRelevant` AS `real`, + `c`.`email` AS `e-mail`, + `c`.`iban` AS `iban`, + `c`.`dueDay` AS `vencimiento`, + `c`.`accountingAccount` AS `Cuenta`, + `c`.`isEqualizated` AS `RE`, + `c`.`provinceFk` AS `province_id`, + `c`.`hasToInvoice` AS `invoice`, + `c`.`credit` AS `credito`, + `c`.`countryFk` AS `Id_Pais`, + `c`.`isActive` AS `activo`, + `c`.`gestdocFk` AS `gestdoc_id`, + `c`.`quality` AS `calidad`, + `c`.`payMethodFk` AS `pay_met_id`, + `c`.`created` AS `created`, + `c`.`isToBeMailed` AS `mail`, + `c`.`contactChannelFk` AS `chanel_id`, + `c`.`hasSepaVnl` AS `sepaVnl`, + `c`.`hasCoreVnl` AS `coreVnl`, + `c`.`hasCoreVnh` AS `coreVnh`, + `c`.`hasLcr` AS `hasLcr`, + `c`.`defaultAddressFk` AS `default_address`, + `c`.`riskCalculated` AS `risk_calculated`, + `c`.`hasToInvoiceByAddress` AS `invoiceByAddress`, + `c`.`isTaxDataChecked` AS `contabilizado`, + `c`.`isFreezed` AS `congelado`, + `c`.`creditInsurance` AS `creditInsurance`, + `c`.`isCreatedAsServed` AS `isCreatedAsServed`, + `c`.`hasInvoiceSimplified` AS `hasInvoiceSimplified`, + `c`.`salesPersonFk` AS `Id_Trabajador`, + `c`.`isVies` AS `vies`, + `c`.`eypbc` AS `EYPBC`, + `c`.`bankEntityFk` AS `bankEntityFk`, + `c`.`typeFk` AS `typeFk` +FROM `vn`.`client` `c`; \ No newline at end of file From 9aad1dd6e843cfb20f3d7494937e1cebe4aae41a Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 5 Mar 2024 12:41:54 +0100 Subject: [PATCH 028/161] 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 029/161] 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 030/161] 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 031/161] 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 032/161] 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 033/161] 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 034/161] 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 035/161] 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 036/161] 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 052acdcc0874f36b2e5e1913eca080c243a75126 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 13 Mar 2024 13:20:14 +0100 Subject: [PATCH 037/161] feat: refs #7029 packaging --- db/versions/10950-greenArborvitae/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/versions/10950-greenArborvitae/00-firstScript.sql diff --git a/db/versions/10950-greenArborvitae/00-firstScript.sql b/db/versions/10950-greenArborvitae/00-firstScript.sql new file mode 100644 index 000000000..e8d4e31f2 --- /dev/null +++ b/db/versions/10950-greenArborvitae/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +ALTER TABLE vn.packaging +MODIFY COLUMN volume decimal(10,2) CHECK (volume >= COALESCE(width, 1) * COALESCE(depth, 1) * COALESCE(height, 1)); From 562dd4034f2a9311fb45afaed6954ca73d0d1fc4 Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 27 Mar 2024 07:58:35 +0100 Subject: [PATCH 038/161] 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 039/161] 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 040/161] 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 041/161] 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 042/161] 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 043/161] 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 044/161] 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 045/161] 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 046/161] 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 047/161] 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 048/161] 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 049/161] 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 050/161] 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 051/161] 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 052/161] 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 053/161] 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 054/161] 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 055/161] 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 056/161] 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 057/161] 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 058/161] 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 059/161] 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 060/161] 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 061/161] #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 062/161] 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 063/161] 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 065/161] 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 066/161] 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 067/161] 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 283d8b12417e012d72d8267b59bedb1357c6d05c Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 8 Apr 2024 09:11:40 +0200 Subject: [PATCH 068/161] feat: refs #4409 Disable old available triggers --- db/.editorconfig | 13 +++++++ .../hedera/procedures/order_requestRecalc.sql | 3 +- .../hedera/triggers/orderRow_afterDelete.sql | 3 +- .../hedera/triggers/orderRow_afterInsert.sql | 3 +- .../hedera/triggers/orderRow_afterUpdate.sql | 5 ++- .../hedera/triggers/order_afterUpdate.sql | 34 +++++++++---------- .../stock/procedures/inbound_addPick.sql | 4 +-- .../stock/procedures/inbound_removePick.sql | 6 ++-- .../procedures/inbound_requestQuantity.sql | 10 +++--- db/routines/stock/procedures/inbound_sync.sql | 10 +++--- db/routines/stock/procedures/log_add.sql | 21 ------------ .../stock/procedures/log_refreshAll.sql | 2 +- .../stock/procedures/log_refreshBuy.sql | 12 +++---- .../stock/procedures/log_refreshOrder.sql | 18 +++++----- .../stock/procedures/log_refreshSale.sql | 30 ++++++++-------- .../stock/procedures/outbound_sync.sql | 4 +-- db/routines/stock/procedures/visible_log.sql | 8 ++--- .../stock/triggers/inbound_afterDelete.sql | 8 ++--- .../stock/triggers/inbound_beforeInsert.sql | 10 +++--- .../stock/triggers/outbound_afterDelete.sql | 8 ++--- .../stock/triggers/outbound_beforeInsert.sql | 10 +++--- .../vn/procedures/ticket_requestRecalc.sql | 3 +- db/routines/vn/triggers/buy_afterDelete.sql | 5 --- db/routines/vn/triggers/buy_afterInsert.sql | 2 -- db/routines/vn/triggers/buy_afterUpdate.sql | 8 ----- db/routines/vn/triggers/entry_afterUpdate.sql | 9 +---- db/routines/vn/triggers/sale_afterDelete.sql | 1 - db/routines/vn/triggers/sale_afterInsert.sql | 1 - db/routines/vn/triggers/sale_afterUpdate.sql | 9 ----- .../vn/triggers/ticket_afterUpdate.sql | 9 +---- .../vn/triggers/travel_afterUpdate.sql | 8 ++--- 31 files changed, 112 insertions(+), 165 deletions(-) create mode 100644 db/.editorconfig delete mode 100644 db/routines/stock/procedures/log_add.sql diff --git a/db/.editorconfig b/db/.editorconfig new file mode 100644 index 000000000..c97043430 --- /dev/null +++ b/db/.editorconfig @@ -0,0 +1,13 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# http://editorconfig.org + +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/db/routines/hedera/procedures/order_requestRecalc.sql b/db/routines/hedera/procedures/order_requestRecalc.sql index 4bcb1010e..aae4a0179 100644 --- a/db/routines/hedera/procedures/order_requestRecalc.sql +++ b/db/routines/hedera/procedures/order_requestRecalc.sql @@ -10,6 +10,7 @@ proc: BEGIN LEAVE proc; END IF; - INSERT INTO orderRecalc SET orderFk = vSelf; + -- #4409 Deprecated by MyCDC + -- INSERT INTO orderRecalc SET orderFk = vSelf; END$$ DELIMITER ; diff --git a/db/routines/hedera/triggers/orderRow_afterDelete.sql b/db/routines/hedera/triggers/orderRow_afterDelete.sql index 10b5ae9e3..e22f786c1 100644 --- a/db/routines/hedera/triggers/orderRow_afterDelete.sql +++ b/db/routines/hedera/triggers/orderRow_afterDelete.sql @@ -3,7 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterDel AFTER DELETE ON `orderRow` FOR EACH ROW BEGIN - CALL stock.log_add('orderRow', NULL, OLD.id); - CALL order_requestRecalc(OLD.orderFk); + CALL order_requestRecalc(OLD.orderFk); END$$ DELIMITER ; diff --git a/db/routines/hedera/triggers/orderRow_afterInsert.sql b/db/routines/hedera/triggers/orderRow_afterInsert.sql index 7e8d5f341..c95e0bbdc 100644 --- a/db/routines/hedera/triggers/orderRow_afterInsert.sql +++ b/db/routines/hedera/triggers/orderRow_afterInsert.sql @@ -3,7 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterIns AFTER INSERT ON `orderRow` FOR EACH ROW BEGIN - CALL stock.log_add('orderRow', NEW.id, NULL); - CALL order_requestRecalc(NEW.orderFk); + CALL order_requestRecalc(NEW.orderFk); END$$ DELIMITER ; diff --git a/db/routines/hedera/triggers/orderRow_afterUpdate.sql b/db/routines/hedera/triggers/orderRow_afterUpdate.sql index 33f4ae84e..bce81a8e4 100644 --- a/db/routines/hedera/triggers/orderRow_afterUpdate.sql +++ b/db/routines/hedera/triggers/orderRow_afterUpdate.sql @@ -3,8 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterUpd AFTER UPDATE ON `orderRow` FOR EACH ROW BEGIN - CALL stock.log_add('orderRow', NEW.id, OLD.id); - CALL order_requestRecalc(OLD.orderFk); - CALL order_requestRecalc(NEW.orderFk); + CALL order_requestRecalc(OLD.orderFk); + CALL order_requestRecalc(NEW.orderFk); END$$ DELIMITER ; diff --git a/db/routines/hedera/triggers/order_afterUpdate.sql b/db/routines/hedera/triggers/order_afterUpdate.sql index a4549549a..da82d242c 100644 --- a/db/routines/hedera/triggers/order_afterUpdate.sql +++ b/db/routines/hedera/triggers/order_afterUpdate.sql @@ -2,23 +2,21 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`order_afterUpdate` AFTER UPDATE ON `order` FOR EACH ROW -BEGIN - CALL stock.log_add('order', NEW.id, OLD.id); - - IF !(OLD.address_id <=> NEW.address_id) - OR !(OLD.company_id <=> NEW.company_id) - OR !(OLD.customer_id <=> NEW.customer_id) THEN - CALL order_requestRecalc(NEW.id); - END IF; - - IF !(OLD.address_id <=> NEW.address_id) AND NEW.address_id = 2850 THEN - -- Fallo que se actualiza no se sabe como tickets en este cliente - CALL vn.mail_insert( - 'jgallego@verdnatura.es', - 'noreply@verdnatura.es', - 'Actualizada order al address 2850', - CONCAT(account.myUser_getName(), ' ha creado la order ',NEW.id) - ); - END IF; +BEGIN + IF !(OLD.address_id <=> NEW.address_id) + OR !(OLD.company_id <=> NEW.company_id) + OR !(OLD.customer_id <=> NEW.customer_id) THEN + CALL order_requestRecalc(NEW.id); + END IF; + + IF !(OLD.address_id <=> NEW.address_id) AND NEW.address_id = 2850 THEN + -- Fallo que se actualiza no se sabe como tickets en este cliente + CALL vn.mail_insert( + 'jgallego@verdnatura.es', + 'noreply@verdnatura.es', + 'Actualizada order al address 2850', + CONCAT(account.myUser_getName(), ' ha creado la order ',NEW.id) + ); + END IF; END$$ DELIMITER ; diff --git a/db/routines/stock/procedures/inbound_addPick.sql b/db/routines/stock/procedures/inbound_addPick.sql index d867b5641..41b93a986 100644 --- a/db/routines/stock/procedures/inbound_addPick.sql +++ b/db/routines/stock/procedures/inbound_addPick.sql @@ -1,8 +1,8 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`inbound_addPick`( vSelf INT, - vOutboundFk INT, - vQuantity INT + vOutboundFk INT, + vQuantity INT ) BEGIN INSERT INTO inboundPick diff --git a/db/routines/stock/procedures/inbound_removePick.sql b/db/routines/stock/procedures/inbound_removePick.sql index e125ee8a7..e183e1171 100644 --- a/db/routines/stock/procedures/inbound_removePick.sql +++ b/db/routines/stock/procedures/inbound_removePick.sql @@ -1,9 +1,9 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`inbound_removePick`( vSelf INT, - vOutboundFk INT, - vQuantity INT, - vTotalQuantity INT + vOutboundFk INT, + vQuantity INT, + vTotalQuantity INT ) BEGIN IF vQuantity < vTotalQuantity THEN diff --git a/db/routines/stock/procedures/inbound_requestQuantity.sql b/db/routines/stock/procedures/inbound_requestQuantity.sql index 5d814ce2c..1cbc1908b 100644 --- a/db/routines/stock/procedures/inbound_requestQuantity.sql +++ b/db/routines/stock/procedures/inbound_requestQuantity.sql @@ -1,9 +1,9 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`inbound_requestQuantity`( vSelf INT, - vRequested INT, - vDated DATETIME, - OUT vSupplied INT) + vRequested INT, + vDated DATETIME, + OUT vSupplied INT) BEGIN /** * Disassociates inbound picks after the given date until the @@ -29,7 +29,7 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - + SET vSupplied = 0; OPEN vPicks; @@ -45,7 +45,7 @@ BEGIN SET vPickGranted = LEAST(vRequested - vSupplied, vPickQuantity); SET vSupplied = vSupplied + vPickGranted; CALL inbound_removePick(vSelf, vOutboundFk, vPickGranted, vPickQuantity); - + UPDATE outbound SET isSync = FALSE, lack = lack + vPickGranted diff --git a/db/routines/stock/procedures/inbound_sync.sql b/db/routines/stock/procedures/inbound_sync.sql index fc672d920..77d3e42f7 100644 --- a/db/routines/stock/procedures/inbound_sync.sql +++ b/db/routines/stock/procedures/inbound_sync.sql @@ -23,7 +23,7 @@ BEGIN SELECT id, lack, lack < quantity FROM outbound WHERE warehouseFk = vWarehouse - AND itemFk = vItem + AND itemFk = vItem AND dated >= vDated AND (vExpired IS NULL OR dated < vExpired) ORDER BY dated, created; @@ -51,8 +51,8 @@ BEGIN END IF; SET vSupplied = LEAST(vAvailable, vLack); - - IF vSupplied > 0 THEN + + IF vSupplied > 0 THEN SET vAvailable = vAvailable - vSupplied; UPDATE outbound SET lack = lack - vSupplied @@ -64,8 +64,8 @@ BEGIN SET vSupplied = vSupplied + vSuppliedFromRequest; SET vAvailable = vAvailable - vSuppliedFromRequest; END IF; - - IF vSupplied > 0 THEN + + IF vSupplied > 0 THEN CALL inbound_addPick(vSelf, vOutboundFk, vSupplied); END IF; diff --git a/db/routines/stock/procedures/log_add.sql b/db/routines/stock/procedures/log_add.sql deleted file mode 100644 index 2b75c7f72..000000000 --- a/db/routines/stock/procedures/log_add.sql +++ /dev/null @@ -1,21 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_add`(IN `vTableName` VARCHAR(255), IN `vNewId` VARCHAR(255), IN `vOldId` VARCHAR(255)) -proc: BEGIN - -- XXX: Disabled while testing - LEAVE proc; - - IF vOldId IS NOT NULL AND !(vOldId <=> vNewId) THEN - INSERT IGNORE INTO `log` SET - tableName = vTableName, - tableId = vOldId, - operation = 'delete'; - END IF; - - IF vNewId IS NOT NULL THEN - INSERT IGNORE INTO `log` SET - tableName = vTableName, - tableId = vNewId, - operation = 'insert'; - END IF; -END$$ -DELIMITER ; diff --git a/db/routines/stock/procedures/log_refreshAll.sql b/db/routines/stock/procedures/log_refreshAll.sql index eab91f8e9..3eaad07f2 100644 --- a/db/routines/stock/procedures/log_refreshAll.sql +++ b/db/routines/stock/procedures/log_refreshAll.sql @@ -10,7 +10,7 @@ BEGIN DO RELEASE_LOCK('stock.log_sync'); RESIGNAL; END; - + IF !GET_LOCK('stock.log_sync', 30) THEN CALL util.throw('Lock timeout exceeded'); END IF; diff --git a/db/routines/stock/procedures/log_refreshBuy.sql b/db/routines/stock/procedures/log_refreshBuy.sql index 62fa73435..488c00a28 100644 --- a/db/routines/stock/procedures/log_refreshBuy.sql +++ b/db/routines/stock/procedures/log_refreshBuy.sql @@ -1,7 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_refreshBuy`( - `vTableName` VARCHAR(255), - `vTableId` INT) + `vTableName` VARCHAR(255), + `vTableId` INT) BEGIN DROP TEMPORARY TABLE IF EXISTS tValues; CREATE TEMPORARY TABLE tValues @@ -11,7 +11,7 @@ BEGIN e.id entryFk, t.id travelFk, b.itemFk, - e.isRaid, + e.isRaid, ADDTIME(t.shipped, IFNULL(t.shipmentHour, '00:00:00')) shipped, t.warehouseOutFk, @@ -24,7 +24,7 @@ BEGIN ABS(b.quantity) quantity, b.created, b.quantity > 0 isIn, - t.shipped < vn.getInventoryDate() lessThanInventory + t.shipped < vn.getInventoryDate() lessThanInventory FROM vn.buy b JOIN vn.entry e ON e.id = b.entryFk JOIN vn.travel t ON t.id = e.travelFk @@ -52,7 +52,7 @@ BEGIN quantity, IF(isIn, isReceived, isDelivered) AND !isRaid FROM tValues - WHERE isIn OR !lessThanInventory; + WHERE isIn OR !lessThanInventory; REPLACE INTO outbound ( tableName, tableId, warehouseFk, dated, @@ -67,7 +67,7 @@ BEGIN quantity, IF(isIn, isDelivered, isReceived) AND !isRaid FROM tValues - WHERE !isIn OR !lessThanInventory; + WHERE !isIn OR !lessThanInventory; DROP TEMPORARY TABLE tValues; END$$ diff --git a/db/routines/stock/procedures/log_refreshOrder.sql b/db/routines/stock/procedures/log_refreshOrder.sql index 49225ddf0..ce5b31cc8 100644 --- a/db/routines/stock/procedures/log_refreshOrder.sql +++ b/db/routines/stock/procedures/log_refreshOrder.sql @@ -1,13 +1,13 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_refreshOrder`( - `vTableName` VARCHAR(255), - `vTableId` INT) + `vTableName` VARCHAR(255), + `vTableId` INT) BEGIN DECLARE vExpireTime INT DEFAULT 20; DECLARE vExpired DATETIME DEFAULT TIMESTAMPADD(MINUTE, -vExpireTime, util.VN_NOW()); DROP TEMPORARY TABLE IF EXISTS tValues; - CREATE TEMPORARY TABLE tValues + CREATE TEMPORARY TABLE tValues ENGINE = MEMORY SELECT r.id rowFk, @@ -23,24 +23,24 @@ BEGIN OR (vTableName = 'order' AND o.id = vTableId) OR (vTableName = 'orderRow' AND r.id = vTableId) ) - AND !o.confirmed - AND r.shipment >= vn.getInventoryDate() + AND !o.confirmed + AND r.shipment >= vn.getInventoryDate() AND r.created >= vExpired AND r.amount != 0; REPLACE INTO outbound ( tableName, tableId, warehouseFk, dated, - itemFk, created, expired, quantity + itemFk, created, expired, quantity ) - SELECT 'orderRow', + SELECT 'orderRow', rowFk, warehouseFk, shipped, itemFk, created, - TIMESTAMPADD(MINUTE, vExpireTime, created), + TIMESTAMPADD(MINUTE, vExpireTime, created), quantity - FROM tValues; + FROM tValues; DROP TEMPORARY TABLE tValues; END$$ diff --git a/db/routines/stock/procedures/log_refreshSale.sql b/db/routines/stock/procedures/log_refreshSale.sql index 0499fc711..983616dca 100644 --- a/db/routines/stock/procedures/log_refreshSale.sql +++ b/db/routines/stock/procedures/log_refreshSale.sql @@ -1,10 +1,10 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_refreshSale`( - `vTableName` VARCHAR(255), - `vTableId` INT) + `vTableName` VARCHAR(255), + `vTableId` INT) BEGIN DROP TEMPORARY TABLE IF EXISTS tValues; - CREATE TEMPORARY TABLE tValues + CREATE TEMPORARY TABLE tValues ENGINE = MEMORY SELECT m.id saleFk, @@ -14,7 +14,7 @@ BEGIN t.shipped, ABS(m.quantity) quantity, m.created, - TIMESTAMPADD(DAY, tp.life, t.shipped) expired, + TIMESTAMPADD(DAY, tp.life, t.shipped) expired, m.quantity < 0 isIn, m.isPicked OR s.alertLevel > 1 isPicked FROM vn.sale m @@ -32,33 +32,33 @@ BEGIN REPLACE INTO inbound ( tableName, tableId, warehouseFk, dated, - itemFk, expired, quantity, isPicked + itemFk, expired, quantity, isPicked ) - SELECT 'sale', + SELECT 'sale', saleFk, warehouseFk, shipped, itemFk, - expired, + expired, quantity, - isPicked - FROM tValues - WHERE isIn; + isPicked + FROM tValues + WHERE isIn; REPLACE INTO outbound ( tableName, tableId, warehouseFk, dated, - itemFk, created, quantity, isPicked + itemFk, created, quantity, isPicked ) - SELECT 'sale', + SELECT 'sale', saleFk, warehouseFk, shipped, itemFk, created, quantity, - isPicked - FROM tValues - WHERE !isIn; + isPicked + FROM tValues + WHERE !isIn; DROP TEMPORARY TABLE tValues; END$$ diff --git a/db/routines/stock/procedures/outbound_sync.sql b/db/routines/stock/procedures/outbound_sync.sql index c79bde45f..0de352176 100644 --- a/db/routines/stock/procedures/outbound_sync.sql +++ b/db/routines/stock/procedures/outbound_sync.sql @@ -7,7 +7,7 @@ BEGIN * @param vSelf The outbound reference */ DECLARE vDated DATETIME; - DECLARE vItem INT; + DECLARE vItem INT; DECLARE vWarehouse INT; DECLARE vLack INT; DECLARE vSupplied INT; @@ -21,7 +21,7 @@ BEGIN SELECT id, available, available < quantity FROM inbound WHERE warehouseFk = vWarehouse - AND itemFk = vItem + AND itemFk = vItem AND dated <= vDated AND (expired IS NULL OR expired > vDated) ORDER BY dated; diff --git a/db/routines/stock/procedures/visible_log.sql b/db/routines/stock/procedures/visible_log.sql index 2867f1186..cc88d3205 100644 --- a/db/routines/stock/procedures/visible_log.sql +++ b/db/routines/stock/procedures/visible_log.sql @@ -1,16 +1,16 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`visible_log`( vIsPicked BOOL, - vWarehouseFk INT, - vItemFk INT, - vQuantity INT + vWarehouseFk INT, + vItemFk INT, + vQuantity INT ) proc: BEGIN IF !vIsPicked THEN LEAVE proc; END IF; - INSERT INTO visible + INSERT INTO visible SET itemFk = vItemFk, warehouseFk = vWarehouseFk, quantity = vQuantity diff --git a/db/routines/stock/triggers/inbound_afterDelete.sql b/db/routines/stock/triggers/inbound_afterDelete.sql index b485299b0..451dcc599 100644 --- a/db/routines/stock/triggers/inbound_afterDelete.sql +++ b/db/routines/stock/triggers/inbound_afterDelete.sql @@ -12,11 +12,11 @@ BEGIN DELETE FROM inboundPick WHERE inboundFk = OLD.id; - CALL visible_log( + CALL visible_log( OLD.isPicked, - OLD.warehouseFk, - OLD.itemFk, - -OLD.quantity + OLD.warehouseFk, + OLD.itemFk, + -OLD.quantity ); END$$ DELIMITER ; diff --git a/db/routines/stock/triggers/inbound_beforeInsert.sql b/db/routines/stock/triggers/inbound_beforeInsert.sql index 8aabb0682..723cb3222 100644 --- a/db/routines/stock/triggers/inbound_beforeInsert.sql +++ b/db/routines/stock/triggers/inbound_beforeInsert.sql @@ -4,12 +4,12 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `stock`.`inbound_beforeInse FOR EACH ROW BEGIN SET NEW.isPicked = NEW.isPicked OR NEW.dated < util.VN_CURDATE(); - - CALL visible_log( + + CALL visible_log( NEW.isPicked, - NEW.warehouseFk, - NEW.itemFk, - NEW.quantity + NEW.warehouseFk, + NEW.itemFk, + NEW.quantity ); END$$ DELIMITER ; diff --git a/db/routines/stock/triggers/outbound_afterDelete.sql b/db/routines/stock/triggers/outbound_afterDelete.sql index dce0aed7a..e7d756871 100644 --- a/db/routines/stock/triggers/outbound_afterDelete.sql +++ b/db/routines/stock/triggers/outbound_afterDelete.sql @@ -12,11 +12,11 @@ BEGIN DELETE FROM inboundPick WHERE outboundFk = OLD.id; - CALL visible_log( + CALL visible_log( OLD.isPicked, - OLD.warehouseFk, - OLD.itemFk, - OLD.quantity + OLD.warehouseFk, + OLD.itemFk, + OLD.quantity ); END$$ DELIMITER ; diff --git a/db/routines/stock/triggers/outbound_beforeInsert.sql b/db/routines/stock/triggers/outbound_beforeInsert.sql index e41edae43..86546413e 100644 --- a/db/routines/stock/triggers/outbound_beforeInsert.sql +++ b/db/routines/stock/triggers/outbound_beforeInsert.sql @@ -5,12 +5,12 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `stock`.`outbound_beforeIns BEGIN SET NEW.lack = NEW.quantity; SET NEW.isPicked = NEW.isPicked OR NEW.dated < util.VN_CURDATE(); - - CALL visible_log( + + CALL visible_log( NEW.isPicked, - NEW.warehouseFk, - NEW.itemFk, - -NEW.quantity + NEW.warehouseFk, + NEW.itemFk, + -NEW.quantity ); END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_requestRecalc.sql b/db/routines/vn/procedures/ticket_requestRecalc.sql index 6636e4c0f..7f1ff3be8 100644 --- a/db/routines/vn/procedures/ticket_requestRecalc.sql +++ b/db/routines/vn/procedures/ticket_requestRecalc.sql @@ -10,6 +10,7 @@ proc: BEGIN LEAVE proc; END IF; - INSERT INTO ticketRecalc SET ticketFk = vSelf; + -- #4409 Deprecated by MyCDC + -- INSERT INTO ticketRecalc SET ticketFk = vSelf; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/buy_afterDelete.sql b/db/routines/vn/triggers/buy_afterDelete.sql index 2fcb0852d..5daaefa33 100644 --- a/db/routines/vn/triggers/buy_afterDelete.sql +++ b/db/routines/vn/triggers/buy_afterDelete.sql @@ -3,19 +3,14 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`buy_afterDelete` AFTER DELETE ON `buy` FOR EACH ROW trig: BEGIN - DECLARE vValues VARCHAR(255); - IF @isModeInventory OR @isTriggerDisabled THEN LEAVE trig; END IF; - CALL stock.log_add('buy', NULL, OLD.id); - INSERT INTO entryLog SET `action` = 'delete', `changedModel` = 'Buy', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/buy_afterInsert.sql b/db/routines/vn/triggers/buy_afterInsert.sql index 25682f1bb..b39842d35 100644 --- a/db/routines/vn/triggers/buy_afterInsert.sql +++ b/db/routines/vn/triggers/buy_afterInsert.sql @@ -7,8 +7,6 @@ trig: BEGIN LEAVE trig; END IF; - CALL stock.log_add('buy', NEW.id, NULL); - CALL buy_afterUpsert(NEW.id); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/buy_afterUpdate.sql b/db/routines/vn/triggers/buy_afterUpdate.sql index 9866f5bb8..fc7ca152d 100644 --- a/db/routines/vn/triggers/buy_afterUpdate.sql +++ b/db/routines/vn/triggers/buy_afterUpdate.sql @@ -12,14 +12,6 @@ trig: BEGIN LEAVE trig; END IF; - IF !(NEW.id <=> OLD.id) - OR !(NEW.entryFk <=> OLD.entryFk) - OR !(NEW.itemFk <=> OLD.itemFk) - OR !(NEW.quantity <=> OLD.quantity) - OR !(NEW.created <=> OLD.created) THEN - CALL stock.log_add('buy', NEW.id, OLD.id); - END IF; - CALL buy_afterUpsert(NEW.id); SELECT w.isBuyerToBeEmailed, t.landed diff --git a/db/routines/vn/triggers/entry_afterUpdate.sql b/db/routines/vn/triggers/entry_afterUpdate.sql index 60adc0003..c2d205768 100644 --- a/db/routines/vn/triggers/entry_afterUpdate.sql +++ b/db/routines/vn/triggers/entry_afterUpdate.sql @@ -3,24 +3,17 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_afterUpdate` AFTER UPDATE ON `entry` FOR EACH ROW BEGIN - IF NOT(NEW.id <=> OLD.id) - OR NOT(NEW.travelFk <=> OLD.travelFk) - OR NOT(NEW.isRaid <=> OLD.isRaid) THEN - CALL stock.log_add('entry', NEW.id, OLD.id); - END IF; - IF NOT (NEW.travelFk <=> OLD.travelFk) THEN CALL travel_requestRecalc(OLD.travelFk); CALL travel_requestRecalc(NEW.travelFk); END IF; - IF NOT (NEW.travelFk <=> OLD.travelFk) THEN CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck SELECT b.id FROM buy b WHERE b.entryFk = NEW.id; - + CALL buy_checkItem(); END IF; END$$ diff --git a/db/routines/vn/triggers/sale_afterDelete.sql b/db/routines/vn/triggers/sale_afterDelete.sql index fab1c52cd..da74c05ec 100644 --- a/db/routines/vn/triggers/sale_afterDelete.sql +++ b/db/routines/vn/triggers/sale_afterDelete.sql @@ -12,7 +12,6 @@ BEGIN `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - CALL stock.log_add('sale', NULL, OLD.id); CALL ticket_requestRecalc(OLD.ticketFk); SELECT account.myUser_getName() INTO vUserRole; diff --git a/db/routines/vn/triggers/sale_afterInsert.sql b/db/routines/vn/triggers/sale_afterInsert.sql index d4c2d60f5..3ce5ce8d9 100644 --- a/db/routines/vn/triggers/sale_afterInsert.sql +++ b/db/routines/vn/triggers/sale_afterInsert.sql @@ -7,7 +7,6 @@ BEGIN CALL util.throw('Cannot insert a service item into a ticket'); END IF; - CALL stock.log_add('sale', NEW.id, NULL); CALL ticket_requestRecalc(NEW.ticketFk); IF NEW.quantity > 0 THEN diff --git a/db/routines/vn/triggers/sale_afterUpdate.sql b/db/routines/vn/triggers/sale_afterUpdate.sql index 0d21f08d7..8500afbe3 100644 --- a/db/routines/vn/triggers/sale_afterUpdate.sql +++ b/db/routines/vn/triggers/sale_afterUpdate.sql @@ -6,15 +6,6 @@ BEGIN DECLARE vIsToSendMail BOOL; DECLARE vUserRole VARCHAR(255); - IF !(NEW.id <=> OLD.id) - OR !(NEW.ticketFk <=> OLD.ticketFk) - OR !(NEW.itemFk <=> OLD.itemFk) - OR !(NEW.quantity <=> OLD.quantity) - OR !(NEW.created <=> OLD.created) - OR !(NEW.isPicked <=> OLD.isPicked) THEN - CALL stock.log_add('sale', NEW.id, OLD.id); - END IF; - IF !(NEW.price <=> OLD.price) OR !(NEW.ticketFk <=> OLD.ticketFk) OR !(NEW.itemFk <=> OLD.itemFk) diff --git a/db/routines/vn/triggers/ticket_afterUpdate.sql b/db/routines/vn/triggers/ticket_afterUpdate.sql index df939c9d1..fd4b01571 100644 --- a/db/routines/vn/triggers/ticket_afterUpdate.sql +++ b/db/routines/vn/triggers/ticket_afterUpdate.sql @@ -3,13 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticket_afterUpdate` AFTER UPDATE ON `ticket` FOR EACH ROW BEGIN - - IF !(NEW.id <=> OLD.id) - OR !(NEW.warehouseFk <=> OLD.warehouseFk) - OR !(NEW.shipped <=> OLD.shipped) THEN - CALL stock.log_add('ticket', NEW.id, OLD.id); - END IF; - IF !(NEW.clientFk <=> OLD.clientFk) OR !(NEW.addressFk <=> OLD.addressFk) OR !(NEW.companyFk <=> OLD.companyFk) THEN @@ -17,7 +10,7 @@ BEGIN END IF; IF NEW.routeFk <> OLD.routeFk THEN - UPDATE expedition + UPDATE expedition SET hasNewRoute = TRUE WHERE ticketFk = NEW.id; END IF; diff --git a/db/routines/vn/triggers/travel_afterUpdate.sql b/db/routines/vn/triggers/travel_afterUpdate.sql index 38cd3ba13..7cfe865f3 100644 --- a/db/routines/vn/triggers/travel_afterUpdate.sql +++ b/db/routines/vn/triggers/travel_afterUpdate.sql @@ -3,10 +3,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`travel_afterUpdate` AFTER UPDATE ON `travel` FOR EACH ROW BEGIN - CALL stock.log_add('travel', NEW.id, OLD.id); - IF NOT(NEW.shipped <=> OLD.shipped) THEN - UPDATE entry + UPDATE entry SET commission = entry_getCommission(travelFk, currencyFk,supplierFk) WHERE travelFk = NEW.id; END IF; @@ -15,11 +13,11 @@ BEGIN IF (SELECT hasWeightVolumetric FROM agencyMode WHERE id = NEW.agencyModeFk) THEN CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck SELECT b.id - FROM entry e + FROM entry e JOIN buy b ON b.entryFk = e.id JOIN item i ON i.id = b.itemFk WHERE e.travelFk = NEW.id; - + CALL buy_checkItem(); END IF; END IF; From dddcacee7a417fddb9dd712d4b02e3b9424b9668 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 8 Apr 2024 12:01:27 +0200 Subject: [PATCH 069/161] 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 070/161] 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 071/161] 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 072/161] 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 073/161] 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 074/161] 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 075/161] 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 076/161] 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 077/161] 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 078/161] 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 079/161] 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 c2a2a86f355aa30ffb225cdf9d311bacfcdc289b Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 10 Apr 2024 09:42:55 +0200 Subject: [PATCH 080/161] feat: refs #6777 ultima comprobacion --- .../bs/procedures/ventas_contables_add.sql | 16 +++--- .../ventas_contables_por_cliente.sql | 14 +++--- db/routines/vn2008/views/Rutas.sql | 19 ------- db/routines/vn2008/views/state.sql | 13 ----- db/routines/vn2008/views/tag.sql | 10 ---- .../vn2008/views/tarifa_componentes.sql | 10 ---- .../views/tarifa_componentes_series.sql | 7 --- db/routines/vn2008/views/tblContadores.sql | 39 --------------- db/routines/vn2008/views/thermograph.sql | 6 --- .../vn2008/views/ticket_observation.sql | 8 --- db/routines/vn2008/views/tickets_gestdoc.sql | 6 --- .../10921-bronzeAralia/00-firstScript.sql | 49 ------------------- 12 files changed, 15 insertions(+), 182 deletions(-) delete mode 100644 db/routines/vn2008/views/Rutas.sql delete mode 100644 db/routines/vn2008/views/state.sql delete mode 100644 db/routines/vn2008/views/tag.sql delete mode 100644 db/routines/vn2008/views/tarifa_componentes.sql delete mode 100644 db/routines/vn2008/views/tarifa_componentes_series.sql delete mode 100644 db/routines/vn2008/views/tblContadores.sql delete mode 100644 db/routines/vn2008/views/thermograph.sql delete mode 100644 db/routines/vn2008/views/ticket_observation.sql delete mode 100644 db/routines/vn2008/views/tickets_gestdoc.sql delete mode 100644 db/versions/10921-bronzeAralia/00-firstScript.sql diff --git a/db/routines/bs/procedures/ventas_contables_add.sql b/db/routines/bs/procedures/ventas_contables_add.sql index abb4be25d..ad4e80a06 100644 --- a/db/routines/bs/procedures/ventas_contables_add.sql +++ b/db/routines/bs/procedures/ventas_contables_add.sql @@ -21,9 +21,9 @@ BEGIN CREATE TEMPORARY TABLE tmp.ticket_list (PRIMARY KEY (id)) ENGINE = MEMORY - SELECT Id_Ticket - FROM vn2008.Tickets t - JOIN vn.invoiceOut io ON io.`ref` = t.Factura + SELECT t.id + FROM vn.ticket t + JOIN vn.invoiceOut io ON io.`ref` = t.refFk WHERE year(io.issued) = vYear AND month(io.issued) = vMonth; @@ -46,7 +46,7 @@ BEGIN ) as grupo , tp.reino_id , a.tipo_id - , t.empresa_id + , t.companyFk , a.expenseFk + IF(e.empresa_grupo = e2.empresa_grupo ,1 @@ -54,8 +54,8 @@ BEGIN ) * 100000 + tp.reino_id * 1000 as Gasto FROM vn2008.Movimientos m - JOIN vn2008.Tickets t on t.Id_Ticket = m.Id_Ticket - JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.Id_Consigna + JOIN vn.ticket t ON t.id = m.Id_Ticket + JOIN vn2008.Consignatarios cs on cs.Id_Consigna = t.addressFk JOIN vn2008.Clientes c on c.Id_Cliente = cs.Id_Cliente JOIN tmp.ticket_list tt on tt.id = t.id JOIN vn2008.Articles a on m.Id_Article = a.Id_Article @@ -66,7 +66,7 @@ BEGIN AND Preu <> 0 AND m.Descuento <> 100 AND a.tipo_id != TIPO_PATRIMONIAL - GROUP BY grupo, reino_id, tipo_id, empresa_id, Gasto; + GROUP BY grupo, reino_id, tipo_id, companyFk, Gasto; INSERT INTO bs.ventas_contables(year , month @@ -92,7 +92,7 @@ BEGIN JOIN vn.ticket t ON ts.ticketFk = t.id JOIN vn.address a on a.id = t.addressFk JOIN vn.client cl on cl.id = a.clientFk - JOIN tmp.ticket_list tt on tt.Id_Ticket = t.id + JOIN tmp.ticket_list tt on tt.id = t.id JOIN vn.company c on c.id = t.companyFk LEFT JOIN vn.company c2 on c2.clientFk = cl.id GROUP BY grupo, t.companyFk ; diff --git a/db/routines/bs/procedures/ventas_contables_por_cliente.sql b/db/routines/bs/procedures/ventas_contables_por_cliente.sql index 26ba670b1..ed3773cf7 100644 --- a/db/routines/bs/procedures/ventas_contables_por_cliente.sql +++ b/db/routines/bs/procedures/ventas_contables_por_cliente.sql @@ -10,13 +10,13 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tmp.ticket_list; CREATE TEMPORARY TABLE tmp.ticket_list - (PRIMARY KEY (Id_Ticket)) - SELECT Id_Ticket - FROM vn2008.Tickets t - JOIN vn.invoiceOut io ON io.id = t.Factura + (PRIMARY KEY (id)) + SELECT t.id + FROM vn.ticket t + JOIN vn.invoiceOut io ON io.id = t.refFk WHERE year(io.issued) = vYear - AND month(io.issued) = vMonth; - + AND month(io.issued) = vMonth; + SELECT vYear Año, vMonth Mes, t.clientFk Id_Cliente, @@ -40,7 +40,7 @@ BEGIN AND m.Descuento <> 100 AND a.tipo_id != 188 GROUP BY t.clientFk, grupo,t.companyFk; - + DROP TEMPORARY TABLE tmp.ticket_list; END$$ diff --git a/db/routines/vn2008/views/Rutas.sql b/db/routines/vn2008/views/Rutas.sql deleted file mode 100644 index 78b3bb471..000000000 --- a/db/routines/vn2008/views/Rutas.sql +++ /dev/null @@ -1,19 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Rutas` -AS SELECT `r`.`id` AS `Id_Ruta`, - `r`.`workerFk` AS `Id_Trabajador`, - `r`.`created` AS `Fecha`, - `r`.`vehicleFk` AS `Id_Vehiculo`, - `r`.`agencyModeFk` AS `Id_Agencia`, - `r`.`time` AS `Hora`, - `r`.`isOk` AS `ok`, - `r`.`kmStart` AS `km_start`, - `r`.`kmEnd` AS `km_end`, - `r`.`started` AS `date_start`, - `r`.`finished` AS `date_end`, - `r`.`gestdocFk` AS `gestdoc_id`, - `r`.`cost` AS `cost`, - `r`.`m3` AS `m3`, - `r`.`description` AS `description` -FROM `vn`.`route` `r` diff --git a/db/routines/vn2008/views/state.sql b/db/routines/vn2008/views/state.sql deleted file mode 100644 index 63f6589af..000000000 --- a/db/routines/vn2008/views/state.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`state` -AS SELECT `s`.`id` AS `id`, - `s`.`name` AS `name`, - `s`.`order` AS `order`, - `s`.`alertLevel` AS `alert_level`, - `s`.`code` AS `code`, - `s`.`sectorProdPriority` AS `sectorProdPriority`, - `s`.`nextStateFk` AS `nextStateFk`, - `s`.`isPreviousPreparable` AS `isPreviousPreparable`, - `s`.`isPicked` AS `isPicked` -FROM `vn`.`state` `s` diff --git a/db/routines/vn2008/views/tag.sql b/db/routines/vn2008/views/tag.sql deleted file mode 100644 index 25b3ab82e..000000000 --- a/db/routines/vn2008/views/tag.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`tag` -AS SELECT `t`.`id` AS `id`, - `t`.`name` AS `name`, - `t`.`isFree` AS `isFree`, - `t`.`isQuantitatif` AS `isQuantitatif`, - `t`.`sourceTable` AS `sourceTable`, - `t`.`unit` AS `unit` -FROM `vn`.`tag` `t` diff --git a/db/routines/vn2008/views/tarifa_componentes.sql b/db/routines/vn2008/views/tarifa_componentes.sql deleted file mode 100644 index bec53abd9..000000000 --- a/db/routines/vn2008/views/tarifa_componentes.sql +++ /dev/null @@ -1,10 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`tarifa_componentes` -AS SELECT `tarifa_componentes`.`Id_Componente` AS `Id_Componente`, - `tarifa_componentes`.`Componente` AS `Componente`, - `tarifa_componentes`.`tarifa_componentes_series_id` AS `tarifa_componentes_series_id`, - `tarifa_componentes`.`tarifa_class` AS `tarifa_class`, - `tarifa_componentes`.`tax` AS `tax`, - `tarifa_componentes`.`is_renewable` AS `is_renewable` -FROM `bi`.`tarifa_componentes` diff --git a/db/routines/vn2008/views/tarifa_componentes_series.sql b/db/routines/vn2008/views/tarifa_componentes_series.sql deleted file mode 100644 index a1d188709..000000000 --- a/db/routines/vn2008/views/tarifa_componentes_series.sql +++ /dev/null @@ -1,7 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`tarifa_componentes_series` -AS SELECT `tarifa_componentes_series`.`tarifa_componentes_series_id` AS `tarifa_componentes_series_id`, - `tarifa_componentes_series`.`Serie` AS `Serie`, - `tarifa_componentes_series`.`base` AS `base` -FROM `bi`.`tarifa_componentes_series` diff --git a/db/routines/vn2008/views/tblContadores.sql b/db/routines/vn2008/views/tblContadores.sql deleted file mode 100644 index 129d3ce8b..000000000 --- a/db/routines/vn2008/views/tblContadores.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`tblContadores` -AS SELECT `c`.`id` AS `id`, - `c`.`ochoa` AS `ochoa`, - `c`.`invoiceOutFk` AS `nfactura`, - `c`.`inventoried` AS `FechaInventario`, - `c`.`itemLog` AS `HistoricoArticulo`, - `c`.`weekGoal` AS `week_goal`, - `c`.`photosPath` AS `Rutafotos`, - `c`.`cashBoxNumber` AS `numCaja`, - `c`.`redCode` AS `CodigoRojo`, - `c`.`TabletTime` AS `Tablet_Hora`, - `c`.`t0` AS `t0`, - `c`.`t1` AS `t1`, - `c`.`t2` AS `t2`, - `c`.`t3` AS `t3`, - `c`.`cc` AS `cc`, - `c`.`palet` AS `palet`, - `c`.`campaign` AS `campaign`, - `c`.`campaignLife` AS `campaign_life`, - `c`.`truckDays` AS `truck_days`, - `c`.`transportCharges` AS `tasa_transporte`, - `c`.`escanerPath` AS `escaner_path`, - `c`.`printedTurn` AS `turnoimpreso`, - `c`.`truckLength` AS `truck_length`, - `c`.`fuelConsumption` AS `fuel_consumption`, - `c`.`petrol` AS `petrol`, - `c`.`maintenance` AS `maintenance`, - `c`.`hourPrice` AS `hour_price`, - `c`.`meterPrice` AS `meter_price`, - `c`.`kmPrice` AS `km_price`, - `c`.`routeOption` AS `route_option`, - `c`.`dbproduccion` AS `dbproduccion`, - `c`.`mdbServer` AS `mdbServer`, - `c`.`fakeEmail` AS `fakeEmail`, - `c`.`defaultersMaxAmount` AS `defaultersMaxAmount`, - `c`.`ASIEN` AS `ASIEN` -FROM `vn`.`config` `c` diff --git a/db/routines/vn2008/views/thermograph.sql b/db/routines/vn2008/views/thermograph.sql deleted file mode 100644 index f51b83d24..000000000 --- a/db/routines/vn2008/views/thermograph.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`thermograph` -AS SELECT `t`.`id` AS `thermograph_id`, - `t`.`model` AS `model` -FROM `vn`.`thermograph` `t` diff --git a/db/routines/vn2008/views/ticket_observation.sql b/db/routines/vn2008/views/ticket_observation.sql deleted file mode 100644 index deb85e4b6..000000000 --- a/db/routines/vn2008/views/ticket_observation.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`ticket_observation` -AS SELECT `to`.`id` AS `ticket_observation_id`, - `to`.`ticketFk` AS `Id_Ticket`, - `to`.`observationTypeFk` AS `observation_type_id`, - `to`.`description` AS `text` -FROM `vn`.`ticketObservation` `to` diff --git a/db/routines/vn2008/views/tickets_gestdoc.sql b/db/routines/vn2008/views/tickets_gestdoc.sql deleted file mode 100644 index a8682db57..000000000 --- a/db/routines/vn2008/views/tickets_gestdoc.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`tickets_gestdoc` -AS SELECT `td`.`ticketFk` AS `Id_Ticket`, - `td`.`dmsFk` AS `gestdoc_id` -FROM `vn`.`ticketDms` `td` diff --git a/db/versions/10921-bronzeAralia/00-firstScript.sql b/db/versions/10921-bronzeAralia/00-firstScript.sql deleted file mode 100644 index 55aa03dca..000000000 --- a/db/versions/10921-bronzeAralia/00-firstScript.sql +++ /dev/null @@ -1,49 +0,0 @@ --- Para evitar el error al hacer myt run -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `vn2008`.`Clientes` -AS SELECT `c`.`id` AS `id_cliente`, - `c`.`name` AS `cliente`, - `c`.`fi` AS `if`, - `c`.`socialName` AS `razonSocial`, - `c`.`contact` AS `contacto`, - `c`.`street` AS `domicilio`, - `c`.`city` AS `poblacion`, - `c`.`postcode` AS `codPostal`, - `c`.`phone` AS `telefono`, - `c`.`mobile` AS `movil`, - `c`.`isRelevant` AS `real`, - `c`.`email` AS `e-mail`, - `c`.`iban` AS `iban`, - `c`.`dueDay` AS `vencimiento`, - `c`.`accountingAccount` AS `Cuenta`, - `c`.`isEqualizated` AS `RE`, - `c`.`provinceFk` AS `province_id`, - `c`.`hasToInvoice` AS `invoice`, - `c`.`credit` AS `credito`, - `c`.`countryFk` AS `Id_Pais`, - `c`.`isActive` AS `activo`, - `c`.`gestdocFk` AS `gestdoc_id`, - `c`.`quality` AS `calidad`, - `c`.`payMethodFk` AS `pay_met_id`, - `c`.`created` AS `created`, - `c`.`isToBeMailed` AS `mail`, - `c`.`contactChannelFk` AS `chanel_id`, - `c`.`hasSepaVnl` AS `sepaVnl`, - `c`.`hasCoreVnl` AS `coreVnl`, - `c`.`hasCoreVnh` AS `coreVnh`, - `c`.`hasLcr` AS `hasLcr`, - `c`.`defaultAddressFk` AS `default_address`, - `c`.`riskCalculated` AS `risk_calculated`, - `c`.`hasToInvoiceByAddress` AS `invoiceByAddress`, - `c`.`isTaxDataChecked` AS `contabilizado`, - `c`.`isFreezed` AS `congelado`, - `c`.`creditInsurance` AS `creditInsurance`, - `c`.`isCreatedAsServed` AS `isCreatedAsServed`, - `c`.`hasInvoiceSimplified` AS `hasInvoiceSimplified`, - `c`.`salesPersonFk` AS `Id_Trabajador`, - `c`.`isVies` AS `vies`, - `c`.`eypbc` AS `EYPBC`, - `c`.`bankEntityFk` AS `bankEntityFk`, - `c`.`typeFk` AS `typeFk` -FROM `vn`.`client` `c`; \ No newline at end of file From 67172676139a69aa27d52566856590d4d9734b3f Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Wed, 10 Apr 2024 11:23:33 +0200 Subject: [PATCH 081/161] refs ~6921 feat:addNoteFromDelivery --- .../vn/procedures/addNoteFromDelivery.sql | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/addNoteFromDelivery.sql b/db/routines/vn/procedures/addNoteFromDelivery.sql index 61295b7db..37bb198ad 100644 --- a/db/routines/vn/procedures/addNoteFromDelivery.sql +++ b/db/routines/vn/procedures/addNoteFromDelivery.sql @@ -1,13 +1,20 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`addNoteFromDelivery`(idTicket INT,nota TEXT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`addNoteFromDelivery`(vTicketFk INT, vDescription TEXT, vCode VARCHAR(45)) BEGIN - - DECLARE observationTypeFk INT DEFAULT 3; /*3 = REPARTIDOR*/ - INSERT INTO ticketObservation(ticketFk,observationTypeFk,description) - VALUES (idTicket,observationTypeFk,nota) - ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' '); + /** + * Inserta observaciones para los tickets + * + * @param vTicketFk Identificador del ticket + * @param vDescription Texto de la nota a insertar + * param vCode Identificador del tipo de nota + */ + INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) + SELECT vTicketFk, id, vDescription + FROM vn.observationType + WHERE code = vCode + ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description, VALUES(description),' '); END$$ DELIMITER ; From 0956dbc7b1c2f280ac745d50bc5ac841e8cb9061 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 10 Apr 2024 11:32:45 +0200 Subject: [PATCH 082/161] refs #6921 feat: addFromDelivery --- db/versions/10987-tealMonstera/00-firstScript.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 db/versions/10987-tealMonstera/00-firstScript.sql diff --git a/db/versions/10987-tealMonstera/00-firstScript.sql b/db/versions/10987-tealMonstera/00-firstScript.sql new file mode 100644 index 000000000..e78d54fd4 --- /dev/null +++ b/db/versions/10987-tealMonstera/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here + +USE vn; +INSERT INTO vn.observationType (description,code) VALUES ('Entrega','dropOff') \ No newline at end of file From b46102653b24bba10c087bcd4819f9b6284e4c8c Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 10 Apr 2024 11:35:28 +0200 Subject: [PATCH 083/161] refs #6921 feat: addFromDelivery --- db/routines/vn/procedures/addNoteFromDelivery.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/addNoteFromDelivery.sql b/db/routines/vn/procedures/addNoteFromDelivery.sql index 37bb198ad..7431d4f49 100644 --- a/db/routines/vn/procedures/addNoteFromDelivery.sql +++ b/db/routines/vn/procedures/addNoteFromDelivery.sql @@ -7,7 +7,7 @@ BEGIN * * @param vTicketFk Identificador del ticket * @param vDescription Texto de la nota a insertar - * param vCode Identificador del tipo de nota + * @param vCode Identificador del tipo de nota */ INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) From 9c373d9ef3d9fa83ee5cd2fb306665c5f9575a21 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 10 Apr 2024 12:02:25 +0200 Subject: [PATCH 084/161] refs #6921 feat: getTicketsObservations --- modules/route/back/methods/route/getTickets.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/route/back/methods/route/getTickets.js b/modules/route/back/methods/route/getTickets.js index 59ba389ed..6f7162178 100644 --- a/modules/route/back/methods/route/getTickets.js +++ b/modules/route/back/methods/route/getTickets.js @@ -44,13 +44,13 @@ module.exports = Self => { st.name ticketStateName, wh.name warehouseName, tob.description ticketObservation, + tob2.description ticketObservationDropOff, a.street, a.postalCode, a.city, am.name agencyModeName, u.nickname userNickname, vn.ticketTotalVolume(t.id) volume, - tob.description, GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, c.phone clientPhone, c.mobile clientMobile, @@ -72,6 +72,9 @@ module.exports = Self => { LEFT JOIN observationType ot ON ot.code = 'delivery' LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id AND tob.observationTypeFk = ot.id + LEFT JOIN observationType ot2 ON ot2.code = 'dropOff' + LEFT JOIN ticketObservation tob2 ON tob2.ticketFk = t.id + AND tob2.observationTypeFk = ot2.id LEFT JOIN address a ON a.id = t.addressFk LEFT JOIN agencyMode am ON am.id = t.agencyModeFk LEFT JOIN account.user u ON u.id = r.workerFk From c581deef66f0fd24f5639e8d4403f71239655ed3 Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 10 Apr 2024 13:09:31 +0200 Subject: [PATCH 085/161] refactor: refs #6005 refactor spec --- back/methods/notification/specs/send.spec.js | 32 ------------------- .../methods/operator/spec/operator.spec.js | 10 +++++- 2 files changed, 9 insertions(+), 33 deletions(-) diff --git a/back/methods/notification/specs/send.spec.js b/back/methods/notification/specs/send.spec.js index c506dc4b0..f0b186e06 100644 --- a/back/methods/notification/specs/send.spec.js +++ b/back/methods/notification/specs/send.spec.js @@ -1,38 +1,6 @@ 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 cf0b1e4b8..8a7d05298 100644 --- a/modules/worker/back/methods/operator/spec/operator.spec.js +++ b/modules/worker/back/methods/operator/spec/operator.spec.js @@ -8,9 +8,17 @@ describe('Operator', () => { const sentStatus = 'sent'; beforeEach(async() => { - await models.NotificationQueue.destroyAll({notificationFk: notificationName}); + await deleteNotification(); }); + afterAll(async() => { + await deleteNotification(); + }); + + async function deleteNotification() { + 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'}); From 7d925bac87ef0a9b2b14a613e3e89f3147813728 Mon Sep 17 00:00:00 2001 From: jcasado Date: Wed, 10 Apr 2024 13:16:41 +0200 Subject: [PATCH 086/161] refs #6641 fix PR changes --- db/dump/fixtures.before.sql | 6 +++--- modules/claim/back/methods/claim/filter.js | 7 +------ .../back/methods/claim/specs/filter.spec.js | 21 ++++++++++++------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index f874c8aee..cd7c15dca 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3747,6 +3747,6 @@ INSERT INTO `vn`.`supplierDms`(`supplierFk`, `dmsFk`, `editorFk`) VALUES (1, 10, 9); -INSERT INTO vn.workerTeam -(id, team, workerFk) -VALUES(8, 1, 19); +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 56d4fdfed..f60b6572e 100644 --- a/modules/claim/back/methods/claim/filter.js +++ b/modules/claim/back/methods/claim/filter.js @@ -4,15 +4,10 @@ const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; module.exports = Self => { - Self.remoteMethod('filter', { + Self.remoteMethodCtx('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', diff --git a/modules/claim/back/methods/claim/specs/filter.spec.js b/modules/claim/back/methods/claim/specs/filter.spec.js index 08e680e97..acaa3c527 100644 --- a/modules/claim/back/methods/claim/specs/filter.spec.js +++ b/modules/claim/back/methods/claim/specs/filter.spec.js @@ -1,7 +1,7 @@ const app = require('vn-loopback/server/server'); const models = require('vn-loopback/server/server').models; -describe('claim filter()', () => { +fdescribe('claim filter()', () => { let ctx; beforeEach(() => { ctx = { @@ -18,7 +18,8 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({...ctx, args: {filter: {}, search: 1}}, null, options); + ctx.args = {search: 1}; + const result = await app.models.Claim.filter(ctx, null, options); expect(result.length).toEqual(1); expect(result[0].id).toEqual(1); @@ -36,7 +37,8 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({...ctx, args: {filter: {}, search: 'Tony Stark'}}, null, options); + ctx.args = {search: 'Tony Stark'}; + const result = await app.models.Claim.filter(ctx, null, options); expect(result.length).toEqual(1); expect(result[0].id).toEqual(4); @@ -54,7 +56,8 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({...ctx, args: {filter: {}, workerFk: 18}}, null, options); + ctx.args = {workerFk: 18}; + const result = await app.models.Claim.filter(ctx, null, options); expect(result.length).toEqual(4); expect(result[0].id).toEqual(1); @@ -75,7 +78,8 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({...ctx, args: {filter: {}, itemFk: 2}}, null, options); + ctx.args = {itemFk: 2}; + const result = await app.models.Claim.filter(ctx, null, options); expect(result.length).toEqual(3); expect(result[0].id).toEqual(1); @@ -95,7 +99,8 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const result = await app.models.Claim.filter({...ctx, args: {filter: {}, claimResponsibleFk: 7}}, null, options); + ctx.args = {claimResponsibleFk: 7}; + const result = await app.models.Claim.filter(ctx, null, options); expect(result.length).toEqual(3); expect(result[0].id).toEqual(2); @@ -115,8 +120,8 @@ describe('claim filter()', () => { try { const options = {transaction: tx}; - const filter = {}; - const result = await models.Claim.filter({...ctx, args: {filter: {}, itemFk: null, myTeam: true}}, filter, options); + ctx.args = {itemFk: null, myTeam: true}; + const result = await app.models.Claim.filter(ctx, null, options); expect(result.length).toEqual(2); From 0cf1ced7476685e3cea1ae0c3cc1ef9f9fe38db3 Mon Sep 17 00:00:00 2001 From: jcasado Date: Wed, 10 Apr 2024 13:17:43 +0200 Subject: [PATCH 087/161] remove focus --- modules/claim/back/methods/claim/specs/filter.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/claim/back/methods/claim/specs/filter.spec.js b/modules/claim/back/methods/claim/specs/filter.spec.js index acaa3c527..872f49aa3 100644 --- a/modules/claim/back/methods/claim/specs/filter.spec.js +++ b/modules/claim/back/methods/claim/specs/filter.spec.js @@ -1,7 +1,7 @@ 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 = { From 5044cd454d3cab2d92a9a3700e42004c8263e778 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Apr 2024 14:17:03 +0200 Subject: [PATCH 088/161] refactor: refs #7181 vn2008.Deleted risk_vs_client_list --- .../vn/procedures/creditInsurance_getRisk.sql | 42 ---------- db/routines/vn/procedures/riskAllClients.sql | 45 +++++----- .../vn2008/procedures/risk_vs_client_list.sql | 84 ------------------- 3 files changed, 22 insertions(+), 149 deletions(-) delete mode 100644 db/routines/vn/procedures/creditInsurance_getRisk.sql delete mode 100644 db/routines/vn2008/procedures/risk_vs_client_list.sql diff --git a/db/routines/vn/procedures/creditInsurance_getRisk.sql b/db/routines/vn/procedures/creditInsurance_getRisk.sql deleted file mode 100644 index 8028dc5fb..000000000 --- a/db/routines/vn/procedures/creditInsurance_getRisk.sql +++ /dev/null @@ -1,42 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditInsurance_getRisk`() -BEGIN -/** - * Devuelve el riesgo de los clientes que estan asegurados - */ - CREATE OR REPLACE TEMPORARY TABLE tmp.client_list - (PRIMARY KEY (Id_Cliente)) - ENGINE = MEMORY - SELECT * FROM ( - SELECT cc.client Id_Cliente, ci.grade - FROM creditClassification cc - JOIN creditInsurance ci ON cc.id = ci.creditClassification - 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()); - - SELECT - c.id, - c.name, - c.credit clientCredit, - c.creditInsurance solunion, - CAST(r.risk AS DECIMAL(10,0)) risk, - CAST(c.creditInsurance - r.risk AS DECIMAL(10,0)) riskAlive, - cac.invoiced billedAnnually, - c.dueDay, - ci.grade, - c2.country - FROM tmp.client_list ci - LEFT JOIN tmp.risk r ON r.Id_Cliente = ci.Id_Cliente - JOIN client c ON c.id = ci.Id_Cliente - JOIN bs.clientAnnualConsumption cac ON c.id = cac.clientFk - JOIN country c2 ON c2.id = c.countryFk - GROUP BY c.id; - - DROP TEMPORARY TABLE IF EXISTS tmp.risk; - DROP TEMPORARY TABLE IF EXISTS tmp.client_list; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/riskAllClients.sql b/db/routines/vn/procedures/riskAllClients.sql index 66c0a0dd5..86135afdf 100644 --- a/db/routines/vn/procedures/riskAllClients.sql +++ b/db/routines/vn/procedures/riskAllClients.sql @@ -1,29 +1,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)) + CREATE OR REPLACE TEMPORARY TABLE tmp.clientGetDebt + (PRIMARY KEY (clientFk)) ENGINE = MEMORY - SELECT id Id_Cliente, null grade FROM vn.client; - - 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.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; + SELECT id clientFk + FROM client + WHERE isActive; + + CALL client_getDebt(maxRiskDate); + + SELECT c.socialName, + r.clientFk, + c.credit, + CAST(r.risk AS DECIMAL (10,2)) risk, + CAST(c.credit - r.risk AS DECIMAL (10,2)) difference, + co.country + FROM client c + JOIN tmp.risk r ON r.clientFk = c.id + JOIN country co ON co.id = c.countryFk + GROUP BY c.id; + + DROP TEMPORARY TABLE + tmp.risk, + tmp.clientGetDebt; 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 7b3472aa0bf0a4d385f1fa4e38b425defcea92d5 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 10 Apr 2024 14:23:24 +0200 Subject: [PATCH 089/161] refactor: refs #7181 Minor change --- db/routines/vn/procedures/riskAllClients.sql | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/riskAllClients.sql b/db/routines/vn/procedures/riskAllClients.sql index 86135afdf..70e7c2619 100644 --- a/db/routines/vn/procedures/riskAllClients.sql +++ b/db/routines/vn/procedures/riskAllClients.sql @@ -1,6 +1,13 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`riskAllClients`(maxRiskDate DATE) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`riskAllClients`( + vDate DATE +) BEGIN +/** + * Retorna el riesgo de los clientes activos. + * + * @param vDate Fecha a calcular + */ CREATE OR REPLACE TEMPORARY TABLE tmp.clientGetDebt (PRIMARY KEY (clientFk)) ENGINE = MEMORY @@ -8,7 +15,7 @@ BEGIN FROM client WHERE isActive; - CALL client_getDebt(maxRiskDate); + CALL client_getDebt(vDate); SELECT c.socialName, r.clientFk, From 7ddc0b087e65a52927455968014c633e57a5f84d Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 11 Apr 2024 08:28:43 +0200 Subject: [PATCH 090/161] deploy: refs #7199 init version 2418 --- CHANGELOG.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c031a3874..b2be92faa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [24.18.01] - 2024-05-02 + ## [24.16.01] - 2024-04-18 ## [2414.01] - 2024-04-04 diff --git a/package.json b/package.json index 39c5e15b7..4874f2b86 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.16.0", + "version": "24.18.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From b1dc5efc8b55e2a64d1752dac5f0ee82ad3b65d6 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 11 Apr 2024 09:29:25 +0200 Subject: [PATCH 091/161] refactor: refs #7181 Requested changes --- .../vn/procedures/{riskAllClients.sql => client_getRisk.sql} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename db/routines/vn/procedures/{riskAllClients.sql => client_getRisk.sql} (89%) diff --git a/db/routines/vn/procedures/riskAllClients.sql b/db/routines/vn/procedures/client_getRisk.sql similarity index 89% rename from db/routines/vn/procedures/riskAllClients.sql rename to db/routines/vn/procedures/client_getRisk.sql index 70e7c2619..7fbade303 100644 --- a/db/routines/vn/procedures/riskAllClients.sql +++ b/db/routines/vn/procedures/client_getRisk.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`riskAllClients`( +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_getRisk`( vDate DATE ) BEGIN From bff3aef73b40a87d7437f66f47d1bbcb8e4ddb4b Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 11 Apr 2024 13:20:41 +0200 Subject: [PATCH 092/161] recovering procs --- db/routines/floranet/procedures/catalogue_get.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/floranet/procedures/catalogue_get.sql b/db/routines/floranet/procedures/catalogue_get.sql index e45fa7ddf..32624f383 100644 --- a/db/routines/floranet/procedures/catalogue_get.sql +++ b/db/routines/floranet/procedures/catalogue_get.sql @@ -6,7 +6,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_get(vLanded DATE, READS SQL DATA proc:BEGIN /** - * Returns list, price and all the stuff regarding the floranet items + * Returns list, price and all the stuff regarding the floranet items. * * @param vLanded Delivery date * @param vPostalCode Delivery address postal code From 9de4095260fdab7c1628976893d9b9e84f7b31ee Mon Sep 17 00:00:00 2001 From: Pako Date: Thu, 11 Apr 2024 13:25:43 +0200 Subject: [PATCH 093/161] moreProcs --- db/routines/floranet/procedures/contact_request.sql | 2 +- db/routines/floranet/procedures/deliveryDate_get.sql | 2 +- db/routines/floranet/procedures/order_confirm.sql | 2 +- db/routines/floranet/procedures/order_put.sql | 2 +- db/routines/floranet/procedures/sliders_get.sql | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/floranet/procedures/contact_request.sql b/db/routines/floranet/procedures/contact_request.sql index 044c22c6f..2ca25b87d 100644 --- a/db/routines/floranet/procedures/contact_request.sql +++ b/db/routines/floranet/procedures/contact_request.sql @@ -11,7 +11,7 @@ PROCEDURE floranet.contact_request( READS SQL DATA BEGIN /** - * Set actions for contact request. + * Set actions for contact request * * @param vPostalCode Delivery address postal code */ diff --git a/db/routines/floranet/procedures/deliveryDate_get.sql b/db/routines/floranet/procedures/deliveryDate_get.sql index 29751ebe4..75e9d6257 100644 --- a/db/routines/floranet/procedures/deliveryDate_get.sql +++ b/db/routines/floranet/procedures/deliveryDate_get.sql @@ -6,7 +6,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE `floranet`.`deliveryDate_get`(vPosta READS SQL DATA BEGIN /** - * Returns available dates for this postalCode, in the next seven days + * Returns available dates for this postalCode, in the next seven days. * * @param vPostalCode Delivery address postal code */ diff --git a/db/routines/floranet/procedures/order_confirm.sql b/db/routines/floranet/procedures/order_confirm.sql index fed123663..b6aec033d 100644 --- a/db/routines/floranet/procedures/order_confirm.sql +++ b/db/routines/floranet/procedures/order_confirm.sql @@ -7,7 +7,7 @@ CREATE DEFINER=`root`@`localhost`PROCEDURE floranet.order_confirm(vCatalogueFk I READS SQL DATA BEGIN -/** Update order.isPaid field +/** Update order.isPaid field. * * @param vCatalogueFk floranet.catalogue.id * diff --git a/db/routines/floranet/procedures/order_put.sql b/db/routines/floranet/procedures/order_put.sql index c26cef19a..564587268 100644 --- a/db/routines/floranet/procedures/order_put.sql +++ b/db/routines/floranet/procedures/order_put.sql @@ -6,7 +6,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.order_put(vOrder JSON) READS SQL DATA BEGIN /** - * Get and process an order + * Get and process an order. * * @param vOrder Data of the order * diff --git a/db/routines/floranet/procedures/sliders_get.sql b/db/routines/floranet/procedures/sliders_get.sql index bd791dec7..0e4aa297a 100644 --- a/db/routines/floranet/procedures/sliders_get.sql +++ b/db/routines/floranet/procedures/sliders_get.sql @@ -6,7 +6,7 @@ CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.sliders_get() READS SQL DATA BEGIN /** - * Returns list of url for sliders + * Returns list of url for sliders. */ SELECT CONCAT('https://cdn.verdnatura.es/image/catalog/1600x900/', i.image) url, From f545a57c9fe91f07d9c775a32e4d6bc9e36a3257 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 12 Apr 2024 07:58:18 +0200 Subject: [PATCH 094/161] feat: refs #6500 --- db/routines/vn/procedures/creditRecovery.sql | 4 ++++ db/routines/vn/procedures/raidUpdate.sql | 5 +++-- db/routines/vn/procedures/rateView.sql | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/creditRecovery.sql b/db/routines/vn/procedures/creditRecovery.sql index f61b1499a..687d652dd 100644 --- a/db/routines/vn/procedures/creditRecovery.sql +++ b/db/routines/vn/procedures/creditRecovery.sql @@ -1,6 +1,10 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditRecovery`() BEGIN +/** + * Actualiza el crédito de los clientes + */ + DECLARE EXIT HANDLER FOR SQLSTATE '45000' BEGIN ROLLBACK; diff --git a/db/routines/vn/procedures/raidUpdate.sql b/db/routines/vn/procedures/raidUpdate.sql index 214974350..abdf44ddc 100644 --- a/db/routines/vn/procedures/raidUpdate.sql +++ b/db/routines/vn/procedures/raidUpdate.sql @@ -1,7 +1,9 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`raidUpdate`() BEGIN - +/** + * Actualiza el travel de las entradas de redadas + */ UPDATE entry e JOIN entryVirtual ev ON ev.entryFk = e.id JOIN travel t ON t.id = e.travelFk @@ -17,7 +19,6 @@ BEGIN 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 diff --git a/db/routines/vn/procedures/rateView.sql b/db/routines/vn/procedures/rateView.sql index fb03c192a..8a6c1305d 100644 --- a/db/routines/vn/procedures/rateView.sql +++ b/db/routines/vn/procedures/rateView.sql @@ -1,7 +1,9 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`rateView`() BEGIN - +/** + * Muestra información sobre tasas de cambio de Dolares + */ SELECT t.year, t.month, From c0cabc894bd85d3136b5d35c71d3d34673765fd7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 12 Apr 2024 08:08:49 +0200 Subject: [PATCH 095/161] refactor: refs #7181 Added grant --- db/versions/10990-yellowPalmetto/00-firstScript.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/versions/10990-yellowPalmetto/00-firstScript.sql diff --git a/db/versions/10990-yellowPalmetto/00-firstScript.sql b/db/versions/10990-yellowPalmetto/00-firstScript.sql new file mode 100644 index 000000000..7f8267ff2 --- /dev/null +++ b/db/versions/10990-yellowPalmetto/00-firstScript.sql @@ -0,0 +1,2 @@ +-- Place your SQL code here +GRANT EXECUTE ON PROCEDURE vn.client_getRisk TO financialBoss; From b5f3b5ebeecd6887552ee7b8c29c5db8c03ed6bb Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 12 Apr 2024 08:19:57 +0200 Subject: [PATCH 096/161] Fix version --- db/versions/10990-yellowPalmetto/00-firstScript.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/versions/10990-yellowPalmetto/00-firstScript.sql b/db/versions/10990-yellowPalmetto/00-firstScript.sql index 7f8267ff2..be866af8c 100644 --- a/db/versions/10990-yellowPalmetto/00-firstScript.sql +++ b/db/versions/10990-yellowPalmetto/00-firstScript.sql @@ -1,2 +1,5 @@ --- Place your SQL code here +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_getRisk`() +BEGIN +END; + GRANT EXECUTE ON PROCEDURE vn.client_getRisk TO financialBoss; From adadf70f1e18dea2961bbbb821ac6a0e8678f492 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 12 Apr 2024 08:44:06 +0200 Subject: [PATCH 097/161] feat: refs #6500 --- db/routines/vn/procedures/raidUpdate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/raidUpdate.sql b/db/routines/vn/procedures/raidUpdate.sql index abdf44ddc..99a30ed04 100644 --- a/db/routines/vn/procedures/raidUpdate.sql +++ b/db/routines/vn/procedures/raidUpdate.sql @@ -22,7 +22,7 @@ BEGIN WHERE shipped > util.VN_CURDATE() AND isDelivered = FALSE ORDER BY t.landed LIMIT 10000000000000000000 - ) t + ) t GROUP BY warehouseInFk, warehouseOutFk ) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk SET e.travelFk = t.id; From 0d03cf76b4f69716fb2c2ae5a715d52b4a571621 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 12 Apr 2024 10:17:04 +0200 Subject: [PATCH 098/161] fix(sql): refs #6005 fix fk formation --- db/versions/10895-pinkArborvitae/01-secondScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/10895-pinkArborvitae/01-secondScript.sql b/db/versions/10895-pinkArborvitae/01-secondScript.sql index 4397bcf01..03f1aeccb 100644 --- a/db/versions/10895-pinkArborvitae/01-secondScript.sql +++ b/db/versions/10895-pinkArborvitae/01-secondScript.sql @@ -16,7 +16,7 @@ ALTER TABLE `vn`.`packingSite` MODIFY COLUMN IF EXISTS `printerRfidFk` int unsig 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`.`printQueue` ADD CONSTRAINT `printQueue_FK` FOREIGN KEY IF NOT EXISTS (printerFk) 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; From 1a71be38a36901020ecba3e25b51f1e3ec484c19 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 12 Apr 2024 12:03:34 +0200 Subject: [PATCH 099/161] feat: test --- .husky/addReferenceTag.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index 399c69301..1f35309d5 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -13,14 +13,17 @@ function getCurrentBranchName(p = process.cwd()) { return headContent.trim().split('/')[2]; } -const branchName = getCurrentBranchName(); +const branchName = 'peterParkersl'; if (branchName) { const msgPath = `.git/COMMIT_EDITMSG`; const msg = fs.readFileSync(msgPath, 'utf-8'); + const reference = branchName.match(/^\d+/)[0]; - const referenceTag = `refs #${branchName.match(/^\d+/)}`; - if (!msg.includes(referenceTag)) { + const referenceTag = `refs #${reference}`; + if (!msg.includes(referenceTag) && reference) { + console.log('reference: ', reference); + const splitedMsg = msg.split(':'); if (splitedMsg.length > 1) { From fa1e679b487537662007865a3a96bf703c9805be Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 12 Apr 2024 12:04:05 +0200 Subject: [PATCH 100/161] feat: refs #12 peter --- .husky/addReferenceTag.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index 1f35309d5..cab45e885 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -13,12 +13,12 @@ function getCurrentBranchName(p = process.cwd()) { return headContent.trim().split('/')[2]; } -const branchName = 'peterParkersl'; +const branchName = '12peterParkersl'; if (branchName) { const msgPath = `.git/COMMIT_EDITMSG`; const msg = fs.readFileSync(msgPath, 'utf-8'); - const reference = branchName.match(/^\d+/)[0]; + const reference = branchName.match(/^\d+/); const referenceTag = `refs #${reference}`; if (!msg.includes(referenceTag) && reference) { From f30f907d8e6fe0d0da52058f379bbc34d02fa73c Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 12 Apr 2024 12:13:07 +0200 Subject: [PATCH 101/161] feat: refs #6500 cambios solicitados --- db/routines/vn/procedures/raidUpdate.sql | 6 +++--- db/routines/vn/procedures/rateView.sql | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/raidUpdate.sql b/db/routines/vn/procedures/raidUpdate.sql index 99a30ed04..703c14e5c 100644 --- a/db/routines/vn/procedures/raidUpdate.sql +++ b/db/routines/vn/procedures/raidUpdate.sql @@ -10,7 +10,7 @@ BEGIN JOIN ( SELECT * FROM ( - SELECT id, landed, tt.warehouseInFk, tt.warehouseOutFk + SELECT t.id, t.landed, tt.warehouseInFk, tt.warehouseOutFk FROM travel t JOIN ( SELECT t.warehouseInFk, t.warehouseOutFk @@ -19,11 +19,11 @@ BEGIN 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 + WHERE shipped > util.VN_CURDATE() AND NOT isDelivered ORDER BY t.landed LIMIT 10000000000000000000 ) t - GROUP BY warehouseInFk, warehouseOutFk + GROUP BY t.warehouseInFk, t.warehouseOutFk ) tt ON t.warehouseInFk = tt.warehouseInFk AND t.warehouseOutFk = tt.warehouseOutFk SET e.travelFk = t.id; diff --git a/db/routines/vn/procedures/rateView.sql b/db/routines/vn/procedures/rateView.sql index 8a6c1305d..153e3584a 100644 --- a/db/routines/vn/procedures/rateView.sql +++ b/db/routines/vn/procedures/rateView.sql @@ -18,14 +18,14 @@ BEGIN ( SELECT t.year, t.month, - CAST(SUM(divisa) AS DECIMAL(10,2)) dollars, - CAST(SUM(divisa) / SUM(amount) AS DECIMAL(5,4)) changePractical, + CAST(SUM(p.divisa) AS DECIMAL(10,2)) dollars, + CAST(SUM(p.divisa) / SUM(p.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 + WHERE p.divisa AND c.code = 'USD' GROUP BY t.year, t.month ) pagos ON t.year = pagos.year AND t.month = pagos.MONTH From 0db4cd7a12a93a0582a8bb5fb225956bfedbe15b Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 12 Apr 2024 12:20:18 +0200 Subject: [PATCH 102/161] feat: refs #6130 handle branch without task --- .husky/addReferenceTag.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index cab45e885..6fd08ca48 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -13,7 +13,7 @@ function getCurrentBranchName(p = process.cwd()) { return headContent.trim().split('/')[2]; } -const branchName = '12peterParkersl'; +const branchName = getCurrentBranchName(); if (branchName) { const msgPath = `.git/COMMIT_EDITMSG`; @@ -21,8 +21,7 @@ if (branchName) { const reference = branchName.match(/^\d+/); const referenceTag = `refs #${reference}`; - if (!msg.includes(referenceTag) && reference) { - console.log('reference: ', reference); + if (!msg.includes(referenceTag) || reference) { const splitedMsg = msg.split(':'); From 8887550713ca315c9a5c28346f51f883ec1b3ec6 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 12 Apr 2024 12:22:00 +0200 Subject: [PATCH 103/161] fix: refs #6130 test --- .husky/addReferenceTag.js | 1 - .husky/commit-msg | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index 6fd08ca48..9267d1a67 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -22,7 +22,6 @@ if (branchName) { const referenceTag = `refs #${reference}`; if (!msg.includes(referenceTag) || reference) { - const splitedMsg = msg.split(':'); if (splitedMsg.length > 1) { diff --git a/.husky/commit-msg b/.husky/commit-msg index b813583c2..4a86ca68a 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -4,5 +4,5 @@ echo "Running husky commit-msg hook" npx --no-install commitlint --edit echo "Adding reference tag to commit message" -pnpm run addReferenceTag +npm run addReferenceTag From 85e6f3069797333b75a24f713d74ee387c4cc74e Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 12 Apr 2024 13:18:34 +0200 Subject: [PATCH 104/161] test: refs #null commit --- .husky/commit-msg | 2 +- package.json | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.husky/commit-msg b/.husky/commit-msg index 4a86ca68a..0c9a94c64 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -4,5 +4,5 @@ echo "Running husky commit-msg hook" npx --no-install commitlint --edit echo "Adding reference tag to commit message" -npm run addReferenceTag +node .husky/addReferenceTag.js diff --git a/package.json b/package.json index 6c444acd2..aa2aa2238 100644 --- a/package.json +++ b/package.json @@ -113,10 +113,7 @@ "test:e2e": "node e2e/tests.js", "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", - "prepare": "husky install", - "addReferenceTag": "node .husky/addReferenceTag.js" + "lint": "eslint ./ --cache --ignore-pattern .gitignore" }, "jest": { "projects": [ From bb52b1bae24abd779bdd32b1d4b1f442c7ce25bf Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 12 Apr 2024 13:21:37 +0200 Subject: [PATCH 105/161] test: refs #null test --- .husky/addReferenceTag.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index 9267d1a67..bf2164c0a 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'); function getCurrentBranchName(p = process.cwd()) { if (!fs.existsSync(p)) return false; @@ -21,6 +21,7 @@ if (branchName) { const reference = branchName.match(/^\d+/); const referenceTag = `refs #${reference}`; + console.log('reference: ', reference); if (!msg.includes(referenceTag) || reference) { const splitedMsg = msg.split(':'); From f0604bedd0ac32692f0abb50c63f9652faeebd29 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 12 Apr 2024 13:22:32 +0200 Subject: [PATCH 106/161] test: refs #null asd --- .husky/addReferenceTag.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index bf2164c0a..a4bd31fcc 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -22,6 +22,7 @@ if (branchName) { const referenceTag = `refs #${reference}`; console.log('reference: ', reference); + console.log('asd', !msg.includes(referenceTag)); if (!msg.includes(referenceTag) || reference) { const splitedMsg = msg.split(':'); From 827f15278366660023b398042c3c670fe10c15e9 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 12 Apr 2024 13:23:36 +0200 Subject: [PATCH 107/161] fix: husky --- .husky/addReferenceTag.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index a4bd31fcc..d097859e4 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -23,7 +23,7 @@ if (branchName) { const referenceTag = `refs #${reference}`; console.log('reference: ', reference); console.log('asd', !msg.includes(referenceTag)); - if (!msg.includes(referenceTag) || reference) { + if (!msg.includes(referenceTag) && reference) { const splitedMsg = msg.split(':'); if (splitedMsg.length > 1) { From cc57fa72fd8936add4988e281cbf35c926ec07f1 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 12 Apr 2024 13:24:24 +0200 Subject: [PATCH 108/161] fix: remove logs --- .husky/addReferenceTag.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/.husky/addReferenceTag.js b/.husky/addReferenceTag.js index d097859e4..b4ee706a0 100644 --- a/.husky/addReferenceTag.js +++ b/.husky/addReferenceTag.js @@ -21,8 +21,6 @@ if (branchName) { const reference = branchName.match(/^\d+/); const referenceTag = `refs #${reference}`; - console.log('reference: ', reference); - console.log('asd', !msg.includes(referenceTag)); if (!msg.includes(referenceTag) && reference) { const splitedMsg = msg.split(':'); From 253465cf139491cb70836533f4f542baa8d9f8c6 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 15 Apr 2024 08:47:27 +0200 Subject: [PATCH 109/161] refs #7190 feat: renewToken for multimedia --- back/methods/vn-user/renew-token.js | 8 +++- .../methods/vn-user/specs/share-token.spec.js | 43 +++++++++++++++++-- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/back/methods/vn-user/renew-token.js b/back/methods/vn-user/renew-token.js index d00085d8a..bc432d7ad 100644 --- a/back/methods/vn-user/renew-token.js +++ b/back/methods/vn-user/renew-token.js @@ -40,9 +40,15 @@ module.exports = Self => { } }, courtesyTime * 1000); + // Get scopes + + let createTokenOptions = {}; + const {scopes} = token; + if (scopes) + createTokenOptions = {scopes: [scopes[0]]}; // Create new accessToken const user = await Self.findById(token.userId); - const accessToken = await user.createAccessToken(); + const accessToken = await user.accessTokens.create(createTokenOptions); return {id: accessToken.id, ttl: accessToken.ttl}; }; diff --git a/back/methods/vn-user/specs/share-token.spec.js b/back/methods/vn-user/specs/share-token.spec.js index aaa83817c..e072a4fa8 100644 --- a/back/methods/vn-user/specs/share-token.spec.js +++ b/back/methods/vn-user/specs/share-token.spec.js @@ -1,6 +1,9 @@ const {models} = require('vn-loopback/server/server'); +const TOKEN_MULTIMEDIA = 'read:multimedia'; describe('Share Token', () => { let ctx = null; + const startingTime = Date.now(); + let multimediaToken = null; beforeAll(async() => { const unAuthCtx = { req: { @@ -17,11 +20,45 @@ describe('Share Token', () => { ctx = {req: {accessToken: accessToken}}; }); - it('should renew token', async() => { - const multimediaToken = await models.VnUser.shareToken(ctx); + beforeEach(async() => { + multimediaToken = await models.VnUser.shareToken(ctx); + jasmine.clock().install(); + jasmine.clock().mockDate(new Date(startingTime)); + }); + afterEach(() => { + jasmine.clock().uninstall(); + }); + + it('should generate token', async() => { expect(Object.keys(multimediaToken).length).toEqual(1); expect(multimediaToken.multimediaToken.userId).toEqual(ctx.req.accessToken.userId); - expect(multimediaToken.multimediaToken.scopes[0]).toEqual('read:multimedia'); + expect(multimediaToken.multimediaToken.scopes[0]).toEqual(TOKEN_MULTIMEDIA); + }); + + it('NOT should renew', async() => { + let error; + let response; + try { + response = await models.VnUser.renewToken(ctx); + } catch (e) { + error = e; + } + + expect(error).toBeUndefined(); + expect(response.id).toEqual(ctx.req.accessToken.id); + }); + + it('should renew token', async() => { + const mockDate = new Date(startingTime + 26600000); + jasmine.clock().mockDate(mockDate); + + const newShareToken = await models.VnUser.renewToken({req: {accessToken: multimediaToken.multimediaToken}}); + const {id} = newShareToken; + + expect(id).not.toEqual(ctx.req.accessToken.id); + const newMultimediaToken = await models.AccessToken.findById(id); + + expect(newMultimediaToken.scopes[0]).toEqual(TOKEN_MULTIMEDIA); }); }); From 25b5c35dc6bbe6303982b7de4dd20baddc9c8750 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 15 Apr 2024 08:47:49 +0200 Subject: [PATCH 110/161] refs #6835 fix: issue --- back/methods/vn-user/renew-token.js | 3 ++- back/methods/vn-user/specs/renew-token.spec.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/back/methods/vn-user/renew-token.js b/back/methods/vn-user/renew-token.js index bc432d7ad..2fd1f43c0 100644 --- a/back/methods/vn-user/renew-token.js +++ b/back/methods/vn-user/renew-token.js @@ -33,7 +33,8 @@ module.exports = Self => { // Schedule to remove current token setTimeout(async() => { try { - await Self.logout(token.id); + const exists = await models.AccessToken.findById(token.id); + exists && await Self.logout(token.id); } catch (err) { // eslint-disable-next-line no-console console.error(err); diff --git a/back/methods/vn-user/specs/renew-token.spec.js b/back/methods/vn-user/specs/renew-token.spec.js index 8d9bbf11c..741388bf9 100644 --- a/back/methods/vn-user/specs/renew-token.spec.js +++ b/back/methods/vn-user/specs/renew-token.spec.js @@ -33,6 +33,17 @@ describe('Renew Token', () => { const {id} = await models.VnUser.renewToken(ctx); expect(id).not.toEqual(ctx.req.accessToken.id); + + await models.VnUser.logout(ctx.req.accessToken.id); + jasmine.clock().tick(70 * 1000); + let tokenNotExists; + try { + tokenNotExists = await models.AccessToken.findById(ctx.req.accessToken.id); + } catch (e) { + error = e; + } + + expect(tokenNotExists).toBeNull(); }); it('NOT should renew', async() => { From 50d6c234be0d2ffb8a361f692cc5fe9357086442 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 15 Apr 2024 09:31:24 +0200 Subject: [PATCH 111/161] feat(binlog): refs #4409 New function for binlog queue monitoring --- .../util/functions/binlogQueue_getDelay.sql | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 db/routines/util/functions/binlogQueue_getDelay.sql diff --git a/db/routines/util/functions/binlogQueue_getDelay.sql b/db/routines/util/functions/binlogQueue_getDelay.sql new file mode 100644 index 000000000..a440fc0ab --- /dev/null +++ b/db/routines/util/functions/binlogQueue_getDelay.sql @@ -0,0 +1,45 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`binlogQueue_getDelay`(vCode VARCHAR(255)) + RETURNS BIGINT + NOT DETERMINISTIC +BEGIN +/** + * Returns the difference between the current position of the binary log and + * the passed queue. + * + * @param vCode The queue code + * @return The difference in MB + */ + DECLARE vCurLogName VARCHAR(255); + DECLARE vCurPosition BIGINT; + DECLARE vQueueLogName VARCHAR(255); + DECLARE vQueuePosition BIGINT; + DECLARE vDelay BIGINT; + + SELECT VARIABLE_VALUE INTO vCurLogName + FROM information_schema.GLOBAL_STATUS + WHERE VARIABLE_NAME = 'BINLOG_SNAPSHOT_FILE'; + + SELECT VARIABLE_VALUE INTO vCurPosition + FROM information_schema.GLOBAL_STATUS + WHERE VARIABLE_NAME = 'BINLOG_SNAPSHOT_POSITION'; + + SELECT logName, `position` + INTO vQueueLogName, vQueuePosition + FROM binlogQueue + WHERE code = vCode; + + IF vQueuePosition IS NULL THEN + RETURN NULL; + END IF; + + SET vDelay = + vCurPosition - CAST(vQueuePosition AS SIGNED) + + @@max_binlog_size * ( + CAST(REGEXP_SUBSTR(vCurLogName, '[0-9]+') AS SIGNED) - + CAST(REGEXP_SUBSTR(vQueueLogName, '[0-9]+') AS SIGNED) + ); + + RETURN ROUND(vDelay / POW(1024, 2)); +END$$ +DELIMITER ; From 5414aaa1b49a841a3c8f60b20e6e933b9d85d7cd Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 15 Apr 2024 10:18:06 +0200 Subject: [PATCH 112/161] fix(binlog): refs #4409 Fixtures for binlogQueue --- db/dump/fixtures.after.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index fade82c3e..523f41bfb 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -9,6 +9,10 @@ SET foreign_key_checks = 0; INSERT INTO util.config (id, environment, mockTime, mockUtcTime, mockEnabled) VALUES (1, 'local', '2001-01-01 12:00:00', '2001-01-01 11:00:00', TRUE); + +INSERT INTO util.binlogQueue (code,logName, `position`) + VALUES ('mylogger', 'bin.000001', 4); + /* #5483 INSERT INTO vn.entryConfig (defaultEntry, mailToNotify, inventorySupplierFk, maxLockTime, defaultSupplierFk) VALUES(1, NULL, 1, 300, 1); From a68b8431c5915ec958478f3d5112c6d4c504080d Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 10:21:59 +0200 Subject: [PATCH 113/161] feat: refs #6938 add scope & acls --- .../10994-wheatLaurel/00-modifyAcls.sql | 4 ++ modules/worker/back/models/worker.json | 53 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 db/versions/10994-wheatLaurel/00-modifyAcls.sql diff --git a/db/versions/10994-wheatLaurel/00-modifyAcls.sql b/db/versions/10994-wheatLaurel/00-modifyAcls.sql new file mode 100644 index 000000000..5b264482a --- /dev/null +++ b/db/versions/10994-wheatLaurel/00-modifyAcls.sql @@ -0,0 +1,4 @@ +UPDATE salix.ACL SET principalId = "hr" WHERE property IN ('find','findById','findOne') AND model = "Worker"; + +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) + VALUES ('Worker', 'summary', 'READ', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index ed430f133..4b7e4a512 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -92,5 +92,58 @@ "model": "WorkerTeamCollegues", "foreignKey": "workerFk" } + }, + "scopes":{ + "summary": { + "fields": [ + [ + "id", + "firstName", + "lastName", + "bossFk", + "maritalStatus", + "originCountryFk", + "educationLevelFk", + "SSN", + "mobileExtension", + "code", + "locker", + "fi", + "birth", + "isF11Allowed" + ] + + ], + "include": [ + { + "relation": "user", + "scope": { + "fields": ["email", "name", "nickname", "roleFk"], + "include": { + "relation": "role", + "scope": { + "fields": ["name"] + } + } + } + }, { + "relation": "department", + "scope": { + "include": { + "relation": "department", + "scope": { + "fields": ["name"] + } + } + } + }, { + "relation": "boss" + }, { + "relation": "client" + }, { + "relation": "sip" + } + ] + } } } From 200cbd8d74bedf95605c3b8ab260fb2155100494 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 11:03:57 +0200 Subject: [PATCH 114/161] fix: refs #6938 acls & scope --- db/versions/10994-wheatLaurel/00-modifyAcls.sql | 2 +- modules/worker/back/models/worker.json | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/db/versions/10994-wheatLaurel/00-modifyAcls.sql b/db/versions/10994-wheatLaurel/00-modifyAcls.sql index 5b264482a..905f67aba 100644 --- a/db/versions/10994-wheatLaurel/00-modifyAcls.sql +++ b/db/versions/10994-wheatLaurel/00-modifyAcls.sql @@ -1,4 +1,4 @@ UPDATE salix.ACL SET principalId = "hr" WHERE property IN ('find','findById','findOne') AND model = "Worker"; INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) - VALUES ('Worker', 'summary', 'READ', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file + VALUES ('Worker', '__get__summary', 'READ', 'ALLOW', 'ROLE', 'employee'); \ No newline at end of file diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 4b7e4a512..0c4f91118 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -96,7 +96,6 @@ "scopes":{ "summary": { "fields": [ - [ "id", "firstName", "lastName", @@ -112,8 +111,7 @@ "birth", "isF11Allowed" ] - - ], + , "include": [ { "relation": "user", From d7b06fe637ca4662cdd8672ba287ca03a2f07c76 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 12:47:27 +0200 Subject: [PATCH 115/161] fix: refs #6938 scope --- modules/worker/back/models/worker.json | 67 +++++++++++++++++--------- 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 0c4f91118..10776af90 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -95,23 +95,6 @@ }, "scopes":{ "summary": { - "fields": [ - "id", - "firstName", - "lastName", - "bossFk", - "maritalStatus", - "originCountryFk", - "educationLevelFk", - "SSN", - "mobileExtension", - "code", - "locker", - "fi", - "birth", - "isF11Allowed" - ] - , "include": [ { "relation": "user", @@ -128,16 +111,56 @@ "relation": "department", "scope": { "include": { - "relation": "department", - "scope": { - "fields": ["name"] - } + "relation": "department" } } }, { "relation": "boss" }, { - "relation": "client" + "relation": "client", + "scope": { + "fields": [ + "id", + "name", + "fi", + "socialName", + "contact", + "street", + "city", + "postcode", + "email", + "mobile", + "isActive", + "credit", + "creditInsurance", + "iban", + "dueDay", + "isEqualizated", + "isFreezed", + "hasToInvoiceByAddress", + "hasToInvoice", + "isToBeMailed", + "hasSepaVnl", + "hasLcr", + "hasCoreVnl", + "hasCoreVnh", + "hasIncoterms", + "isTaxDataChecked", + "eypbc", + "quality", + "isVies", + "isRelevant", + "accountingAccount", + "created", + "sageTaxTypeFk", + "sageTransactionTypeFk", + "businessTypeFk", + "salesPersonFk", + "hasElectronicInvoice", + "rating", + "recommendedCredit" + ] + } }, { "relation": "sip" } From 5c524ecc7db005c933f0d6657ed86ad8daca9c01 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 15 Apr 2024 13:13:40 +0200 Subject: [PATCH 116/161] rollback: refs #6724 entry.js --- modules/entry/back/models/entry.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 9d5cd4e1f..6148ae559 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -46,15 +46,4 @@ 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 0f26fb46b6f0127b1bcf4b54b1656749fb5dd8f7 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 15 Apr 2024 13:16:36 +0200 Subject: [PATCH 117/161] feat: refs #6724 Grant changes --- .../10944-tealLaurel/00-firstScript.sql | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/db/versions/10944-tealLaurel/00-firstScript.sql b/db/versions/10944-tealLaurel/00-firstScript.sql index d11bcb333..2d61cde90 100644 --- a/db/versions/10944-tealLaurel/00-firstScript.sql +++ b/db/versions/10944-tealLaurel/00-firstScript.sql @@ -1,10 +1,8 @@ - - 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; +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, loadPriority, + kop, sub, pro, auction, invoiceAmount, buyerFk, typeFk, reference, + observationEditorFk, clonedFrom, editorFk, lockerUserFk, locked +) ON vn.entry TO entryEditor; From 339c349ed037c6454e585c7e5b6a876465ec5365 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 15 Apr 2024 14:00:54 +0200 Subject: [PATCH 118/161] feat: refs #6724 Added admon acl to vn-check --- modules/entry/front/basic-data/index.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/entry/front/basic-data/index.html b/modules/entry/front/basic-data/index.html index 6bccb0b5f..57de1c5f7 100644 --- a/modules/entry/front/basic-data/index.html +++ b/modules/entry/front/basic-data/index.html @@ -123,7 +123,9 @@ + ng-model="$ctrl.entry.isBooked" + vn-acl="administrative" + > From 3e1218463c03b2cda4ea390a262299b49d661fac Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 14:44:18 +0200 Subject: [PATCH 119/161] fix: refs #6938 filters & scope --- modules/worker/back/models/worker.json | 18 ++++++--- modules/worker/front/card/index.js | 32 ++-------------- modules/worker/front/descriptor/index.js | 36 ++--------------- modules/worker/front/summary/index.js | 49 +++--------------------- 4 files changed, 25 insertions(+), 110 deletions(-) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 10776af90..57dc80ec9 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -100,12 +100,20 @@ "relation": "user", "scope": { "fields": ["email", "name", "nickname", "roleFk"], - "include": { - "relation": "role", - "scope": { - "fields": ["name"] + "include": [ + { + "relation": "role", + "scope": { + "fields": ["name"] + } + }, + { + "relation": "emailUser", + "scope": { + "fields": ["email"] + } } - } + ] } }, { "relation": "department", diff --git a/modules/worker/front/card/index.js b/modules/worker/front/card/index.js index 9a40e31c2..1aa548db9 100644 --- a/modules/worker/front/card/index.js +++ b/modules/worker/front/card/index.js @@ -4,37 +4,13 @@ import ModuleCard from 'salix/components/module-card'; class Controller extends ModuleCard { reload() { const filter = { - include: [ - { - relation: 'user', - scope: { - fields: ['name', 'emailVerified'], - include: { - relation: 'emailUser', - scope: { - fields: ['email'] - } - } - } - }, { - relation: 'sip', - scope: { - fields: ['extension', 'secret'] - } - }, { - relation: 'department', - scope: { - include: { - relation: 'department' - } - } - } - ] + where: { + id: this.$params.id} }; return Promise.all([ - this.$http.get(`Workers/${this.$params.id}`, {filter}) - .then(res => this.worker = res.data), + this.$http.get(`Workers/summary`, {filter}) + .then(res => this.worker = res.data[0]), this.$http.get(`Workers/${this.$params.id}/activeContract`) .then(res => this.hasWorkCenter = res.data?.workCenterFk) ]); diff --git a/modules/worker/front/descriptor/index.js b/modules/worker/front/descriptor/index.js index d7962369c..ebf3d65ed 100644 --- a/modules/worker/front/descriptor/index.js +++ b/modules/worker/front/descriptor/index.js @@ -37,41 +37,11 @@ class Controller extends Descriptor { loadData() { const filter = { - include: [ - { - relation: 'user', - scope: { - fields: ['name', 'emailVerified'], - include: { - relation: 'emailUser', - scope: { - fields: ['email'] - } - } - } - }, { - relation: 'client', - scope: { - fields: ['fi'] - } - }, { - relation: 'sip', - scope: { - fields: ['extension'] - } - }, { - relation: 'department', - scope: { - include: { - relation: 'department' - } - } - } - ] + where: {id: this.id}, }; - return this.getData(`Workers/${this.id}`, {filter}) - .then(res => this.entity = res.data); + return this.getData(`Workers/summary`, {filter}) + .then(res => this.entity = res.data[0]); } getPassRequirements() { diff --git a/modules/worker/front/summary/index.js b/modules/worker/front/summary/index.js index 212609f58..d1a27a6d4 100644 --- a/modules/worker/front/summary/index.js +++ b/modules/worker/front/summary/index.js @@ -10,53 +10,14 @@ class Controller extends Summary { this.$.worker = null; if (!value) return; - const query = `Workers/${value.id}`; const filter = { - include: [ - { - relation: 'user', - scope: { - fields: ['name', 'roleFk'], - include: [{ - relation: 'role', - scope: { - fields: ['name'] - } - }, - { - relation: 'emailUser', - scope: { - fields: ['email'] - } - }] - } - }, - { - relation: 'client', - scope: {fields: ['fi', 'phone']} - }, - { - relation: 'boss', - scope: {fields: ['id', 'name']} - }, - { - relation: 'sip', - scope: {fields: ['extension']} - }, - { - relation: 'department', - scope: { - include: { - relation: 'department', - scope: {fields: ['id', 'code', 'name']} - } - } - } - ] + where: { + id: value.id + } }; - this.$http.get(query, {params: {filter}}).then(res => { - this.$.worker = res.data; + this.$http.get(`Workers/summary`, {filter}).then(res => { + this.$.worker = res.data[0]; }); } From 3c9ac9634b6c4ab5890bb232d2d68b9d12eb9a63 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 15:02:45 +0200 Subject: [PATCH 120/161] fix: refs #6938 front tests --- modules/worker/front/descriptor/index.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/worker/front/descriptor/index.spec.js b/modules/worker/front/descriptor/index.spec.js index 4f7fa6a05..cee8b0def 100644 --- a/modules/worker/front/descriptor/index.spec.js +++ b/modules/worker/front/descriptor/index.spec.js @@ -14,14 +14,14 @@ describe('vnWorkerDescriptor', () => { describe('loadData()', () => { it(`should perform a get query to store the worker data into the controller`, () => { const id = 1; - const response = 'foo'; + const response = ['foo']; $httpBackend.whenGET('UserConfigs/getUserConfig').respond({}); - $httpBackend.expectRoute('GET', `Workers/${id}`).respond(response); + $httpBackend.expectRoute('GET', `Workers/summary`).respond(response); controller.id = id; $httpBackend.flush(); - expect(controller.worker).toEqual(response); + expect([controller.worker]).toEqual(response); }); }); From adb2249d2f8b4a74149e195b471963b2e317aade Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 15 Apr 2024 15:09:41 +0200 Subject: [PATCH 121/161] fix: refs #6938 e2e tests --- e2e/paths/03-worker/01_summary.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/e2e/paths/03-worker/01_summary.spec.js b/e2e/paths/03-worker/01_summary.spec.js index 51992b41d..3c6149726 100644 --- a/e2e/paths/03-worker/01_summary.spec.js +++ b/e2e/paths/03-worker/01_summary.spec.js @@ -2,7 +2,6 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; describe('Worker summary path', () => { - const workerId = 3; let browser; let page; beforeAll(async() => { @@ -10,7 +9,7 @@ describe('Worker summary path', () => { page = browser.page; await page.loginAndModule('employee', 'worker'); const httpDataResponse = page.waitForResponse(response => { - return response.status() === 200 && response.url().includes(`Workers/${workerId}`); + return response.status() === 200 && response.url().includes(`Workers/summary`); }); await page.accessToSearchResult('agencyNick'); await httpDataResponse; From 6e183b74264099ed0cb928d5f6d6ad3698f6e848 Mon Sep 17 00:00:00 2001 From: ivanm Date: Mon, 15 Apr 2024 15:59:05 +0200 Subject: [PATCH 122/161] refs #7161 change vAddress to vAddressShortage --- db/routines/vn/procedures/itemTrash.sql | 56 +++++++++++++++++++ .../vn/procedures/item_setVisibleDiscard.sql | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 db/routines/vn/procedures/itemTrash.sql diff --git a/db/routines/vn/procedures/itemTrash.sql b/db/routines/vn/procedures/itemTrash.sql new file mode 100644 index 000000000..bbb30b78a --- /dev/null +++ b/db/routines/vn/procedures/itemTrash.sql @@ -0,0 +1,56 @@ +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 1f2dbee93..0a6c54971 100644 --- a/db/routines/vn/procedures/item_setVisibleDiscard.sql +++ b/db/routines/vn/procedures/item_setVisibleDiscard.sql @@ -34,7 +34,7 @@ BEGIN SELECT a.clientFk INTO vClientFk FROM address a - WHERE a.id = vAddressFk; + WHERE a.id = vAddressShortage; SELECT t.id INTO vTicketFk FROM ticket t From d24de61213e68fea6df21da0d8e7ae7c970a62c3 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Tue, 16 Apr 2024 08:29:39 +0200 Subject: [PATCH 123/161] refs #6921 feat: addFromDelivery --- modules/route/back/methods/route/getTickets.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/route/back/methods/route/getTickets.js b/modules/route/back/methods/route/getTickets.js index 6f7162178..2393018cf 100644 --- a/modules/route/back/methods/route/getTickets.js +++ b/modules/route/back/methods/route/getTickets.js @@ -43,8 +43,9 @@ module.exports = Self => { st.code ticketStateCode, st.name ticketStateName, wh.name warehouseName, - tob.description ticketObservation, - tob2.description ticketObservationDropOff, + tob.description observationDelivery, + tob2.description observationDropOff, + tob2.id, a.street, a.postalCode, a.city, From 93abfdd8a1e8d2bd2508300918518d38e4b1d984 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 16 Apr 2024 08:44:50 +0200 Subject: [PATCH 124/161] feat: refs #7173 Added restrictions in invoiceIn structure --- db/dump/fixtures.before.sql | 16 ++++++++++------ .../vn/procedures/invoiceInTax_afterUpsert.sql | 2 ++ ...eckIsBooked.sql => invoiceIn_checkBooked.sql} | 2 +- .../invoiceInCorrection_beforeDelete.sql | 2 +- .../vn/triggers/invoiceInDueDay_beforeDelete.sql | 4 ++-- .../vn/triggers/invoiceInDueDay_beforeInsert.sql | 2 ++ .../triggers/invoiceInIntrastat_beforeDelete.sql | 2 +- .../triggers/invoiceInIntrastat_beforeInsert.sql | 8 ++++++++ ...tesql => invoiceInIntrastat_beforeUpdate.sql} | 0 .../vn/triggers/invoiceInTax_beforeDelete.sql | 2 +- .../vn/triggers/invoiceInTax_beforeUpdate.sql | 2 +- .../vn/triggers/invoiceIn_afterDelete.sql | 2 -- .../vn/triggers/invoiceIn_afterUpdate.sql | 2 -- .../vn/triggers/invoiceIn_beforeDelete.sql | 8 ++++++++ .../vn/triggers/invoiceIn_beforeUpdate.sql | 4 +++- .../methods/invoice-in-due-day/specs/new.spec.js | 3 +-- .../back/methods/invoice-in/specs/filter.spec.js | 2 +- 17 files changed, 42 insertions(+), 21 deletions(-) rename db/routines/vn/procedures/{invoiceIn_checkIsBooked.sql => invoiceIn_checkBooked.sql} (94%) create mode 100644 db/routines/vn/triggers/invoiceInIntrastat_beforeInsert.sql rename db/routines/vn/triggers/{invoiceInIntrastat_beforeUpdatesql => invoiceInIntrastat_beforeUpdate.sql} (100%) create mode 100644 db/routines/vn/triggers/invoiceIn_beforeDelete.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 1dad68b2c..cca080e45 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2542,15 +2542,15 @@ INSERT INTO `vn`.`duaEntry` (`duaFk`, `entryFk`, `value`, `customsValue`, `euroV REPLACE INTO `vn`.`invoiceIn`(`id`, `serialNumber`,`serial`, `supplierFk`, `issued`, `created`, `supplierRef`, `isBooked`, `companyFk`, `docFk`) VALUES (1, 1001, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1234, 0, 442, 1), - (2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 1, 442, 1), + (2, 1002, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1235, 0, 442, 1), (3, 1003, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1236, 0, 442, 1), (4, 1004, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1237, 0, 442, 1), - (5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 1, 442, 1), + (5, 1005, 'R', 1, util.VN_CURDATE(), util.VN_CURDATE(), 1238, 0, 442, 1), (6, 1006, 'R', 2, util.VN_CURDATE(), util.VN_CURDATE(), 1239, 0, 442, 1), - (7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 1, 442, 1), - (8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 1, 442, 1), - (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 1, 442, 1), - (10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 1, 442, 1); + (7, 1007, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1240, 0, 442, 1), + (8, 1008, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1241, 0, 442, 1), + (9, 1009, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1242, 0, 442, 1), + (10, 1010, 'R', 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1243, 0, 442, 1); INSERT INTO `vn`.`invoiceInConfig` (`id`, `retentionRate`, `retentionName`, `sageWithholdingFk`, `daysAgo`) VALUES @@ -2605,6 +2605,10 @@ INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amo (2, 13.20, 5080000, 15.00, 580, 5), (2, 16.10, 6021010, 25.00, 80, 5); +UPDATE `vn`.`invoiceIn` + SET isBooked = TRUE + WHERE id IN (2, 5, 7, 8, 9, 10); + INSERT INTO `vn`.`ticketRecalc`(`ticketFk`) SELECT t.id FROM vn.ticket t diff --git a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql index 60ec34696..43d54c28c 100644 --- a/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql +++ b/db/routines/vn/procedures/invoiceInTax_afterUpsert.sql @@ -10,6 +10,8 @@ BEGIN DECLARE vLines INT; DECLARE vHasDistinctTransactions INT; + CALL invoiceIn_checkBooked(vInvoiceInFk); + SELECT taxRowLimit INTO vTaxRowLimit FROM invoiceInConfig; SELECT COUNT(*) INTO vLines diff --git a/db/routines/vn/procedures/invoiceIn_checkIsBooked.sql b/db/routines/vn/procedures/invoiceIn_checkBooked.sql similarity index 94% rename from db/routines/vn/procedures/invoiceIn_checkIsBooked.sql rename to db/routines/vn/procedures/invoiceIn_checkBooked.sql index 35008fcd5..862870eb4 100644 --- a/db/routines/vn/procedures/invoiceIn_checkIsBooked.sql +++ b/db/routines/vn/procedures/invoiceIn_checkBooked.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_checkIsBooked`( +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`invoiceIn_checkBooked`( vSelf INT ) BEGIN diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeDelete.sql index 309d53af2..f4df48dcd 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_checkIsBooked(OLD.correctingFk); + 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 index eed070950..10c9d0b52 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_checkIsBooked(OLD.id); + CALL invoiceIn_checkBooked(OLD.invoiceInFk); END$$ -DELIMITER ; \ No newline at end of file +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql index f7e4265a7..95b227616 100644 --- a/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql +++ b/db/routines/vn/triggers/invoiceInDueDay_beforeInsert.sql @@ -5,6 +5,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInDueDay_befor BEGIN DECLARE vIsNotified BOOLEAN; + CALL invoiceIn_checkBooked(NEW.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 e3dfc769c..412b091f4 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_checkIsBooked(OLD.invoiceInFk); + CALL invoiceIn_checkBooked(OLD.invoiceInFk); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeInsert.sql b/db/routines/vn/triggers/invoiceInIntrastat_beforeInsert.sql new file mode 100644 index 000000000..d6c25c505 --- /dev/null +++ b/db/routines/vn/triggers/invoiceInIntrastat_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInIntrastat_beforeInsert` + BEFORE INSERT ON `invoiceInIntrastat` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(NEW.invoiceInFk); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdatesql b/db/routines/vn/triggers/invoiceInIntrastat_beforeUpdate.sql similarity index 100% rename from db/routines/vn/triggers/invoiceInIntrastat_beforeUpdatesql rename to db/routines/vn/triggers/invoiceInIntrastat_beforeUpdate.sql diff --git a/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql b/db/routines/vn/triggers/invoiceInTax_beforeDelete.sql index c48e7a227..a43f602b4 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_checkIsBooked(OLD.invoiceInFk); + 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 99ccd2c1d..3e5ecf030 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_checkIsBooked(OLD.invoiceInFk); + CALL invoiceIn_checkBooked(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 62a01ebc2..c088f6492 100644 --- a/db/routines/vn/triggers/invoiceIn_afterDelete.sql +++ b/db/routines/vn/triggers/invoiceIn_afterDelete.sql @@ -3,8 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_afterDelete AFTER DELETE ON `invoiceIn` FOR EACH ROW BEGIN - CALL invoiceIn_checkIsBooked(OLD.id); - INSERT INTO invoiceInLog SET `action` = 'delete', `changedModel` = 'InvoiceIn', diff --git a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql index 8d3df4ed5..1a9105c9e 100644 --- a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql @@ -3,8 +3,6 @@ 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 diff --git a/db/routines/vn/triggers/invoiceIn_beforeDelete.sql b/db/routines/vn/triggers/invoiceIn_beforeDelete.sql new file mode 100644 index 000000000..2ffff923a --- /dev/null +++ b/db/routines/vn/triggers/invoiceIn_beforeDelete.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeDelete` + BEFORE DELETE ON `invoiceIn` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(OLD.id); +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql index 688a3af92..d0762de96 100644 --- a/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_beforeUpdate.sql @@ -5,7 +5,9 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdat BEGIN DECLARE vWithholdingSageFk INT; - CALL invoiceIn_checkBooked(OLD.id); + IF NEW.isBooked = OLD.isBooked THEN + CALL invoiceIn_checkBooked(OLD.id); + END IF; IF NOT (NEW.supplierRef <=> OLD.supplierRef) AND NOT util.checkPrintableChars(NEW.supplierRef) THEN CALL util.throw('The invoiceIn reference contains invalid characters'); diff --git a/modules/invoiceIn/back/methods/invoice-in-due-day/specs/new.spec.js b/modules/invoiceIn/back/methods/invoice-in-due-day/specs/new.spec.js index c188a511d..f21dad9f2 100644 --- a/modules/invoiceIn/back/methods/invoice-in-due-day/specs/new.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in-due-day/specs/new.spec.js @@ -13,11 +13,10 @@ describe('invoiceInDueDay new()', () => { it('should correctly create a new due day', async() => { const userId = 9; - const invoiceInFk = 6; + const invoiceInFk = 3; const ctx = { req: { - accessToken: {userId: userId}, } }; diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js index 9834989fc..3ff5a92f3 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js @@ -158,7 +158,7 @@ describe('InvoiceIn filter()', () => { const result = await models.InvoiceIn.filter(ctx, {}, options); - expect(result.length).toEqual(6); + expect(result.length).toEqual(4); await tx.rollback(); } catch (e) { From 45fac06c6b6bf82d38cc105f45055cb1044d4693 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 16 Apr 2024 08:58:26 +0200 Subject: [PATCH 125/161] feat: refs #7173 Added restrictions in invoiceIn structure --- .../vn/triggers/invoiceInCorrection_beforeInsert.sql | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 db/routines/vn/triggers/invoiceInCorrection_beforeInsert.sql diff --git a/db/routines/vn/triggers/invoiceInCorrection_beforeInsert.sql b/db/routines/vn/triggers/invoiceInCorrection_beforeInsert.sql new file mode 100644 index 000000000..aec58a265 --- /dev/null +++ b/db/routines/vn/triggers/invoiceInCorrection_beforeInsert.sql @@ -0,0 +1,8 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`invoiceInCorrection_beforeInsert` + BEFORE INSERT ON `invoiceInCorrection` + FOR EACH ROW +BEGIN + CALL invoiceIn_checkBooked(NEW.correctingFk); +END$$ +DELIMITER ; From 7a557be09a0256d95636dbfc34d9c80daecb4e6b Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 16 Apr 2024 11:07:57 +0200 Subject: [PATCH 126/161] feat: refs #6968 Changed groupingMode to enum --- db/dump/fixtures.before.sql | 52 +++++++++---------- db/routines/edi/procedures/ekt_load.sql | 3 +- .../procedures/floramondo_offerRefresh.sql | 10 ++-- .../procedures/catalog_componentCalculate.sql | 7 +-- .../vn/procedures/collectionPlacement_get.sql | 4 +- db/routines/vn/procedures/inventoryMake.sql | 2 +- db/routines/vn/procedures/item_getSimilar.sql | 4 +- .../vn/procedures/sale_replaceItem.sql | 8 ++- db/routines/vn/triggers/buy_beforeInsert.sql | 2 +- db/versions/10997-crimsonCyca/00-part1.sql | 2 + db/versions/10997-crimsonCyca/01-part2.sql | 7 +++ db/versions/10997-crimsonCyca/02-part3.sql | 2 + modules/entry/back/models/buy.json | 2 +- modules/entry/front/buy/index/index.html | 8 +-- modules/entry/front/buy/index/index.js | 8 +-- modules/entry/front/buy/index/index.spec.js | 27 +++------- modules/entry/front/latest-buys/index.html | 4 +- modules/entry/front/summary/index.html | 4 +- modules/item/front/last-entries/index.html | 4 +- 19 files changed, 77 insertions(+), 83 deletions(-) create mode 100644 db/versions/10997-crimsonCyca/00-part1.sql create mode 100644 db/versions/10997-crimsonCyca/01-part2.sql create mode 100644 db/versions/10997-crimsonCyca/02-part3.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index c9832545f..277734eb7 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1492,21 +1492,21 @@ INSERT INTO `bs`.`waste`(`buyer`, `year`, `week`, `family`, `itemFk`, `itemTypeF INSERT INTO `vn`.`buy`(`id`,`entryFk`,`itemFk`,`buyingValue`,`quantity`,`packagingFk`,`stickers`,`freightValue`,`packageValue`,`comissionValue`,`packing`,`grouping`,`groupingMode`,`location`,`price1`,`price2`,`price3`, `printedStickers`,`isChecked`,`isIgnored`,`weight`, `created`) VALUES - (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH), - (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 1 MONTH), - (3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 0, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE()), - (4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, 0, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 2.5, util.VN_CURDATE()), - (5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, 0, NULL, 0.00, 78.3, 75.6, 0, 1, 0, 2.5, util.VN_CURDATE()), - (6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 2.5, util.VN_CURDATE()), - (7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 30.50, 29.00, 0, 1, 0, 2.5, util.VN_CURDATE()), - (8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 2.5, util.VN_CURDATE()), - (9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), - (10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), - (11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), - (12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), - (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 1, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), - (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()), - (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 1, NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()); + (1, 1, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH), + (2, 2, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 1 MONTH), + (3, 3, 1, 50, 100, 4, 1, 1.500, 1.500, 0.000, 1, 1, NULL, NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE()), + (4, 2, 2, 5, 450, 3, 1, 1.000, 1.000, 0.000, 10, 10, NULL, NULL, 0.00, 7.30, 7.00, 0, 1, 0, 2.5, util.VN_CURDATE()), + (5, 3, 3, 55, 500, 5, 1, 1.000, 1.000, 0.000, 1, 1, NULL, NULL, 0.00, 78.3, 75.6, 0, 1, 0, 2.5, util.VN_CURDATE()), + (6, 4, 8, 50, 1000, 4, 1, 1.000, 1.000, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 2.5, util.VN_CURDATE()), + (7, 4, 9, 20, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'packing', NULL, 0.00, 30.50, 29.00, 0, 1, 0, 2.5, util.VN_CURDATE()), + (8, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 2.5, util.VN_CURDATE()), + (9, 4, 4, 1.25, 1000, 3, 1, 0.500, 0.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), + (10, 5, 1, 50, 10, 4, 1, 2.500, 2.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), + (11, 5, 4, 1.25, 10, 3, 1, 2.500, 2.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), + (12, 6, 4, 1.25, 0, 3, 1, 2.500, 2.500, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()), + (13, 7, 1, 50, 0, 3, 1, 2.000, 2.000, 0.000, 1, 1, 'packing', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 4, util.VN_CURDATE()), + (14, 7, 2, 5, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 7.30, 7.00, 0, 1, 0, 4, util.VN_CURDATE()), + (15, 7, 4, 1.25, 0, 3, 1, 2.000, 2.000, 0.000, 10, 10, 'grouping', NULL, 0.00, 1.75, 1.67, 0, 1, 0, 4, util.VN_CURDATE()); INSERT INTO `hedera`.`order`(`id`, `date_send`, `customer_id`, `delivery_method_id`, `agency_id`, `address_id`, `company_id`, `note`, `source_app`, `confirmed`,`total`, `date_make`, `first_row_stamp`, `confirm_date`) VALUES @@ -3235,7 +3235,7 @@ INSERT INTO vn.buy stickers = 1, packing = 20, `grouping` = 1, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3273,7 +3273,7 @@ INSERT INTO vn.buy stickers = 1, packing = 40, `grouping` = 5, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3311,7 +3311,7 @@ INSERT INTO vn.buy stickers = 2, packing = 10, `grouping` = 5, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3357,7 +3357,7 @@ INSERT INTO vn.buy stickers = 1, packing = 20, `grouping` = 4, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3395,7 +3395,7 @@ INSERT INTO vn.buy stickers = 1, packing = 20, `grouping` = 1, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3434,7 +3434,7 @@ INSERT INTO vn.buy stickers = 1, packing = 200, `grouping` = 30, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3473,7 +3473,7 @@ INSERT INTO vn.buy stickers = 1, packing = 500, `grouping` = 10, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3512,7 +3512,7 @@ INSERT INTO vn.buy stickers = 2, packing = 300, `grouping` = 50, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3551,7 +3551,7 @@ INSERT INTO vn.buy stickers = 2, packing = 50, `grouping` = 5, - groupingMode = 1, + groupingMode = 'packing', price1 = 1, price2 = 1, price3 = 1, @@ -3591,7 +3591,7 @@ INSERT vn.buy stickers = 1, packing = 5, `grouping` = 2, - groupingMode = 1, + groupingMode = 'packing', price1 = 7, price2 = 7, price3 = 7, @@ -3630,7 +3630,7 @@ INSERT vn.buy stickers = 1, packing = 100, `grouping` = 5, - groupingMode = 1, + groupingMode = 'packing', price1 = 7, price2 = 7, price3 = 7, diff --git a/db/routines/edi/procedures/ekt_load.sql b/db/routines/edi/procedures/ekt_load.sql index ccdcd1999..a72f48674 100644 --- a/db/routines/edi/procedures/ekt_load.sql +++ b/db/routines/edi/procedures/ekt_load.sql @@ -14,7 +14,6 @@ proc:BEGIN DECLARE vPackage INT; DECLARE vPutOrderFk INT; DECLARE vIsLot BOOLEAN; - DECLARE vForceToPacking INT DEFAULT 2; DECLARE vEntryFk INT; DECLARE vHasToChangePackagingFk BOOLEAN; DECLARE vIsFloramondoDirect BOOLEAN; @@ -150,7 +149,7 @@ proc:BEGIN @pac := IFNULL(i.stemMultiplier, 1) * e.pac / @t packing, IFNULL(b.`grouping`, e.pac), @pac * e.qty, - vForceToPacking, + 'packing', IF(vHasToChangePackagingFk OR b.packagingFk IS NULL, vPackage, b.packagingFk), (IFNULL(i.weightByPiece, 0) * @pac) / 1000 FROM ekt e diff --git a/db/routines/edi/procedures/floramondo_offerRefresh.sql b/db/routines/edi/procedures/floramondo_offerRefresh.sql index 26e09ebaf..18d3f8b7e 100644 --- a/db/routines/edi/procedures/floramondo_offerRefresh.sql +++ b/db/routines/edi/procedures/floramondo_offerRefresh.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`floramondo_offerRefresh`() +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `edi`.`floramondo_offerRefresh`() proc: BEGIN DECLARE vLanded DATETIME; DECLARE vDone INT DEFAULT FALSE; @@ -417,7 +417,7 @@ proc: BEGIN o.NumberOfUnits etiquetas, o.NumberOfItemsPerCask packing, GREATEST(1, IFNULL(o.MinimumQuantity,0)) * o.NumberOfItemsPerCask `grouping`, - 2, -- Obliga al Packing + 'packing', o.embalageCode, o.diId FROM edi.offer o @@ -518,5 +518,5 @@ proc: BEGIN fieldValue = TIMEDIFF(util.VN_NOW(), vStartingTime); DO RELEASE_LOCK('edi.floramondo_offerRefresh'); -END$$ -DELIMITER ; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/catalog_componentCalculate.sql b/db/routines/vn/procedures/catalog_componentCalculate.sql index 1af0ff9eb..4b860103d 100644 --- a/db/routines/vn/procedures/catalog_componentCalculate.sql +++ b/db/routines/vn/procedures/catalog_componentCalculate.sql @@ -48,7 +48,7 @@ BEGIN IF(i.hasMinPrice, GREATEST(i.minPrice,IFNULL(pf.rate3, b.price3)),IFNULL(pf.rate3, b.price3)) rate3, IFNULL(pf.packing, GREATEST(b.grouping, b.packing)) packing, IFNULL(pf.`grouping`, b.`grouping`) `grouping`, - ABS(IFNULL(pf.box, b.groupingMode)) groupingMode, + b.groupingMode groupingMode, tl.buyFk, i.typeFk, IF(i.hasKgPrice, b.weight / b.packing, NULL) weightGrouping @@ -252,14 +252,15 @@ BEGIN SELECT tcc.warehouseFk, tcc.itemFk, 1 rate, - IF(tcc.groupingMode = 1, tcc.`grouping`, 1) `grouping`, + IF(tcc.groupingMode = 'grouping', tcc.`grouping`, 1) `grouping`, CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) price, CAST(SUM(tcs.sumCost) AS DECIMAL(10,2)) / weightGrouping priceKg FROM tmp.ticketComponentCalculate tcc JOIN tmp.ticketComponentSum tcs ON tcs.itemFk = tcc.itemFk AND tcs.warehouseFk = tcc.warehouseFk WHERE IFNULL(tcs.classRate, 1) = 1 - AND tcc.groupingMode < 2 AND (tcc.packing > tcc.`grouping` or tcc.groupingMode = 0) + AND NOT tcc.groupingMode = 'packing' + AND (tcc.packing > tcc.`grouping` OR tcc.groupingMode IS NULL) GROUP BY tcs.warehouseFk, tcs.itemFk; INSERT INTO tmp.ticketComponentRate (warehouseFk, itemFk, rate, `grouping`, price, priceKg) diff --git a/db/routines/vn/procedures/collectionPlacement_get.sql b/db/routines/vn/procedures/collectionPlacement_get.sql index 3641ba705..3fb3339e7 100644 --- a/db/routines/vn/procedures/collectionPlacement_get.sql +++ b/db/routines/vn/procedures/collectionPlacement_get.sql @@ -40,8 +40,8 @@ BEGIN ENGINE = MEMORY SELECT b.itemFk, CASE b.groupingMode - WHEN 0 THEN 1 - WHEN 2 THEN b.packing + WHEN NULL THEN 1 + WHEN 'packing' THEN b.packing ELSE b.`grouping` END `grouping` FROM buy b diff --git a/db/routines/vn/procedures/inventoryMake.sql b/db/routines/vn/procedures/inventoryMake.sql index c50d75b05..b7ea377d2 100644 --- a/db/routines/vn/procedures/inventoryMake.sql +++ b/db/routines/vn/procedures/inventoryMake.sql @@ -116,7 +116,7 @@ BEGIN freightValue decimal(10,3) DEFAULT '0.000', packing int(11) DEFAULT '1', `grouping` smallint(5) unsigned NOT NULL DEFAULT '1', - groupingMode tinyint(4) NOT NULL DEFAULT 0 , + groupingMode enum('grouping', 'packing') DEFAULT NULL, comissionValue decimal(10,3) DEFAULT '0.000', packageValue decimal(10,3) DEFAULT '0.000', packageFk varchar(10) COLLATE utf8_unicode_ci DEFAULT '--', diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index f79bed375..1da60cf70 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -61,8 +61,8 @@ BEGIN a.available, IFNULL(ip.counter, 0) `counter`, CASE - WHEN b.groupingMode = 1 THEN b.grouping - WHEN b.groupingMode = 2 THEN b.packing + WHEN b.groupingMode = 'grouping' THEN b.grouping + WHEN b.groupingMode = 'packing' THEN b.packing ELSE 1 END AS minQuantity, iss.visible located diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index 82c5d1ec2..2514c14c7 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -13,7 +13,7 @@ BEGIN DECLARE vWarehouseFk SMALLINT; DECLARE vDate DATE; DECLARE vGrouping INT; - DECLARE vGroupingModeFk INT; + DECLARE vGroupingModeFk VARCHAR(255); DECLARE vPacking INT; DECLARE vRoundQuantity INT DEFAULT 1; DECLARE vLanded DATE; @@ -23,8 +23,6 @@ BEGIN DECLARE vOldPrice DECIMAL(10,2); DECLARE vOption VARCHAR(255); DECLARE vNewSaleFk INT; - DECLARE vForceToGrouping INT DEFAULT 1; - DECLARE vForceToPacking INT DEFAULT 2; DECLARE vFinalPrice DECIMAL(10,2); DECLARE EXIT HANDLER FOR SQLEXCEPTION @@ -63,10 +61,10 @@ BEGIN JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk; - IF vGroupingModeFk = vForceToPacking AND vPacking > 0 THEN + IF vGroupingModeFk = 'packing' AND vPacking > 0 THEN SET vRoundQuantity = vPacking; END IF; - IF vGroupingModeFk = vForceToGrouping AND vGrouping > 0 THEN + IF vGroupingModeFk = 'grouping' AND vGrouping > 0 THEN SET vRoundQuantity = vGrouping; END IF; diff --git a/db/routines/vn/triggers/buy_beforeInsert.sql b/db/routines/vn/triggers/buy_beforeInsert.sql index bc51ac852..6ad72916b 100644 --- a/db/routines/vn/triggers/buy_beforeInsert.sql +++ b/db/routines/vn/triggers/buy_beforeInsert.sql @@ -6,7 +6,7 @@ trig: BEGIN DECLARE vWarehouse INT; DECLARE vLanding DATE; DECLARE vGrouping INT; - DECLARE vGroupingMode TINYINT; + DECLARE vGroupingMode VARCHAR(255); DECLARE vGenericFk INT; DECLARE vGenericInDate BOOL; DECLARE vBuyerFk INT; diff --git a/db/versions/10997-crimsonCyca/00-part1.sql b/db/versions/10997-crimsonCyca/00-part1.sql new file mode 100644 index 000000000..8811b81a7 --- /dev/null +++ b/db/versions/10997-crimsonCyca/00-part1.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.buy ADD groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL; +ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL AFTER groupingMode; diff --git a/db/versions/10997-crimsonCyca/01-part2.sql b/db/versions/10997-crimsonCyca/01-part2.sql new file mode 100644 index 000000000..1f7a3c9f6 --- /dev/null +++ b/db/versions/10997-crimsonCyca/01-part2.sql @@ -0,0 +1,7 @@ +UPDATE vn.buy + SET groupingMode2 = 'packing' + WHERE groupingMode = 2; + +UPDATE vn.buy + SET groupingMode2 = 'grouping' + WHERE groupingMode = 1; diff --git a/db/versions/10997-crimsonCyca/02-part3.sql b/db/versions/10997-crimsonCyca/02-part3.sql new file mode 100644 index 000000000..c63560957 --- /dev/null +++ b/db/versions/10997-crimsonCyca/02-part3.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.buy DROP COLUMN groupingMode; +ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode enum('grouping','packing') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL; diff --git a/modules/entry/back/models/buy.json b/modules/entry/back/models/buy.json index fa804f4d8..35861fd81 100644 --- a/modules/entry/back/models/buy.json +++ b/modules/entry/back/models/buy.json @@ -34,7 +34,7 @@ "type": "number" }, "groupingMode": { - "type": "number" + "type": "string" }, "comissionValue": { "type": "number" diff --git a/modules/entry/front/buy/index/index.html b/modules/entry/front/buy/index/index.html index 203d6c522..0e0c69788 100644 --- a/modules/entry/front/buy/index/index.html +++ b/modules/entry/front/buy/index/index.html @@ -119,13 +119,13 @@ @@ -140,13 +140,13 @@ diff --git a/modules/entry/front/buy/index/index.js b/modules/entry/front/buy/index/index.js index c991b745b..9131c31f6 100644 --- a/modules/entry/front/buy/index/index.js +++ b/modules/entry/front/buy/index/index.js @@ -53,12 +53,8 @@ export default class Controller extends Section { } toggleGroupingMode(buy, mode) { - const grouping = 1; - const packing = 2; - const groupingMode = mode === 'grouping' ? grouping : packing; - - const newGroupingMode = buy.groupingMode === groupingMode ? 0 : groupingMode; - + const groupingMode = mode === 'grouping' ? mode : 'packing'; + const newGroupingMode = buy.groupingMode === groupingMode ? null : groupingMode; const params = { groupingMode: newGroupingMode }; diff --git a/modules/entry/front/buy/index/index.spec.js b/modules/entry/front/buy/index/index.spec.js index b9d5fab51..f5c6d1bdb 100644 --- a/modules/entry/front/buy/index/index.spec.js +++ b/modules/entry/front/buy/index/index.spec.js @@ -57,45 +57,34 @@ describe('Entry buy', () => { describe('toggleGroupingMode()', () => { it(`should toggle grouping mode from grouping to packing`, () => { - const grouping = 1; - const packing = 2; - const buy = {id: 999, groupingMode: grouping}; + const buy = {id: 999, groupingMode: 'grouping'}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: packing}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: 'packing'}).respond(200); controller.toggleGroupingMode(buy, 'packing'); $httpBackend.flush(); }); it(`should toggle grouping mode from packing to grouping`, () => { - const grouping = 1; - const packing = 2; - const buy = {id: 999, groupingMode: packing}; - + const buy = {id: 999, groupingMode: 'packing'}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: grouping}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: 'grouping'}).respond(200); controller.toggleGroupingMode(buy, 'grouping'); $httpBackend.flush(); }); it(`should toggle off the grouping mode if it was packing to packing`, () => { - const noGrouping = 0; - const packing = 2; - const buy = {id: 999, groupingMode: packing}; - + const buy = {id: 999, groupingMode: 'packing'}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: noGrouping}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: null}).respond(200); controller.toggleGroupingMode(buy, 'packing'); $httpBackend.flush(); }); it(`should toggle off the grouping mode if it was grouping to grouping`, () => { - const noGrouping = 0; - const grouping = 1; - const buy = {id: 999, groupingMode: grouping}; - + const buy = {id: 999, groupingMode: 'grouping'}; const query = `Buys/${buy.id}`; - $httpBackend.expectPATCH(query, {groupingMode: noGrouping}).respond(200); + $httpBackend.expectPATCH(query, {groupingMode: null}).respond(200); controller.toggleGroupingMode(buy, 'grouping'); $httpBackend.flush(); }); diff --git a/modules/entry/front/latest-buys/index.html b/modules/entry/front/latest-buys/index.html index 16e039cf0..2e6de83b9 100644 --- a/modules/entry/front/latest-buys/index.html +++ b/modules/entry/front/latest-buys/index.html @@ -143,12 +143,12 @@ - + {{::buy.packing | dashIfEmpty}} - + {{::buy.grouping | dashIfEmpty}} diff --git a/modules/entry/front/summary/index.html b/modules/entry/front/summary/index.html index 655dcd66f..baa310bb6 100644 --- a/modules/entry/front/summary/index.html +++ b/modules/entry/front/summary/index.html @@ -121,12 +121,12 @@ {{::line.packagingFk | dashIfEmpty}} {{::line.weight}} - + {{::line.packing | dashIfEmpty}} - + {{::line.grouping | dashIfEmpty}} diff --git a/modules/item/front/last-entries/index.html b/modules/item/front/last-entries/index.html index 429955ef5..e3b84655c 100644 --- a/modules/item/front/last-entries/index.html +++ b/modules/item/front/last-entries/index.html @@ -71,12 +71,12 @@ {{entry.stickers | dashIfEmpty}} - + {{::entry.packing | dashIfEmpty}} - + {{::entry.grouping | dashIfEmpty}} From f5fd70889124a7d27a1eb81fdd5c7b659c0d1ef8 Mon Sep 17 00:00:00 2001 From: pako Date: Tue, 16 Apr 2024 17:08:45 +0200 Subject: [PATCH 127/161] item_get --- db/routines/floranet/procedures/item_get.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 db/routines/floranet/procedures/item_get.sql diff --git a/db/routines/floranet/procedures/item_get.sql b/db/routines/floranet/procedures/item_get.sql new file mode 100644 index 000000000..44f01f2a1 --- /dev/null +++ b/db/routines/floranet/procedures/item_get.sql @@ -0,0 +1,15 @@ +DELIMITER $$ +$$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.item_get(vCatalogueFk INT) +READS SQL DATA +BEGIN +/** + * Returns one recordset from catalogue + * + * @param vCatalogueFk Identifier de vn.catalogue + */ + SELECT * + FROM catalogue + WHERE id = vCatalogueFk; +END$$ +DELIMITER ; From f05b33787f32d3645159b79bac3a3402071a9792 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 16 Apr 2024 17:42:36 +0200 Subject: [PATCH 128/161] feat: refs #6021 order_put refactor --- db/routines/floranet/procedures/order_put.sql | 42 +++++-------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/db/routines/floranet/procedures/order_put.sql b/db/routines/floranet/procedures/order_put.sql index 564587268..979588f8f 100644 --- a/db/routines/floranet/procedures/order_put.sql +++ b/db/routines/floranet/procedures/order_put.sql @@ -1,41 +1,21 @@ -DROP PROCEDURE IF EXISTS floranet.order_put; - DELIMITER $$ -$$ -CREATE DEFINER=`root`@`localhost` PROCEDURE floranet.order_put(vOrder JSON) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.order_put(vJsonData JSON) READS SQL DATA BEGIN /** * Get and process an order. * - * @param vOrder Data of the order - * - * Customer data: , , - * - * Item data: , - * - * Delivery data: ,
, - * + * @param vJsonData The order data in json format */ - INSERT IGNORE INTO `order`( - catalogueFk, - customerName, - email, - customerPhone, - message, - deliveryName, - address, - deliveryPhone - ) - VALUES (JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.catalogueFk')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerName')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.email')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.customerPhone')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.message')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryName')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.address')), - JSON_UNQUOTE(JSON_EXTRACT(vOrder,'$.deliveryPhone')) - ); + INSERT INTO `order` + SET catalogueFk = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.products[0].id')), + customerName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerName')), + email = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.email')), + customerPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.customerPhone')), + message= JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.message')), + deliveryName = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryName')), + address = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.address')), + deliveryPhone = JSON_UNQUOTE(JSON_EXTRACT(vJsonData, '$.customer.customerData.deliveryPhone')); SELECT LAST_INSERT_ID() orderFk; END$$ From 70836b93b6186413f132a814290a14a58f7d5906 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 16 Apr 2024 17:51:34 +0200 Subject: [PATCH 129/161] fix: refs #6021 catalogue_findById --- .../procedures/{item_get.sql => catalogue_findById.sql} | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) rename db/routines/floranet/procedures/{item_get.sql => catalogue_findById.sql} (71%) diff --git a/db/routines/floranet/procedures/item_get.sql b/db/routines/floranet/procedures/catalogue_findById.sql similarity index 71% rename from db/routines/floranet/procedures/item_get.sql rename to db/routines/floranet/procedures/catalogue_findById.sql index 44f01f2a1..7058ae03c 100644 --- a/db/routines/floranet/procedures/item_get.sql +++ b/db/routines/floranet/procedures/catalogue_findById.sql @@ -1,6 +1,6 @@ DELIMITER $$ $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.item_get(vCatalogueFk INT) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE floranet.catalogue_findById(vSelf INT) READS SQL DATA BEGIN /** @@ -8,8 +8,6 @@ BEGIN * * @param vCatalogueFk Identifier de vn.catalogue */ - SELECT * - FROM catalogue - WHERE id = vCatalogueFk; + SELECT * FROM catalogue WHERE id = vCatalogueFk; END$$ DELIMITER ; From 1d29c77aa7148a74b8697e7d707b7dd1c2cf1d74 Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 16 Apr 2024 17:53:21 +0200 Subject: [PATCH 130/161] feat: refs #6021 fix proc --- db/routines/floranet/procedures/catalogue_findById.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/floranet/procedures/catalogue_findById.sql b/db/routines/floranet/procedures/catalogue_findById.sql index 7058ae03c..728eb8519 100644 --- a/db/routines/floranet/procedures/catalogue_findById.sql +++ b/db/routines/floranet/procedures/catalogue_findById.sql @@ -6,7 +6,7 @@ BEGIN /** * Returns one recordset from catalogue * - * @param vCatalogueFk Identifier de vn.catalogue + * @param vCatalogueFk Identifier de floranet.catalogue */ SELECT * FROM catalogue WHERE id = vCatalogueFk; END$$ From e15fb8dec69a17e0d3535b6bff21899d5dbad30d Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 16 Apr 2024 18:00:15 +0200 Subject: [PATCH 131/161] fix: refs #6021 proc --- db/routines/floranet/procedures/catalogue_findById.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/floranet/procedures/catalogue_findById.sql b/db/routines/floranet/procedures/catalogue_findById.sql index 728eb8519..aca6ca4d6 100644 --- a/db/routines/floranet/procedures/catalogue_findById.sql +++ b/db/routines/floranet/procedures/catalogue_findById.sql @@ -8,6 +8,6 @@ BEGIN * * @param vCatalogueFk Identifier de floranet.catalogue */ - SELECT * FROM catalogue WHERE id = vCatalogueFk; + SELECT * FROM catalogue WHERE id = vSelf; END$$ DELIMITER ; From c8e7706652702ff5106359c2d1e1f17c7de9e6fd Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 17 Apr 2024 07:15:24 +0200 Subject: [PATCH 132/161] feat: refs #6968 Requested changes --- db/routines/vn/procedures/sale_replaceItem.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/sale_replaceItem.sql b/db/routines/vn/procedures/sale_replaceItem.sql index 2514c14c7..9fece1ebd 100644 --- a/db/routines/vn/procedures/sale_replaceItem.sql +++ b/db/routines/vn/procedures/sale_replaceItem.sql @@ -13,7 +13,7 @@ BEGIN DECLARE vWarehouseFk SMALLINT; DECLARE vDate DATE; DECLARE vGrouping INT; - DECLARE vGroupingModeFk VARCHAR(255); + DECLARE vGroupingMode VARCHAR(255); DECLARE vPacking INT; DECLARE vRoundQuantity INT DEFAULT 1; DECLARE vLanded DATE; @@ -56,15 +56,15 @@ BEGIN CALL buyUltimate(vWarehouseFk, vDate); SELECT `grouping`, groupingMode, packing - INTO vGrouping,vGroupingModeFk,vPacking + INTO vGrouping,vGroupingMode,vPacking FROM buy b JOIN tmp.buyUltimate tmp ON b.id = tmp.buyFk WHERE tmp.itemFk = vNewItemFk AND tmp.WarehouseFk = vWarehouseFk; - IF vGroupingModeFk = 'packing' AND vPacking > 0 THEN + IF vGroupingMode = 'packing' AND vPacking > 0 THEN SET vRoundQuantity = vPacking; END IF; - IF vGroupingModeFk = 'grouping' AND vGrouping > 0 THEN + IF vGroupingMode = 'grouping' AND vGrouping > 0 THEN SET vRoundQuantity = vGrouping; END IF; From bc2b6ff97ea63912bc790d6278357d46b0f50a64 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 17 Apr 2024 07:25:46 +0200 Subject: [PATCH 133/161] feat: refs #7173 Added traduction --- loopback/locale/es.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 8b02f3048..d7f9564fe 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -352,5 +352,6 @@ "The line could not be marked": "La linea no puede ser marcada", "This password can only be changed by the user themselves": "Esta contraseña solo puede ser modificada por el propio usuario", "They're not your subordinate": "No es tu subordinado/a.", - "No results found": "No se han encontrado resultados" + "No results found": "No se han encontrado resultados", + "InvoiceIn is already booked": "La factura recibida está contabilizada" } \ No newline at end of file From 6214da2c42eec2b1604bed71c76747e2418e4add Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 17 Apr 2024 09:52:53 +0200 Subject: [PATCH 134/161] feat(salix): refs #6930 Undo rollback salix-back --- back/methods/dms/downloadFile.js | 2 +- back/methods/docuware/download.js | 2 +- back/methods/image/download.js | 2 +- modules/claim/back/methods/claim/claimPickupPdf.js | 2 +- modules/claim/back/methods/claim/downloadFile.js | 2 +- modules/client/back/methods/client/campaignMetricsPdf.js | 2 +- modules/entry/back/methods/entry/entryOrderPdf.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/download.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/downloadZip.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js | 2 +- modules/item/back/methods/item-image-queue/download.js | 2 +- modules/route/back/methods/route/cmr.js | 3 ++- modules/route/back/methods/route/downloadCmrsZip.js | 2 +- modules/route/back/methods/route/downloadZip.js | 2 +- modules/route/back/methods/route/driverRoutePdf.js | 2 +- modules/supplier/back/methods/supplier/campaignMetricsPdf.js | 2 +- modules/ticket/back/methods/ticket/deliveryNoteCsv.js | 2 +- modules/ticket/back/methods/ticket/deliveryNotePdf.js | 2 +- modules/travel/back/methods/travel/extraCommunityPdf.js | 2 +- modules/worker/back/methods/worker-dms/downloadFile.js | 2 +- 22 files changed, 23 insertions(+), 22 deletions(-) diff --git a/back/methods/dms/downloadFile.js b/back/methods/dms/downloadFile.js index 6f2451505..d64b15b70 100644 --- a/back/methods/dms/downloadFile.js +++ b/back/methods/dms/downloadFile.js @@ -30,7 +30,7 @@ module.exports = Self => { path: `/:id/downloadFile`, verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.downloadFile = async function(ctx, id) { diff --git a/back/methods/docuware/download.js b/back/methods/docuware/download.js index 4aa40197f..a1776cde5 100644 --- a/back/methods/docuware/download.js +++ b/back/methods/docuware/download.js @@ -43,7 +43,7 @@ module.exports = Self => { path: `/:id/download`, verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.download = async function(id, fileCabinet, filter) { diff --git a/back/methods/image/download.js b/back/methods/image/download.js index 9ac06f30b..201e16164 100644 --- a/back/methods/image/download.js +++ b/back/methods/image/download.js @@ -48,7 +48,7 @@ module.exports = Self => { path: `/:collection/:size/:id/download`, verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.download = async function(ctx, collection, size, id) { diff --git a/modules/claim/back/methods/claim/claimPickupPdf.js b/modules/claim/back/methods/claim/claimPickupPdf.js index 390be33b9..4b66bd418 100644 --- a/modules/claim/back/methods/claim/claimPickupPdf.js +++ b/modules/claim/back/methods/claim/claimPickupPdf.js @@ -35,7 +35,7 @@ module.exports = Self => { path: '/:id/claim-pickup-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.claimPickupPdf = (ctx, id) => Self.printReport(ctx, id, 'claim-pickup-order'); diff --git a/modules/claim/back/methods/claim/downloadFile.js b/modules/claim/back/methods/claim/downloadFile.js index 7e49708f5..61784f39e 100644 --- a/modules/claim/back/methods/claim/downloadFile.js +++ b/modules/claim/back/methods/claim/downloadFile.js @@ -33,7 +33,7 @@ module.exports = Self => { path: `/:id/downloadFile`, verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.downloadFile = async function(ctx, id) { diff --git a/modules/client/back/methods/client/campaignMetricsPdf.js b/modules/client/back/methods/client/campaignMetricsPdf.js index 14ae8646d..20c35494e 100644 --- a/modules/client/back/methods/client/campaignMetricsPdf.js +++ b/modules/client/back/methods/client/campaignMetricsPdf.js @@ -46,7 +46,7 @@ module.exports = Self => { path: '/:id/campaign-metrics-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'campaign-metrics'); diff --git a/modules/entry/back/methods/entry/entryOrderPdf.js b/modules/entry/back/methods/entry/entryOrderPdf.js index 2f6489d3f..93c1b6bd9 100644 --- a/modules/entry/back/methods/entry/entryOrderPdf.js +++ b/modules/entry/back/methods/entry/entryOrderPdf.js @@ -34,7 +34,7 @@ module.exports = Self => { path: '/:id/entry-order-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.entryOrderPdf = (ctx, id) => Self.printReport(ctx, id, 'entry-order'); diff --git a/modules/invoiceOut/back/methods/invoiceOut/download.js b/modules/invoiceOut/back/methods/invoiceOut/download.js index 24fb9fde3..cb71121d5 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/download.js +++ b/modules/invoiceOut/back/methods/invoiceOut/download.js @@ -32,7 +32,7 @@ module.exports = Self => { path: '/:id/download', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.download = async function(ctx, id, options) { diff --git a/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js b/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js index 13305f6ed..4f2a8aab3 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js +++ b/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js @@ -32,7 +32,7 @@ module.exports = Self => { path: '/downloadZip', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.downloadZip = async function(ctx, ids, options) { diff --git a/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js b/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js index a2d877189..0b08aec6d 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js +++ b/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js @@ -35,7 +35,7 @@ module.exports = Self => { path: '/:reference/exportation-pdf', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.exportationPdf = (ctx, reference) => Self.printReport(ctx, reference, 'exportation'); diff --git a/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js b/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js index 6208d0625..6822e5a23 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js +++ b/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js @@ -38,7 +38,7 @@ module.exports = Self => { path: '/:reference/invoice-csv', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.invoiceCsv = async reference => { diff --git a/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js b/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js index 6970bf368..6ac56b68c 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js +++ b/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js @@ -40,7 +40,7 @@ module.exports = Self => { path: '/negativeBasesCsv', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.negativeBasesCsv = async(ctx, options) => { diff --git a/modules/item/back/methods/item-image-queue/download.js b/modules/item/back/methods/item-image-queue/download.js index 354771071..e1bc248ae 100644 --- a/modules/item/back/methods/item-image-queue/download.js +++ b/modules/item/back/methods/item-image-queue/download.js @@ -11,7 +11,7 @@ module.exports = Self => { path: `/download`, verb: 'POST', }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.download = async() => { diff --git a/modules/route/back/methods/route/cmr.js b/modules/route/back/methods/route/cmr.js index cd7ef57ce..08a8182e0 100644 --- a/modules/route/back/methods/route/cmr.js +++ b/modules/route/back/methods/route/cmr.js @@ -29,7 +29,8 @@ module.exports = Self => { http: { path: '/:id/cmr', verb: 'GET' - } + }, + accessScopes: ['read:multimedia'] }); Self.cmr = (ctx, id) => Self.printReport(ctx, id, 'cmr'); diff --git a/modules/route/back/methods/route/downloadCmrsZip.js b/modules/route/back/methods/route/downloadCmrsZip.js index 1ef25d175..43f6e9648 100644 --- a/modules/route/back/methods/route/downloadCmrsZip.js +++ b/modules/route/back/methods/route/downloadCmrsZip.js @@ -30,7 +30,7 @@ module.exports = Self => { path: '/downloadCmrsZip', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.downloadCmrsZip = async function(ctx, ids, options) { diff --git a/modules/route/back/methods/route/downloadZip.js b/modules/route/back/methods/route/downloadZip.js index b226cf7f8..d7fc30aa3 100644 --- a/modules/route/back/methods/route/downloadZip.js +++ b/modules/route/back/methods/route/downloadZip.js @@ -30,7 +30,7 @@ module.exports = Self => { path: '/downloadZip', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.downloadZip = async function(ctx, id, options) { diff --git a/modules/route/back/methods/route/driverRoutePdf.js b/modules/route/back/methods/route/driverRoutePdf.js index 9469356bb..e7b4dee17 100644 --- a/modules/route/back/methods/route/driverRoutePdf.js +++ b/modules/route/back/methods/route/driverRoutePdf.js @@ -35,7 +35,7 @@ module.exports = Self => { path: '/:id/driver-route-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); diff --git a/modules/supplier/back/methods/supplier/campaignMetricsPdf.js b/modules/supplier/back/methods/supplier/campaignMetricsPdf.js index 55767e9c6..51c626e69 100644 --- a/modules/supplier/back/methods/supplier/campaignMetricsPdf.js +++ b/modules/supplier/back/methods/supplier/campaignMetricsPdf.js @@ -45,7 +45,7 @@ module.exports = Self => { path: '/:id/campaign-metrics-pdf', verb: 'GET' }, - // accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'supplier-campaign-metrics'); diff --git a/modules/ticket/back/methods/ticket/deliveryNoteCsv.js b/modules/ticket/back/methods/ticket/deliveryNoteCsv.js index 29a859842..9fa3c183e 100644 --- a/modules/ticket/back/methods/ticket/deliveryNoteCsv.js +++ b/modules/ticket/back/methods/ticket/deliveryNoteCsv.js @@ -38,7 +38,7 @@ module.exports = Self => { path: '/:id/delivery-note-csv', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.deliveryNoteCsv = async id => { diff --git a/modules/ticket/back/methods/ticket/deliveryNotePdf.js b/modules/ticket/back/methods/ticket/deliveryNotePdf.js index 6155ff81e..adc9e4435 100644 --- a/modules/ticket/back/methods/ticket/deliveryNotePdf.js +++ b/modules/ticket/back/methods/ticket/deliveryNotePdf.js @@ -42,7 +42,7 @@ module.exports = Self => { path: '/:id/delivery-note-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.deliveryNotePdf = (ctx, id) => Self.printReport(ctx, id, 'delivery-note'); diff --git a/modules/travel/back/methods/travel/extraCommunityPdf.js b/modules/travel/back/methods/travel/extraCommunityPdf.js index 0c7f0a682..73748ac50 100644 --- a/modules/travel/back/methods/travel/extraCommunityPdf.js +++ b/modules/travel/back/methods/travel/extraCommunityPdf.js @@ -79,7 +79,7 @@ module.exports = Self => { path: '/extra-community-pdf', verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.extraCommunityPdf = ctx => Self.printReport(ctx, null, 'extra-community'); diff --git a/modules/worker/back/methods/worker-dms/downloadFile.js b/modules/worker/back/methods/worker-dms/downloadFile.js index 871bbffde..08fbcf924 100644 --- a/modules/worker/back/methods/worker-dms/downloadFile.js +++ b/modules/worker/back/methods/worker-dms/downloadFile.js @@ -30,7 +30,7 @@ module.exports = Self => { path: `/:id/downloadFile`, verb: 'GET' }, - //accessScopes: ['read:multimedia'] + accessScopes: ['read:multimedia'] }); Self.downloadFile = async function(ctx, id) { From d5cb52cb6459777cb5cedb0e44ce77b3bc747674 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Wed, 17 Apr 2024 10:03:01 +0200 Subject: [PATCH 135/161] feat(salix): refs #6930 Undo rollback salix-front --- front/core/services/auth.js | 3 +-- front/core/services/token.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/front/core/services/auth.js b/front/core/services/auth.js index d77966aca..753bc3fba 100644 --- a/front/core/services/auth.js +++ b/front/core/services/auth.js @@ -86,8 +86,7 @@ export default class Auth { return this.$http.get('VnUsers/ShareToken', { headers: {Authorization: json.data.token} }).then(({data}) => { - // 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.vnToken.set(json.data.token, data.multimediaToken.id, now, json.data.ttl, remember); this.loadAcls().then(() => { let continueHash = this.$state.params.continue; if (continueHash) diff --git a/front/core/services/token.js b/front/core/services/token.js index 028ebd841..125de6b9a 100644 --- a/front/core/services/token.js +++ b/front/core/services/token.js @@ -59,8 +59,7 @@ export default class Token { getStorage(storage) { this.token = storage.getItem('vnToken'); - // Cambio realizado temporalmente - this.tokenMultimedia = this.token; // storage.getItem('vnTokenMultimedia'); + this.tokenMultimedia = storage.getItem('vnTokenMultimedia'); if (!this.token) return; const created = storage.getItem('vnTokenCreated'); this.created = created && new Date(created); From cffc1964b64adcf8575aa5a567fec4477fbe8e75 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 17 Apr 2024 10:26:21 +0200 Subject: [PATCH 136/161] feat: refs #6968 Transactioned and isTriggerDisabled --- .../10997-crimsonCyca/00-groupingMode.sql | 16 ++++++++++++++++ db/versions/10997-crimsonCyca/00-part1.sql | 2 -- db/versions/10997-crimsonCyca/01-part2.sql | 7 ------- db/versions/10997-crimsonCyca/02-part3.sql | 2 -- 4 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 db/versions/10997-crimsonCyca/00-groupingMode.sql delete mode 100644 db/versions/10997-crimsonCyca/00-part1.sql delete mode 100644 db/versions/10997-crimsonCyca/01-part2.sql delete mode 100644 db/versions/10997-crimsonCyca/02-part3.sql diff --git a/db/versions/10997-crimsonCyca/00-groupingMode.sql b/db/versions/10997-crimsonCyca/00-groupingMode.sql new file mode 100644 index 000000000..dd4896cc1 --- /dev/null +++ b/db/versions/10997-crimsonCyca/00-groupingMode.sql @@ -0,0 +1,16 @@ +START TRANSACTION; + +SET @isTriggerDisabled = TRUE; + +ALTER TABLE vn.buy ADD groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL; +ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL AFTER groupingMode; + +UPDATE vn.buy SET groupingMode2 = 'packing' WHERE groupingMode = 2; +UPDATE vn.buy SET groupingMode2 = 'grouping' WHERE groupingMode = 1; + +ALTER TABLE vn.buy DROP COLUMN groupingMode; +ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode enum('grouping','packing') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL; + +SET @isTriggerDisabled = FALSE; + +COMMIT; \ No newline at end of file diff --git a/db/versions/10997-crimsonCyca/00-part1.sql b/db/versions/10997-crimsonCyca/00-part1.sql deleted file mode 100644 index 8811b81a7..000000000 --- a/db/versions/10997-crimsonCyca/00-part1.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE vn.buy ADD groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL; -ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode2 enum('grouping', 'packing') DEFAULT NULL NULL AFTER groupingMode; diff --git a/db/versions/10997-crimsonCyca/01-part2.sql b/db/versions/10997-crimsonCyca/01-part2.sql deleted file mode 100644 index 1f7a3c9f6..000000000 --- a/db/versions/10997-crimsonCyca/01-part2.sql +++ /dev/null @@ -1,7 +0,0 @@ -UPDATE vn.buy - SET groupingMode2 = 'packing' - WHERE groupingMode = 2; - -UPDATE vn.buy - SET groupingMode2 = 'grouping' - WHERE groupingMode = 1; diff --git a/db/versions/10997-crimsonCyca/02-part3.sql b/db/versions/10997-crimsonCyca/02-part3.sql deleted file mode 100644 index c63560957..000000000 --- a/db/versions/10997-crimsonCyca/02-part3.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE vn.buy DROP COLUMN groupingMode; -ALTER TABLE vn.buy CHANGE groupingMode2 groupingMode enum('grouping','packing') CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci DEFAULT NULL NULL; From 8ca278b5a9c64572234178a459b35d35d827fc42 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 17 Apr 2024 11:00:00 +0200 Subject: [PATCH 137/161] feat: refs #6500 cambios solicitados --- db/routines/vn/procedures/rateView.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/rateView.sql b/db/routines/vn/procedures/rateView.sql index 153e3584a..69e429c37 100644 --- a/db/routines/vn/procedures/rateView.sql +++ b/db/routines/vn/procedures/rateView.sql @@ -7,10 +7,10 @@ BEGIN SELECT t.year, t.month, - pagos.dollars, - pagos.changePractical, + pay.dollars, + pay.changePractical, CAST(SUM(iit.foreignValue ) / SUM(iit.taxableBase) AS DECIMAL(5,4)) cambioTeorico, - pagos.changeOfficial + pay.changeOfficial FROM invoiceIn ii JOIN time t ON t.dated = ii.issued JOIN invoiceInTax iit ON ii.id = iit.invoiceInFk @@ -28,7 +28,7 @@ BEGIN WHERE p.divisa AND c.code = 'USD' GROUP BY t.year, t.month - ) pagos ON t.year = pagos.year AND t.month = pagos.MONTH + ) pay ON t.year = pay.year AND t.month = pay.month JOIN currency c ON c.id = ii.currencyFk WHERE c.code = 'USD' AND iit.foreignValue From e769081a7469ebe9985dd89adceea693c2720fe5 Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 17 Apr 2024 13:11:28 +0200 Subject: [PATCH 138/161] feat: refs #6500 --- db/routines/vn/procedures/rateView.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/procedures/rateView.sql b/db/routines/vn/procedures/rateView.sql index 69e429c37..d840aa9d5 100644 --- a/db/routines/vn/procedures/rateView.sql +++ b/db/routines/vn/procedures/rateView.sql @@ -5,12 +5,12 @@ BEGIN * Muestra información sobre tasas de cambio de Dolares */ SELECT - t.year, - t.month, - pay.dollars, - pay.changePractical, - CAST(SUM(iit.foreignValue ) / SUM(iit.taxableBase) AS DECIMAL(5,4)) cambioTeorico, - pay.changeOfficial + t.year año, + t.month mes, + pay.dollars dolares, + pay.changePractical cambioPractico, + CAST(SUM(iit.foreignValue ) / SUM(iit.taxableBase) AS DECIMAL(5,4))cambioTeorico, + pay.changeOfficial cambioOficial FROM invoiceIn ii JOIN time t ON t.dated = ii.issued JOIN invoiceInTax iit ON ii.id = iit.invoiceInFk From ae326e6e2edaa7f6db264266e69b9878173e6c03 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Wed, 17 Apr 2024 13:21:27 +0200 Subject: [PATCH 139/161] feat(binlog): refs #4409 Old recalc code removed Queues: orderTotal, ticketTotal and travelEntries --- db/dump/fixtures.before.sql | 28 +++++++--- db/routines/hedera/events/order_doRecalc.sql | 8 --- .../hedera/procedures/order_doRecalc.sql | 53 ------------------- .../hedera/procedures/order_requestRecalc.sql | 16 ------ .../hedera/triggers/orderRow_afterDelete.sql | 8 --- .../hedera/triggers/orderRow_afterInsert.sql | 8 --- .../hedera/triggers/orderRow_afterUpdate.sql | 9 ---- .../hedera/triggers/order_afterUpdate.sql | 6 --- db/routines/vn/events/ticket_doRecalc.sql | 8 --- db/routines/vn/events/travel_doRecalc.sql | 8 --- db/routines/vn/procedures/ticket_doRecalc.sql | 53 ------------------- .../vn/procedures/ticket_recalcByScope.sql | 40 ++++++++++++++ .../vn/procedures/ticket_requestRecalc.sql | 16 ------ db/routines/vn/procedures/travel_doRecalc.sql | 34 ------------ db/routines/vn/procedures/travel_recalc.sql | 17 ++++++ .../vn/procedures/travel_requestRecalc.sql | 15 ------ .../vn/triggers/address_afterUpdate.sql | 26 ++++----- .../vn/triggers/client_afterUpdate.sql | 15 ++---- db/routines/vn/triggers/entry_afterDelete.sql | 2 - db/routines/vn/triggers/entry_afterInsert.sql | 8 --- db/routines/vn/triggers/entry_afterUpdate.sql | 5 -- db/routines/vn/triggers/sale_afterDelete.sql | 2 - db/routines/vn/triggers/sale_afterInsert.sql | 3 -- db/routines/vn/triggers/sale_afterUpdate.sql | 9 ---- .../vn/triggers/ticketService_afterDelete.sql | 3 -- .../vn/triggers/ticketService_afterInsert.sql | 10 ---- .../vn/triggers/ticketService_afterUpdate.sql | 13 ----- .../vn/triggers/ticket_afterUpdate.sql | 7 --- .../10996-pinkPhormium/00-dropOrderRecalc.sql | 1 + .../01-dropTicketRecalc.sql | 1 + .../02-dropTravelRecalc.sql | 1 + 31 files changed, 97 insertions(+), 336 deletions(-) delete mode 100644 db/routines/hedera/events/order_doRecalc.sql delete mode 100644 db/routines/hedera/procedures/order_doRecalc.sql delete mode 100644 db/routines/hedera/procedures/order_requestRecalc.sql delete mode 100644 db/routines/hedera/triggers/orderRow_afterDelete.sql delete mode 100644 db/routines/hedera/triggers/orderRow_afterInsert.sql delete mode 100644 db/routines/hedera/triggers/orderRow_afterUpdate.sql delete mode 100644 db/routines/vn/events/ticket_doRecalc.sql delete mode 100644 db/routines/vn/events/travel_doRecalc.sql delete mode 100644 db/routines/vn/procedures/ticket_doRecalc.sql create mode 100644 db/routines/vn/procedures/ticket_recalcByScope.sql delete mode 100644 db/routines/vn/procedures/ticket_requestRecalc.sql delete mode 100644 db/routines/vn/procedures/travel_doRecalc.sql create mode 100644 db/routines/vn/procedures/travel_recalc.sql delete mode 100644 db/routines/vn/procedures/travel_requestRecalc.sql delete mode 100644 db/routines/vn/triggers/entry_afterInsert.sql delete mode 100644 db/routines/vn/triggers/ticketService_afterInsert.sql delete mode 100644 db/routines/vn/triggers/ticketService_afterUpdate.sql create mode 100644 db/versions/10996-pinkPhormium/00-dropOrderRecalc.sql create mode 100644 db/versions/10996-pinkPhormium/01-dropTicketRecalc.sql create mode 100644 db/versions/10996-pinkPhormium/02-dropTravelRecalc.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index c9832545f..9b14cf1fd 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2614,13 +2614,29 @@ INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amo (2, 13.20, 5080000, 15.00, 580, 5), (2, 16.10, 6021010, 25.00, 80, 5); -INSERT INTO `vn`.`ticketRecalc`(`ticketFk`) - SELECT t.id - FROM vn.ticket t - LEFT JOIN vn.ticketRecalc tr ON tr.ticketFk = t.id - WHERE tr.ticketFk IS NULL; +DELIMITER $$ +CREATE PROCEDURE `tmp`.`ticket_recalc`() +BEGIN + DECLARE vDone BOOL; + DECLARE vTicketFk INT; -CALL `vn`.`ticket_doRecalc`(); + DECLARE cCur CURSOR FOR SELECT id FROM vn.ticket; + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + OPEN cCur; + myLoop: LOOP + SET vDone = FALSE; + FETCH cCur INTO vTicketFk; + IF vDone THEN LEAVE myLoop; END IF; + CALL vn.ticket_recalc(vTicketFk, NULL); + END LOOP; + CLOSE cCur; +END$$ +DELIMITER ; + +CALL tmp.ticket_recalc; +DROP PROCEDURE tmp.ticket_recalc; UPDATE `vn`.`ticket` SET refFk = 'T1111111' diff --git a/db/routines/hedera/events/order_doRecalc.sql b/db/routines/hedera/events/order_doRecalc.sql deleted file mode 100644 index d355e1a55..000000000 --- a/db/routines/hedera/events/order_doRecalc.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `hedera`.`order_doRecalc` - ON SCHEDULE EVERY 10 SECOND - STARTS '2019-08-29 14:18:04.000' - ON COMPLETION PRESERVE - ENABLE -DO CALL order_doRecalc$$ -DELIMITER ; diff --git a/db/routines/hedera/procedures/order_doRecalc.sql b/db/routines/hedera/procedures/order_doRecalc.sql deleted file mode 100644 index 4c0ee0499..000000000 --- a/db/routines/hedera/procedures/order_doRecalc.sql +++ /dev/null @@ -1,53 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_doRecalc`() -proc: BEGIN -/** - * Recalculates modified orders. - */ - DECLARE vDone BOOL; - DECLARE vOrderFk INT; - - DECLARE cCur CURSOR FOR - SELECT DISTINCT orderFk FROM tOrder; - - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; - - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION - BEGIN - DO RELEASE_LOCK('hedera.order_doRecalc'); - ROLLBACK; - RESIGNAL; - END; - - IF !GET_LOCK('hedera.order_doRecalc', 0) THEN - LEAVE proc; - END IF; - - DROP TEMPORARY TABLE IF EXISTS tOrder; - CREATE TEMPORARY TABLE tOrder - ENGINE = MEMORY - SELECT id, orderFk FROM orderRecalc; - - OPEN cCur; - - myLoop: LOOP - SET vDone = FALSE; - FETCH cCur INTO vOrderFk; - - IF vDone THEN - LEAVE myLoop; - END IF; - - CALL order_recalc(vOrderFk); - END LOOP; - - CLOSE cCur; - - DELETE o FROM orderRecalc o JOIN tOrder t ON t.id = o.id; - - DROP TEMPORARY TABLE tOrder; - - DO RELEASE_LOCK('hedera.order_doRecalc'); -END$$ -DELIMITER ; diff --git a/db/routines/hedera/procedures/order_requestRecalc.sql b/db/routines/hedera/procedures/order_requestRecalc.sql deleted file mode 100644 index aae4a0179..000000000 --- a/db/routines/hedera/procedures/order_requestRecalc.sql +++ /dev/null @@ -1,16 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_requestRecalc`(vSelf INT) -proc: BEGIN -/** - * Adds a request to recalculate the order total. - * - * @param vSelf The order identifier - */ - IF vSelf IS NULL THEN - LEAVE proc; - END IF; - - -- #4409 Deprecated by MyCDC - -- INSERT INTO orderRecalc SET orderFk = vSelf; -END$$ -DELIMITER ; diff --git a/db/routines/hedera/triggers/orderRow_afterDelete.sql b/db/routines/hedera/triggers/orderRow_afterDelete.sql deleted file mode 100644 index e22f786c1..000000000 --- a/db/routines/hedera/triggers/orderRow_afterDelete.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterDelete` - AFTER DELETE ON `orderRow` - FOR EACH ROW -BEGIN - CALL order_requestRecalc(OLD.orderFk); -END$$ -DELIMITER ; diff --git a/db/routines/hedera/triggers/orderRow_afterInsert.sql b/db/routines/hedera/triggers/orderRow_afterInsert.sql deleted file mode 100644 index c95e0bbdc..000000000 --- a/db/routines/hedera/triggers/orderRow_afterInsert.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterInsert` - AFTER INSERT ON `orderRow` - FOR EACH ROW -BEGIN - CALL order_requestRecalc(NEW.orderFk); -END$$ -DELIMITER ; diff --git a/db/routines/hedera/triggers/orderRow_afterUpdate.sql b/db/routines/hedera/triggers/orderRow_afterUpdate.sql deleted file mode 100644 index bce81a8e4..000000000 --- a/db/routines/hedera/triggers/orderRow_afterUpdate.sql +++ /dev/null @@ -1,9 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`orderRow_afterUpdate` - AFTER UPDATE ON `orderRow` - FOR EACH ROW -BEGIN - CALL order_requestRecalc(OLD.orderFk); - CALL order_requestRecalc(NEW.orderFk); -END$$ -DELIMITER ; diff --git a/db/routines/hedera/triggers/order_afterUpdate.sql b/db/routines/hedera/triggers/order_afterUpdate.sql index da82d242c..25f51b3f0 100644 --- a/db/routines/hedera/triggers/order_afterUpdate.sql +++ b/db/routines/hedera/triggers/order_afterUpdate.sql @@ -3,12 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `hedera`.`order_afterUpdate AFTER UPDATE ON `order` FOR EACH ROW BEGIN - IF !(OLD.address_id <=> NEW.address_id) - OR !(OLD.company_id <=> NEW.company_id) - OR !(OLD.customer_id <=> NEW.customer_id) THEN - CALL order_requestRecalc(NEW.id); - END IF; - IF !(OLD.address_id <=> NEW.address_id) AND NEW.address_id = 2850 THEN -- Fallo que se actualiza no se sabe como tickets en este cliente CALL vn.mail_insert( diff --git a/db/routines/vn/events/ticket_doRecalc.sql b/db/routines/vn/events/ticket_doRecalc.sql deleted file mode 100644 index 9209c5715..000000000 --- a/db/routines/vn/events/ticket_doRecalc.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`ticket_doRecalc` - ON SCHEDULE EVERY 10 SECOND - STARTS '2022-01-28 09:29:18.000' - ON COMPLETION PRESERVE - ENABLE -DO CALL ticket_doRecalc$$ -DELIMITER ; diff --git a/db/routines/vn/events/travel_doRecalc.sql b/db/routines/vn/events/travel_doRecalc.sql deleted file mode 100644 index a08ecc068..000000000 --- a/db/routines/vn/events/travel_doRecalc.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `vn`.`travel_doRecalc` - ON SCHEDULE EVERY 15 SECOND - STARTS '2019-05-17 10:52:29.000' - ON COMPLETION PRESERVE - ENABLE -DO CALL travel_doRecalc$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_doRecalc.sql b/db/routines/vn/procedures/ticket_doRecalc.sql deleted file mode 100644 index 1dd2a05cb..000000000 --- a/db/routines/vn/procedures/ticket_doRecalc.sql +++ /dev/null @@ -1,53 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_doRecalc`() -proc: BEGIN -/** - * Recalculates modified ticket. - */ - DECLARE vDone BOOL; - DECLARE vTicketFk INT; - - DECLARE cCur CURSOR FOR - SELECT DISTINCT ticketFk FROM tTicket; - - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; - - DECLARE CONTINUE HANDLER FOR SQLEXCEPTION - BEGIN - DO RELEASE_LOCK('vn.ticket_doRecalc'); - ROLLBACK; - RESIGNAL; - END; - - IF !GET_LOCK('vn.ticket_doRecalc', 0) THEN - LEAVE proc; - END IF; - - DROP TEMPORARY TABLE IF EXISTS tTicket; - CREATE TEMPORARY TABLE tTicket - ENGINE = MEMORY - SELECT id, ticketFk FROM ticketRecalc; - - OPEN cCur; - - myLoop: LOOP - SET vDone = FALSE; - FETCH cCur INTO vTicketFk; - - IF vDone THEN - LEAVE myLoop; - END IF; - - CALL ticket_recalc(vTicketFk, NULL); - END LOOP; - - CLOSE cCur; - - DELETE tr FROM ticketRecalc tr JOIN tTicket t ON tr.id = t.id; - - DROP TEMPORARY TABLE tTicket; - - DO RELEASE_LOCK('vn.ticket_doRecalc'); -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_recalcByScope.sql b/db/routines/vn/procedures/ticket_recalcByScope.sql new file mode 100644 index 000000000..e20244648 --- /dev/null +++ b/db/routines/vn/procedures/ticket_recalcByScope.sql @@ -0,0 +1,40 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_recalcByScope`( + vScope VARCHAR(255), + vId INT +) +BEGIN +/** + * Recalculates tickets in an scope. + * + * @param vScope The scope name + * @param vId The scope id + */ + DECLARE vDone BOOL; + DECLARE vTicketFk INT; + + DECLARE cCur CURSOR FOR + SELECT id FROM ticket + WHERE refFk IS NULL + AND ((vScope = 'client' AND clientFk = vId) + OR (vScope = 'address' AND addressFk = vId)); + + DECLARE CONTINUE HANDLER FOR NOT FOUND + SET vDone = TRUE; + + OPEN cCur; + + myLoop: LOOP + SET vDone = FALSE; + FETCH cCur INTO vTicketFk; + + IF vDone THEN + LEAVE myLoop; + END IF; + + CALL ticket_recalc(vTicketFk, NULL); + END LOOP; + + CLOSE cCur; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/ticket_requestRecalc.sql b/db/routines/vn/procedures/ticket_requestRecalc.sql deleted file mode 100644 index 7f1ff3be8..000000000 --- a/db/routines/vn/procedures/ticket_requestRecalc.sql +++ /dev/null @@ -1,16 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_requestRecalc`(vSelf INT) -proc: BEGIN -/** - * Adds a request to recalculate the ticket total. - * - * @param vSelf The ticket identifier - */ - IF vSelf IS NULL THEN - LEAVE proc; - END IF; - - -- #4409 Deprecated by MyCDC - -- INSERT INTO ticketRecalc SET ticketFk = vSelf; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/travel_doRecalc.sql b/db/routines/vn/procedures/travel_doRecalc.sql deleted file mode 100644 index 5d877174c..000000000 --- a/db/routines/vn/procedures/travel_doRecalc.sql +++ /dev/null @@ -1,34 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_doRecalc`() -proc: BEGIN -/** -* Recounts the number of entries of changed travels. -*/ - DECLARE vTravelFk INT; - - DECLARE EXIT HANDLER FOR SQLEXCEPTION - BEGIN - DO RELEASE_LOCK('vn.ticket_doRecalc'); - END; - - IF !GET_LOCK('vn.travel_doRecalc', 0) THEN - LEAVE proc; - END IF; - - CREATE OR REPLACE TEMPORARY TABLE tTravel - ENGINE = MEMORY - SELECT travelFk FROM travelRecalc; - - UPDATE travel t - JOIN tTravel tt ON tt.travelFk = t.id - SET t.totalEntries = ( - SELECT COUNT(e.id) - FROM entry e - WHERE e.travelFk = t.id - ); - - DELETE tr FROM travelRecalc tr JOIN tTravel t ON tr.travelFk = t.travelFk; - DROP TEMPORARY TABLE tTravel; - DO RELEASE_LOCK('vn.travel_doRecalc'); -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/travel_recalc.sql b/db/routines/vn/procedures/travel_recalc.sql new file mode 100644 index 000000000..46d1cdc4f --- /dev/null +++ b/db/routines/vn/procedures/travel_recalc.sql @@ -0,0 +1,17 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_recalc`(vSelf INT) +proc: BEGIN +/** + * Updates the number of entries assigned to the travel. + * + * @param vSelf The travel id + */ + UPDATE travel + SET totalEntries = ( + SELECT COUNT(id) + FROM entry + WHERE travelFk = vSelf + ) + WHERE id = vSelf; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/travel_requestRecalc.sql b/db/routines/vn/procedures/travel_requestRecalc.sql deleted file mode 100644 index 5797f2397..000000000 --- a/db/routines/vn/procedures/travel_requestRecalc.sql +++ /dev/null @@ -1,15 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_requestRecalc`(vSelf INT) -proc: BEGIN -/** - * Adds a request to recount the number of entries for the travel. - * - * @param vSelf The travel reference - */ - IF vSelf IS NULL THEN - LEAVE proc; - END IF; - - INSERT IGNORE INTO travelRecalc SET travelFk = vSelf; -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/address_afterUpdate.sql b/db/routines/vn/triggers/address_afterUpdate.sql index 6160aa2a5..ab5e03882 100644 --- a/db/routines/vn/triggers/address_afterUpdate.sql +++ b/db/routines/vn/triggers/address_afterUpdate.sql @@ -5,36 +5,32 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`address_afterUpdate` BEGIN -- Recargos de equivalencia distintos implican facturacion por consignatario IF NEW.isEqualizated != OLD.isEqualizated THEN - IF + IF (SELECT COUNT(*) FROM ( SELECT DISTINCT (isEqualizated = FALSE) as Equ - FROM address + FROM address WHERE clientFk = NEW.clientFk ) t1 ) > 1 - THEN - UPDATE client + THEN + UPDATE client SET hasToInvoiceByAddress = TRUE WHERE id = NEW.clientFk; END IF; END IF; + IF NEW.isDefaultAddress AND NEW.isActive = FALSE THEN CALL util.throw ('Cannot desactivate the default address'); END IF; - IF NOT (NEW.isEqualizated <=> OLD.isEqualizated) THEN - INSERT IGNORE INTO ticketRecalc (ticketFk) - SELECT id FROM ticket t - WHERE t.addressFk = NEW.id - AND t.refFk IS NULL; - END IF; - - IF (NEW.clientFk <> OLD.clientFk OR NEW.isActive <> OLD.isActive OR NOT (NEW.provinceFk <=> OLD.provinceFk)) - AND (SELECT client_hasDifferentCountries(NEW.clientFk)) THEN - UPDATE client + IF (NEW.clientFk <> OLD.clientFk + OR NEW.isActive <> OLD.isActive + OR NOT (NEW.provinceFk <=> OLD.provinceFk)) + AND (SELECT client_hasDifferentCountries(NEW.clientFk)) THEN + UPDATE client SET hasToInvoiceByAddress = TRUE WHERE id = NEW.clientFk; - END IF; + END IF; END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/client_afterUpdate.sql b/db/routines/vn/triggers/client_afterUpdate.sql index 481b00007..8bca36d63 100644 --- a/db/routines/vn/triggers/client_afterUpdate.sql +++ b/db/routines/vn/triggers/client_afterUpdate.sql @@ -4,20 +4,13 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`client_afterUpdate` FOR EACH ROW BEGIN IF !(NEW.defaultAddressFk <=> OLD.defaultAddressFk) THEN - UPDATE `address` SET isDefaultAddress = 0 + UPDATE `address` SET isDefaultAddress = FALSE WHERE clientFk = NEW.id; - - UPDATE `address` SET isDefaultAddress = 1 - WHERE id = NEW.defaultAddressFk; + + UPDATE `address` SET isDefaultAddress = TRUE + WHERE id = NEW.defaultAddressFk; END IF; - IF NOT (NEW.provinceFk <=> OLD.provinceFk) OR NOT (NEW.isVies <=> OLD.isVies) THEN - INSERT IGNORE INTO ticketRecalc (ticketFk) - SELECT id FROM ticket t - WHERE t.clientFk = NEW.id - AND t.refFk IS NULL; - END IF; - IF NOT NEW.isActive THEN UPDATE account.`user` SET active = FALSE diff --git a/db/routines/vn/triggers/entry_afterDelete.sql b/db/routines/vn/triggers/entry_afterDelete.sql index 5c246651d..c723930fa 100644 --- a/db/routines/vn/triggers/entry_afterDelete.sql +++ b/db/routines/vn/triggers/entry_afterDelete.sql @@ -8,7 +8,5 @@ BEGIN `changedModel` = 'Entry', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - - CALL travel_requestRecalc(OLD.travelFk); END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/entry_afterInsert.sql b/db/routines/vn/triggers/entry_afterInsert.sql deleted file mode 100644 index 79563c17f..000000000 --- a/db/routines/vn/triggers/entry_afterInsert.sql +++ /dev/null @@ -1,8 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_afterInsert` - AFTER INSERT ON `entry` - FOR EACH ROW -BEGIN - CALL travel_requestRecalc(NEW.travelFk); -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/entry_afterUpdate.sql b/db/routines/vn/triggers/entry_afterUpdate.sql index c2d205768..47d61ed30 100644 --- a/db/routines/vn/triggers/entry_afterUpdate.sql +++ b/db/routines/vn/triggers/entry_afterUpdate.sql @@ -3,11 +3,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`entry_afterUpdate` AFTER UPDATE ON `entry` FOR EACH ROW BEGIN - IF NOT (NEW.travelFk <=> OLD.travelFk) THEN - CALL travel_requestRecalc(OLD.travelFk); - CALL travel_requestRecalc(NEW.travelFk); - END IF; - IF NOT (NEW.travelFk <=> OLD.travelFk) THEN CREATE OR REPLACE TEMPORARY TABLE tmp.buysToCheck SELECT b.id diff --git a/db/routines/vn/triggers/sale_afterDelete.sql b/db/routines/vn/triggers/sale_afterDelete.sql index da74c05ec..6365208b2 100644 --- a/db/routines/vn/triggers/sale_afterDelete.sql +++ b/db/routines/vn/triggers/sale_afterDelete.sql @@ -12,8 +12,6 @@ BEGIN `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - CALL ticket_requestRecalc(OLD.ticketFk); - SELECT account.myUser_getName() INTO vUserRole; SELECT account.user_getMysqlRole(vUserRole) INTO vUserRole; diff --git a/db/routines/vn/triggers/sale_afterInsert.sql b/db/routines/vn/triggers/sale_afterInsert.sql index 3ce5ce8d9..b5b28257f 100644 --- a/db/routines/vn/triggers/sale_afterInsert.sql +++ b/db/routines/vn/triggers/sale_afterInsert.sql @@ -7,10 +7,7 @@ BEGIN CALL util.throw('Cannot insert a service item into a ticket'); END IF; - CALL ticket_requestRecalc(NEW.ticketFk); - IF NEW.quantity > 0 THEN - UPDATE vn.collection c JOIN vn.ticketCollection tc ON tc.collectionFk = c.id AND tc.ticketFk = NEW.ticketFk diff --git a/db/routines/vn/triggers/sale_afterUpdate.sql b/db/routines/vn/triggers/sale_afterUpdate.sql index 8500afbe3..3f59c9188 100644 --- a/db/routines/vn/triggers/sale_afterUpdate.sql +++ b/db/routines/vn/triggers/sale_afterUpdate.sql @@ -6,15 +6,6 @@ BEGIN DECLARE vIsToSendMail BOOL; DECLARE vUserRole VARCHAR(255); - IF !(NEW.price <=> OLD.price) - OR !(NEW.ticketFk <=> OLD.ticketFk) - OR !(NEW.itemFk <=> OLD.itemFk) - OR !(NEW.quantity <=> OLD.quantity) - OR !(NEW.discount <=> OLD.discount) THEN - CALL ticket_requestRecalc(NEW.ticketFk); - CALL ticket_requestRecalc(OLD.ticketFk); - END IF; - IF !(OLD.ticketFk <=> NEW.ticketFk) THEN UPDATE ticketRequest SET ticketFk = NEW.ticketFk WHERE saleFk = NEW.id; diff --git a/db/routines/vn/triggers/ticketService_afterDelete.sql b/db/routines/vn/triggers/ticketService_afterDelete.sql index 11d5aaf24..ca2675ce8 100644 --- a/db/routines/vn/triggers/ticketService_afterDelete.sql +++ b/db/routines/vn/triggers/ticketService_afterDelete.sql @@ -8,8 +8,5 @@ BEGIN `changedModel` = 'TicketService', `changedModelId` = OLD.id, `userFk` = account.myUser_getId(); - - CALL ticket_requestRecalc(OLD.ticketFk); - END$$ DELIMITER ; diff --git a/db/routines/vn/triggers/ticketService_afterInsert.sql b/db/routines/vn/triggers/ticketService_afterInsert.sql deleted file mode 100644 index b9142ff72..000000000 --- a/db/routines/vn/triggers/ticketService_afterInsert.sql +++ /dev/null @@ -1,10 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketService_afterInsert` - AFTER INSERT ON `ticketService` - FOR EACH ROW -BEGIN - - CALL ticket_requestRecalc(NEW.ticketFk); - -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/ticketService_afterUpdate.sql b/db/routines/vn/triggers/ticketService_afterUpdate.sql deleted file mode 100644 index ecc9e9a5a..000000000 --- a/db/routines/vn/triggers/ticketService_afterUpdate.sql +++ /dev/null @@ -1,13 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticketService_afterUpdate` - AFTER UPDATE ON `ticketService` - FOR EACH ROW -BEGIN - IF !(NEW.price <=> OLD.price) - OR !(NEW.ticketFk <=> OLD.ticketFk) - OR !(NEW.quantity <=> OLD.quantity) THEN - CALL ticket_requestRecalc(NEW.ticketFk); - CALL ticket_requestRecalc(OLD.ticketFk); - END IF; -END$$ -DELIMITER ; diff --git a/db/routines/vn/triggers/ticket_afterUpdate.sql b/db/routines/vn/triggers/ticket_afterUpdate.sql index fd4b01571..f1ad394ef 100644 --- a/db/routines/vn/triggers/ticket_afterUpdate.sql +++ b/db/routines/vn/triggers/ticket_afterUpdate.sql @@ -3,17 +3,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`ticket_afterUpdate` AFTER UPDATE ON `ticket` FOR EACH ROW BEGIN - IF !(NEW.clientFk <=> OLD.clientFk) - OR !(NEW.addressFk <=> OLD.addressFk) - OR !(NEW.companyFk <=> OLD.companyFk) THEN - CALL ticket_requestRecalc(NEW.id); - END IF; - IF NEW.routeFk <> OLD.routeFk THEN UPDATE expedition SET hasNewRoute = TRUE WHERE ticketFk = NEW.id; END IF; - END$$ DELIMITER ; diff --git a/db/versions/10996-pinkPhormium/00-dropOrderRecalc.sql b/db/versions/10996-pinkPhormium/00-dropOrderRecalc.sql new file mode 100644 index 000000000..13216936b --- /dev/null +++ b/db/versions/10996-pinkPhormium/00-dropOrderRecalc.sql @@ -0,0 +1 @@ +DROP TABLE hedera.orderRecalc; diff --git a/db/versions/10996-pinkPhormium/01-dropTicketRecalc.sql b/db/versions/10996-pinkPhormium/01-dropTicketRecalc.sql new file mode 100644 index 000000000..e7c765e91 --- /dev/null +++ b/db/versions/10996-pinkPhormium/01-dropTicketRecalc.sql @@ -0,0 +1 @@ +DROP TABLE vn.ticketRecalc; diff --git a/db/versions/10996-pinkPhormium/02-dropTravelRecalc.sql b/db/versions/10996-pinkPhormium/02-dropTravelRecalc.sql new file mode 100644 index 000000000..49b26f83f --- /dev/null +++ b/db/versions/10996-pinkPhormium/02-dropTravelRecalc.sql @@ -0,0 +1 @@ +DROP TABLE vn.travelRecalc; From 32e2827287161a494541f6ff97a8f267c1fe6ba8 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 17 Apr 2024 13:55:07 +0200 Subject: [PATCH 140/161] refs #6921 feat: addFromDelivery --- db/dump/fixtures.before.sql | 3 +- ...-firstScript.sql => 00-firstScript.vn.sql} | 2 +- .../methods/ticket-observation/addDropOff.js | 54 +++++++++++++++++++ .../specs/addDropOff.spec.js | 37 +++++++++++++ .../ticket/back/models/ticket-observation.js | 1 + 5 files changed, 95 insertions(+), 2 deletions(-) rename db/versions/10987-tealMonstera/{00-firstScript.sql => 00-firstScript.vn.sql} (87%) create mode 100644 modules/ticket/back/methods/ticket-observation/addDropOff.js create mode 100644 modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 8660d61c9..30564d8a2 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -527,7 +527,8 @@ INSERT INTO `vn`.`observationType`(`id`,`description`, `code`) (4, 'SalesPerson', 'salesPerson'), (5, 'Administrative', 'administrative'), (6, 'Weight', 'weight'), - (7, 'InvoiceOut', 'invoiceOut'); + (7, 'InvoiceOut', 'invoiceOut'), + (8, 'DropOff', 'dropOff'); INSERT INTO `vn`.`addressObservation`(`id`,`addressFk`,`observationTypeFk`,`description`) VALUES diff --git a/db/versions/10987-tealMonstera/00-firstScript.sql b/db/versions/10987-tealMonstera/00-firstScript.vn.sql similarity index 87% rename from db/versions/10987-tealMonstera/00-firstScript.sql rename to db/versions/10987-tealMonstera/00-firstScript.vn.sql index e78d54fd4..d24ddd5de 100644 --- a/db/versions/10987-tealMonstera/00-firstScript.sql +++ b/db/versions/10987-tealMonstera/00-firstScript.vn.sql @@ -1,4 +1,4 @@ -- Place your SQL code here USE vn; -INSERT INTO vn.observationType (description,code) VALUES ('Entrega','dropOff') \ No newline at end of file +INSERT INTO vn.observationType (description,code) VALUES ('Entrega','dropOff'); \ No newline at end of file diff --git a/modules/ticket/back/methods/ticket-observation/addDropOff.js b/modules/ticket/back/methods/ticket-observation/addDropOff.js new file mode 100644 index 000000000..52a12a58e --- /dev/null +++ b/modules/ticket/back/methods/ticket-observation/addDropOff.js @@ -0,0 +1,54 @@ + +module.exports = Self => { + Self.remoteMethod('addDropOff', { + description: 'Add a dropOff note in a ticket', + accessType: 'WRITE', + accepts: [{ + arg: 'ticketFk', + type: 'number', + required: true, + description: 'ticket ID' + }, { + arg: 'note', + type: 'string', + required: true, + description: 'note text' + }], + + http: { + path: `/addDropOff`, + verb: 'post' + } + }); + + Self.addDropOff = async(ticketFk, note, options) => { + const models = Self.app.models; + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + try { + const observationTypeDropOff = await models.ObservationType.findOne({ + where: {code: 'dropOff'} + }, myOptions); + + await models.TicketObservation.create({ + ticketFk: ticketFk, + observationTypeFk: observationTypeDropOff.id, + description: note + + }, myOptions); + + if (tx) await tx.commit(); + } catch (error) { + if (tx) await tx.rollback(); + throw error; + } + }; +}; diff --git a/modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js b/modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js new file mode 100644 index 000000000..1034dbe67 --- /dev/null +++ b/modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js @@ -0,0 +1,37 @@ +const {models} = require('vn-loopback/server/server'); + +describe('ticketObservation addDropOff()', () => { + const ticketFk = 5; + const note = 'DropOff note'; + const code = 'dropOff'; + + it('should return a dropOff note', async() => { + const myOptions = {}; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + if (!myOptions.transaction) { + tx = await models.TicketObservation.beginTransaction({}); + myOptions.transaction = tx; + } + try { + await models.TicketObservation.addDropOff( + ticketFk, note, myOptions); + + const observationTypeDropOff = await models.TicketObservation.find({ + where: { + ticketFk, + code + } + }, myOptions); + + expect(observationTypeDropOff.length).toEqual(1); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/ticket/back/models/ticket-observation.js b/modules/ticket/back/models/ticket-observation.js index 77d15d85c..3076484bf 100644 --- a/modules/ticket/back/models/ticket-observation.js +++ b/modules/ticket/back/models/ticket-observation.js @@ -1,6 +1,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { + require('../methods/ticket-observation/addDropOff')(Self); Self.rewriteDbError(function(err) { if (err.code === 'ER_DUP_ENTRY') return new UserError(`The observation type can't be repeated`); From 3f291da02ce8a52654f2707b9f5a08db29265148 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 17 Apr 2024 13:57:56 +0200 Subject: [PATCH 141/161] refs #6921 feat: addFromDelivery --- .../vn/procedures/addNoteFromDelivery.sql | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/db/routines/vn/procedures/addNoteFromDelivery.sql b/db/routines/vn/procedures/addNoteFromDelivery.sql index 7431d4f49..61295b7db 100644 --- a/db/routines/vn/procedures/addNoteFromDelivery.sql +++ b/db/routines/vn/procedures/addNoteFromDelivery.sql @@ -1,20 +1,13 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`addNoteFromDelivery`(vTicketFk INT, vDescription TEXT, vCode VARCHAR(45)) +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`addNoteFromDelivery`(idTicket INT,nota TEXT) BEGIN + + DECLARE observationTypeFk INT DEFAULT 3; /*3 = REPARTIDOR*/ - /** - * Inserta observaciones para los tickets - * - * @param vTicketFk Identificador del ticket - * @param vDescription Texto de la nota a insertar - * @param vCode Identificador del tipo de nota - */ + INSERT INTO ticketObservation(ticketFk,observationTypeFk,description) + VALUES (idTicket,observationTypeFk,nota) + ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description,VALUES(description),' '); - INSERT INTO ticketObservation(ticketFk, observationTypeFk, description) - SELECT vTicketFk, id, vDescription - FROM vn.observationType - WHERE code = vCode - ON DUPLICATE KEY UPDATE description = CONCAT(ticketObservation.description, VALUES(description),' '); END$$ DELIMITER ; From d42aab346fa5021917f86ff4c72f66b256f7a744 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 18 Apr 2024 08:17:43 +0200 Subject: [PATCH 142/161] refactor: refs #7139 replace warehouse with ticket --- modules/route/front/summary/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/route/front/summary/index.html b/modules/route/front/summary/index.html index 56f7a49b9..8269bf118 100644 --- a/modules/route/front/summary/index.html +++ b/modules/route/front/summary/index.html @@ -81,7 +81,7 @@ City PC Client - Warehouse + State Packages Packaging @@ -109,7 +109,7 @@ {{ticket.nickname}} - {{ticket.warehouseName}} + {{ticket.ticketStateName}} {{ticket.packages}} {{ticket.volume}} {{ticket.ipt}} From e909d647579befa0b0361311f4f5e8c0d4e6b8ad Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 18 Apr 2024 10:01:22 +0200 Subject: [PATCH 143/161] refs #6921 feat: addFromDelivery --- .../methods/ticket-observation/addDropOff.js | 28 ++++++------------- .../specs/addDropOff.spec.js | 14 +++------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/modules/ticket/back/methods/ticket-observation/addDropOff.js b/modules/ticket/back/methods/ticket-observation/addDropOff.js index 52a12a58e..5f773f593 100644 --- a/modules/ticket/back/methods/ticket-observation/addDropOff.js +++ b/modules/ticket/back/methods/ticket-observation/addDropOff.js @@ -24,31 +24,19 @@ module.exports = Self => { Self.addDropOff = async(ticketFk, note, options) => { const models = Self.app.models; const myOptions = {}; - let tx; if (typeof options == 'object') Object.assign(myOptions, options); - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - try { - const observationTypeDropOff = await models.ObservationType.findOne({ - where: {code: 'dropOff'} - }, myOptions); + const observationTypeDropOff = await models.ObservationType.findOne({ + where: {code: 'dropOff'} + }, myOptions); - await models.TicketObservation.create({ - ticketFk: ticketFk, - observationTypeFk: observationTypeDropOff.id, - description: note + await models.TicketObservation.create({ + ticketFk: ticketFk, + observationTypeFk: observationTypeDropOff.id, + description: note - }, myOptions); - - if (tx) await tx.commit(); - } catch (error) { - if (tx) await tx.rollback(); - throw error; - } + }, myOptions); }; }; diff --git a/modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js b/modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js index 1034dbe67..82c692946 100644 --- a/modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js +++ b/modules/ticket/back/methods/ticket-observation/specs/addDropOff.spec.js @@ -6,25 +6,19 @@ describe('ticketObservation addDropOff()', () => { const code = 'dropOff'; it('should return a dropOff note', async() => { - const myOptions = {}; + const tx = await models.TicketObservation.beginTransaction({}); - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await models.TicketObservation.beginTransaction({}); - myOptions.transaction = tx; - } try { + const options = {transaction: tx}; await models.TicketObservation.addDropOff( - ticketFk, note, myOptions); + ticketFk, note, options); const observationTypeDropOff = await models.TicketObservation.find({ where: { ticketFk, code } - }, myOptions); + }, options); expect(observationTypeDropOff.length).toEqual(1); From bb8379f8dbdec5bbec388193b03aea16bd01eeed Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 18 Apr 2024 14:42:29 +0200 Subject: [PATCH 144/161] refactor: refs #6724 Minor change --- .../vn/procedures/invoiceInTax_getFromEntries.sql | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql b/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql index 5a53b7543..631b8f31c 100644 --- a/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql +++ b/db/routines/vn/procedures/invoiceInTax_getFromEntries.sql @@ -4,16 +4,9 @@ BEGIN DECLARE vRate DOUBLE DEFAULT 1; DECLARE vDated DATE; DECLARE vExpenseFk VARCHAR(10); - DECLARE vIsBooked BOOLEAN DEFAULT FALSE; - SELECT isBooked INTO vIsBooked - FROM invoiceIn ii - WHERE id = vInvoiceInFk; + CALL invoiceIn_checkBooked(vInvoiceInFk); - IF vIsBooked THEN - CALL util.throw('A booked invoice cannot be modified'); - END IF; - SELECT MAX(rr.dated) INTO vDated FROM referenceRate rr JOIN invoiceIn ii ON ii.id = vInvoiceInFk From 067e71e3ce0ff545cc1a38e8b97148e9438dcf31 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 19 Apr 2024 07:48:45 +0200 Subject: [PATCH 145/161] feat: refs #6777 puppeteer --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index d700ce1f9..bfe31fc60 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -71,6 +71,7 @@ pipeline { stage('Back') { steps { sh 'pnpm install --prefer-offline' + sh 'node node_modules/puppeteer/install.mjs' } } stage('Print') { From 322d91d81404f5d2d5ec001749ca9f7a639ea180 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 19 Apr 2024 10:49:57 +0200 Subject: [PATCH 146/161] feat(salix): refs #6930 Add DEFAULT scope --- back/methods/dms/downloadFile.js | 2 +- back/methods/docuware/download.js | 2 +- back/methods/image/download.js | 2 +- modules/claim/back/methods/claim/claimPickupPdf.js | 2 +- modules/claim/back/methods/claim/downloadFile.js | 2 +- modules/client/back/methods/client/campaignMetricsPdf.js | 2 +- modules/entry/back/methods/entry/entryOrderPdf.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/download.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/downloadZip.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js | 2 +- modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js | 2 +- modules/item/back/methods/item-image-queue/download.js | 2 +- modules/route/back/methods/route/cmr.js | 2 +- modules/route/back/methods/route/downloadCmrsZip.js | 2 +- modules/route/back/methods/route/downloadZip.js | 2 +- modules/route/back/methods/route/driverRoutePdf.js | 2 +- modules/supplier/back/methods/supplier/campaignMetricsPdf.js | 2 +- modules/ticket/back/methods/ticket/deliveryNoteCsv.js | 2 +- modules/ticket/back/methods/ticket/deliveryNotePdf.js | 2 +- modules/travel/back/methods/travel/extraCommunityPdf.js | 2 +- modules/worker/back/methods/worker-dms/downloadFile.js | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/back/methods/dms/downloadFile.js b/back/methods/dms/downloadFile.js index d64b15b70..9290188a1 100644 --- a/back/methods/dms/downloadFile.js +++ b/back/methods/dms/downloadFile.js @@ -30,7 +30,7 @@ module.exports = Self => { path: `/:id/downloadFile`, verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadFile = async function(ctx, id) { diff --git a/back/methods/docuware/download.js b/back/methods/docuware/download.js index a1776cde5..eb575236d 100644 --- a/back/methods/docuware/download.js +++ b/back/methods/docuware/download.js @@ -43,7 +43,7 @@ module.exports = Self => { path: `/:id/download`, verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.download = async function(id, fileCabinet, filter) { diff --git a/back/methods/image/download.js b/back/methods/image/download.js index 201e16164..e0fcb0951 100644 --- a/back/methods/image/download.js +++ b/back/methods/image/download.js @@ -48,7 +48,7 @@ module.exports = Self => { path: `/:collection/:size/:id/download`, verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.download = async function(ctx, collection, size, id) { diff --git a/modules/claim/back/methods/claim/claimPickupPdf.js b/modules/claim/back/methods/claim/claimPickupPdf.js index 4b66bd418..232c134f6 100644 --- a/modules/claim/back/methods/claim/claimPickupPdf.js +++ b/modules/claim/back/methods/claim/claimPickupPdf.js @@ -35,7 +35,7 @@ module.exports = Self => { path: '/:id/claim-pickup-pdf', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.claimPickupPdf = (ctx, id) => Self.printReport(ctx, id, 'claim-pickup-order'); diff --git a/modules/claim/back/methods/claim/downloadFile.js b/modules/claim/back/methods/claim/downloadFile.js index 61784f39e..ffcf51367 100644 --- a/modules/claim/back/methods/claim/downloadFile.js +++ b/modules/claim/back/methods/claim/downloadFile.js @@ -33,7 +33,7 @@ module.exports = Self => { path: `/:id/downloadFile`, verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadFile = async function(ctx, id) { diff --git a/modules/client/back/methods/client/campaignMetricsPdf.js b/modules/client/back/methods/client/campaignMetricsPdf.js index 20c35494e..dc89a6802 100644 --- a/modules/client/back/methods/client/campaignMetricsPdf.js +++ b/modules/client/back/methods/client/campaignMetricsPdf.js @@ -46,7 +46,7 @@ module.exports = Self => { path: '/:id/campaign-metrics-pdf', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'campaign-metrics'); diff --git a/modules/entry/back/methods/entry/entryOrderPdf.js b/modules/entry/back/methods/entry/entryOrderPdf.js index 93c1b6bd9..7a432123e 100644 --- a/modules/entry/back/methods/entry/entryOrderPdf.js +++ b/modules/entry/back/methods/entry/entryOrderPdf.js @@ -34,7 +34,7 @@ module.exports = Self => { path: '/:id/entry-order-pdf', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.entryOrderPdf = (ctx, id) => Self.printReport(ctx, id, 'entry-order'); diff --git a/modules/invoiceOut/back/methods/invoiceOut/download.js b/modules/invoiceOut/back/methods/invoiceOut/download.js index cb71121d5..748e2df17 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/download.js +++ b/modules/invoiceOut/back/methods/invoiceOut/download.js @@ -32,7 +32,7 @@ module.exports = Self => { path: '/:id/download', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.download = async function(ctx, id, options) { diff --git a/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js b/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js index 4f2a8aab3..8d6e7c6d9 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js +++ b/modules/invoiceOut/back/methods/invoiceOut/downloadZip.js @@ -32,7 +32,7 @@ module.exports = Self => { path: '/downloadZip', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadZip = async function(ctx, ids, options) { diff --git a/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js b/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js index 0b08aec6d..6c4845c11 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js +++ b/modules/invoiceOut/back/methods/invoiceOut/exportationPdf.js @@ -35,7 +35,7 @@ module.exports = Self => { path: '/:reference/exportation-pdf', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.exportationPdf = (ctx, reference) => Self.printReport(ctx, reference, 'exportation'); diff --git a/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js b/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js index 6822e5a23..fd754d51b 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js +++ b/modules/invoiceOut/back/methods/invoiceOut/invoiceCsv.js @@ -38,7 +38,7 @@ module.exports = Self => { path: '/:reference/invoice-csv', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.invoiceCsv = async reference => { diff --git a/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js b/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js index 6ac56b68c..3e466d1f4 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js +++ b/modules/invoiceOut/back/methods/invoiceOut/negativeBasesCsv.js @@ -40,7 +40,7 @@ module.exports = Self => { path: '/negativeBasesCsv', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.negativeBasesCsv = async(ctx, options) => { diff --git a/modules/item/back/methods/item-image-queue/download.js b/modules/item/back/methods/item-image-queue/download.js index e1bc248ae..001a2b950 100644 --- a/modules/item/back/methods/item-image-queue/download.js +++ b/modules/item/back/methods/item-image-queue/download.js @@ -11,7 +11,7 @@ module.exports = Self => { path: `/download`, verb: 'POST', }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.download = async() => { diff --git a/modules/route/back/methods/route/cmr.js b/modules/route/back/methods/route/cmr.js index 08a8182e0..5033dee2f 100644 --- a/modules/route/back/methods/route/cmr.js +++ b/modules/route/back/methods/route/cmr.js @@ -30,7 +30,7 @@ module.exports = Self => { path: '/:id/cmr', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.cmr = (ctx, id) => Self.printReport(ctx, id, 'cmr'); diff --git a/modules/route/back/methods/route/downloadCmrsZip.js b/modules/route/back/methods/route/downloadCmrsZip.js index 43f6e9648..c6934edca 100644 --- a/modules/route/back/methods/route/downloadCmrsZip.js +++ b/modules/route/back/methods/route/downloadCmrsZip.js @@ -30,7 +30,7 @@ module.exports = Self => { path: '/downloadCmrsZip', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadCmrsZip = async function(ctx, ids, options) { diff --git a/modules/route/back/methods/route/downloadZip.js b/modules/route/back/methods/route/downloadZip.js index d7fc30aa3..8eecf62e4 100644 --- a/modules/route/back/methods/route/downloadZip.js +++ b/modules/route/back/methods/route/downloadZip.js @@ -30,7 +30,7 @@ module.exports = Self => { path: '/downloadZip', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadZip = async function(ctx, id, options) { diff --git a/modules/route/back/methods/route/driverRoutePdf.js b/modules/route/back/methods/route/driverRoutePdf.js index e7b4dee17..69b26d846 100644 --- a/modules/route/back/methods/route/driverRoutePdf.js +++ b/modules/route/back/methods/route/driverRoutePdf.js @@ -35,7 +35,7 @@ module.exports = Self => { path: '/:id/driver-route-pdf', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); diff --git a/modules/supplier/back/methods/supplier/campaignMetricsPdf.js b/modules/supplier/back/methods/supplier/campaignMetricsPdf.js index 51c626e69..58282747d 100644 --- a/modules/supplier/back/methods/supplier/campaignMetricsPdf.js +++ b/modules/supplier/back/methods/supplier/campaignMetricsPdf.js @@ -45,7 +45,7 @@ module.exports = Self => { path: '/:id/campaign-metrics-pdf', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.campaignMetricsPdf = (ctx, id) => Self.printReport(ctx, id, 'supplier-campaign-metrics'); diff --git a/modules/ticket/back/methods/ticket/deliveryNoteCsv.js b/modules/ticket/back/methods/ticket/deliveryNoteCsv.js index 9fa3c183e..f02debba8 100644 --- a/modules/ticket/back/methods/ticket/deliveryNoteCsv.js +++ b/modules/ticket/back/methods/ticket/deliveryNoteCsv.js @@ -38,7 +38,7 @@ module.exports = Self => { path: '/:id/delivery-note-csv', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.deliveryNoteCsv = async id => { diff --git a/modules/ticket/back/methods/ticket/deliveryNotePdf.js b/modules/ticket/back/methods/ticket/deliveryNotePdf.js index adc9e4435..205f4ba7b 100644 --- a/modules/ticket/back/methods/ticket/deliveryNotePdf.js +++ b/modules/ticket/back/methods/ticket/deliveryNotePdf.js @@ -42,7 +42,7 @@ module.exports = Self => { path: '/:id/delivery-note-pdf', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.deliveryNotePdf = (ctx, id) => Self.printReport(ctx, id, 'delivery-note'); diff --git a/modules/travel/back/methods/travel/extraCommunityPdf.js b/modules/travel/back/methods/travel/extraCommunityPdf.js index 73748ac50..459e74d69 100644 --- a/modules/travel/back/methods/travel/extraCommunityPdf.js +++ b/modules/travel/back/methods/travel/extraCommunityPdf.js @@ -79,7 +79,7 @@ module.exports = Self => { path: '/extra-community-pdf', verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.extraCommunityPdf = ctx => Self.printReport(ctx, null, 'extra-community'); diff --git a/modules/worker/back/methods/worker-dms/downloadFile.js b/modules/worker/back/methods/worker-dms/downloadFile.js index 08fbcf924..93d685429 100644 --- a/modules/worker/back/methods/worker-dms/downloadFile.js +++ b/modules/worker/back/methods/worker-dms/downloadFile.js @@ -30,7 +30,7 @@ module.exports = Self => { path: `/:id/downloadFile`, verb: 'GET' }, - accessScopes: ['read:multimedia'] + accessScopes: ['DEFAULT', 'read:multimedia'] }); Self.downloadFile = async function(ctx, id) { From 30d0db163e875f158c049bb08a383c45a7e52d71 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 19 Apr 2024 10:50:14 +0200 Subject: [PATCH 147/161] feat(salix): refs #6930 minor updates --- .../methods/vn-user/specs/renew-token.spec.js | 5 +- loopback/locale/en.json | 433 +++++++++--------- modules/worker/back/models/worker.json | 4 +- 3 files changed, 223 insertions(+), 219 deletions(-) diff --git a/back/methods/vn-user/specs/renew-token.spec.js b/back/methods/vn-user/specs/renew-token.spec.js index 741388bf9..70e7473d1 100644 --- a/back/methods/vn-user/specs/renew-token.spec.js +++ b/back/methods/vn-user/specs/renew-token.spec.js @@ -28,6 +28,9 @@ describe('Renew Token', () => { }); it('should renew token', async() => { + const {courtesyTime} = await models.AccessTokenConfig.findOne({ + fields: ['courtesyTime'] + }); const mockDate = new Date(startingTime + 26600000); jasmine.clock().mockDate(mockDate); const {id} = await models.VnUser.renewToken(ctx); @@ -35,7 +38,7 @@ describe('Renew Token', () => { expect(id).not.toEqual(ctx.req.accessToken.id); await models.VnUser.logout(ctx.req.accessToken.id); - jasmine.clock().tick(70 * 1000); + jasmine.clock().tick((courtesyTime + 10) * 1000); let tokenNotExists; try { tokenNotExists = await models.AccessToken.findById(ctx.req.accessToken.id); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index a0e60550f..9a3a1f52a 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -1,217 +1,217 @@ { - "State cannot be blank": "State cannot be blank", - "Cannot be blank": "Cannot be blank", - "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 an integer greater than or equal to zero": "The grade must be an integer greater than or equal to zero", - "Invalid email": "Invalid email", - "Name cannot be blank": "Name cannot be blank", - "Phone cannot be blank": "Phone cannot be blank", - "Description should have maximum of 45 characters": "Description should have maximum of 45 characters", - "Period cannot be blank": "Period cannot be blank", - "Sample type cannot be blank": "Sample type cannot be blank", - "That payment method requires an IBAN": "That payment method requires an IBAN", - "That payment method requires a BIC": "That payment method requires a BIC", - "The default consignee can not be unchecked": "The default consignee can not be unchecked", - "Enter an integer different to zero": "Enter an integer different to zero", - "Package cannot be blank": "Package cannot be blank", - "The price of the item changed": "The price of the item changed", - "The sales of this ticket can't be modified": "The sales of this ticket can't be modified", - "Cannot check Equalization Tax in this NIF/CIF": "Cannot check Equalization Tax in this NIF/CIF", - "You can't create an order for a frozen client": "You can't create an order for a frozen client", - "This address doesn't exist": "This address doesn't exist", - "Warehouse cannot be blank": "Warehouse cannot be blank", - "Agency cannot be blank": "Agency cannot be blank", - "The IBAN does not have the correct format": "The IBAN does not have the correct format", - "You can't make changes on the basic data of an confirmed order or with rows": "You can't make changes on the basic data of an confirmed order or with rows", - "You can't create a ticket for an inactive client": "You can't create a ticket for an inactive client", - "Worker cannot be blank": "Worker cannot be blank", - "You must delete the claim id %d first": "You must delete the claim id %d first", - "You don't have enough privileges": "You don't have enough privileges", - "Tag value cannot be blank": "Tag value cannot be blank", - "A client with that Web User name already exists": "A client with that Web User name already exists", - "The warehouse can't be repeated": "The warehouse can't be repeated", - "Barcode must be unique": "Barcode must be unique", - "You don't have enough privileges to do that": "You don't have enough privileges to do that", - "You can't create a ticket for a frozen client": "You can't create a ticket for a frozen client", - "can't be blank": "can't be blank", - "Street cannot be empty": "Street cannot be empty", - "City cannot be empty": "City cannot be empty", - "EXTENSION_INVALID_FORMAT": "Invalid extension", - "The secret can't be blank": "The secret can't be blank", - "Invalid TIN": "Invalid Tax number", - "This ticket can't be invoiced": "This ticket can't be invoiced", - "The value should be a number": "The value should be a number", - "The current ticket can't be modified": "The current ticket can't be modified", - "Extension format is invalid": "Extension format is invalid", - "NO_ZONE_FOR_THIS_PARAMETERS": "NO_ZONE_FOR_THIS_PARAMETERS", - "This client can't be invoiced": "This client can't be invoiced", - "You must provide the correction information to generate a corrective invoice": "You must provide the correction information to generate a corrective invoice", - "The introduced hour already exists": "The introduced hour already exists", - "Invalid parameters to create a new ticket": "Invalid parameters to create a new ticket", - "Concept cannot be blank": "Concept cannot be blank", - "Ticket id cannot be blank": "Ticket id cannot be blank", - "Weekday cannot be blank": "Weekday cannot be blank", - "This ticket can not be modified": "This ticket can not be modified", - "You can't delete a confirmed order": "You can't delete a confirmed order", - "Value has an invalid format": "Value has an invalid format", - "The postcode doesn't exist. Please enter a correct one": "The postcode doesn't exist. Please enter a correct one", - "Swift / BIC can't be empty": "Swift / BIC can't be empty", - "Deleted sales from ticket": "I have deleted the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", - "Added sale to ticket": "I have added the following line to the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", - "Changed sale discount": "I have changed the following lines discounts from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Created claim": "I have created the claim [{{claimId}}]({{{claimUrl}}}) for the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Changed sale price": "I have changed the price of [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) from {{oldPrice}}€ ➔ *{{newPrice}}€* of the ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale quantity": "I have changed the quantity of [{{itemId}} {{concept}}]({{{itemUrl}}}) from {{oldQuantity}} ➔ *{{newQuantity}}* of the ticket [{{ticketId}}]({{{ticketUrl}}})", - "Changed sale reserved state": "I have changed the following lines reserved state from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "Bought units from buy request": "Bought {{quantity}} units of [{{itemId}} {{concept}}]({{{urlItem}}}) for the ticket id [{{ticketId}}]({{{url}}})", - "MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} ({{clientId}})]({{{url}}}) to *{{credit}} €*", - "Changed client paymethod": "I have changed the pay method for client [{{clientName}} ({{clientId}})]({{{url}}})", - "Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} ({{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [{{ticketId}}]({{{ticketUrl}}})", - "Change quantity": "{{concept}} change of {{oldQuantity}} to {{newQuantity}}", - "Claim will be picked": "The product from the claim [({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked, with the pickup type *{{claimPickup}}*", - "Claim state has changed to": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *{{newState}}*", - "Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member", - "Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member", - "Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}", - "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment", - "NOT_ZONE_WITH_THIS_PARAMETERS": "There's no zone available for this day", - "Created absence": "The worker {{author}} has added an absence of type '{{absenceType}}' to {{employee}} for day {{dated}}.", - "Deleted absence": "The worker {{author}} has deleted an absence of type '{{absenceType}}' to {{employee}} for day {{dated}}.", - "I have deleted the ticket id": "I have deleted the ticket id [{{id}}]({{{url}}})", - "I have restored the ticket id": "I have restored the ticket id [{{id}}]({{{url}}})", - "Changed this data from the ticket": "I have changed the data from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", - "The grade must be similar to the last one": "The grade must be similar to the last one", - "agencyModeFk": "Agency", - "clientFk": "Client", - "zoneFk": "Zone", - "warehouseFk": "Warehouse", - "shipped": "Shipped", - "landed": "Landed", - "addressFk": "Address", - "companyFk": "Company", - "agency": "Agency", - "delivery": "Delivery", - "You need to fill sage information before you check verified data": "You need to fill sage information before you check verified data", - "The social name cannot be empty": "The social name cannot be empty", - "The nif cannot be empty": "The nif cannot be empty", - "Amount cannot be zero": "Amount cannot be zero", - "Company has to be official": "Company has to be official", - "Unable to clone this travel": "Unable to clone this travel", - "The observation type can't be repeated": "The observation type can't be repeated", - "New ticket request has been created with price": "New ticket request has been created *'{{description}}'* for day *{{shipped}}*, with a quantity of *{{quantity}}* and a price of *{{price}} €*", - "New ticket request has been created": "New ticket request has been created *'{{description}}'* for day *{{shipped}}*, with a quantity of *{{quantity}}*", - "There's a new urgent ticket": "There's a new urgent ticket: [{{title}}](https://cau.verdnatura.es/WorkOrder.do?woMode=viewWO&woID={{issueId}})", - "Swift / BIC cannot be empty": "Swift / BIC cannot be empty", - "Role name must be written in camelCase": "Role name must be written in camelCase", - "Client assignment has changed": "I did change the salesperson ~*\"<{{previousWorkerName}}>\"*~ by *\"<{{currentWorkerName}}>\"* from the client [{{clientName}} ({{clientId}})]({{{url}}})", - "None": "None", - "error densidad = 0": "error densidad = 0", - "This document already exists on this ticket": "This document already exists on this ticket", - "serial non editable": "This serial doesn't allow to set a reference", - "nickname": "nickname", - "State": "State", - "regular": "regular", - "reserved": "reserved", - "Global invoicing failed": "[Global invoicing] Wasn't able to invoice some of the clients", - "A ticket with a negative base can't be invoiced": "A ticket with a negative base can't be invoiced", - "This client is not invoiceable": "This client is not invoiceable", - "INACTIVE_PROVIDER": "Inactive provider", - "reference duplicated": "reference duplicated", - "The PDF document does not exist": "The PDF document does not exists. Try regenerating it from 'Regenerate invoice PDF' option", - "This item is not available": "This item is not available", - "Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}", - "The type of business must be filled in basic data": "The type of business must be filled in basic data", - "The worker has hours recorded that day": "The worker has hours recorded that day", - "isWithoutNegatives": "isWithoutNegatives", - "routeFk": "routeFk", - "Not enough privileges to edit a client with verified data": "Not enough privileges to edit a client with verified data", - "Can't change the password of another worker": "Can't change the password of another worker", - "No hay un contrato en vigor": "There is no existing contract", - "No está permitido trabajar": "Not allowed to work", - "Dirección incorrecta": "Wrong direction", - "No se permite fichar a futuro": "It is not allowed to sign in the future", - "Descanso diario 12h.": "Daily rest 12h.", - "Fichadas impares": "Odd signs", - "Descanso diario 9h.": "Daily rest 9h.", - "Descanso semanal 36h. / 72h.": "Weekly rest 36h. / 72h.", - "Verify email": "Verify email", - "Click on the following link to verify this email. If you haven't requested this email, just ignore it": "Click on the following link to verify this email. If you haven't requested this email, just ignore it", - "Password does not meet requirements": "Password does not meet requirements", - "You don't have privileges to change the zone": "You don't have privileges to change the zone or for these parameters there are more than one shipping options, talk to agencies", - "Not enough privileges to edit a client": "Not enough privileges to edit a client", - "Claim pickup order sent": "Claim pickup order sent [{{claimId}}]({{{claimUrl}}}) to client *{{clientName}}*", - "You don't have grant privilege": "You don't have grant privilege", - "You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user", - "Email verify": "Email verify", - "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) merged with [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})", - "App locked": "App locked by user {{userId}}", - "The sales of the receiver ticket can't be modified": "The sales of the receiver ticket can't be modified", - "Receipt's bank was not found": "Receipt's bank was not found", - "This receipt was not compensated": "This receipt was not compensated", - "Client's email was not found": "Client's email was not found", - "Tickets with associated refunds": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº %d", - "It is not possible to modify tracked sales": "It is not possible to modify tracked sales", - "It is not possible to modify sales that their articles are from Floramondo": "It is not possible to modify sales that their articles are from Floramondo", - "It is not possible to modify cloned sales": "It is not possible to modify cloned sales", - "Warehouse inventory not set": "Almacén inventario no está establecido", - "Component cost not set": "Componente coste no está estabecido", - "Description cannot be blank": "Description cannot be blank", - "company": "Company", - "country": "Country", - "clientId": "Id client", - "clientSocialName": "Client", - "amount": "Amount", - "taxableBase": "Taxable base", - "ticketFk": "Id ticket", - "isActive": "Active", - "hasToInvoice": "Invoice", - "isTaxDataChecked": "Data checked", - "comercialId": "Id Comercial", - "comercialName": "Comercial", - "Added observation": "Added observation", - "Comment added to client": "Comment added to client", - "This ticket is already a refund": "This ticket is already a refund", - "A claim with that sale already exists": "A claim with that sale already exists", - "Pass expired": "The password has expired, change it from Salix", - "Can't transfer claimed sales": "Can't transfer claimed sales", - "Invalid quantity": "Invalid quantity", - "Failed to upload delivery note": "Error to upload delivery note {{id}}", - "Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address", - "The renew period has not been exceeded": "The renew period has not been exceeded", - "You can not use the same password": "You can not use the same password", - "Valid priorities": "Valid priorities: %d", - "hasAnyNegativeBase": "Negative basis of tickets: {{ticketsIds}}", - "hasAnyPositiveBase": "Positive basis of tickets: {{ticketsIds}}", - "This ticket cannot be left empty.": "This ticket cannot be left empty. %s", - "Social name should be uppercase": "Social name should be uppercase", - "Street should be uppercase": "Street should be uppercase", - "You don't have enough privileges.": "You don't have enough privileges.", - "This ticket is locked": "This ticket is locked", - "This ticket is not editable.": "This ticket is not editable.", - "The ticket doesn't exist.": "The ticket doesn't exist.", - "The sales do not exists": "The sales do not exists", - "Ticket without Route": "Ticket without route", - "Select a different client": "Select a different client", - "Fill all the fields": "Fill all the fields", - "Error while generating PDF": "Error while generating PDF", - "Can't invoice to future": "Can't invoice to future", - "This ticket is already invoiced": "This ticket is already invoiced", - "Negative basis of tickets: 23": "Negative basis of tickets: 23", - "Booking completed": "Booking complete", - "The ticket is in preparation": "The ticket [{{ticketId}}]({{{ticketUrl}}}) of the sales person {{salesPersonId}} is in preparation", - "You can only add negative amounts in refund tickets": "You can only add negative amounts in refund tickets", - "Bank entity must be specified": "Bank entity must be specified", - "Try again": "Try again", - "keepPrice": "keepPrice", - "Cannot past travels with entries": "Cannot past travels with entries", - "It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}", - "Incorrect pin": "Incorrect pin.", - "The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified", - "Name should be uppercase": "Name should be uppercase", - "You cannot update these fields": "You cannot update these fields", - "CountryFK cannot be empty": "Country cannot be empty", - "You are not allowed to modify the alias": "You are not allowed to modify the alias", - "You already have the mailAlias": "You already have the mailAlias", + "State cannot be blank": "State cannot be blank", + "Cannot be blank": "Cannot be blank", + "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 an integer greater than or equal to zero": "The grade must be an integer greater than or equal to zero", + "Invalid email": "Invalid email", + "Name cannot be blank": "Name cannot be blank", + "Phone cannot be blank": "Phone cannot be blank", + "Description should have maximum of 45 characters": "Description should have maximum of 45 characters", + "Period cannot be blank": "Period cannot be blank", + "Sample type cannot be blank": "Sample type cannot be blank", + "That payment method requires an IBAN": "That payment method requires an IBAN", + "That payment method requires a BIC": "That payment method requires a BIC", + "The default consignee can not be unchecked": "The default consignee can not be unchecked", + "Enter an integer different to zero": "Enter an integer different to zero", + "Package cannot be blank": "Package cannot be blank", + "The price of the item changed": "The price of the item changed", + "The sales of this ticket can't be modified": "The sales of this ticket can't be modified", + "Cannot check Equalization Tax in this NIF/CIF": "Cannot check Equalization Tax in this NIF/CIF", + "You can't create an order for a frozen client": "You can't create an order for a frozen client", + "This address doesn't exist": "This address doesn't exist", + "Warehouse cannot be blank": "Warehouse cannot be blank", + "Agency cannot be blank": "Agency cannot be blank", + "The IBAN does not have the correct format": "The IBAN does not have the correct format", + "You can't make changes on the basic data of an confirmed order or with rows": "You can't make changes on the basic data of an confirmed order or with rows", + "You can't create a ticket for an inactive client": "You can't create a ticket for an inactive client", + "Worker cannot be blank": "Worker cannot be blank", + "You must delete the claim id %d first": "You must delete the claim id %d first", + "You don't have enough privileges": "You don't have enough privileges", + "Tag value cannot be blank": "Tag value cannot be blank", + "A client with that Web User name already exists": "A client with that Web User name already exists", + "The warehouse can't be repeated": "The warehouse can't be repeated", + "Barcode must be unique": "Barcode must be unique", + "You don't have enough privileges to do that": "You don't have enough privileges to do that", + "You can't create a ticket for a frozen client": "You can't create a ticket for a frozen client", + "can't be blank": "can't be blank", + "Street cannot be empty": "Street cannot be empty", + "City cannot be empty": "City cannot be empty", + "EXTENSION_INVALID_FORMAT": "Invalid extension", + "The secret can't be blank": "The secret can't be blank", + "Invalid TIN": "Invalid Tax number", + "This ticket can't be invoiced": "This ticket can't be invoiced", + "The value should be a number": "The value should be a number", + "The current ticket can't be modified": "The current ticket can't be modified", + "Extension format is invalid": "Extension format is invalid", + "NO_ZONE_FOR_THIS_PARAMETERS": "NO_ZONE_FOR_THIS_PARAMETERS", + "This client can't be invoiced": "This client can't be invoiced", + "You must provide the correction information to generate a corrective invoice": "You must provide the correction information to generate a corrective invoice", + "The introduced hour already exists": "The introduced hour already exists", + "Invalid parameters to create a new ticket": "Invalid parameters to create a new ticket", + "Concept cannot be blank": "Concept cannot be blank", + "Ticket id cannot be blank": "Ticket id cannot be blank", + "Weekday cannot be blank": "Weekday cannot be blank", + "This ticket can not be modified": "This ticket can not be modified", + "You can't delete a confirmed order": "You can't delete a confirmed order", + "Value has an invalid format": "Value has an invalid format", + "The postcode doesn't exist. Please enter a correct one": "The postcode doesn't exist. Please enter a correct one", + "Swift / BIC can't be empty": "Swift / BIC can't be empty", + "Deleted sales from ticket": "I have deleted the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{deletions}}}", + "Added sale to ticket": "I have added the following line to the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{addition}}}", + "Changed sale discount": "I have changed the following lines discounts from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Created claim": "I have created the claim [{{claimId}}]({{{claimUrl}}}) for the following lines from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Changed sale price": "I have changed the price of [{{itemId}} {{concept}}]({{{itemUrl}}}) ({{quantity}}) from {{oldPrice}}€ ➔ *{{newPrice}}€* of the ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale quantity": "I have changed the quantity of [{{itemId}} {{concept}}]({{{itemUrl}}}) from {{oldQuantity}} ➔ *{{newQuantity}}* of the ticket [{{ticketId}}]({{{ticketUrl}}})", + "Changed sale reserved state": "I have changed the following lines reserved state from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "Bought units from buy request": "Bought {{quantity}} units of [{{itemId}} {{concept}}]({{{urlItem}}}) for the ticket id [{{ticketId}}]({{{url}}})", + "MESSAGE_INSURANCE_CHANGE": "I have changed the insurence credit of client [{{clientName}} ({{clientId}})]({{{url}}}) to *{{credit}} €*", + "Changed client paymethod": "I have changed the pay method for client [{{clientName}} ({{clientId}})]({{{url}}})", + "Sent units from ticket": "I sent *{{quantity}}* units of [{{concept}} ({{itemId}})]({{{itemUrl}}}) to *\"{{nickname}}\"* coming from ticket id [{{ticketId}}]({{{ticketUrl}}})", + "Change quantity": "{{concept}} change of {{oldQuantity}} to {{newQuantity}}", + "Claim will be picked": "The product from the claim [({{claimId}})]({{{claimUrl}}}) from the client *{{clientName}}* will be picked, with the pickup type *{{claimPickup}}*", + "Claim state has changed to": "The state of the claim [({{claimId}})]({{{claimUrl}}}) from client *{{clientName}}* has changed to *{{newState}}*", + "Customs agent is required for a non UEE member": "Customs agent is required for a non UEE member", + "Incoterms is required for a non UEE member": "Incoterms is required for a non UEE member", + "Client checked as validated despite of duplication": "Client checked as validated despite of duplication from client id {{clientId}}", + "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment", + "NOT_ZONE_WITH_THIS_PARAMETERS": "There's no zone available for this day", + "Created absence": "The worker {{author}} has added an absence of type '{{absenceType}}' to {{employee}} for day {{dated}}.", + "Deleted absence": "The worker {{author}} has deleted an absence of type '{{absenceType}}' to {{employee}} for day {{dated}}.", + "I have deleted the ticket id": "I have deleted the ticket id [{{id}}]({{{url}}})", + "I have restored the ticket id": "I have restored the ticket id [{{id}}]({{{url}}})", + "Changed this data from the ticket": "I have changed the data from the ticket [{{ticketId}}]({{{ticketUrl}}}): {{{changes}}}", + "The grade must be similar to the last one": "The grade must be similar to the last one", + "agencyModeFk": "Agency", + "clientFk": "Client", + "zoneFk": "Zone", + "warehouseFk": "Warehouse", + "shipped": "Shipped", + "landed": "Landed", + "addressFk": "Address", + "companyFk": "Company", + "agency": "Agency", + "delivery": "Delivery", + "You need to fill sage information before you check verified data": "You need to fill sage information before you check verified data", + "The social name cannot be empty": "The social name cannot be empty", + "The nif cannot be empty": "The nif cannot be empty", + "Amount cannot be zero": "Amount cannot be zero", + "Company has to be official": "Company has to be official", + "Unable to clone this travel": "Unable to clone this travel", + "The observation type can't be repeated": "The observation type can't be repeated", + "New ticket request has been created with price": "New ticket request has been created *'{{description}}'* for day *{{shipped}}*, with a quantity of *{{quantity}}* and a price of *{{price}} €*", + "New ticket request has been created": "New ticket request has been created *'{{description}}'* for day *{{shipped}}*, with a quantity of *{{quantity}}*", + "There's a new urgent ticket": "There's a new urgent ticket: [{{title}}](https://cau.verdnatura.es/WorkOrder.do?woMode=viewWO&woID={{issueId}})", + "Swift / BIC cannot be empty": "Swift / BIC cannot be empty", + "Role name must be written in camelCase": "Role name must be written in camelCase", + "Client assignment has changed": "I did change the salesperson ~*\"<{{previousWorkerName}}>\"*~ by *\"<{{currentWorkerName}}>\"* from the client [{{clientName}} ({{clientId}})]({{{url}}})", + "None": "None", + "error densidad = 0": "error densidad = 0", + "This document already exists on this ticket": "This document already exists on this ticket", + "serial non editable": "This serial doesn't allow to set a reference", + "nickname": "nickname", + "State": "State", + "regular": "regular", + "reserved": "reserved", + "Global invoicing failed": "[Global invoicing] Wasn't able to invoice some of the clients", + "A ticket with a negative base can't be invoiced": "A ticket with a negative base can't be invoiced", + "This client is not invoiceable": "This client is not invoiceable", + "INACTIVE_PROVIDER": "Inactive provider", + "reference duplicated": "reference duplicated", + "The PDF document does not exist": "The PDF document does not exists. Try regenerating it from 'Regenerate invoice PDF' option", + "This item is not available": "This item is not available", + "Deny buy request": "Purchase request for ticket id [{{ticketId}}]({{{url}}}) has been rejected. Reason: {{observation}}", + "The type of business must be filled in basic data": "The type of business must be filled in basic data", + "The worker has hours recorded that day": "The worker has hours recorded that day", + "isWithoutNegatives": "isWithoutNegatives", + "routeFk": "routeFk", + "Not enough privileges to edit a client with verified data": "Not enough privileges to edit a client with verified data", + "Can't change the password of another worker": "Can't change the password of another worker", + "No hay un contrato en vigor": "There is no existing contract", + "No está permitido trabajar": "Not allowed to work", + "Dirección incorrecta": "Wrong direction", + "No se permite fichar a futuro": "It is not allowed to sign in the future", + "Descanso diario 12h.": "Daily rest 12h.", + "Fichadas impares": "Odd signs", + "Descanso diario 9h.": "Daily rest 9h.", + "Descanso semanal 36h. / 72h.": "Weekly rest 36h. / 72h.", + "Verify email": "Verify email", + "Click on the following link to verify this email. If you haven't requested this email, just ignore it": "Click on the following link to verify this email. If you haven't requested this email, just ignore it", + "Password does not meet requirements": "Password does not meet requirements", + "You don't have privileges to change the zone": "You don't have privileges to change the zone or for these parameters there are more than one shipping options, talk to agencies", + "Not enough privileges to edit a client": "Not enough privileges to edit a client", + "Claim pickup order sent": "Claim pickup order sent [{{claimId}}]({{{claimUrl}}}) to client *{{clientName}}*", + "You don't have grant privilege": "You don't have grant privilege", + "You don't own the role and you can't assign it to another user": "You don't own the role and you can't assign it to another user", + "Email verify": "Email verify", + "Ticket merged": "Ticket [{{originId}}]({{{originFullPath}}}) ({{{originDated}}}) merged with [{{destinationId}}]({{{destinationFullPath}}}) ({{{destinationDated}}})", + "App locked": "App locked by user {{userId}}", + "The sales of the receiver ticket can't be modified": "The sales of the receiver ticket can't be modified", + "Receipt's bank was not found": "Receipt's bank was not found", + "This receipt was not compensated": "This receipt was not compensated", + "Client's email was not found": "Client's email was not found", + "Tickets with associated refunds": "Tickets with associated refunds can't be deleted. This ticket is associated with refund Nº %d", + "It is not possible to modify tracked sales": "It is not possible to modify tracked sales", + "It is not possible to modify sales that their articles are from Floramondo": "It is not possible to modify sales that their articles are from Floramondo", + "It is not possible to modify cloned sales": "It is not possible to modify cloned sales", + "Warehouse inventory not set": "Almacén inventario no está establecido", + "Component cost not set": "Componente coste no está estabecido", + "Description cannot be blank": "Description cannot be blank", + "company": "Company", + "country": "Country", + "clientId": "Id client", + "clientSocialName": "Client", + "amount": "Amount", + "taxableBase": "Taxable base", + "ticketFk": "Id ticket", + "isActive": "Active", + "hasToInvoice": "Invoice", + "isTaxDataChecked": "Data checked", + "comercialId": "Id Comercial", + "comercialName": "Comercial", + "Added observation": "Added observation", + "Comment added to client": "Comment added to client", + "This ticket is already a refund": "This ticket is already a refund", + "A claim with that sale already exists": "A claim with that sale already exists", + "Pass expired": "The password has expired, change it from Salix", + "Can't transfer claimed sales": "Can't transfer claimed sales", + "Invalid quantity": "Invalid quantity", + "Failed to upload delivery note": "Error to upload delivery note {{id}}", + "Mail not sent": "There has been an error sending the invoice to the client [{{clientId}}]({{{clientUrl}}}), please check the email address", + "The renew period has not been exceeded": "The renew period has not been exceeded", + "You can not use the same password": "You can not use the same password", + "Valid priorities": "Valid priorities: %d", + "hasAnyNegativeBase": "Negative basis of tickets: {{ticketsIds}}", + "hasAnyPositiveBase": "Positive basis of tickets: {{ticketsIds}}", + "This ticket cannot be left empty.": "This ticket cannot be left empty. %s", + "Social name should be uppercase": "Social name should be uppercase", + "Street should be uppercase": "Street should be uppercase", + "You don't have enough privileges.": "You don't have enough privileges.", + "This ticket is locked": "This ticket is locked", + "This ticket is not editable.": "This ticket is not editable.", + "The ticket doesn't exist.": "The ticket doesn't exist.", + "The sales do not exists": "The sales do not exists", + "Ticket without Route": "Ticket without route", + "Select a different client": "Select a different client", + "Fill all the fields": "Fill all the fields", + "Error while generating PDF": "Error while generating PDF", + "Can't invoice to future": "Can't invoice to future", + "This ticket is already invoiced": "This ticket is already invoiced", + "Negative basis of tickets: 23": "Negative basis of tickets: 23", + "Booking completed": "Booking complete", + "The ticket is in preparation": "The ticket [{{ticketId}}]({{{ticketUrl}}}) of the sales person {{salesPersonId}} is in preparation", + "You can only add negative amounts in refund tickets": "You can only add negative amounts in refund tickets", + "Bank entity must be specified": "Bank entity must be specified", + "Try again": "Try again", + "keepPrice": "keepPrice", + "Cannot past travels with entries": "Cannot past travels with entries", + "It was not able to remove the next expeditions:": "It was not able to remove the next expeditions: {{expeditions}}", + "Incorrect pin": "Incorrect pin.", + "The notification subscription of this worker cant be modified": "The notification subscription of this worker cant be modified", + "Name should be uppercase": "Name should be uppercase", + "You cannot update these fields": "You cannot update these fields", + "CountryFK cannot be empty": "Country cannot be empty", + "You are not allowed to modify the alias": "You are not allowed to modify the alias", + "You already have the mailAlias": "You already have the mailAlias", "This machine is already in use.": "This machine is already in use.", "the plate does not exist": "The plate {{plate}} does not exist", "We do not have availability for the selected item": "We do not have availability for the selected item", @@ -223,6 +223,7 @@ "printerNotExists": "The printer does not exist", "There are not picking tickets": "There are not picking tickets", "ticketCommercial": "The ticket {{ ticket }} for the salesperson {{ salesMan }} is in preparation. (automatically generated message)", - "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", - "They're not your subordinate": "They're not your subordinate" -} + "This password can only be changed by the user themselves": "This password can only be changed by the user themselves", + "They're not your subordinate": "They're not your subordinate", + "InvoiceIn is already booked": "InvoiceIn is already booked" +} \ No newline at end of file diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 57dc80ec9..f959d3138 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -99,7 +99,7 @@ { "relation": "user", "scope": { - "fields": ["email", "name", "nickname", "roleFk"], + "fields": ["email", "name", "nickname", "roleFk", "name", "emailVerified","recoveryPhone"], "include": [ { "relation": "role", @@ -127,7 +127,7 @@ }, { "relation": "client", "scope": { - "fields": [ + "fields": [ "id", "name", "fi", From fb17a54ebd3ac6cf431acd648b37b396dcedc1c0 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 19 Apr 2024 10:53:03 +0200 Subject: [PATCH 148/161] feat: refs #6777 resotre view --- db/routines/vn2008/views/tblContadores.sql | 39 +++++++++++++++++++ db/routines/vn2008/views/thermograph.sql | 6 +++ .../vn2008/views/ticket_observation.sql | 8 ++++ db/routines/vn2008/views/tickets_gestdoc.sql | 6 +++ 4 files changed, 59 insertions(+) create mode 100644 db/routines/vn2008/views/tblContadores.sql create mode 100644 db/routines/vn2008/views/thermograph.sql create mode 100644 db/routines/vn2008/views/ticket_observation.sql create mode 100644 db/routines/vn2008/views/tickets_gestdoc.sql diff --git a/db/routines/vn2008/views/tblContadores.sql b/db/routines/vn2008/views/tblContadores.sql new file mode 100644 index 000000000..129d3ce8b --- /dev/null +++ b/db/routines/vn2008/views/tblContadores.sql @@ -0,0 +1,39 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`tblContadores` +AS SELECT `c`.`id` AS `id`, + `c`.`ochoa` AS `ochoa`, + `c`.`invoiceOutFk` AS `nfactura`, + `c`.`inventoried` AS `FechaInventario`, + `c`.`itemLog` AS `HistoricoArticulo`, + `c`.`weekGoal` AS `week_goal`, + `c`.`photosPath` AS `Rutafotos`, + `c`.`cashBoxNumber` AS `numCaja`, + `c`.`redCode` AS `CodigoRojo`, + `c`.`TabletTime` AS `Tablet_Hora`, + `c`.`t0` AS `t0`, + `c`.`t1` AS `t1`, + `c`.`t2` AS `t2`, + `c`.`t3` AS `t3`, + `c`.`cc` AS `cc`, + `c`.`palet` AS `palet`, + `c`.`campaign` AS `campaign`, + `c`.`campaignLife` AS `campaign_life`, + `c`.`truckDays` AS `truck_days`, + `c`.`transportCharges` AS `tasa_transporte`, + `c`.`escanerPath` AS `escaner_path`, + `c`.`printedTurn` AS `turnoimpreso`, + `c`.`truckLength` AS `truck_length`, + `c`.`fuelConsumption` AS `fuel_consumption`, + `c`.`petrol` AS `petrol`, + `c`.`maintenance` AS `maintenance`, + `c`.`hourPrice` AS `hour_price`, + `c`.`meterPrice` AS `meter_price`, + `c`.`kmPrice` AS `km_price`, + `c`.`routeOption` AS `route_option`, + `c`.`dbproduccion` AS `dbproduccion`, + `c`.`mdbServer` AS `mdbServer`, + `c`.`fakeEmail` AS `fakeEmail`, + `c`.`defaultersMaxAmount` AS `defaultersMaxAmount`, + `c`.`ASIEN` AS `ASIEN` +FROM `vn`.`config` `c` diff --git a/db/routines/vn2008/views/thermograph.sql b/db/routines/vn2008/views/thermograph.sql new file mode 100644 index 000000000..f51b83d24 --- /dev/null +++ b/db/routines/vn2008/views/thermograph.sql @@ -0,0 +1,6 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`thermograph` +AS SELECT `t`.`id` AS `thermograph_id`, + `t`.`model` AS `model` +FROM `vn`.`thermograph` `t` diff --git a/db/routines/vn2008/views/ticket_observation.sql b/db/routines/vn2008/views/ticket_observation.sql new file mode 100644 index 000000000..deb85e4b6 --- /dev/null +++ b/db/routines/vn2008/views/ticket_observation.sql @@ -0,0 +1,8 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`ticket_observation` +AS SELECT `to`.`id` AS `ticket_observation_id`, + `to`.`ticketFk` AS `Id_Ticket`, + `to`.`observationTypeFk` AS `observation_type_id`, + `to`.`description` AS `text` +FROM `vn`.`ticketObservation` `to` diff --git a/db/routines/vn2008/views/tickets_gestdoc.sql b/db/routines/vn2008/views/tickets_gestdoc.sql new file mode 100644 index 000000000..a8682db57 --- /dev/null +++ b/db/routines/vn2008/views/tickets_gestdoc.sql @@ -0,0 +1,6 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`tickets_gestdoc` +AS SELECT `td`.`ticketFk` AS `Id_Ticket`, + `td`.`dmsFk` AS `gestdoc_id` +FROM `vn`.`ticketDms` `td` From e601310d3e347281535d2031ce0b9e9ecdd372e2 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 19 Apr 2024 11:27:54 +0200 Subject: [PATCH 149/161] feat: refs #6777 restore view --- db/routines/vn2008/views/Rutas.sql | 19 +++++++++++++++++++ db/routines/vn2008/views/Tickets_turno.sql | 6 ++++++ db/routines/vn2008/views/state.sql | 13 +++++++++++++ db/routines/vn2008/views/tag.sql | 10 ++++++++++ .../vn2008/views/tarifa_componentes.sql | 10 ++++++++++ .../views/tarifa_componentes_series.sql | 7 +++++++ 6 files changed, 65 insertions(+) create mode 100644 db/routines/vn2008/views/Rutas.sql create mode 100644 db/routines/vn2008/views/Tickets_turno.sql create mode 100644 db/routines/vn2008/views/state.sql create mode 100644 db/routines/vn2008/views/tag.sql create mode 100644 db/routines/vn2008/views/tarifa_componentes.sql create mode 100644 db/routines/vn2008/views/tarifa_componentes_series.sql diff --git a/db/routines/vn2008/views/Rutas.sql b/db/routines/vn2008/views/Rutas.sql new file mode 100644 index 000000000..78b3bb471 --- /dev/null +++ b/db/routines/vn2008/views/Rutas.sql @@ -0,0 +1,19 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`Rutas` +AS SELECT `r`.`id` AS `Id_Ruta`, + `r`.`workerFk` AS `Id_Trabajador`, + `r`.`created` AS `Fecha`, + `r`.`vehicleFk` AS `Id_Vehiculo`, + `r`.`agencyModeFk` AS `Id_Agencia`, + `r`.`time` AS `Hora`, + `r`.`isOk` AS `ok`, + `r`.`kmStart` AS `km_start`, + `r`.`kmEnd` AS `km_end`, + `r`.`started` AS `date_start`, + `r`.`finished` AS `date_end`, + `r`.`gestdocFk` AS `gestdoc_id`, + `r`.`cost` AS `cost`, + `r`.`m3` AS `m3`, + `r`.`description` AS `description` +FROM `vn`.`route` `r` diff --git a/db/routines/vn2008/views/Tickets_turno.sql b/db/routines/vn2008/views/Tickets_turno.sql new file mode 100644 index 000000000..28bc2d55f --- /dev/null +++ b/db/routines/vn2008/views/Tickets_turno.sql @@ -0,0 +1,6 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`Tickets_turno` +AS SELECT `tw`.`ticketFk` AS `Id_Ticket`, + `tw`.`weekDay` AS `weekDay` +FROM `vn`.`ticketWeekly` `tw` diff --git a/db/routines/vn2008/views/state.sql b/db/routines/vn2008/views/state.sql new file mode 100644 index 000000000..63f6589af --- /dev/null +++ b/db/routines/vn2008/views/state.sql @@ -0,0 +1,13 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`state` +AS SELECT `s`.`id` AS `id`, + `s`.`name` AS `name`, + `s`.`order` AS `order`, + `s`.`alertLevel` AS `alert_level`, + `s`.`code` AS `code`, + `s`.`sectorProdPriority` AS `sectorProdPriority`, + `s`.`nextStateFk` AS `nextStateFk`, + `s`.`isPreviousPreparable` AS `isPreviousPreparable`, + `s`.`isPicked` AS `isPicked` +FROM `vn`.`state` `s` diff --git a/db/routines/vn2008/views/tag.sql b/db/routines/vn2008/views/tag.sql new file mode 100644 index 000000000..25b3ab82e --- /dev/null +++ b/db/routines/vn2008/views/tag.sql @@ -0,0 +1,10 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`tag` +AS SELECT `t`.`id` AS `id`, + `t`.`name` AS `name`, + `t`.`isFree` AS `isFree`, + `t`.`isQuantitatif` AS `isQuantitatif`, + `t`.`sourceTable` AS `sourceTable`, + `t`.`unit` AS `unit` +FROM `vn`.`tag` `t` diff --git a/db/routines/vn2008/views/tarifa_componentes.sql b/db/routines/vn2008/views/tarifa_componentes.sql new file mode 100644 index 000000000..bec53abd9 --- /dev/null +++ b/db/routines/vn2008/views/tarifa_componentes.sql @@ -0,0 +1,10 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`tarifa_componentes` +AS SELECT `tarifa_componentes`.`Id_Componente` AS `Id_Componente`, + `tarifa_componentes`.`Componente` AS `Componente`, + `tarifa_componentes`.`tarifa_componentes_series_id` AS `tarifa_componentes_series_id`, + `tarifa_componentes`.`tarifa_class` AS `tarifa_class`, + `tarifa_componentes`.`tax` AS `tax`, + `tarifa_componentes`.`is_renewable` AS `is_renewable` +FROM `bi`.`tarifa_componentes` diff --git a/db/routines/vn2008/views/tarifa_componentes_series.sql b/db/routines/vn2008/views/tarifa_componentes_series.sql new file mode 100644 index 000000000..a1d188709 --- /dev/null +++ b/db/routines/vn2008/views/tarifa_componentes_series.sql @@ -0,0 +1,7 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`tarifa_componentes_series` +AS SELECT `tarifa_componentes_series`.`tarifa_componentes_series_id` AS `tarifa_componentes_series_id`, + `tarifa_componentes_series`.`Serie` AS `Serie`, + `tarifa_componentes_series`.`base` AS `base` +FROM `bi`.`tarifa_componentes_series` From 5b027a88fa20d99329cf42cc4a7b654bb982884a Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 19 Apr 2024 11:33:33 +0200 Subject: [PATCH 150/161] feat: refs #6777 restore view --- db/routines/vn2008/views/Tickets_state.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 db/routines/vn2008/views/Tickets_state.sql diff --git a/db/routines/vn2008/views/Tickets_state.sql b/db/routines/vn2008/views/Tickets_state.sql new file mode 100644 index 000000000..be59a750f --- /dev/null +++ b/db/routines/vn2008/views/Tickets_state.sql @@ -0,0 +1,7 @@ +CREATE OR REPLACE DEFINER=`root`@`localhost` + SQL SECURITY DEFINER + VIEW `vn2008`.`Tickets_state` +AS SELECT `t`.`ticketFk` AS `Id_Ticket`, + `t`.`ticketTrackingFk` AS `inter_id`, + `t`.`name` AS `state_name` +FROM `vn`.`ticketLastState` `t` From ad317cb5e545f5c53bded7269823ec14c7047bc2 Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 19 Apr 2024 14:11:35 +0200 Subject: [PATCH 151/161] refs #7021 Delete rfid schema --- db/versions/11003-greenRoebelini/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11003-greenRoebelini/00-firstScript.sql diff --git a/db/versions/11003-greenRoebelini/00-firstScript.sql b/db/versions/11003-greenRoebelini/00-firstScript.sql new file mode 100644 index 000000000..97c5f355f --- /dev/null +++ b/db/versions/11003-greenRoebelini/00-firstScript.sql @@ -0,0 +1 @@ +DROP SCHEMA IF EXISTS rfid; From a0126748e2e3da3a2085d887e9cffea36a098ede Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Fri, 19 Apr 2024 14:19:34 +0200 Subject: [PATCH 152/161] fix(binlog): refs #4409 Fix fixtures cursor name --- db/dump/fixtures.before.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 353d4f3e0..ca34284da 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2624,18 +2624,18 @@ BEGIN DECLARE vDone BOOL; DECLARE vTicketFk INT; - DECLARE cCur CURSOR FOR SELECT id FROM vn.ticket; + DECLARE cTickets CURSOR FOR SELECT id FROM vn.ticket; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - OPEN cCur; + OPEN cTickets; myLoop: LOOP SET vDone = FALSE; - FETCH cCur INTO vTicketFk; + FETCH cTickets INTO vTicketFk; IF vDone THEN LEAVE myLoop; END IF; CALL vn.ticket_recalc(vTicketFk, NULL); END LOOP; - CLOSE cCur; + CLOSE cTickets; END$$ DELIMITER ; From 0615510a9cc7a4090da2e3474ed45c70ef319055 Mon Sep 17 00:00:00 2001 From: ivanm Date: Fri, 19 Apr 2024 15:28:53 +0200 Subject: [PATCH 153/161] refs #7021 Modify myt.config.yml --- myt.config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/myt.config.yml b/myt.config.yml index 2ac8b8e5e..d94913b05 100755 --- a/myt.config.yml +++ b/myt.config.yml @@ -15,7 +15,6 @@ schemas: - hedera - pbx - psico - - rfid - sage - salix - srt From 283d27e1c5b5a7402fe312127f115bf848abf180 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 22 Apr 2024 06:22:36 +0000 Subject: [PATCH 154/161] Actualizar modules/worker/back/models/worker.json --- modules/worker/back/models/worker.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index f959d3138..c9db0aeee 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -99,7 +99,7 @@ { "relation": "user", "scope": { - "fields": ["email", "name", "nickname", "roleFk", "name", "emailVerified","recoveryPhone"], + "fields": ["email", "name", "nickname", "roleFk", "name", "emailVerified"], "include": [ { "relation": "role", From f6199f8f8ede30cf3097d8a4de14780bb41cd107 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 22 Apr 2024 06:56:05 +0000 Subject: [PATCH 155/161] Actualizar modules/worker/back/models/worker.json --- modules/worker/back/models/worker.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index c9db0aeee..c203f6e09 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -99,7 +99,7 @@ { "relation": "user", "scope": { - "fields": ["email", "name", "nickname", "roleFk", "name", "emailVerified"], + "fields": ["email", "name", "nickname", "roleFk", "emailVerified"], "include": [ { "relation": "role", From 739ae82ace3c34c9737bd7269376b3ce06ad1a59 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 22 Apr 2024 09:02:43 +0200 Subject: [PATCH 156/161] fix(binlog): refs #4409 Fix cursor name --- db/routines/util/functions/binlogQueue_getDelay.sql | 1 + db/routines/vn/procedures/ticket_recalcByScope.sql | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/db/routines/util/functions/binlogQueue_getDelay.sql b/db/routines/util/functions/binlogQueue_getDelay.sql index a440fc0ab..d6cf49377 100644 --- a/db/routines/util/functions/binlogQueue_getDelay.sql +++ b/db/routines/util/functions/binlogQueue_getDelay.sql @@ -1,6 +1,7 @@ DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `util`.`binlogQueue_getDelay`(vCode VARCHAR(255)) RETURNS BIGINT + READS SQL DATA NOT DETERMINISTIC BEGIN /** diff --git a/db/routines/vn/procedures/ticket_recalcByScope.sql b/db/routines/vn/procedures/ticket_recalcByScope.sql index e20244648..41105fe23 100644 --- a/db/routines/vn/procedures/ticket_recalcByScope.sql +++ b/db/routines/vn/procedures/ticket_recalcByScope.sql @@ -13,7 +13,7 @@ BEGIN DECLARE vDone BOOL; DECLARE vTicketFk INT; - DECLARE cCur CURSOR FOR + DECLARE cTickets CURSOR FOR SELECT id FROM ticket WHERE refFk IS NULL AND ((vScope = 'client' AND clientFk = vId) @@ -22,11 +22,11 @@ BEGIN DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - OPEN cCur; + OPEN cTickets; myLoop: LOOP SET vDone = FALSE; - FETCH cCur INTO vTicketFk; + FETCH cTickets INTO vTicketFk; IF vDone THEN LEAVE myLoop; @@ -35,6 +35,6 @@ BEGIN CALL ticket_recalc(vTicketFk, NULL); END LOOP; - CLOSE cCur; + CLOSE cTickets; END$$ DELIMITER ; From b88dff0d997e66e1ad6295a23d7a3eb01b426141 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 22 Apr 2024 10:48:37 +0200 Subject: [PATCH 157/161] feat: refs #6777 --- db/routines/vn/functions/getAlert3StateTest.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/functions/getAlert3StateTest.sql b/db/routines/vn/functions/getAlert3StateTest.sql index beba0948c..f1a8ac4cc 100644 --- a/db/routines/vn/functions/getAlert3StateTest.sql +++ b/db/routines/vn/functions/getAlert3StateTest.sql @@ -13,7 +13,7 @@ BEGIN INTO vDeliveryType FROM ticket t JOIN vn2008.Agencias a ON a.Id_Agencia = t.agencyModeFk - WHERE id = vTicket; + WHERE t.id = vTicket; CASE vDeliveryType WHEN 1 THEN -- AGENCIAS From eb9f81c81d94ab6bd91d18c289607cf1dd18cc7f Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 22 Apr 2024 13:05:16 +0200 Subject: [PATCH 158/161] feat #7181 Rollback creditInsurance_getRisk --- .../vn/procedures/creditInsurance_getRisk.sql | 42 +++++++++++++++++++ .../10990-yellowPalmetto/00-firstScript.sql | 8 +++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 db/routines/vn/procedures/creditInsurance_getRisk.sql diff --git a/db/routines/vn/procedures/creditInsurance_getRisk.sql b/db/routines/vn/procedures/creditInsurance_getRisk.sql new file mode 100644 index 000000000..8ddb9d721 --- /dev/null +++ b/db/routines/vn/procedures/creditInsurance_getRisk.sql @@ -0,0 +1,42 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditInsurance_getRisk`() +BEGIN +/** +* Devuelve el riesgo de los clientes que estan asegurados +*/ + CREATE OR REPLACE TEMPORARY TABLE tmp.clientGetDebt + (PRIMARY KEY (clientFk)) + ENGINE = MEMORY + SELECT * FROM ( + SELECT cc.client clientFk, ci.grade + FROM creditClassification cc + JOIN 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()); + + SELECT c.id, + c.name, + c.credit clientCredit, + c.creditInsurance solunion, + CAST(r.risk AS DECIMAL(10,0)) risk, + CAST(c.creditInsurance - r.risk AS DECIMAL(10,0)) riskAlive, + cac.invoiced billedAnnually, + c.dueDay, + cgd.grade, + c2.country + FROM tmp.clientGetDebt cgd + LEFT JOIN tmp.risk r ON r.clientFk = cgd.clientFk + JOIN client c ON c.id = cgd.clientFk + JOIN bs.clientAnnualConsumption cac ON c.id = cac.clientFk + JOIN country c2 ON c2.id = c.countryFk + GROUP BY c.id; + + DROP TEMPORARY TABLE + tmp.risk, + tmp.clientGetDebt; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/versions/10990-yellowPalmetto/00-firstScript.sql b/db/versions/10990-yellowPalmetto/00-firstScript.sql index be866af8c..56b1541fb 100644 --- a/db/versions/10990-yellowPalmetto/00-firstScript.sql +++ b/db/versions/10990-yellowPalmetto/00-firstScript.sql @@ -2,4 +2,10 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_getRisk`() BEGIN END; -GRANT EXECUTE ON PROCEDURE vn.client_getRisk TO financialBoss; +GRANT EXECUTE ON PROCEDURE vn.client_getRisk TO financial; + +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`creditInsurance_getRisk`() +BEGIN +END; + +GRANT EXECUTE ON PROCEDURE vn.creditInsurance_getRisk TO financial; From 85491613b0d536f1562ad3accdcb0b75982164b9 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Apr 2024 08:47:28 +0200 Subject: [PATCH 159/161] test: refs #7173 fix fixtures --- db/dump/fixtures.before.sql | 2 +- .../invoiceIn/back/methods/invoice-in/specs/filter.spec.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 219686fac..ff58af2e2 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2617,7 +2617,7 @@ INSERT INTO `vn`.`invoiceInIntrastat` (`invoiceInFk`, `net`, `intrastatFk`, `amo UPDATE `vn`.`invoiceIn` SET isBooked = TRUE - WHERE id IN (2, 5, 7, 8, 9, 10); + WHERE id IN (5, 7, 8, 9, 10); DELIMITER $$ CREATE PROCEDURE `tmp`.`ticket_recalc`() diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js index 3ff5a92f3..ff2164783 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js @@ -158,7 +158,7 @@ describe('InvoiceIn filter()', () => { const result = await models.InvoiceIn.filter(ctx, {}, options); - expect(result.length).toEqual(4); + expect(result.length).toEqual(5); await tx.rollback(); } catch (e) { @@ -180,7 +180,7 @@ describe('InvoiceIn filter()', () => { const result = await models.InvoiceIn.filter(ctx, {}, options); - expect(result.length).toEqual(6); + expect(result.length).toEqual(5); expect(result[0].isBooked).toBeTruthy(); await tx.rollback(); From 60d5b9e4aaa5c64354740fe8fd68deeb30173d49 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 23 Apr 2024 08:47:52 +0200 Subject: [PATCH 160/161] test: refs #7173 fix sql, adding alias --- .../route/back/methods/route/getTickets.js | 96 +++++++++---------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/modules/route/back/methods/route/getTickets.js b/modules/route/back/methods/route/getTickets.js index 2393018cf..0e7c9fe20 100644 --- a/modules/route/back/methods/route/getTickets.js +++ b/modules/route/back/methods/route/getTickets.js @@ -33,54 +33,54 @@ module.exports = Self => { const stmt = new ParameterizedSQL( `SELECT - t.id, - t.packages, - t.warehouseFk, - t.nickname, - t.clientFk, - t.priority, - t.addressFk, - st.code ticketStateCode, - st.name ticketStateName, - wh.name warehouseName, - tob.description observationDelivery, - tob2.description observationDropOff, - tob2.id, - a.street, - a.postalCode, - a.city, - am.name agencyModeName, - u.nickname userNickname, - vn.ticketTotalVolume(t.id) volume, - GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, - c.phone clientPhone, - c.mobile clientMobile, - a.phone addressPhone, - a.mobile addressMobile, - a.longitude, - a.latitude, - wm.mediaValue salePersonPhone, - t.cmrFk, - t.isSigned signed - FROM vn.route r - JOIN ticket t ON t.routeFk = r.id - JOIN client c ON t.clientFk = c.id - LEFT JOIN vn.sale s ON s.ticketFk = t.id - LEFT JOIN vn.item i ON i.id = s.itemFk - LEFT JOIN ticketState ts ON ts.ticketFk = t.id - LEFT JOIN state st ON st.id = ts.stateFk - LEFT JOIN warehouse wh ON wh.id = t.warehouseFk - LEFT JOIN observationType ot ON ot.code = 'delivery' - LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id - AND tob.observationTypeFk = ot.id - LEFT JOIN observationType ot2 ON ot2.code = 'dropOff' - LEFT JOIN ticketObservation tob2 ON tob2.ticketFk = t.id - AND tob2.observationTypeFk = ot2.id - LEFT JOIN address a ON a.id = t.addressFk - LEFT JOIN agencyMode am ON am.id = t.agencyModeFk - LEFT JOIN account.user u ON u.id = r.workerFk - LEFT JOIN vehicle v ON v.id = r.vehicleFk - LEFT JOIN workerMedia wm ON wm.workerFk = c.salesPersonFk` + t.id, + t.packages, + t.warehouseFk, + t.nickname, + t.clientFk, + t.priority, + t.addressFk, + st.code ticketStateCode, + st.name ticketStateName, + wh.name warehouseName, + tob.description observationDelivery, + tob2.description observationDropOff, + tob2.id observationId, + a.street, + a.postalCode, + a.city, + am.name agencyModeName, + u.nickname userNickname, + vn.ticketTotalVolume(t.id) volume, + GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk) ipt, + c.phone clientPhone, + c.mobile clientMobile, + a.phone addressPhone, + a.mobile addressMobile, + a.longitude, + a.latitude, + wm.mediaValue salePersonPhone, + t.cmrFk, + t.isSigned signed + FROM vn.route r + JOIN ticket t ON t.routeFk = r.id + JOIN client c ON t.clientFk = c.id + LEFT JOIN vn.sale s ON s.ticketFk = t.id + LEFT JOIN vn.item i ON i.id = s.itemFk + LEFT JOIN ticketState ts ON ts.ticketFk = t.id + LEFT JOIN state st ON st.id = ts.stateFk + LEFT JOIN warehouse wh ON wh.id = t.warehouseFk + LEFT JOIN observationType ot ON ot.code = 'delivery' + LEFT JOIN ticketObservation tob ON tob.ticketFk = t.id + AND tob.observationTypeFk = ot.id + LEFT JOIN observationType ot2 ON ot2.code = 'dropOff' + LEFT JOIN ticketObservation tob2 ON tob2.ticketFk = t.id + AND tob2.observationTypeFk = ot2.id + LEFT JOIN address a ON a.id = t.addressFk + LEFT JOIN agencyMode am ON am.id = t.agencyModeFk + LEFT JOIN account.user u ON u.id = r.workerFk + LEFT JOIN vehicle v ON v.id = r.vehicleFk + LEFT JOIN workerMedia wm ON wm.workerFk = c.salesPersonFk` ); if (!filter.where) filter.where = {}; From 06e743f5daea979efe0deec892c53d94fb36299b Mon Sep 17 00:00:00 2001 From: pablone Date: Tue, 23 Apr 2024 10:00:11 +0200 Subject: [PATCH 161/161] fix: refs #7253 check booked add new restriction to be tested --- e2e/paths/12-entry/05_basicData.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/paths/12-entry/05_basicData.spec.js b/e2e/paths/12-entry/05_basicData.spec.js index 15282820e..f1f14f8da 100644 --- a/e2e/paths/12-entry/05_basicData.spec.js +++ b/e2e/paths/12-entry/05_basicData.spec.js @@ -76,6 +76,6 @@ describe('Entry basic data path', () => { expect(confirmed).toBe('checked'); expect(inventory).toBe('checked'); expect(raid).toBe('checked'); - expect(booked).toBe('checked'); + expect(booked).toBe('unchecked'); }); });