From 6fbc5a1a544e3feff1e9a6feb05785db15eda975 Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 30 Sep 2024 09:17:27 +0200 Subject: [PATCH 001/219] feat: refs #7202 added new field --- db/dump/fixtures.before.sql | 98 +++++++++---------- .../11269-wheatBirch/00-firstScript.sql | 9 ++ .../back/methods/invoiceOut/filter.js | 14 ++- .../invoiceOut/back/models/invoice-out.json | 5 + 4 files changed, 75 insertions(+), 51 deletions(-) create mode 100644 db/versions/11269-wheatBirch/00-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index ffbc6a864..33090d7a6 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -425,50 +425,50 @@ INSERT INTO `vn`.`clientConfig`(`id`, `riskTolerance`, `maxCreditRows`, `maxPric (1, 200, 10, 0.25, 2, 4, 5, 300.00, 1, 1, 2); -INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`, `isDefaultAddress`) +INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`, `isDefaultAddress`, `customsAgentFk`) VALUES - (1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 1), - (2, 'Petter Parker', '20 Ingram Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 1), - (3, 'Clark Kent', '344 Clinton Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 1), - (4, 'Tony Stark', '10880 Malibu Point', 'Gotham', 46460, 1, 1111111111, 222222222, 1 , 1104, 2, NULL, NULL, 0, 1), - (5, 'Max Eisenhardt', 'Unknown Whereabouts', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 1), - (6, 'DavidCharlesHaller', 'Evil hideout', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 1), - (7, 'Hank Pym', 'Anthill', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 1), - (8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Gotham', 46460, 5, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 1), - (9, 'Bruce Banner', 'Somewhere in New York', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 1), - (10, 'Jessica Jones', 'NYCC 2015 Poster', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 1), - (11, 'Missing', 'The space', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1111, 10, NULL, NULL, 0, 1), - (12, 'Trash', 'New York city', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1112, 10, NULL, NULL, 0, 1), - (101, 'Somewhere in Thailand', 'address 01', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (102, 'Somewhere in Poland', 'address 02', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0), - (103, 'Somewhere in Japan', 'address 03', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0), - (104, 'Somewhere in Spain', 'address 04', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0), - (105, 'Somewhere in Potugal', 'address 05', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0), - (106, 'Somewhere in UK', 'address 06', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0), - (107, 'Somewhere in Valencia', 'address 07', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0), - (108, 'Somewhere in Gotham', 'address 08', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0), - (109, 'Somewhere in London', 'address 09', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (110, 'Somewhere in Algemesi', 'address 10', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (111, 'Somewhere in Carlet', 'address 11', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (112, 'Somewhere in Campanar', 'address 12', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (113, 'Somewhere in Malilla', 'address 13', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (114, 'Somewhere in France', 'address 14', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (115, 'Somewhere in Birmingham', 'address 15', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (116, 'Somewhere in Scotland', 'address 16', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (117, 'Somewhere in nowhere', 'address 17', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (118, 'Somewhere over the rainbow', 'address 18', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (119, 'Somewhere in Alberic', 'address 19', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (120, 'Somewhere in Montortal', 'address 20', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), - (121, 'the bat cave', 'address 21', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 0), - (122, 'NY roofs', 'address 22', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 0), - (123, 'The phone box', 'address 23', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 0), - (124, 'Stark tower Gotham', 'address 24', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 0), - (125, 'The plastic cell', 'address 25', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 0), - (126, 'Many places', 'address 26', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 0), - (127, 'Your pocket', 'address 27', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 0), - (128, 'Cerebro', 'address 28', 'Gotham', 46460, 5, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 0), - (129, 'Luke Cages Bar', 'address 29', 'Gotham', 'EC170150', 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 0), - (130, 'Non valid address', 'address 30', 'Gotham', 46460, 1, 1111111111, 222222222, 0, 1101, 2, NULL, NULL, 0, 0); + (1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 1, 1), + (2, 'Petter Parker', '20 Ingram Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 1, NULL), + (3, 'Clark Kent', '344 Clinton Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 1, NULL), + (4, 'Tony Stark', '10880 Malibu Point', 'Gotham', 46460, 1, 1111111111, 222222222, 1 , 1104, 2, NULL, NULL, 0, 1, NULL), + (5, 'Max Eisenhardt', 'Unknown Whereabouts', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 1, NULL), + (6, 'DavidCharlesHaller', 'Evil hideout', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 1, NULL), + (7, 'Hank Pym', 'Anthill', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 1, NULL), + (8, 'Charles Xavier', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Gotham', 46460, 5, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 1, NULL), + (9, 'Bruce Banner', 'Somewhere in New York', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 1, NULL), + (10, 'Jessica Jones', 'NYCC 2015 Poster', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 1, NULL), + (11, 'Missing', 'The space', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1111, 10, NULL, NULL, 0, 1, NULL), + (12, 'Trash', 'New York city', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1112, 10, NULL, NULL, 0, 1, NULL), + (101, 'Somewhere in Thailand', 'address 01', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (102, 'Somewhere in Poland', 'address 02', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (103, 'Somewhere in Japan', 'address 03', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (104, 'Somewhere in Spain', 'address 04', 'Gotham', 46460, 1, 3333333333, 444444444, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (105, 'Somewhere in Potugal', 'address 05', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (106, 'Somewhere in UK', 'address 06', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (107, 'Somewhere in Valencia', 'address 07', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (108, 'Somewhere in Gotham', 'address 08', 'Gotham', 46460, 1, 5555555555, 666666666, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (109, 'Somewhere in London', 'address 09', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (110, 'Somewhere in Algemesi', 'address 10', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (111, 'Somewhere in Carlet', 'address 11', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (112, 'Somewhere in Campanar', 'address 12', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (113, 'Somewhere in Malilla', 'address 13', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (114, 'Somewhere in France', 'address 14', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (115, 'Somewhere in Birmingham', 'address 15', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (116, 'Somewhere in Scotland', 'address 16', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (117, 'Somewhere in nowhere', 'address 17', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (118, 'Somewhere over the rainbow', 'address 18', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (119, 'Somewhere in Alberic', 'address 19', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (120, 'Somewhere in Montortal', 'address 20', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0, NULL), + (121, 'the bat cave', 'address 21', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 0, NULL), + (122, 'NY roofs', 'address 22', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 0, NULL), + (123, 'The phone box', 'address 23', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 0, NULL), + (124, 'Stark tower Gotham', 'address 24', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 0, NULL), + (125, 'The plastic cell', 'address 25', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 0, NULL), + (126, 'Many places', 'address 26', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 0, NULL), + (127, 'Your pocket', 'address 27', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 0, NULL), + (128, 'Cerebro', 'address 28', 'Gotham', 46460, 5, 1111111111, 222222222, 1, 1108, 2, NULL, NULL, 0, 0, NULL), + (129, 'Luke Cages Bar', 'address 29', 'Gotham', 'EC170150', 1, 1111111111, 222222222, 1, 1110, 2, NULL, NULL, 0, 0, NULL), + (130, 'Non valid address', 'address 30', 'Gotham', 46460, 1, 1111111111, 222222222, 0, 1101, 2, NULL, NULL, 0, 0, NULL); INSERT INTO `vn`.`address`( `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `isActive`, `clientFk`, `agencyModeFk`, `isDefaultAddress`) SELECT name, CONCAT(name, 'Street'), 'GOTHAM', 46460, 1, 1, id, 2, 1 @@ -639,13 +639,13 @@ INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaF ('R', 'Rectificativa', 1, 'NATIONAL', 0, NULL), ('E', 'Exportación rápida', 0, 'WORLD', 0, 'quick'); -INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`) +INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`, `customsAgentFk`) VALUES - (1, 'T', 1026.24, util.VN_CURDATE(), 1101, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), - (2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), - (3, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), - (4, 'T', 8.88, util.VN_CURDATE(), 1104, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0), - (5, 'A', 8.88, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 0); + (1, 'T', 1026.24, util.VN_CURDATE(), 1101, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0, 1), + (2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0, NULL), + (3, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0, NULL), + (4, 'T', 8.88, util.VN_CURDATE(), 1104, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0, NULL), + (5, 'A', 8.88, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 0, NULL); UPDATE `vn`.`invoiceOut` SET ref = 'T1111111' WHERE id = 1; UPDATE `vn`.`invoiceOut` SET ref = 'T2222222' WHERE id = 2; diff --git a/db/versions/11269-wheatBirch/00-firstScript.sql b/db/versions/11269-wheatBirch/00-firstScript.sql new file mode 100644 index 000000000..b2f113167 --- /dev/null +++ b/db/versions/11269-wheatBirch/00-firstScript.sql @@ -0,0 +1,9 @@ +ALTER TABLE vn.invoiceOut ADD COLUMN IF NOT EXISTS customsAgentFk INT(11) DEFAULT NULL AFTER siiTrascendencyInvoiceOutFk; + +ALTER TABLE vn.invoiceOut ADD CONSTRAINT invoiceOut_customsAgentFk FOREIGN KEY (customsAgentFk) + REFERENCES vn.customsAgent (id) ON DELETE RESTRICT ON UPDATE CASCADE; + +UPDATE vn.invoiceOut i + JOIN vn.client c ON c.id = io.clientFk + JOIN vn.address a ON a.id = c.defaultAddressFk + SET i.customsAgentFk = a.customsAgentFk; \ No newline at end of file diff --git a/modules/invoiceOut/back/methods/invoiceOut/filter.js b/modules/invoiceOut/back/methods/invoiceOut/filter.js index 99a80c169..3b6aa4d82 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/filter.js +++ b/modules/invoiceOut/back/methods/invoiceOut/filter.js @@ -73,6 +73,12 @@ module.exports = Self => { type: 'date', description: 'The due date filter', http: {source: 'query'} + }, + { + arg: 'customsAgentFk', + type: 'integer', + description: 'The customsAgent id', + http: {source: 'query'} } ], returns: { @@ -112,6 +118,7 @@ module.exports = Self => { case 'companyFk': case 'issued': case 'dued': + case 'customsAgentFk': param = `i.${param}`; return {[param]: value}; } @@ -131,11 +138,14 @@ module.exports = Self => { i.dued, i.clientFk, i.hasPdf, + i.customsAgentFk, c.socialName AS clientSocialName, - co.code AS companyCode + co.code AS companyCode, + ca.fiscalName AS customsAgentName FROM invoiceOut i LEFT JOIN client c ON c.id = i.clientFk - LEFT JOIN company co ON co.id = i.companyFk` + LEFT JOIN company co ON co.id = i.companyFk + LEFT JOIN customsAgent ca ON ca.id = i.customsAgentFk` ); stmt.merge(conn.makeSuffix(filter)); diff --git a/modules/invoiceOut/back/models/invoice-out.json b/modules/invoiceOut/back/models/invoice-out.json index 1ee36accb..2ad13fe3f 100644 --- a/modules/invoiceOut/back/models/invoice-out.json +++ b/modules/invoiceOut/back/models/invoice-out.json @@ -66,6 +66,11 @@ "model": "Ticket", "foreignKey": "refFk", "primaryKey": "ref" + }, + "customsAgentFk": { + "type": "belongsTo", + "model": "CustomsAgent", + "foreignKey": "customsAgentFk" } } } From da749a5dcbe9cbc648ec16281d80a96493acda4b Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 30 Sep 2024 09:21:05 +0200 Subject: [PATCH 002/219] fix: refs #7202 fixed sql --- db/versions/11269-wheatBirch/00-firstScript.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/versions/11269-wheatBirch/00-firstScript.sql b/db/versions/11269-wheatBirch/00-firstScript.sql index b2f113167..6a50e5232 100644 --- a/db/versions/11269-wheatBirch/00-firstScript.sql +++ b/db/versions/11269-wheatBirch/00-firstScript.sql @@ -3,7 +3,7 @@ ALTER TABLE vn.invoiceOut ADD COLUMN IF NOT EXISTS customsAgentFk INT(11) DEFAUL ALTER TABLE vn.invoiceOut ADD CONSTRAINT invoiceOut_customsAgentFk FOREIGN KEY (customsAgentFk) REFERENCES vn.customsAgent (id) ON DELETE RESTRICT ON UPDATE CASCADE; -UPDATE vn.invoiceOut i +UPDATE vn.invoiceOut io JOIN vn.client c ON c.id = io.clientFk JOIN vn.address a ON a.id = c.defaultAddressFk - SET i.customsAgentFk = a.customsAgentFk; \ No newline at end of file + SET io.customsAgentFk = a.customsAgentFk; \ No newline at end of file From 451e3bebefaad230d5eb30222aa07afff29d6e3b Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 30 Sep 2024 09:45:55 +0200 Subject: [PATCH 003/219] fix: refs #7202 fixed back test --- .../client/back/methods/client/specs/updateAddress.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/client/back/methods/client/specs/updateAddress.spec.js b/modules/client/back/methods/client/specs/updateAddress.spec.js index 68981f8b7..0453332d7 100644 --- a/modules/client/back/methods/client/specs/updateAddress.spec.js +++ b/modules/client/back/methods/client/specs/updateAddress.spec.js @@ -1,7 +1,7 @@ const models = require('vn-loopback/server/server').models; describe('Address updateAddress', () => { - const clientId = 1101; - const addressId = 1; + const clientId = 1102; + const addressId = 2; const provinceId = 5; const incotermsId = 'FAS'; const customAgentOneId = 1; From a6799cba0ff74c1740220430b18ad38fea1f5a79 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 1 Oct 2024 10:39:57 +0200 Subject: [PATCH 004/219] refactor: refs #7202 modified procedure to include customsAgent field when creating an invoice --- db/routines/vn/procedures/invoiceOut_new.sql | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/invoiceOut_new.sql b/db/routines/vn/procedures/invoiceOut_new.sql index 723f33df5..6f2f7f8ff 100644 --- a/db/routines/vn/procedures/invoiceOut_new.sql +++ b/db/routines/vn/procedures/invoiceOut_new.sql @@ -105,7 +105,8 @@ BEGIN clientFk, dued, companyFk, - siiTypeInvoiceOutFk + siiTypeInvoiceOutFk, + customsAgentFk ) SELECT 1, @@ -118,9 +119,11 @@ BEGIN vCplusCorrectingInvoiceTypeFk, IF(vSerial = vSimplifiedSerial, vCplusSimplifiedInvoiceTypeFk, - vCplusStandardInvoiceTypeFk)) - FROM client - WHERE id = vClientFk; + vCplusStandardInvoiceTypeFk)), + a.customsAgentFk + FROM client c + JOIN address a ON a.id = c.defaultAddressFk + WHERE c.id = vClientFk; SET vNewInvoiceId = LAST_INSERT_ID(); From ca3ac64072f0480650b7f9dd623e99b1d75172a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 1 Oct 2024 16:37:12 +0200 Subject: [PATCH 005/219] feat: refs #4460 invoiceIn refund --- db/routines/sage/procedures/invoiceIn_add.sql | 18 +++---- .../sage/procedures/invoiceOut_add.sql | 5 +- .../00-firstScript.sql | 47 +++++++++++++++++++ 3 files changed, 59 insertions(+), 11 deletions(-) create mode 100644 db/versions/11266-goldenChrysanthemum/00-firstScript.sql diff --git a/db/routines/sage/procedures/invoiceIn_add.sql b/db/routines/sage/procedures/invoiceIn_add.sql index 0898d6810..ba7a0c6c0 100644 --- a/db/routines/sage/procedures/invoiceIn_add.sql +++ b/db/routines/sage/procedures/invoiceIn_add.sql @@ -4,10 +4,10 @@ BEGIN /** * Traslada la info de contabilidad relacionada con las facturas recibidas * - * @vInvoiceInFk Factura recibida - * @vXDiarioFk Id tabla XDiario + * @param vInvoiceInFk Factura recibida + * @param vXDiarioFk Id tabla XDiario */ - DECLARE vInvoiceInOriginalFk INT; + DECLARE vInvoiceInOriginalFk INT; DECLARE vDone BOOL DEFAULT FALSE; DECLARE vBase DOUBLE; DECLARE vVat DOUBLE; @@ -204,9 +204,9 @@ BEGIN WHERE correctingFk = vInvoiceInFk; IF vInvoiceInOriginalFk THEN - UPDATE movContaIVA mci - JOIN vn.invoiceInRefund iir ON iir.invoiceInRefundFk = vInvoiceInFk + JOIN vn.invoiceInCorrection iic ON iic.correctingFk = vInvoiceInFk + JOIN vn.siiTypeInvoiceOut st ON st.id = iic.siiTypeInvoiceOutFk JOIN (SELECT issued, SUM(sub.taxableBase) taxableBase, SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat @@ -215,20 +215,20 @@ BEGIN ti.PorcentajeIva FROM vn.invoiceIn i JOIN vn.invoiceInTax iit ON iit.invoiceInFk = i.id - JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk + JOIN TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk WHERE i.id = vInvoiceInOriginalFk GROUP BY ti.CodigoIva)sub )invoiceInOriginal JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa' - SET mci.TipoRectificativa = iir.refundCategoryFk, - mci.ClaseAbonoRectificativas = iir.refundType, + SET mci.TipoRectificativa = iic.cplusRectificationTypeFk, + mci.ClaseAbonoRectificativas = REGEXP_REPLACE(st.`code`, '[^0-9]', ''), mci.FechaFacturaOriginal = invoiceInOriginal.issued, mci.FechaOperacion = invoiceInOriginal.issued, mci.BaseImponibleOriginal = invoiceInOriginal.taxableBase, mci.CuotaIvaOriginal = invoiceInOriginal.vat, mci.ClaveOperacionFactura = co.ClaveOperacionFactura_ WHERE mci.id = vXDiarioFk; - END IF; END$$ +$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/sage/procedures/invoiceOut_add.sql b/db/routines/sage/procedures/invoiceOut_add.sql index 95d6a56dd..f9c6f6b87 100644 --- a/db/routines/sage/procedures/invoiceOut_add.sql +++ b/db/routines/sage/procedures/invoiceOut_add.sql @@ -169,6 +169,7 @@ BEGIN UPDATE movContaIVA mci JOIN vn.invoiceOut i ON i.id = vInvoiceOutCorrectedFk JOIN vn.invoiceCorrection ic ON ic.correctedFk = vInvoiceOutCorrectedFk + JOIN vn.siiTypeInvoiceOut st ON st.id = ic.siiTypeInvoiceOutFk JOIN (SELECT SUM(IF(IFNULL(e.vatFk, TRUE), iot.taxableBase, 0)) taxableBase, SUM(IF(IFNULL(e.vatFk, TRUE), iot.vat, 0)) vat, SUM(IF(IFNULL(e.vatFk, TRUE), 0, iot.vat)) equ @@ -177,8 +178,8 @@ BEGIN WHERE iot.invoiceOutFk = vInvoiceOutCorrectedFk ) tax JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa' - SET mci.TipoRectificativa = 2, - mci.ClaseAbonoRectificativas = 1, + SET mci.TipoRectificativa = ic.cplusRectificationTypeFk, + mci.ClaseAbonoRectificativas = REGEXP_REPLACE(st.`code`, '[^0-9]', ''), mci.FechaFacturaOriginal = i.issued, mci.FechaOperacion = i.issued, mci.BaseImponibleOriginal = tax.taxableBase, diff --git a/db/versions/11266-goldenChrysanthemum/00-firstScript.sql b/db/versions/11266-goldenChrysanthemum/00-firstScript.sql new file mode 100644 index 000000000..37143c99b --- /dev/null +++ b/db/versions/11266-goldenChrysanthemum/00-firstScript.sql @@ -0,0 +1,47 @@ + USE vn; + + DROP TRIGGER IF EXISTS invoiceIn_beforeUpdate; + + UPDATE vn.invoiceIn + SET cplusRectificationTypeFk = NULL + WHERE cplusRectificationTypeFk = 1; + + DELETE IGNORE FROM vn.cplusRectificationType WHERE id = 1; + + UPDATE vn.cplusRectificationType + SET id = 1 + WHERE id = 3; + +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceIn_beforeUpdate` + BEFORE UPDATE ON `invoiceIn` + FOR EACH ROW +BEGIN + DECLARE vWithholdingSageFk INT; + + IF NOT (NEW.supplierRef <=> OLD.supplierRef) AND NOT util.checkPrintableChars(NEW.supplierRef) THEN + CALL util.throw('The invoiceIn reference contains invalid characters'); + END IF; + + SET NEW.editorFk = account.myUser_getId(); + + IF (SELECT COUNT(*) FROM vn.invoiceIn + WHERE supplierRef = NEW.supplierRef + AND supplierFk = NEW.supplierFk + AND YEAR(issued) = YEAR(NEW.issued) + AND id <> NEW.id + ) THEN + CALL util.throw('reference duplicated'); + END IF; + + IF NEW.supplierFk != OLD.supplierFk THEN + CALL supplier_checkIsActive(NEW.supplierFk); + SELECT withholdingSageFk INTO vWithholdingSageFk + FROM vn.supplier + WHERE id = NEW.supplierFk; + SET NEW.withholdingSageFk = vWithholdingSageFk; + END IF; + +END$$ +DELIMITER ; + From 2a1fa8ca68d34e67767c954fa808c1f51d5e728b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 1 Oct 2024 18:55:29 +0200 Subject: [PATCH 006/219] feat: refs #4466 invoiceIn refund --- db/routines/vn/procedures/invoiceIn_booking.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/invoiceIn_booking.sql b/db/routines/vn/procedures/invoiceIn_booking.sql index 36189afcc..3d1ca402a 100644 --- a/db/routines/vn/procedures/invoiceIn_booking.sql +++ b/db/routines/vn/procedures/invoiceIn_booking.sql @@ -43,7 +43,7 @@ BEGIN ii.cplusTaxBreakFk, ii.cplusSubjectOpFk, ii.siiTypeInvoiceInFk, - ii.cplusRectificationTypeFk, + ic.cplusRectificationTypeFk, ii.booked, IFNULL(a.isUeeMember, c.isUeeMember) isUeeMember, (c.id = cc.id) isSameCountry, @@ -66,6 +66,7 @@ BEGIN e.name expenseName FROM invoiceIn ii JOIN supplier s ON s.id = ii.supplierFk + LEFT JOIN invoiceInCorrection ic ON ic.correctingFk = ii.id LEFT JOIN province p ON p.id = s.provinceFk LEFT JOIN autonomy a ON a.id = p.autonomyFk JOIN country c ON c.id = s.countryFk From bca22e8ad3ce93392f5701cb347bdf9a772fed90 Mon Sep 17 00:00:00 2001 From: carlossa Date: Sun, 20 Oct 2024 15:17:17 +0200 Subject: [PATCH 007/219] fix: refs #6389 saleMonitor filter --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 927f49999..0fa2e60e5 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -194,6 +194,7 @@ module.exports = Self => { u.name userName, c.salesPersonFk, c.credit, + pm.name payMethod, z.hour zoneLanding, z.name zoneName, z.id zoneFk, @@ -211,6 +212,7 @@ module.exports = Self => { LEFT JOIN ticketState ts ON ts.ticketFk = t.id LEFT JOIN state st ON st.id = ts.stateFk LEFT JOIN client c ON c.id = t.clientFk + LEFT JOIN payMethod pm ON pm.id = c.payMethodFk LEFT JOIN worker wk ON wk.id = c.salesPersonFk LEFT JOIN account.user u ON u.id = wk.id LEFT JOIN ( From 2ec0d7f186526d774a79ca07f80da9d9f6efc793 Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 23 Oct 2024 08:10:00 +0200 Subject: [PATCH 008/219] refactor: refs #7202 modified new invoice procedure and incoterms sql --- db/dump/fixtures.before.sql | 12 ++++----- db/routines/vn/procedures/invoiceOut_new.sql | 15 +++++++---- .../11269-wheatBirch/00-firstScript.sql | 12 ++++++--- .../invoice-incoterms/sql/incoterms.sql | 27 +++++++++++-------- 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index e48fb36b0..a418876b0 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -639,13 +639,13 @@ INSERT INTO `vn`.`invoiceOutSerial` (`code`, `description`, `isTaxed`, `taxAreaF ('R', 'Rectificativa', 1, 'NATIONAL', 0, NULL), ('E', 'Exportación rápida', 0, 'WORLD', 0, 'quick'); -INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`, `customsAgentFk`) +INSERT INTO `vn`.`invoiceOut`(`id`, `serial`, `amount`, `issued`,`clientFk`, `created`, `companyFk`, `dued`, `booked`, `bankFk`, `hasPdf`, `customsAgentFk`, `incotermsFk`) VALUES - (1, 'T', 1026.24, util.VN_CURDATE(), 1101, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0, 1), - (2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0, NULL), - (3, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0, NULL), - (4, 'T', 8.88, util.VN_CURDATE(), 1104, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0, NULL), - (5, 'A', 8.88, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 0, NULL); + (1, 'E', 1026.24, util.VN_CURDATE(), 1101, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0, 1, 'FAS'), + (2, 'T', 121.36, util.VN_CURDATE(), 1102, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0, NULL, NULL), + (3, 'T', 8.88, util.VN_CURDATE(), 1103, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0, NULL, NULL), + (4, 'T', 8.88, util.VN_CURDATE(), 1104, util.VN_CURDATE(), 442, util.VN_CURDATE(), util.VN_CURDATE(), 1, 0, NULL, NULL), + (5, 'A', 8.88, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1103, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 442, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 0, NULL, NULL); UPDATE `vn`.`invoiceOut` SET ref = 'T1111111' WHERE id = 1; UPDATE `vn`.`invoiceOut` SET ref = 'T2222222' WHERE id = 2; diff --git a/db/routines/vn/procedures/invoiceOut_new.sql b/db/routines/vn/procedures/invoiceOut_new.sql index 6f2f7f8ff..1f20fb5fc 100644 --- a/db/routines/vn/procedures/invoiceOut_new.sql +++ b/db/routines/vn/procedures/invoiceOut_new.sql @@ -34,6 +34,7 @@ BEGIN DECLARE vMaxShipped DATE; DECLARE vDone BOOL; DECLARE vTicketFk INT; + DECLARE vAddressFk INT; DECLARE vCursor CURSOR FOR SELECT id FROM tmp.ticketToInvoice; @@ -48,11 +49,13 @@ BEGIN DATE(vInvoiceDate) >= invoiceOut_getMaxIssued( vSerial, t.companyFk, - YEAR(vInvoiceDate)) + YEAR(vInvoiceDate)), + t.addressFk INTO vClientFk, vCompanyFk, vMaxShipped, - vIsCorrectInvoiceDate + vIsCorrectInvoiceDate, + vAddressFk FROM tmp.ticketToInvoice tt JOIN ticket t ON t.id = tt.id; @@ -106,7 +109,8 @@ BEGIN dued, companyFk, siiTypeInvoiceOutFk, - customsAgentFk + customsAgentFk, + incotermsFk ) SELECT 1, @@ -120,9 +124,10 @@ BEGIN IF(vSerial = vSimplifiedSerial, vCplusSimplifiedInvoiceTypeFk, vCplusStandardInvoiceTypeFk)), - a.customsAgentFk + a.customsAgentFk, + a.incotermsFk FROM client c - JOIN address a ON a.id = c.defaultAddressFk + JOIN address a ON a.id = vAddressFk WHERE c.id = vClientFk; SET vNewInvoiceId = LAST_INSERT_ID(); diff --git a/db/versions/11269-wheatBirch/00-firstScript.sql b/db/versions/11269-wheatBirch/00-firstScript.sql index 6a50e5232..9432d131b 100644 --- a/db/versions/11269-wheatBirch/00-firstScript.sql +++ b/db/versions/11269-wheatBirch/00-firstScript.sql @@ -1,9 +1,15 @@ ALTER TABLE vn.invoiceOut ADD COLUMN IF NOT EXISTS customsAgentFk INT(11) DEFAULT NULL AFTER siiTrascendencyInvoiceOutFk; +ALTER TABLE vn.invoiceOut ADD COLUMN IF NOT EXISTS incotermsFk varchar(3) DEFAULT NULL AFTER customsAgentFk; ALTER TABLE vn.invoiceOut ADD CONSTRAINT invoiceOut_customsAgentFk FOREIGN KEY (customsAgentFk) REFERENCES vn.customsAgent (id) ON DELETE RESTRICT ON UPDATE CASCADE; +ALTER TABLE vn.invoiceOut ADD CONSTRAINT invoiceOut_incotermsFk FOREIGN KEY (incotermsFk) + REFERENCES vn.incoterms (`code`) ON DELETE RESTRICT ON UPDATE CASCADE; + UPDATE vn.invoiceOut io - JOIN vn.client c ON c.id = io.clientFk - JOIN vn.address a ON a.id = c.defaultAddressFk - SET io.customsAgentFk = a.customsAgentFk; \ No newline at end of file + JOIN vn.client c ON c.id = io.clientFk + JOIN vn.ticket t ON t.clientFk = c.id + JOIN vn.address a ON a.id = t.addressFk + SET io.customsAgentFk = a.customsAgentFk, + io.incotermsFk = a.incotermsFk; \ No newline at end of file diff --git a/print/templates/reports/invoice-incoterms/sql/incoterms.sql b/print/templates/reports/invoice-incoterms/sql/incoterms.sql index 016a8342e..535451674 100644 --- a/print/templates/reports/invoice-incoterms/sql/incoterms.sql +++ b/print/templates/reports/invoice-incoterms/sql/incoterms.sql @@ -1,9 +1,9 @@ WITH tickets AS( -SELECT id, packages, addressFk, weight - FROM ticket - WHERE refFk= ? +SELECT id, addressFk, packages, refFk + FROM vn.ticket + WHERE refFk = ? ), volume AS( -SELECT SUM(volume) volume +SELECT SUM(volume) volume, MAX(weight)weight FROM tickets t JOIN vn.saleVolume sv ON sv.ticketFk = t.id ), intrastat AS( @@ -12,10 +12,14 @@ SELECT GROUP_CONCAT(DISTINCT ir.description ORDER BY ir.description SEPARATOR ' JOIN vn.sale s ON t.id = s.ticketFk JOIN vn.item i ON i.id = s.itemFk JOIN vn.intrastat ir ON ir.id = i.intrastatFk -)SELECT SUM(t.packages) packages, - a.incotermsFk, +), totalPackages AS( +SELECT SUM(packages)packages + FROM tickets s +) +SELECT tp.packages, + io.incotermsFk, ic.name incotermsName, - MAX(t.weight) weight, + v.weight weight, ca.fiscalName customsAgentName, ca.street customsAgentStreet, ca.nif customsAgentNif, @@ -23,9 +27,10 @@ SELECT GROUP_CONCAT(DISTINCT ir.description ORDER BY ir.description SEPARATOR ' ca.email customsAgentEmail, CAST(v.volume AS DECIMAL (10,2)) volume, i.intrastat - FROM tickets t - JOIN vn.address a ON a.id = t.addressFk - JOIN vn.incoterms ic ON ic.code = a.incotermsFk - LEFT JOIN vn.customsAgent ca ON ca.id = a.customsAgentFk + FROM vn.invoiceOut io + JOIN vn.incoterms ic ON ic.code = io.incotermsFk + LEFT JOIN vn.customsAgent ca ON ca.id = io.customsAgentFk JOIN volume v JOIN intrastat i + JOIN totalPackages tp + WHERE `ref` = (SELECT DISTINCT refFk FROM tickets) \ No newline at end of file From dfdd8f28d41783e399123c60c6a1e9cbf8d268bd Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 23 Oct 2024 12:23:31 +0200 Subject: [PATCH 009/219] fix: refs #6389 filter --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 0fa2e60e5..9bfb69b65 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -199,6 +199,8 @@ module.exports = Self => { z.name zoneName, z.id zoneFk, st.classColor, + d.id departmentFk, + d.name department, TIME_FORMAT(t.shipped, '%H:%i') preparationHour, TIME_FORMAT(z.hour, '%H:%i') theoreticalhour, TIME_FORMAT(zed.etc, '%H:%i') practicalHour @@ -214,6 +216,8 @@ module.exports = Self => { LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN payMethod pm ON pm.id = c.payMethodFk LEFT JOIN worker wk ON wk.id = c.salesPersonFk + LEFT JOIN workerDepartment wd ON wd.workerFk = wk.id + LEFT JOIN department d ON d.id = wd.departmentFk LEFT JOIN account.user u ON u.id = wk.id LEFT JOIN ( SELECT zoneFk, From 99bec3e7fe8d5179d5f8ba8ca8d61c2b0f9435cb Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 23 Oct 2024 14:58:20 +0200 Subject: [PATCH 010/219] fix: refs #6389 salesFilter --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 9bfb69b65..5a0ea8d9d 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -169,7 +169,7 @@ module.exports = Self => { stmt = new ParameterizedSQL(` CREATE OR REPLACE TEMPORARY TABLE tmp.filter (PRIMARY KEY (id)) - ENGINE = MEMORY + ENGINE = InnoDB SELECT t.id, t.shipped, CAST(DATE(t.shipped) AS CHAR) shippedDate, @@ -201,6 +201,11 @@ module.exports = Self => { st.classColor, d.id departmentFk, d.name department, + (SELECT GROUP_CONCAT(DISTINCT i.itemPackingTypeFk ORDER BY i.itemPackingTypeFk SEPARATOR ',') + FROM sale s + JOIN item i ON i.id = s.itemFk + WHERE s.ticketFk = t.id + ) AS packing, TIME_FORMAT(t.shipped, '%H:%i') preparationHour, TIME_FORMAT(z.hour, '%H:%i') theoreticalhour, TIME_FORMAT(zed.etc, '%H:%i') practicalHour From c593b95935302ef661dea268525a3546576541f0 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 23 Oct 2024 15:21:24 +0200 Subject: [PATCH 011/219] feat: refs #7880 error code and translations --- .../hedera/procedures/order_confirmWithUser.sql | 2 +- db/versions/11320-salmonRose/00-firstScript.sql | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 db/versions/11320-salmonRose/00-firstScript.sql diff --git a/db/routines/hedera/procedures/order_confirmWithUser.sql b/db/routines/hedera/procedures/order_confirmWithUser.sql index 644d68a87..db83cba5c 100644 --- a/db/routines/hedera/procedures/order_confirmWithUser.sql +++ b/db/routines/hedera/procedures/order_confirmWithUser.sql @@ -107,7 +107,7 @@ BEGIN ) INTO vHas0Amount; IF vHas0Amount THEN - CALL util.throw('Hay líneas vacías. Por favor, elimínelas'); + CALL util.throw('orderLinesWithZero'); END IF; START TRANSACTION; diff --git a/db/versions/11320-salmonRose/00-firstScript.sql b/db/versions/11320-salmonRose/00-firstScript.sql new file mode 100644 index 000000000..cd3431fee --- /dev/null +++ b/db/versions/11320-salmonRose/00-firstScript.sql @@ -0,0 +1,11 @@ +INSERT INTO hedera.message (code, description) + VALUES ('orderLinesWithZero','There are empty lines. Please delete them'); + +INSERT INTO hedera.messageI18n (code, lang, description) + VALUES ('orderLinesWithZero','es','Hay líneas vacías. Por favor, elimínelas'); + +INSERT INTO hedera.messageI18n (code, lang, description) + VALUES ('orderLinesWithZero','fr','Il y a des lignes vides. Veuillez les supprimer'); + +INSERT INTO hedera.messageI18n (code, lang, description) + VALUES ('orderLinesWithZero','pt','Existem linhas vazias. Por favor, apague-os'); \ No newline at end of file From 55483f8e6ba8ef2293ecd59ab3ae370a0243c5ba Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 28 Oct 2024 09:01:10 +0100 Subject: [PATCH 012/219] fix: refs #6389 packing --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 5a0ea8d9d..30df9c0cc 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -88,6 +88,11 @@ module.exports = Self => { arg: 'alertLevel', type: 'number', description: `The alert level of the tickets` + }, + { + arg: 'packing', + type: 'string', + description: `The packing of the items` } ], returns: { @@ -155,6 +160,9 @@ module.exports = Self => { case 'clientFk': param = `t.${param}`; return {[param]: value}; + case 'packing': + param = `i.${param}`; + return {[param]: value}; } }); From f1370d69603c64fb099f6277f6a600a4c962cd3e Mon Sep 17 00:00:00 2001 From: Jbreso Date: Tue, 29 Oct 2024 12:13:25 +0100 Subject: [PATCH 013/219] feat: refs#8174 simSupplier --- .../11327-maroonOak/00-firstScript.sql | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 db/versions/11327-maroonOak/00-firstScript.sql diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql new file mode 100644 index 000000000..973050fba --- /dev/null +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -0,0 +1,19 @@ +CREATE TABLE IF NOT EXISTS `vn`.`simSupplier` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `line` int(9) unsigned DEFAULT NULL, + `ext` int(10) unsigned DEFAULT NULL, + `pin` int(4) unsigned DEFAULT NULL, + `sim` VARCHAR(25), + `puk` int(10) unsigned DEFAULT NULL, + `statusWeb` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `sim_UNIQUE` (`sim`) +) ENGINE=InnoDB AUTO_INCREMENT=1 + DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +ALTER TABLE `deviceProductionUser` +MODIFY `simSerialNumber` VARCHAR(25); + +ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_simSupplier_FK + FOREIGN KEY (simSerialNumber) REFERENCES vn.simSupplier(sim); + From 679dd6929bfde285fe1a501f9199dbcd5fd26af2 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 6 Nov 2024 13:42:36 +0100 Subject: [PATCH 014/219] feat: refs #6583 add new opt in where builder --- modules/ticket/back/methods/ticket/getTicketsAdvance.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/ticket/back/methods/ticket/getTicketsAdvance.js b/modules/ticket/back/methods/ticket/getTicketsAdvance.js index 41f3ee79a..6abac455f 100644 --- a/modules/ticket/back/methods/ticket/getTicketsAdvance.js +++ b/modules/ticket/back/methods/ticket/getTicketsAdvance.js @@ -55,6 +55,11 @@ module.exports = Self => { type: 'number', description: 'Department identifier' }, + { + arg: 'onlyWithDestination', + type: 'Boolean', + description: 'True when only tickets with destination are returned' + }, { arg: 'filter', type: 'object', @@ -103,6 +108,9 @@ module.exports = Self => { return {'f.isFullMovable': value}; case 'departmentFk': return {'f.departmentFk': value}; + case 'onlyWithDestination': + if (!value) return; + return {'f.id': {neq: null}}; } }); From 611cd12392f80e6833c14f4763b956c044a27465 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 7 Nov 2024 16:16:40 +0100 Subject: [PATCH 015/219] feat: refs #6583 retrieve cloned sale --- db/routines/vn/procedures/ticket_canAdvance.sql | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/ticket_canAdvance.sql b/db/routines/vn/procedures/ticket_canAdvance.sql index e8fc70bba..cee706e08 100644 --- a/db/routines/vn/procedures/ticket_canAdvance.sql +++ b/db/routines/vn/procedures/ticket_canAdvance.sql @@ -52,7 +52,8 @@ BEGIN IFNULL(dest.nickname, origin.nickname) nickname, dest.landed, dest.preparation, - origin.departmentFk + origin.departmentFk, + origin.saleClonedFk FROM ( SELECT s.ticketFk, c.salesPersonFk workerFk, @@ -73,11 +74,13 @@ BEGIN t.warehouseFk, t.companyFk, t.agencyModeFk, - wd.departmentFk + wd.departmentFk, + sc.saleClonedFk FROM ticket t JOIN client c ON c.id = t.clientFk JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk JOIN sale s ON s.ticketFk = t.id + LEFT JOIN saleCloned sc ON sc.saleClonedFk = s.id JOIN saleVolume sv ON sv.saleFk = s.id JOIN item i ON i.id = s.itemFk JOIN ticketState ts ON ts.ticketFk = t.id From 41512a0516294d2709b3836585d5239c2b84c97e Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 11 Nov 2024 16:09:26 +0100 Subject: [PATCH 016/219] refactor: refs #6583 entry report table style --- .../reports/entry-order/assets/css/style.css | 5 +++ .../reports/entry-order/entry-order.html | 44 +++++++++---------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/print/templates/reports/entry-order/assets/css/style.css b/print/templates/reports/entry-order/assets/css/style.css index 767b1185a..1a5ea3eb6 100644 --- a/print/templates/reports/entry-order/assets/css/style.css +++ b/print/templates/reports/entry-order/assets/css/style.css @@ -17,4 +17,9 @@ h3 { .tags { font-size: 10px; margin: 0; +} + +.column-oriented th, +.column-oriented td{ + padding: 5px } \ No newline at end of file diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html index e5d3bfb6d..77545ef9b 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -41,36 +41,36 @@ + - + - - - - - - - - + + + + + + + + - - - - - + + + - - - - - + + + + From 3db6ab07789540c213a2403c7223ea040c6841c6 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 11 Nov 2024 16:10:49 +0100 Subject: [PATCH 017/219] feat: refs #6583 rollback --- .../reports/entry-order/assets/css/style.css | 5 +++ .../reports/entry-order/entry-order.html | 44 +++++++++---------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/print/templates/reports/entry-order/assets/css/style.css b/print/templates/reports/entry-order/assets/css/style.css index 767b1185a..1a5ea3eb6 100644 --- a/print/templates/reports/entry-order/assets/css/style.css +++ b/print/templates/reports/entry-order/assets/css/style.css @@ -17,4 +17,9 @@ h3 { .tags { font-size: 10px; margin: 0; +} + +.column-oriented th, +.column-oriented td{ + padding: 5px } \ No newline at end of file diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html index e5d3bfb6d..77545ef9b 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -41,36 +41,36 @@
{{$t('reference')}} {{$t('boxes')}} {{$t('packing')}}{{$t('concept')}}{{$t('reference')}}{{$t('tags')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}{{$t('concept')}}{{$t('tags')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}
{{buy.comment}} {{buy.stickers}}x{{buy.packing}}{{buy.name}}{{buy.comment}} - {{buy.tag5}} → {{buy.value5}} - {{buy.tag6}} → {{buy.value6}} - {{buy.tag7}} → {{buy.value7}} + x{{buy.packing}}{{buy.name}} + {{buy.tag5}} → {{buy.value5}} + {{buy.tag6}} → {{buy.value6}} + {{buy.tag7}} → {{buy.value7}} {{buy.quantity | number($i18n.locale)}}x{{buy.buyingValue | currency('EUR', $i18n.locale)}}= + {{buy.quantity | number($i18n.locale)}}x{{buy.buyingValue | currency('EUR', $i18n.locale)}}= {{buy.buyingValue * buy.quantity | currency('EUR', $i18n.locale)}}
+ - + - - - - - - - - + + + + + + + + - - - - - + + + - - - - - + + + + From 2f3efa15ba8e2a832aff010ddc114c39192576b9 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 11 Nov 2024 16:13:25 +0100 Subject: [PATCH 018/219] feat: refs #6583 rollback --- .../reports/entry-order/assets/css/style.css | 5 --- .../reports/entry-order/entry-order.html | 44 +++++++++---------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/print/templates/reports/entry-order/assets/css/style.css b/print/templates/reports/entry-order/assets/css/style.css index 1a5ea3eb6..767b1185a 100644 --- a/print/templates/reports/entry-order/assets/css/style.css +++ b/print/templates/reports/entry-order/assets/css/style.css @@ -17,9 +17,4 @@ h3 { .tags { font-size: 10px; margin: 0; -} - -.column-oriented th, -.column-oriented td{ - padding: 5px } \ No newline at end of file diff --git a/print/templates/reports/entry-order/entry-order.html b/print/templates/reports/entry-order/entry-order.html index 77545ef9b..e5d3bfb6d 100644 --- a/print/templates/reports/entry-order/entry-order.html +++ b/print/templates/reports/entry-order/entry-order.html @@ -41,36 +41,36 @@
{{$t('reference')}} {{$t('boxes')}} {{$t('packing')}}{{$t('concept')}}{{$t('reference')}}{{$t('tags')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}{{$t('concept')}}{{$t('tags')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}
{{buy.comment}} {{buy.stickers}}x{{buy.packing}}{{buy.name}}{{buy.comment}} - {{buy.tag5}} → {{buy.value5}} - {{buy.tag6}} → {{buy.value6}} - {{buy.tag7}} → {{buy.value7}} + x{{buy.packing}}{{buy.name}} + {{buy.tag5}} → {{buy.value5}} + {{buy.tag6}} → {{buy.value6}} + {{buy.tag7}} → {{buy.value7}} {{buy.quantity | number($i18n.locale)}}x{{buy.buyingValue | currency('EUR', $i18n.locale)}}= + {{buy.quantity | number($i18n.locale)}}x{{buy.buyingValue | currency('EUR', $i18n.locale)}}= {{buy.buyingValue * buy.quantity | currency('EUR', $i18n.locale)}}
- - + - - - - - - - + + + + + + + + - - - - - + + + + - - - - - + + + + From 1c49c073eebf29a7da16101f6bce11ed1eaa37ad Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 13 Nov 2024 15:45:06 +0100 Subject: [PATCH 019/219] feat: refs #8002 drop support btn --- front/core/components/snackbar/snackbar.js | 11 +---------- front/core/components/support-dialog/index.js | 12 ++++++------ 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/front/core/components/snackbar/snackbar.js b/front/core/components/snackbar/snackbar.js index b380c47c3..49d784067 100644 --- a/front/core/components/snackbar/snackbar.js +++ b/front/core/components/snackbar/snackbar.js @@ -27,17 +27,8 @@ export default class Controller extends Component { setTimeout(() => element.classList.add('shown'), 30); shape.element = element; - if (data.additionalData && this.vnToken.token) { + if (data.additionalData && this.vnToken.token) this.additionalData = data.additionalData; - let supportButton = document.createElement('i'); - supportButton.setAttribute('class', 'material-icons clickable'); - supportButton.addEventListener('click', () => this.$.supportDialog.show()); - element.appendChild(supportButton); - - let buttonIcon = 'support_agent'; - buttonIcon = document.createTextNode(buttonIcon); - supportButton.appendChild(buttonIcon); - } if (shape.type) element.classList.add(shape.type); diff --git a/front/core/components/support-dialog/index.js b/front/core/components/support-dialog/index.js index d15c14b4a..45a8147fe 100644 --- a/front/core/components/support-dialog/index.js +++ b/front/core/components/support-dialog/index.js @@ -10,12 +10,12 @@ export default class Controller extends Dialog { if (response !== 'accept') return super.responseHandler(response); - this.$http.post('Ostickets/send-to-support', { - reason: this.reason, - additionalData: this.additionalData - }) - .then(() => super.responseHandler(response)) - .then(() => this.vnApp.showSuccess(this.$t('Email sended!'))); + // this.$http.post('Ostickets/send-to-support', { + // reason: this.reason, + // additionalData: this.additionalData + // }) + // .then(() => super.responseHandler(response)) + // .then(() => this.vnApp.showSuccess(this.$t('Email sended!'))); } } From b75b369716ded8737a6f32d65ec6c93e0f0c25ad Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 13 Nov 2024 17:35:27 +0100 Subject: [PATCH 020/219] feat: refs #8002 adjust to lilium --- back/methods/osticket/sendToSupport.js | 37 ++++++++++++-------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/back/methods/osticket/sendToSupport.js b/back/methods/osticket/sendToSupport.js index e17093839..d05f1a82e 100644 --- a/back/methods/osticket/sendToSupport.js +++ b/back/methods/osticket/sendToSupport.js @@ -29,35 +29,32 @@ module.exports = Self => { }); Self.sendToSupport = async(ctx, reason, additionalData) => { + const userId = ctx.req.accessToken.userId; const emailUser = - await Self.app.models.EmailUser.findById(ctx.req.accessToken.userId, {fields: ['email']}); + await Self.app.models.EmailUser.findById(userId, {fields: ['email']}); + const {code, message, path, request, status, statusText, config: errConfig, name} = additionalData; - let html = `Motivo:
${reason}
`; - html += `Usuario:
${ctx.req.accessToken.userId} ${emailUser.email}
`; + let html = `

Motivo: ${reason}

`; + html += `

Usuario: ${userId} ${emailUser.email}

`; + html += `

Additional Data:

`; + html += `
  • Code: ${code}
  • `; + html += `
  • Message: ${message}
  • `; + html += `
  • Path: ${path}
  • `; + html += `
  • Request: ${request}
  • `; + html += `
  • Status: ${status}
  • `; + html += `
  • StatusText: ${statusText}
  • `; + html += `
  • Config:
    • `; + for (const [key, val] of Object.entries(errConfig)) html += `
    • ${key}: ${parse(val)}
    • `; + html += '
'; - delete additionalData.backError.config.headers.Authorization; - const httpRequest = JSON.parse(additionalData?.httpRequest); - - if (httpRequest) - delete httpRequest.config.headers.Authorization; - additionalData.httpRequest = httpRequest; - - for (const data in additionalData) - html += `${data}:
${tryParse(additionalData[data])}
`; - - const subjectReason = httpRequest?.data?.error; await smtp.send({ to: `${config.app.reportEmail}, ${emailUser.email}`, - subject: - '[Support-Salix] ' + - additionalData?.frontPath + ' ' + - subjectReason?.name + ':' + - subjectReason?.message, + subject: `[Support-Salix] ${path} ${name}: ${message}`, html }); }; - function tryParse(value) { + function parse(value) { try { try { value = JSON.parse(value); From 873b91f1130beb17cc05367d8aecea310914c386 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 13 Nov 2024 17:45:15 +0100 Subject: [PATCH 021/219] chore: refs #8002 drop comments --- front/core/components/support-dialog/index.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/front/core/components/support-dialog/index.js b/front/core/components/support-dialog/index.js index 45a8147fe..82f086184 100644 --- a/front/core/components/support-dialog/index.js +++ b/front/core/components/support-dialog/index.js @@ -9,13 +9,6 @@ export default class Controller extends Dialog { responseHandler(response) { if (response !== 'accept') return super.responseHandler(response); - - // this.$http.post('Ostickets/send-to-support', { - // reason: this.reason, - // additionalData: this.additionalData - // }) - // .then(() => super.responseHandler(response)) - // .then(() => this.vnApp.showSuccess(this.$t('Email sended!'))); } } From 285fe67ca5f64c4db744ace0ded4a95d1332372a Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 14 Nov 2024 10:38:44 +0100 Subject: [PATCH 022/219] chore: refs #8002 drop useless code --- front/core/components/snackbar/snackbar.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/front/core/components/snackbar/snackbar.js b/front/core/components/snackbar/snackbar.js index 49d784067..cce285d14 100644 --- a/front/core/components/snackbar/snackbar.js +++ b/front/core/components/snackbar/snackbar.js @@ -27,9 +27,6 @@ export default class Controller extends Component { setTimeout(() => element.classList.add('shown'), 30); shape.element = element; - if (data.additionalData && this.vnToken.token) - this.additionalData = data.additionalData; - if (shape.type) element.classList.add(shape.type); From dbf5953d69f55e5f7bb866318fd01aff6de2a98b Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 14 Nov 2024 10:47:39 +0100 Subject: [PATCH 023/219] refactor: refs #8002 use loop wip --- back/methods/osticket/sendToSupport.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/back/methods/osticket/sendToSupport.js b/back/methods/osticket/sendToSupport.js index d05f1a82e..dabd35f80 100644 --- a/back/methods/osticket/sendToSupport.js +++ b/back/methods/osticket/sendToSupport.js @@ -32,21 +32,23 @@ module.exports = Self => { const userId = ctx.req.accessToken.userId; const emailUser = await Self.app.models.EmailUser.findById(userId, {fields: ['email']}); - const {code, message, path, request, status, statusText, config: errConfig, name} = additionalData; let html = `

Motivo: ${reason}

`; html += `

Usuario: ${userId} ${emailUser.email}

`; html += `

Additional Data:

`; - html += `
  • Code: ${code}
  • `; - html += `
  • Message: ${message}
  • `; - html += `
  • Path: ${path}
  • `; - html += `
  • Request: ${request}
  • `; - html += `
  • Status: ${status}
  • `; - html += `
  • StatusText: ${statusText}
  • `; - html += `
  • Config:
    • `; - for (const [key, val] of Object.entries(errConfig)) html += `
    • ${key}: ${parse(val)}
    • `; - html += '
'; + html += '
    '; + for (const [key, val] of Object.entries(additionalData)) { + if (key !== 'config') html += `
  • ${key}: ${parse(val)}
  • `; + else { + html += `
  • ${key}:
    • `; + for (const [confKey, confVal] of Object.entries(val)) + html += `
    • ${confKey}: ${parse(confVal)}
    • `; + html += '
    '; + } + } + html += '
'; + const {message, path, name} = additionalData; await smtp.send({ to: `${config.app.reportEmail}, ${emailUser.email}`, subject: `[Support-Salix] ${path} ${name}: ${message}`, From 69314171ea7c8425343dca993c2de5b8b79c138d Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 14 Nov 2024 12:11:14 +0100 Subject: [PATCH 024/219] feat: refs #8190 entry_getCommission --- .../vn/functions/entry_getCommission.sql | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/db/routines/vn/functions/entry_getCommission.sql b/db/routines/vn/functions/entry_getCommission.sql index 4a19f4e63..0d294fe24 100644 --- a/db/routines/vn/functions/entry_getCommission.sql +++ b/db/routines/vn/functions/entry_getCommission.sql @@ -7,41 +7,46 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`entry_getCommission`(v NOT DETERMINISTIC READS SQL DATA BEGIN - DECLARE vCommission INT; - DECLARE vCurrentCommission INT; - DECLARE vIsCurrencyUsd INT; - DECLARE vLastEntryFk INT; - - SELECT count(*) INTO vIsCurrencyUsd - FROM currency c - WHERE c.code = 'USD' AND id = vCurrencyFk; - - IF NOT vIsCurrencyUsd THEN - + DECLARE vCommission INT; + DECLARE vCurrentCommission INT; + DECLARE vIsCurrencyUsd INT; + DECLARE vLastEntryFk INT; + DECLARE vTravelFkLanded INT; + + SELECT count(*) INTO vIsCurrencyUsd + FROM currency c + WHERE c.code = 'USD' AND id = vCurrencyFk; + + IF NOT vIsCurrencyUsd THEN + SELECT landed INTO vTravelFkLanded + FROM travel + WHERE id = vTravelFk; + SELECT e.id INTO vLastEntryFk - FROM vn.entry e - JOIN vn.travel tr ON tr.id = e.travelFk - WHERE e.supplierFk = vSupplierFk - ORDER BY tr.landed DESC - LIMIT 1; - - IF vLastEntryFk THEN - + FROM entry e + JOIN travel tr ON tr.id = e.travelFk + WHERE tr.landed < vTravelFkLanded + AND e.supplierFk = vSupplierFk + ORDER BY (vTravelFkLanded - tr.landed) ASC, tr.landed DESC + LIMIT 1; + + IF vLastEntryFk THEN + SELECT commission INTO vCurrentCommission FROM vn.entry - WHERE id = vLastEntryFk; - - ELSE - + WHERE id = vLastEntryFk; + + ELSE + SELECT commission INTO vCurrentCommission FROM supplier s WHERE s.id = vSupplierFk; - + END IF; - - RETURN vCurrentCommission; - - ELSE + + RETURN vCurrentCommission; + + ELSE SELECT ROUND(-100 * (1 - (1 / r.value))) INTO vCommission FROM travel t @@ -49,10 +54,10 @@ BEGIN WHERE t.id = vTravelFk ORDER BY r.`dated` DESC LIMIT 1; - + RETURN IFNULL(vCommission, 0); - + END IF; - + END$$ DELIMITER ; From c63dfba7da99f9ad7e28d2d38a282f10d64ceb99 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 21 Nov 2024 10:18:09 +0100 Subject: [PATCH 025/219] feat: refs #7301 add inventory-config and acl --- db/dump/fixtures.before.sql | 10 ++++++++-- .../11352-blackErica/00-firstScript.sql | 3 +++ modules/entry/back/model-config.json | 3 +++ .../entry/back/models/inventory-config.json | 18 ++++++++++++++++++ .../back/methods/item/lastEntriesFilter.js | 3 ++- 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 db/versions/11352-blackErica/00-firstScript.sql create mode 100644 modules/entry/back/models/inventory-config.json diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index eb376b6c6..32653f3c2 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1530,6 +1530,7 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1,''), (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, ''), (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10', 1, ''), + (11, 4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 1', 0, ''), (99, 69, '2000-12-01 00:00:00.000', 11, 0, 442, 'IN2009', 'Movement 99', 0, ''); INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`) @@ -1570,7 +1571,8 @@ INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `sal (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()), - (16, 99,1,50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, '2024-07-30 08:13:51.000'); + (16, 99,1,50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, '2024-07-30 08:13:51.000'), + (17, 11, 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); 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 @@ -4027,4 +4029,8 @@ INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) (8, '1183'); INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) - VALUES ('saysimle-url-mock', 1320); \ No newline at end of file + VALUES ('saysimle-url-mock', 1320); + +INSERT IGNORE INTO vn.inventoryConfig + SET id = 1, + supplierFk = 4; \ No newline at end of file diff --git a/db/versions/11352-blackErica/00-firstScript.sql b/db/versions/11352-blackErica/00-firstScript.sql new file mode 100644 index 000000000..4e17c94c5 --- /dev/null +++ b/db/versions/11352-blackErica/00-firstScript.sql @@ -0,0 +1,3 @@ +-- Place your SQL code here +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId, editorFk) + VALUES('InventoryConfig', '*', 'READ', 'ALLOW', 'ROLE', 'buyer', 100); \ No newline at end of file diff --git a/modules/entry/back/model-config.json b/modules/entry/back/model-config.json index 5c45b6e07..49c2df2db 100644 --- a/modules/entry/back/model-config.json +++ b/modules/entry/back/model-config.json @@ -28,5 +28,8 @@ }, "StockBought": { "dataSource": "vn" + }, + "InventoryConfig": { + "dataSource": "vn" } } diff --git a/modules/entry/back/models/inventory-config.json b/modules/entry/back/models/inventory-config.json new file mode 100644 index 000000000..caa39db88 --- /dev/null +++ b/modules/entry/back/models/inventory-config.json @@ -0,0 +1,18 @@ +{ + "name": "InventoryConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "inventoryConfig" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "supplierFk": { + "type": "number" + } + } +} diff --git a/modules/item/back/methods/item/lastEntriesFilter.js b/modules/item/back/methods/item/lastEntriesFilter.js index 5aafbb4f6..06c60162f 100644 --- a/modules/item/back/methods/item/lastEntriesFilter.js +++ b/modules/item/back/methods/item/lastEntriesFilter.js @@ -54,7 +54,8 @@ module.exports = Self => { b.packageValue, b.packagingFk , s.id AS supplierFk, - s.name AS supplier + s.name AS supplier, + b.printedStickers FROM itemType it RIGHT JOIN (entry e LEFT JOIN supplier s ON s.id = e.supplierFk From e92ce939b85ef5b3ffab66648ff2ce6f2ff699e9 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 22 Nov 2024 06:27:00 +0100 Subject: [PATCH 026/219] refactor: refs #7301 update entry and item filter tests to validate results against specific criteria --- .../back/methods/entry/specs/filter.spec.js | 10 +++++--- .../item/specs/lastEntriesFilter.spec.js | 25 +++++++++++++++++-- .../methods/travel/specs/getEntries.spec.js | 5 ++-- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/modules/entry/back/methods/entry/specs/filter.spec.js b/modules/entry/back/methods/entry/specs/filter.spec.js index 4bf5127b0..b139b00b6 100644 --- a/modules/entry/back/methods/entry/specs/filter.spec.js +++ b/modules/entry/back/methods/entry/specs/filter.spec.js @@ -38,8 +38,9 @@ describe('Entry filter()', () => { }; const result = await models.Entry.filter(ctx, options); + const resultWithCurrency = result.filter(entry => entry.currencyFk === 1); - expect(result.length).toEqual(12); + expect(result.length).toEqual(resultWithCurrency.length); await tx.rollback(); } catch (e) { @@ -141,18 +142,21 @@ describe('Entry filter()', () => { it('should return the entry matching the company', async() => { const tx = await models.Entry.beginTransaction({}); const options = {transaction: tx}; + const companyFk = 442; try { const ctx = { args: { - companyFk: 442 + companyFk }, req: {accessToken: {userId: 9}} }; const result = await models.Entry.filter(ctx, options); - expect(result.length).toEqual(11); + const resultWithCurrency = result.filter(entry => entry.companyFk === companyFk); + + expect(result.length).toEqual(resultWithCurrency.length); await tx.rollback(); } catch (e) { diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js index 2fd30c2ca..d4429e158 100644 --- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js +++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js @@ -34,10 +34,31 @@ describe('item lastEntriesFilter()', () => { const options = {transaction: tx}; try { - const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}}; + const itemFk = 1; + const filter = {where: {itemFk, landed: {between: [minDate, maxDate]}}}; const result = await models.Item.lastEntriesFilter(filter, options); + const minDateUtc = new Date(minDate).getTime(); + const maxDateUtc = new Date(maxDate).getTime(); - expect(result.length).toEqual(6); + const resultMatch = ( + await Promise.all( + result.map(async item => { + const itemRecord = await models.Buy.findOne({ + fields: ['id'], + where: {id: item.id}, + options, + }); + + const isItemFkValid = itemRecord?.id === itemFk; + const landedDate = new Date(item.landed).getTime(); + const isLandedValid = landedDate >= minDateUtc && landedDate <= maxDateUtc; + + return isItemFkValid && isLandedValid; + }) + ) + ).filter(Boolean).length; + + expect(result.length).toEqual(resultMatch); await tx.rollback(); } catch (e) { diff --git a/modules/travel/back/methods/travel/specs/getEntries.spec.js b/modules/travel/back/methods/travel/specs/getEntries.spec.js index fcaa80d02..9286a9d55 100644 --- a/modules/travel/back/methods/travel/specs/getEntries.spec.js +++ b/modules/travel/back/methods/travel/specs/getEntries.spec.js @@ -3,9 +3,10 @@ const models = require('vn-loopback/server/server').models; describe('travel getEntries()', () => { const travelId = 1; it('should check the response contains the id', async() => { - const entries = await models.Travel.getEntries(travelId); + const result = await models.Travel.getEntries(travelId); + const entries = await models.Entry.find({where: {travelFk: travelId}}); - expect(entries.length).toEqual(1); + expect(entries.length).toEqual(result.length); expect(entries[0].id).toEqual(1); }); From 5a92fe16914a906362173f735b01652eece6c395 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 26 Nov 2024 11:57:24 +0100 Subject: [PATCH 027/219] feat: refs #8190 entry_getCommission --- db/routines/vn/functions/entry_getCommission.sql | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/functions/entry_getCommission.sql b/db/routines/vn/functions/entry_getCommission.sql index 0d550358f..9e2b53e5e 100644 --- a/db/routines/vn/functions/entry_getCommission.sql +++ b/db/routines/vn/functions/entry_getCommission.sql @@ -34,9 +34,8 @@ BEGIN SELECT e.id INTO vLastEntryFk FROM `entry` e JOIN travel tr ON tr.id = e.travelFk - WHERE tr.landed < vTravelFkLanded - AND e.supplierFk = vSupplierFk - ORDER BY (vTravelFkLanded - tr.landed) ASC, tr.landed DESC + WHERE e.supplierFk = vSupplierFk + ORDER BY (vTravelFkLanded <= tr.landed) ASC, tr.landed DESC LIMIT 1; IF vLastEntryFk THEN From 9a645c3288bb2db2bcb5604c0500d4c2a283a422 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 26 Nov 2024 16:56:39 +0100 Subject: [PATCH 028/219] fix: refs #7936 add IF NOT EXISTS to isRaid column in travel table --- db/versions/11332-tealErica/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11332-tealErica/00-firstScript.sql b/db/versions/11332-tealErica/00-firstScript.sql index 6358695b2..957aa57e2 100644 --- a/db/versions/11332-tealErica/00-firstScript.sql +++ b/db/versions/11332-tealErica/00-firstScript.sql @@ -1,4 +1,4 @@ -ALTER TABLE vn.travel ADD isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada'; +ALTER TABLE vn.travel ADD IF NOT EXISTS isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada'; ALTER TABLE vn.travel MODIFY COLUMN daysInForward int(10) unsigned DEFAULT NULL COMMENT 'Cuando es una redada, indica el número de días que se añadirán a la fecha de hoy para establecer el landed. NULL si no es una redada'; From a68e287b23cfc568574a215562a629562e2d0465 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 26 Nov 2024 17:01:50 +0100 Subject: [PATCH 029/219] refactor: refs #7936 remove old trigger and add isRaid column to travel table --- db/versions/11332-tealErica/00-firstScript.sql | 2 +- .../00-firstScript.sql | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) rename db/versions/{11266-goldenChrysanthemum => 11368-whiteAspidistra}/00-firstScript.sql (99%) diff --git a/db/versions/11332-tealErica/00-firstScript.sql b/db/versions/11332-tealErica/00-firstScript.sql index 957aa57e2..6358695b2 100644 --- a/db/versions/11332-tealErica/00-firstScript.sql +++ b/db/versions/11332-tealErica/00-firstScript.sql @@ -1,4 +1,4 @@ -ALTER TABLE vn.travel ADD IF NOT EXISTS isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada'; +ALTER TABLE vn.travel ADD isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada'; ALTER TABLE vn.travel MODIFY COLUMN daysInForward int(10) unsigned DEFAULT NULL COMMENT 'Cuando es una redada, indica el número de días que se añadirán a la fecha de hoy para establecer el landed. NULL si no es una redada'; diff --git a/db/versions/11266-goldenChrysanthemum/00-firstScript.sql b/db/versions/11368-whiteAspidistra/00-firstScript.sql similarity index 99% rename from db/versions/11266-goldenChrysanthemum/00-firstScript.sql rename to db/versions/11368-whiteAspidistra/00-firstScript.sql index 37143c99b..333fa1315 100644 --- a/db/versions/11266-goldenChrysanthemum/00-firstScript.sql +++ b/db/versions/11368-whiteAspidistra/00-firstScript.sql @@ -45,3 +45,4 @@ BEGIN END$$ DELIMITER ; + From 6ab25c2ff588c82db06cde389ccdc4fd73efff58 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 26 Nov 2024 17:06:45 +0100 Subject: [PATCH 030/219] fix: refs #7936 add IF NOT EXISTS to isRaid column in travel table --- db/versions/11332-tealErica/00-firstScript.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/versions/11332-tealErica/00-firstScript.sql b/db/versions/11332-tealErica/00-firstScript.sql index 6358695b2..a7870632f 100644 --- a/db/versions/11332-tealErica/00-firstScript.sql +++ b/db/versions/11332-tealErica/00-firstScript.sql @@ -1,4 +1,4 @@ -ALTER TABLE vn.travel ADD isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada'; +ALTER TABLE vn.travel ADD IF NOT EXISTS isRaid tinyint(1) DEFAULT 0 NOT NULL COMMENT 'Redada'; ALTER TABLE vn.travel MODIFY COLUMN daysInForward int(10) unsigned DEFAULT NULL - COMMENT 'Cuando es una redada, indica el número de días que se añadirán a la fecha de hoy para establecer el landed. NULL si no es una redada'; + COMMENT 'Cuando es una redada, indica el número de días que se añadirán a la fecha de hoy para establecer el landed. NULL si no es una redada'; \ No newline at end of file From d9aa11b3e9c91e8912c8f7ac23f20c9b28b5e01a Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 27 Nov 2024 07:27:47 +0100 Subject: [PATCH 031/219] feat: refs #8190 entry_getCommission change request --- db/routines/vn/functions/entry_getCommission.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/functions/entry_getCommission.sql b/db/routines/vn/functions/entry_getCommission.sql index 9e2b53e5e..f8c1ce3b4 100644 --- a/db/routines/vn/functions/entry_getCommission.sql +++ b/db/routines/vn/functions/entry_getCommission.sql @@ -11,7 +11,7 @@ BEGIN DECLARE vCurrentCommission INT; DECLARE vIsNotEUR INT; DECLARE vLastEntryFk INT; - DECLARE vTravelFkLanded INT; + DECLARE vLanded INT; SELECT count(*) INTO vIsNotEUR FROM currency c @@ -27,7 +27,7 @@ BEGIN RETURN IFNULL(vCommission, 0); ELSE - SELECT landed INTO vTravelFkLanded + SELECT landed INTO vLanded FROM travel WHERE id = vTravelFk; @@ -35,7 +35,7 @@ BEGIN FROM `entry` e JOIN travel tr ON tr.id = e.travelFk WHERE e.supplierFk = vSupplierFk - ORDER BY (vTravelFkLanded <= tr.landed) ASC, tr.landed DESC + ORDER BY (vLanded <= tr.landed), tr.landed DESC LIMIT 1; IF vLastEntryFk THEN From 5db1262e082d52d2f5333f7c452aa30a5d69d723 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 27 Nov 2024 10:24:13 +0100 Subject: [PATCH 032/219] feat: refs #7936 add company filter --- .../invoiceIn/back/methods/invoice-in/filter.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js index 936f7bb6c..c549769ab 100644 --- a/modules/invoiceIn/back/methods/invoice-in/filter.js +++ b/modules/invoiceIn/back/methods/invoice-in/filter.js @@ -91,6 +91,10 @@ module.exports = Self => { { arg: 'supplierActivityFk', type: 'string', + }, + { + arg: 'companyFk', + type: 'number', } ], returns: { @@ -161,8 +165,8 @@ module.exports = Self => { : {'ii.id': {nin: correcteds.map(x => x.correctingFk)}}; case 'correctedFk': return {'ii.id': {inq: correctings.map(x => x.correctingFk)}}; - case 'supplierActivityFk': - return {'s.supplierActivityFk': value}; + case 'companyFk': + return {'ii.companyFk': value}; } }); @@ -184,7 +188,8 @@ module.exports = Self => { s.name supplierName, s.account, SUM(iid.amount) amount, - sub.code awbCode + sub.code awbCode, + c.code FROM invoiceIn ii JOIN supplier s ON s.id = ii.supplierFk LEFT JOIN invoiceInDueDay iid ON iid.invoiceInFk = ii.id @@ -199,7 +204,8 @@ module.exports = Self => { GROUP BY de.duaFk ) sub ON sub.duaFk = d.id LEFT JOIN company co ON co.id = ii.companyFk - LEFT JOIN dms dm ON dm.id = ii.docFk` + LEFT JOIN dms dm ON dm.id = ii.docFk + JOIN company c ON c.id = ii.companyFk`, ); const sqlWhere = conn.makeWhere(filter.where); From 8fd133c5e8a10edb4b35b3796887be898d6ff442 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 27 Nov 2024 12:51:09 +0100 Subject: [PATCH 033/219] feat: refs #6818 define prefix model --- back/model-config.json | 3 +++ back/models/prefix.json | 27 +++++++++++++++++++ modules/client/back/methods/client/summary.js | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 back/models/prefix.json diff --git a/back/model-config.json b/back/model-config.json index b543071c9..e0bc92200 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -133,6 +133,9 @@ "Postcode": { "dataSource": "vn" }, + "Prefix": { + "dataSource": "vn" + }, "ReferenceRate": { "dataSource": "vn" }, diff --git a/back/models/prefix.json b/back/models/prefix.json new file mode 100644 index 000000000..762354caa --- /dev/null +++ b/back/models/prefix.json @@ -0,0 +1,27 @@ +{ + "name": "Prefix", + "base": "VnModel", + "options": { + "mysql": { + "table": "pbx.prefix" + } + }, + "properties": { + "country": { + "type": "string", + "id": true + }, + "prefix": { + "type": "string" + } + }, + "acls": [ + { + "property": "*", + "accessType": "READ", + "principalType": "ROLE", + "principalId": "employee", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/modules/client/back/methods/client/summary.js b/modules/client/back/methods/client/summary.js index 9242fbd44..9c1420b61 100644 --- a/modules/client/back/methods/client/summary.js +++ b/modules/client/back/methods/client/summary.js @@ -54,7 +54,7 @@ module.exports = Self => { { relation: 'country', scope: { - fields: ['id', 'name'], + fields: ['id', 'name', 'code'], include: { relation: 'saySimpleCountry', } From 15c755087c929a58f90a8cfcc57d675e4f65e8f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 27 Nov 2024 14:28:50 +0100 Subject: [PATCH 034/219] fix: refs #8221 duaInvoiceIn unique --- db/versions/11369-azureChrysanthemum/00-firstScript.sql | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 db/versions/11369-azureChrysanthemum/00-firstScript.sql diff --git a/db/versions/11369-azureChrysanthemum/00-firstScript.sql b/db/versions/11369-azureChrysanthemum/00-firstScript.sql new file mode 100644 index 000000000..3a86c0c59 --- /dev/null +++ b/db/versions/11369-azureChrysanthemum/00-firstScript.sql @@ -0,0 +1,5 @@ +ALTER TABLE vn.duaInvoiceIn DROP KEY IF EXISTS duaFk_UNIQUE; +ALTER TABLE vn.duaInvoiceIn DROP KEY IF EXISTS duaInvoiceIn_unique; +ALTER TABLE vn.duaInvoiceIn ADD CONSTRAINT duaInvoiceIn_unique + UNIQUE KEY (invoiceInFk); + From d872f164fda67e1803c538863014c3fc3b6261de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 27 Nov 2024 14:55:30 +0000 Subject: [PATCH 035/219] Actualizar modules/entry/back/models/entry.js --- modules/entry/back/models/entry.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 8ca79f531..49c3d2ec3 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -12,6 +12,7 @@ module.exports = Self => { require('../methods/entry/addFromBuy')(Self); require('../methods/entry/buyLabel')(Self); require('../methods/entry/print')(Self); + require('../methods/entry/buyLabelSupplier')(Self); Self.observe('before save', async function(ctx, options) { if (ctx.isNewInstance) return; From 30cc7a49a0f859e9c1d254a3a12d654a9dca045e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 27 Nov 2024 15:38:50 +0000 Subject: [PATCH 036/219] Actualizar modules/entry/back/methods/entry/print.js --- modules/entry/back/methods/entry/print.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/entry/back/methods/entry/print.js b/modules/entry/back/methods/entry/print.js index 5b9de9a69..b604adce6 100644 --- a/modules/entry/back/methods/entry/print.js +++ b/modules/entry/back/methods/entry/print.js @@ -48,6 +48,7 @@ module.exports = Self => { for (const buy of buys) { if (buy.stickers < 1) continue; ctx.args.id = buy.id; + ctx.args.copies = buy.stickers; const pdfBuffer = await models.Entry.buyLabel(ctx, myOptions); await merger.add(new Uint8Array(pdfBuffer[0])); } From ba51052d8836ab43df51f36baa21bc62392329fd Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 27 Nov 2024 17:52:45 +0100 Subject: [PATCH 037/219] feat: refs #7936 add SiiTypeInvoiceIn model and update invoice correction logic --- db/routines/sage/procedures/invoiceIn_add.sql | 2 +- db/versions/11368-whiteAspidistra/01-acls.sql | 23 +++++++++++++++++++ .../back/methods/invoice-in/corrective.js | 2 +- .../invoice-in/specs/corrective.spec.js | 2 +- .../back/models/invoice-in-correction.json | 7 +++--- modules/invoiceOut/back/model-config.json | 5 +++- .../back/models/sii-type-invoice-in.json | 22 ++++++++++++++++++ .../back/models/sii-type-invoice-out.json | 5 +--- 8 files changed, 56 insertions(+), 12 deletions(-) create mode 100644 db/versions/11368-whiteAspidistra/01-acls.sql create mode 100644 modules/invoiceOut/back/models/sii-type-invoice-in.json diff --git a/db/routines/sage/procedures/invoiceIn_add.sql b/db/routines/sage/procedures/invoiceIn_add.sql index a3de50d6a..eeeb28143 100644 --- a/db/routines/sage/procedures/invoiceIn_add.sql +++ b/db/routines/sage/procedures/invoiceIn_add.sql @@ -207,7 +207,7 @@ BEGIN IF vInvoiceInOriginalFk THEN UPDATE movContaIVA mci JOIN vn.invoiceInCorrection iic ON iic.correctingFk = vInvoiceInFk - JOIN vn.siiTypeInvoiceOut st ON st.id = iic.siiTypeInvoiceOutFk + JOIN vn.siiTypeInvoiceIn st ON st.id = iic.siiTypeInvoiceInFk JOIN (SELECT issued, SUM(sub.taxableBase) taxableBase, SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat diff --git a/db/versions/11368-whiteAspidistra/01-acls.sql b/db/versions/11368-whiteAspidistra/01-acls.sql new file mode 100644 index 000000000..6ac98db43 --- /dev/null +++ b/db/versions/11368-whiteAspidistra/01-acls.sql @@ -0,0 +1,23 @@ +INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId) + VALUES('SiiTypeInvoiceIn', 'find', 'READ', 'ALLOW', 'ROLE', 'salesPerson'); + +DROP TABLE IF EXISTS vn.invoiceInCorrection; + +CREATE TABLE `invoiceInCorrection` ( + `correctingFk` mediumint(8) unsigned NOT NULL COMMENT 'Factura rectificativa', + `correctedFk` mediumint(8) unsigned NOT NULL COMMENT 'Factura rectificada', + `cplusRectificationTypeFk` int(10) unsigned NOT NULL, + `siiTypeInvoiceInFk` int(10) unsigned NOT NULL, + `invoiceCorrectionTypeFk` int(11) NOT NULL DEFAULT 3, + PRIMARY KEY (`correctingFk`), + KEY `invoiceInCorrection_correctedFk` (`correctedFk`), + KEY `invoiceInCorrection_cplusRectificationTypeFk` (`cplusRectificationTypeFk`), + KEY `invoiceInCorrection_siiTypeInvoiceIn` (`siiTypeInvoiceInFk`), + KEY `invoiceInCorrection_invoiceCorrectionTypeFk` (`invoiceCorrectionTypeFk`), + CONSTRAINT `invoiceInCorrection_correctedFk` FOREIGN KEY (`correctedFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `invoiceInCorrection_correctingFk` FOREIGN KEY (`correctingFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `invoiceInCorrection_cplusRectificationTypeFk` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `cplusRectificationType` (`id`) ON UPDATE CASCADE, + CONSTRAINT `invoiceInCorrection_invoiceCorrectionTypeFk` FOREIGN KEY (`invoiceCorrectionTypeFk`) REFERENCES `invoiceCorrectionType` (`id`) ON UPDATE CASCADE, + CONSTRAINT `invoiceInCorrection_siiTypeInvoiceIn` FOREIGN KEY (`siiTypeInvoiceInFk`) REFERENCES `siiTypeInvoiceIn` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + diff --git a/modules/invoiceIn/back/methods/invoice-in/corrective.js b/modules/invoiceIn/back/methods/invoice-in/corrective.js index 05f632bcd..e7088d201 100644 --- a/modules/invoiceIn/back/methods/invoice-in/corrective.js +++ b/modules/invoiceIn/back/methods/invoice-in/corrective.js @@ -44,7 +44,7 @@ module.exports = Self => { correctingFk: clone.id, correctedFk: id, cplusRectificationTypeFk: invoiceType, - siiTypeInvoiceOutFk: invoiceClass, + siiTypeInvoiceInFk: invoiceClass, invoiceCorrectionTypeFk: invoiceReason }, myOptions); diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js index c63f02439..9f085694b 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js @@ -30,7 +30,7 @@ describe('invoiceIn corrective()', () => { }, options); expect(correction.cplusRectificationTypeFk).toEqual(invoiceType); - expect(correction.siiTypeInvoiceOutFk).toEqual(invoiceClass); + expect(correction.siiTypeInvoiceInFk).toEqual(invoiceClass); expect(correction.invoiceCorrectionTypeFk).toEqual(invoiceReason); }); }); diff --git a/modules/invoiceIn/back/models/invoice-in-correction.json b/modules/invoiceIn/back/models/invoice-in-correction.json index 52e16d420..d353f9e98 100644 --- a/modules/invoiceIn/back/models/invoice-in-correction.json +++ b/modules/invoiceIn/back/models/invoice-in-correction.json @@ -28,11 +28,10 @@ "model": "InvoiceCorrectionType", "foreignKey": "invoiceCorrectionTypeFk" }, - "siiTypeInvoiceOut": { + "siiTypeInvoiceIn": { "type": "belongsTo", - "model": "SiiTypeInvoiceOut", - "foreignKey": "siiTypeInvoiceOutFk" + "model": "SiiTypeInvoiceIn", + "foreignKey": "siiTypeInvoiceInFk" } - } } \ No newline at end of file diff --git a/modules/invoiceOut/back/model-config.json b/modules/invoiceOut/back/model-config.json index 9c7512429..710d824c3 100644 --- a/modules/invoiceOut/back/model-config.json +++ b/modules/invoiceOut/back/model-config.json @@ -43,5 +43,8 @@ }, "SiiTypeInvoiceOut": { "dataSource": "vn" + }, + "SiiTypeInvoiceIn": { + "dataSource": "vn" } -} +} \ No newline at end of file diff --git a/modules/invoiceOut/back/models/sii-type-invoice-in.json b/modules/invoiceOut/back/models/sii-type-invoice-in.json new file mode 100644 index 000000000..a191febb9 --- /dev/null +++ b/modules/invoiceOut/back/models/sii-type-invoice-in.json @@ -0,0 +1,22 @@ +{ + "name": "SiiTypeInvoiceIn", + "base": "VnModel", + "options": { + "mysql": { + "table": "siiTypeInvoiceIn" + } + }, + "properties": { + "id": { + "id": true, + "type": "number", + "description": "Identifier" + }, + "code": { + "type": "string" + }, + "description": { + "type": "string" + } + } +} \ No newline at end of file diff --git a/modules/invoiceOut/back/models/sii-type-invoice-out.json b/modules/invoiceOut/back/models/sii-type-invoice-out.json index 37fd39c38..89f01bd74 100644 --- a/modules/invoiceOut/back/models/sii-type-invoice-out.json +++ b/modules/invoiceOut/back/models/sii-type-invoice-out.json @@ -17,9 +17,6 @@ }, "description": { "type": "string" - }, - "code": { - "type": "string" } } -} +} \ No newline at end of file From 93388461d184de74a0fe01df4083c48b79fc37ae Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 28 Nov 2024 08:59:08 +0100 Subject: [PATCH 038/219] fix: refs #7266 Changed method name and corrections --- .../back/methods/entry/{print.js => labelSupplier.js} | 8 ++++---- modules/entry/back/models/entry.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) rename modules/entry/back/methods/entry/{print.js => labelSupplier.js} (89%) diff --git a/modules/entry/back/methods/entry/print.js b/modules/entry/back/methods/entry/labelSupplier.js similarity index 89% rename from modules/entry/back/methods/entry/print.js rename to modules/entry/back/methods/entry/labelSupplier.js index b604adce6..32d80c427 100644 --- a/modules/entry/back/methods/entry/print.js +++ b/modules/entry/back/methods/entry/labelSupplier.js @@ -1,6 +1,6 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { - Self.remoteMethodCtx('print', { + Self.remoteMethodCtx('labelSupplier', { description: 'Print stickers of all entries', accessType: 'READ', accepts: [ @@ -28,13 +28,13 @@ module.exports = Self => { } ], http: { - path: '/:id/print', + path: '/:id/labelSupplier', verb: 'GET' }, accessScopes: ['DEFAULT', 'read:multimedia'] }); - Self.print = async function(ctx, id, options) { + Self.labelSupplier = async function(ctx, id, options) { const models = Self.app.models; const myOptions = {}; if (typeof options == 'object') @@ -49,7 +49,7 @@ module.exports = Self => { if (buy.stickers < 1) continue; ctx.args.id = buy.id; ctx.args.copies = buy.stickers; - const pdfBuffer = await models.Entry.buyLabel(ctx, myOptions); + const pdfBuffer = await models.Entry.buyLabelSupplier(ctx, myOptions); await merger.add(new Uint8Array(pdfBuffer[0])); } diff --git a/modules/entry/back/models/entry.js b/modules/entry/back/models/entry.js index 49c3d2ec3..dc5022ada 100644 --- a/modules/entry/back/models/entry.js +++ b/modules/entry/back/models/entry.js @@ -11,7 +11,7 @@ module.exports = Self => { require('../methods/entry/addFromPackaging')(Self); require('../methods/entry/addFromBuy')(Self); require('../methods/entry/buyLabel')(Self); - require('../methods/entry/print')(Self); + require('../methods/entry/labelSupplier')(Self); require('../methods/entry/buyLabelSupplier')(Self); Self.observe('before save', async function(ctx, options) { From d5693291f033303d9c1156c09c676a9a30bfe5c6 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 28 Nov 2024 09:24:02 +0100 Subject: [PATCH 039/219] refactor: refs #8004 simplify SQL query by removing redundant aliases --- modules/item/back/methods/item/filter.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/item/back/methods/item/filter.js b/modules/item/back/methods/item/filter.js index 54dd975a4..a7fde1e6c 100644 --- a/modules/item/back/methods/item/filter.js +++ b/modules/item/back/methods/item/filter.js @@ -178,17 +178,18 @@ module.exports = Self => { i.isFloramondo, i.recycledPlastic, i.nonRecycledPlastic, - pr.name AS producer, - it.name AS typeName, - it.workerFk AS buyerFk, - u.name AS userName, - ori.code AS origin, - ic.name AS category, + pr.name producer, + it.name typeName, + it.workerFk buyerFk, + u.name userName, + ori.code origin, + ic.name category, i.intrastatFk, - intr.description AS intrastat, + intr.description intrastat, b.grouping, b.packing, - lb.landing AS landed + lb.landing landed, + it.name typeName FROM item i LEFT JOIN itemType it ON it.id = i.typeFk LEFT JOIN itemCategory ic ON ic.id = it.categoryFk From 51d96a89c590ecd93ee41f3f589ca67a8f10b902 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 28 Nov 2024 11:15:58 +0100 Subject: [PATCH 040/219] fix: refs #7266 Increased size item id buy-label --- .../templates/reports/buy-label-barcode/assets/css/style.css | 4 +++- .../reports/buy-label-barcode/buy-label-barcode.html | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/print/templates/reports/buy-label-barcode/assets/css/style.css b/print/templates/reports/buy-label-barcode/assets/css/style.css index eece20acb..ce1924878 100644 --- a/print/templates/reports/buy-label-barcode/assets/css/style.css +++ b/print/templates/reports/buy-label-barcode/assets/css/style.css @@ -33,7 +33,9 @@ td { font-size: 26px; } .lg-txt { - font-size: 32px; + font-size: 40px; + padding: 0px; + line-height: 1; } .xl-txt { font-size: 50px; diff --git a/print/templates/reports/buy-label-barcode/buy-label-barcode.html b/print/templates/reports/buy-label-barcode/buy-label-barcode.html index c1725f5c0..ebddb60ec 100644 --- a/print/templates/reports/buy-label-barcode/buy-label-barcode.html +++ b/print/templates/reports/buy-label-barcode/buy-label-barcode.html @@ -36,12 +36,12 @@
- - - + diff --git a/print/templates/reports/driver-route/sql/routes.sql b/print/templates/reports/driver-route/sql/routes.sql index 9d2dd5c13..334f2337d 100644 --- a/print/templates/reports/driver-route/sql/routes.sql +++ b/print/templates/reports/driver-route/sql/routes.sql @@ -1,6 +1,6 @@ SELECT r.id, r.m3, - r.created, + r.dated, r.time, u.nickName userNickName, v.tradeMark vehicleTradeMark, diff --git a/print/templates/reports/expedition-pallet-label/sql/labelData.sql b/print/templates/reports/expedition-pallet-label/sql/labelData.sql index 49a4031ae..5ddf8eb6e 100644 --- a/print/templates/reports/expedition-pallet-label/sql/labelData.sql +++ b/print/templates/reports/expedition-pallet-label/sql/labelData.sql @@ -4,7 +4,7 @@ SELECT ep.id palletFk, r.description `zone`, COUNT(es.id) labels, t.warehouseFk warehouseFk, - dayname(r.created) `dayName`, + dayname(r.dated) `dayName`, rs.id <=> rm.roadmapStopFk isMatch FROM vn.roadmapStop rs JOIN vn.expeditionPallet ep ON ep.truckFk = rs.id From 009b4ab7b9171f48f1c12a4efa526e71740e7a14 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 29 Nov 2024 11:31:31 +0100 Subject: [PATCH 049/219] fix: refs #7920 refs#7920 itemShelvingLogs --- modules/item/back/methods/item-shelving/getListItemNewer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/item/back/methods/item-shelving/getListItemNewer.js b/modules/item/back/methods/item-shelving/getListItemNewer.js index 5c4ca277d..c806c0a7e 100644 --- a/modules/item/back/methods/item-shelving/getListItemNewer.js +++ b/modules/item/back/methods/item-shelving/getListItemNewer.js @@ -51,7 +51,7 @@ module.exports = Self => { JOIN vn.productionConfig pc WHERE sh.code = ? AND s.code = pc.sectorFromCode ), tItemInSector AS ( - SELECT is2.itemFk, is2.created, is2.shelvingFk + SELECT is2.itemFk, is2.created, sh.code FROM vn.itemShelving is2 JOIN vn.shelving sh ON sh.id = is2.shelvingFk JOIN vn.parking p ON p.id = sh.parkingFk @@ -59,7 +59,7 @@ module.exports = Self => { JOIN vn.productionConfig pc WHERE sh.code <> ? AND s.code = pc.sectorFromCode) - SELECT ti.itemFK, tis.shelvingFk + SELECT ti.itemFK, tis.code shelvingFk FROM tItemShelving ti JOIN tItemInSector tis ON tis.itemFk = ti.itemFk JOIN vn.productionConfig pc From 1f6e401e39c45fbb404b8c9434b0f9cb3d052169 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Nov 2024 11:53:07 +0100 Subject: [PATCH 050/219] feat: refs #7936 add save validation --- .../invoiceIn/back/methods/invoice-in/toUnbook.js | 3 ++- .../back/methods/invoice-in/updateInvoiceIn.js | 3 ++- modules/invoiceIn/back/models/invoice-in.js | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/toUnbook.js b/modules/invoiceIn/back/methods/invoice-in/toUnbook.js index a697e9ddc..c27354d73 100644 --- a/modules/invoiceIn/back/methods/invoice-in/toUnbook.js +++ b/modules/invoiceIn/back/methods/invoice-in/toUnbook.js @@ -52,7 +52,8 @@ module.exports = Self => { accountingEntries = await models.Xdiario.count({ASIEN: asien}, myOptions); await models.Xdiario.destroyAll({ASIEN: asien}, myOptions); - await Self.updateAll({id: invoiceInId}, {isBooked: false}, myOptions); + const invoiceIn = await Self.findById(invoiceInId, myOptions); + await invoiceIn.updateAttribute('isBooked', false, myOptions); } else { const linkedBookEntry = await models.Xdiario.findOne({ fields: ['ASIEN'], diff --git a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js index 92a1ba8ee..2f1b4caca 100644 --- a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js +++ b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js @@ -82,7 +82,7 @@ module.exports = Self => { try { const invoiceIn = await Self.findById(id, null, myOptions); - invoiceIn.updateAttributes({supplierFk, + await invoiceIn.updateAttributes({supplierFk, supplierRef, issued, operated, @@ -94,6 +94,7 @@ module.exports = Self => { companyFk, withholdingSageFk }, myOptions); + if (tx) await tx.commit(); return invoiceIn; } catch (e) { diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js index 1e69c0ef8..21aa230c5 100644 --- a/modules/invoiceIn/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoice-in.js @@ -19,4 +19,19 @@ module.exports = Self => { return new UserError(`This invoice has a linked vehicle.`); return err; }); + + Self.observe('before save', async function(ctx) { + if (ctx.newInstance) return; + + const changes = ctx.data || ctx.instance; + const orgData = ctx.currentInstance; + let isNotEditable = orgData.isBooked || (!orgData.isBooked && changes.isBooked); + + if (isNotEditable) { + for (const [key, value] of Object.entries(changes)) { + if (key !== 'isBooked' && value !== orgData[key]) + throw new UserError('InvoiceIn is already booked'); + } + } + }); }; From fc1e0672a4469ae56446707ecd37cc696ff9ef43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 29 Nov 2024 11:59:36 +0100 Subject: [PATCH 051/219] fix: refs #8087 refs#8087 errores travel_moveRaids --- .../vn/procedures/travel_checkRaid.sql | 17 ----- .../vn/procedures/travel_moveRaids.sql | 69 +++++++++++-------- .../vn/triggers/travel_beforeInsert.sql | 4 -- 3 files changed, 41 insertions(+), 49 deletions(-) delete mode 100644 db/routines/vn/procedures/travel_checkRaid.sql diff --git a/db/routines/vn/procedures/travel_checkRaid.sql b/db/routines/vn/procedures/travel_checkRaid.sql deleted file mode 100644 index 64f3355e2..000000000 --- a/db/routines/vn/procedures/travel_checkRaid.sql +++ /dev/null @@ -1,17 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_checkRaid`( - vIsRaid BOOL, - vDaysInForward INT -) -BEGIN -/** - * Check if the values of isRaid and daysInforward are correct - * - * @param vIsRaid idRaid value - * @param vDaysInForward daysInForward value - */ - IF (NOT vIsRaid AND vDaysInForward IS NOT NULL) OR (vIsRaid AND vDaysInForward IS NULL) THEN - CALL util.throw('The raid information is not correct'); - END IF; -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/travel_moveRaids.sql b/db/routines/vn/procedures/travel_moveRaids.sql index cf0fce23c..52f6707bf 100644 --- a/db/routines/vn/procedures/travel_moveRaids.sql +++ b/db/routines/vn/procedures/travel_moveRaids.sql @@ -8,22 +8,16 @@ BEGIN DECLARE vDone BOOL DEFAULT FALSE; DECLARE vBuyerEmail VARCHAR(40); DECLARE vTravelLink TEXT; - DECLARE vMailBody TEXT DEFAULT ''; + DECLARE vMailBody TEXT; + DECLARE vIsMovible BOOL; + DECLARE vSubject VARCHAR(30); - DECLARE vCur CURSOR FOR - SELECT GROUP_CONCAT(DISTINCT - CONCAT('https://salix.verdnatura.es/#!/travel/', - ttm.travelFk, - '/summary ') - ORDER BY ttm.travelFk SEPARATOR '\n\r') travelLink, - CONCAT(u.name, '@verdnatura.es') buyerEmail - FROM tTravelToMove ttm - JOIN entry e ON e.travelFk = ttm.travelFk - JOIN buy b ON b.entryFk = e.id - JOIN item i ON i.id = b.itemFk - JOIN itemType it ON it.id = i.typeFk - JOIN account.user u ON u.id = it.workerFk - GROUP BY u.name; + DECLARE vTravels CURSOR FOR + SELECT GROUP_CONCAT(DISTINCT travelLink ORDER BY id SEPARATOR '\n\r'), + buyerEmail, + isMovable + FROM tTravelToMove + GROUP BY isMovable, buyerEmail; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -34,35 +28,54 @@ BEGIN END; CREATE OR REPLACE TEMPORARY TABLE tTravelToMove - SELECT id travelFk, - util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded + WITH travels AS ( + SELECT id , + CONCAT('https://salix.verdnatura.es/#!/travel/', id,'/summary') travelLink, + util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded, + shipped <= util.VN_CURDATE() + INTERVAL daysInForward DAY isMovable FROM travel WHERE isRaid - AND daysInForward; + AND daysInForward + )SELECT t.*, + CONCAT(u.name, '@verdnatura.es') buyerEmail + FROM travels t + STRAIGHT_JOIN entry e ON e.travelFk = t.id + JOIN buy b ON b.entryFk = e.id + JOIN item i ON i.id = b.itemFk + JOIN itemType it ON it.id = i.typeFk + JOIN account.user u ON u.id = it.workerFk + GROUP BY t.id; START TRANSACTION; UPDATE travel tr - JOIN tTravelToMove ttm ON ttm.travelFk = tr.id - SET tr.landed = ttm.newLanded; + JOIN tTravelToMove ttm ON ttm.id = tr.id + SET tr.landed = ttm.newLanded + WHERE ttm.isMovable; - OPEN vCur; + OPEN vTravels; l: LOOP SET vDone = FALSE; - FETCH vCur INTO vTravelLink, vBuyerEmail; + FETCH vTravels INTO vTravelLink, vBuyerEmail, vIsMovible; IF vDone THEN LEAVE l; END IF; - CALL `vn`.`mail_insert`( - vBuyerEmail, - 'noreply@verdnatura.es', - 'Cambio de fecha en Redadas', - CONCAT('Se ha movido los siguientes travels: \n\r ', vTravelLink)); + IF vIsMovible THEN + SET vSubject = 'Cambio de fecha en Redadas'; + SET vMailBody = 'Se ha movido los siguientes travels'; + ELSE + SET vSubject = 'ERROR al cambiar la fecha en Redadas'; + SET vMailBody = 'Ha ocurrido un error con las fechas al mover los siguiente travels'; + END IF; + + SET vMailBody = CONCAT(vMailBody, ': \n\r ', vTravelLink); + + CALL mail_insert(vBuyerEmail, 'noreply@verdnatura.es', vSubject, vMailBody); END LOOP; - CLOSE vCur; + CLOSE vTravels; COMMIT; DROP TEMPORARY TABLE tTravelToMove; END$$ diff --git a/db/routines/vn/triggers/travel_beforeInsert.sql b/db/routines/vn/triggers/travel_beforeInsert.sql index 5356ed537..50331ba6a 100644 --- a/db/routines/vn/triggers/travel_beforeInsert.sql +++ b/db/routines/vn/triggers/travel_beforeInsert.sql @@ -9,10 +9,6 @@ BEGIN CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk); - IF NEW.isRaid IS NOT NULL OR NEW.daysInForward IS NOT NULL THEN - CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward); - END IF; - IF NEW.awbFk IS NOT NULL THEN CALL travel_throwAwb(NEW.id); END IF; From 332e1c62d9e1361df960d2a0e99033c4b5263e74 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Nov 2024 12:22:01 +0100 Subject: [PATCH 052/219] feat: refs #7936 add validation to InvoiceIn & InvoiceInTax --- .../invoiceIn/back/models/invoice-in-tax.js | 18 ++++++++++++++++++ modules/invoiceIn/back/models/invoice-in.js | 6 ++++++ 2 files changed, 24 insertions(+) create mode 100644 modules/invoiceIn/back/models/invoice-in-tax.js diff --git a/modules/invoiceIn/back/models/invoice-in-tax.js b/modules/invoiceIn/back/models/invoice-in-tax.js new file mode 100644 index 000000000..a9d16ec42 --- /dev/null +++ b/modules/invoiceIn/back/models/invoice-in-tax.js @@ -0,0 +1,18 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.observe('before save', async function(ctx) { + if (ctx.newInstance) return; + + const models = Self.app.models; + const invoiceIn = await models.InvoiceIn.findById(ctx.currentInstance.invoiceInFk); + if (invoiceIn.isBooked) throw new UserError('InvoiceIn is already booked'); + }); + + Self.observe('before delete', async function(ctx) { + const models = Self.app.models; + const invoiceInTax = await models.InvoiceInTax.findById(ctx.where.id); + const invoiceIn = await models.InvoiceIn.findById(invoiceInTax.invoiceInFk); + if (invoiceIn.isBooked) throw new UserError('InvoiceIn is already booked'); + }); +}; diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js index 21aa230c5..ff5d1ba86 100644 --- a/modules/invoiceIn/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoice-in.js @@ -34,4 +34,10 @@ module.exports = Self => { } } }); + + Self.observe('before delete', async function(ctx) { + const invoiceIn = await Self.findById(ctx.where.id); + if (invoiceIn.isBooked) throw new UserError('InvoiceIn is already booked'); + }); }; + From 9ece52c5cecf15fa6d7350999f27cc3dd68d1b71 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Nov 2024 12:42:15 +0100 Subject: [PATCH 053/219] feat: refs #7936 add currency check to updateInvoiceIn --- .../back/methods/invoice-in/updateInvoiceIn.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js index 2f1b4caca..2b059f07b 100644 --- a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js +++ b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js @@ -72,6 +72,7 @@ module.exports = Self => { ) => { let tx; const myOptions = {userId: ctx.req.accessToken.userId}; + const models = Self.app.models; if (typeof options == 'object') Object.assign(myOptions, options); @@ -95,6 +96,17 @@ module.exports = Self => { withholdingSageFk }, myOptions); + if (currencyFk) { + const currency = await models.Currency.findById(currencyFk, null, myOptions); + if (currency.code === 'EUR') { + const invoiceInTaxes = await models.InvoiceInTax.find( + {where: {invoiceInFk: id}}, myOptions); + + for (const invoiceInTax of invoiceInTaxes) + await invoiceInTax.updateAttribute('foreignValue', null, myOptions); + } + } + if (tx) await tx.commit(); return invoiceIn; } catch (e) { From 163c6ddd20b2846cff8a01d2415aa0fb317facf0 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Nov 2024 13:44:42 +0100 Subject: [PATCH 054/219] feat: refs #7936 add currency handling in invoiceIn trigger --- .../vn/triggers/invoiceIn_afterUpdate.sql | 18 ++++++++++++------ .../back/methods/invoice-in/updateInvoiceIn.js | 11 ----------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql index 95b1d98a9..8f0a63465 100644 --- a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql @@ -3,24 +3,30 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceIn_afterUpdate` AFTER UPDATE ON `invoiceIn` FOR EACH ROW BEGIN - IF NEW.issued != OLD.issued - OR NEW.currencyFk != OLD.currencyFk THEN + DECLARE vIsEuro BOOL; + + SELECT if(`code` = 'EUR', TRUE, FALSE) INTO vIsEuro + FROM currency + WHERE id = NEW.currencyFk; + + IF (NOT NEW.issued <=> OLD.issued + OR NEW.currencyFk <> OLD.currencyFk) THEN UPDATE invoiceInTax iit JOIN invoiceIn ii ON ii.id = iit.invoiceInFk LEFT JOIN referenceRate rr ON rr.dated = ii.issued AND rr.currencyFk = ii.currencyFk - SET iit.taxableBase = IF(iit.foreignValue IS NULL, iit.taxableBase, iit.foreignValue / rr.value) + SET iit.taxableBase = IF(vIsEuro, iit.taxableBase, iit.foreignValue / rr.value), + iit.foreignValue = IF(vIsEuro, NULL, iit.foreignValue) WHERE ii.id = NEW.id; UPDATE invoiceInDueDay iidd JOIN invoiceIn ii ON ii.id = iidd.invoiceInFk LEFT JOIN referenceRate rr ON rr.dated = ii.issued AND rr.currencyFk = ii.currencyFk - SET iidd.amount = IF(iidd.foreignValue IS NULL, iidd.amount, iidd.foreignValue / rr.value) + SET iidd.amount = IF(vIsEuro, iidd.amount, iidd.foreignValue / rr.value), + iidd.foreignValue = IF(vIsEuro, NULL, iidd.foreignValue) WHERE ii.id = NEW.id; - END IF; - END$$ DELIMITER ; diff --git a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js index 2b059f07b..6006b1b14 100644 --- a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js +++ b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js @@ -96,17 +96,6 @@ module.exports = Self => { withholdingSageFk }, myOptions); - if (currencyFk) { - const currency = await models.Currency.findById(currencyFk, null, myOptions); - if (currency.code === 'EUR') { - const invoiceInTaxes = await models.InvoiceInTax.find( - {where: {invoiceInFk: id}}, myOptions); - - for (const invoiceInTax of invoiceInTaxes) - await invoiceInTax.updateAttribute('foreignValue', null, myOptions); - } - } - if (tx) await tx.commit(); return invoiceIn; } catch (e) { From c9cf96676b15f0d2d45469a3fbda417422008b8d Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Nov 2024 14:32:12 +0100 Subject: [PATCH 055/219] fix: refs #7936 check if insert in hook & change test description --- .../back/methods/invoice-in/specs/corrective.spec.js | 4 ++-- modules/invoiceIn/back/models/invoice-in-tax.js | 2 +- modules/invoiceIn/back/models/invoice-in.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js index 9f085694b..aee8d3f2c 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/corrective.spec.js @@ -15,11 +15,11 @@ describe('invoiceIn corrective()', () => { await tx.rollback(); }); - it('La función corrective debería devolver un id cuando se ejecuta correctamente', async() => { + it('should return an id when executed correctly', async() => { const originalId = 1; const invoiceReason = 3; const invoiceType = 2; - const invoiceClass = 1; + const invoiceClass = 8; const cloneId = await models.InvoiceIn.corrective(ctx, originalId, invoiceReason, invoiceType, invoiceClass, options); diff --git a/modules/invoiceIn/back/models/invoice-in-tax.js b/modules/invoiceIn/back/models/invoice-in-tax.js index a9d16ec42..0449d7719 100644 --- a/modules/invoiceIn/back/models/invoice-in-tax.js +++ b/modules/invoiceIn/back/models/invoice-in-tax.js @@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.observe('before save', async function(ctx) { - if (ctx.newInstance) return; + if (ctx.isNewInstance) return; const models = Self.app.models; const invoiceIn = await models.InvoiceIn.findById(ctx.currentInstance.invoiceInFk); diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js index ff5d1ba86..ac197e904 100644 --- a/modules/invoiceIn/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoice-in.js @@ -21,7 +21,7 @@ module.exports = Self => { }); Self.observe('before save', async function(ctx) { - if (ctx.newInstance) return; + if (ctx.isNewInstance) return; const changes = ctx.data || ctx.instance; const orgData = ctx.currentInstance; From ac87905351ef6dbebaaee042f3c78132c44706d8 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Nov 2024 15:49:14 +0100 Subject: [PATCH 056/219] feat: refs #7936 add back test for updateInvoiceIn --- .../invoice-in/specs/updateInvoiceIn.spec.js | 59 +++++++++++++++++++ .../methods/invoice-in/updateInvoiceIn.js | 1 - 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 modules/invoiceIn/back/methods/invoice-in/specs/updateInvoiceIn.spec.js diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/updateInvoiceIn.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/updateInvoiceIn.spec.js new file mode 100644 index 000000000..4e856ec71 --- /dev/null +++ b/modules/invoiceIn/back/methods/invoice-in/specs/updateInvoiceIn.spec.js @@ -0,0 +1,59 @@ +const models = require('vn-loopback/server/server').models; + +const invoiceInId = 1; +const supplierId = 791; +fdescribe('invoiceIn updateInvoiceIn()', () => { + const ctx = beforeAll.getCtx(); + let options; + let tx; + + beforeEach(async() => { + options = {transaction: tx}; + tx = await models.Sale.beginTransaction({}); + options.transaction = tx; + }); + + afterEach(async() => { + await tx.rollback(); + }); + + it('should update the invoice', async() => { + const invoiceBefore = await models.InvoiceIn.findById(invoiceInId, null, options); + await update(ctx, options); + const invoiceAfter = await models.InvoiceIn.findById(invoiceInId, null, options); + + expect(invoiceAfter.supplierFk).not.toBe(invoiceBefore.supplierFk); + expect(invoiceAfter.supplierFk).toBe(supplierId); + }); + + it('should not update the invoice if is booked', async() => { + let error; + try { + await models.InvoiceIn.toBook(ctx, invoiceInId, options); + await update(ctx, options); + } catch (e) { + error = e; + } + + expect(error.message).toBe('InvoiceIn is already booked'); + }); +}); + +async function update(ctx, opts) { + const supplierRef = 'mockRef'; + const currencyId = 1; + await models.InvoiceIn.updateInvoiceIn(ctx, + invoiceInId, + supplierId, + supplierRef, + undefined, + undefined, + undefined, + undefined, + undefined, + undefined, + currencyId, + undefined, + undefined, + opts); +} diff --git a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js index 6006b1b14..2f1b4caca 100644 --- a/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js +++ b/modules/invoiceIn/back/methods/invoice-in/updateInvoiceIn.js @@ -72,7 +72,6 @@ module.exports = Self => { ) => { let tx; const myOptions = {userId: ctx.req.accessToken.userId}; - const models = Self.app.models; if (typeof options == 'object') Object.assign(myOptions, options); From 59b5dd5a3627c08c8e1a5d0be468d00833cf68af Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Nov 2024 16:25:47 +0100 Subject: [PATCH 057/219] feat: refs #7936 add tests for invoiceIn --- .../invoice-in/specs/invoiceIn.spec.js | 66 +++++++++++++++++++ .../invoice-in/specs/updateInvoiceIn.spec.js | 2 +- 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js new file mode 100644 index 000000000..4e2ee36d5 --- /dev/null +++ b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js @@ -0,0 +1,66 @@ +const models = require('vn-loopback/server/server').models; + +fdescribe('invoiceIn', () => { + let options; + let tx; + const invoiceId = 1; + const supplierId = 791; + const currencyId = 1; + const companyId = 442; + + beforeEach(async() => { + options = {transaction: tx}; + tx = await models.InvoiceIn.beginTransaction({}); + options.transaction = tx; + }); + + afterEach(async() => { + await tx.rollback(); + }); + + it('should allow insert for new instance', async() => { + const newInvoice = { + supplierFk: supplierId, + issued: Date.vnNew(), + operated: Date.vnNew(), + currencyFk: currencyId, + companyFk: companyId, + isBooked: false + }; + + const createdInvoice = await models.InvoiceIn.create(newInvoice, options); + + expect(createdInvoice).toBeDefined(); + expect(createdInvoice.id).toBeDefined(); + }); + + it('should throw an error if trying to update a booked invoice', async() => { + const invoice = await models.InvoiceIn.findById(invoiceId, null, options); + await invoice.updateAttribute('isBooked', true, options); + + let error; + try { + await invoice.updateAttribute('supplierFk', supplierId, options); + } catch (err) { + error = err; + } + + expect(error).toBeDefined(); + expect(error.message).toBe('InvoiceIn is already booked'); + }); + + it('should throw an error if trying to delete a booked invoice', async() => { + const invoice = await models.InvoiceIn.findById(invoiceId, null, options); + await invoice.updateAttribute('isBooked', true, options); + + let error; + try { + await models.InvoiceIn.deleteById(invoiceId, options); + } catch (err) { + error = err; + } + + expect(error).toBeDefined(); + expect(error.sqlMessage).toBe('InvoiceIn is already booked'); + }); +}); diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/updateInvoiceIn.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/updateInvoiceIn.spec.js index 4e856ec71..773e2ac2f 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/updateInvoiceIn.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/updateInvoiceIn.spec.js @@ -2,7 +2,7 @@ const models = require('vn-loopback/server/server').models; const invoiceInId = 1; const supplierId = 791; -fdescribe('invoiceIn updateInvoiceIn()', () => { +describe('invoiceIn updateInvoiceIn()', () => { const ctx = beforeAll.getCtx(); let options; let tx; From 00085f2b99d61086908ee29975cd731cbcf5b2c9 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 29 Nov 2024 17:05:13 +0100 Subject: [PATCH 058/219] feat: refs #7936 add tests for invoiceIn filter --- .../methods/invoice-in/specs/filter.spec.js | 17 +++++++++++++++++ .../methods/invoice-in/specs/invoiceIn.spec.js | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) 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 48310b32a..beaa608e6 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/filter.spec.js @@ -166,4 +166,21 @@ describe('InvoiceIn filter()', () => { throw e; } }); + + it('should return the invoice in matching companyFk', async() => { + const tx = await models.InvoiceIn.beginTransaction({}); + const options = {transaction: tx}; + + try { + const company = await models.Company.findOne({}, options); + const invoicesByCompany = await models.InvoiceIn.find({where: {companyFk: company.id}}, options); + const filteredInvoices = await models.InvoiceIn.filter({args: {companyFk: company.id}}, {}, options); + + expect(filteredInvoices.length).toEqual(invoicesByCompany.length); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js index 4e2ee36d5..69038d9fd 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js @@ -1,6 +1,6 @@ const models = require('vn-loopback/server/server').models; -fdescribe('invoiceIn', () => { +describe('invoiceIn', () => { let options; let tx; const invoiceId = 1; From b0ee1f3e24260098d712565c1b2a83a8c1cade89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 29 Nov 2024 17:18:25 +0100 Subject: [PATCH 059/219] fix: refs #8087 refs#8087 errores travel_moveRaids --- .../vn/procedures/travel_checkRaid.sql | 17 +++++++++ .../vn/procedures/travel_moveRaids.sql | 38 ++++++++----------- .../vn/triggers/travel_beforeInsert.sql | 4 ++ .../vn/triggers/travel_beforeUpdate.sql | 4 ++ 4 files changed, 40 insertions(+), 23 deletions(-) create mode 100644 db/routines/vn/procedures/travel_checkRaid.sql diff --git a/db/routines/vn/procedures/travel_checkRaid.sql b/db/routines/vn/procedures/travel_checkRaid.sql new file mode 100644 index 000000000..885fc718a --- /dev/null +++ b/db/routines/vn/procedures/travel_checkRaid.sql @@ -0,0 +1,17 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_checkRaid`( + vIsRaid BOOL, + vDaysInForward INT +) +BEGIN +/** + * Check if the values of isRaid and daysInforward are correct + * + * @param vIsRaid idRaid value + * @param vDaysInForward daysInForward value + */ + IF NOT vIsRaid AND vDaysInForward THEN + CALL util.throw('If daysInForward has a value, the raid cannot be unchecked'); + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/vn/procedures/travel_moveRaids.sql b/db/routines/vn/procedures/travel_moveRaids.sql index 52f6707bf..7f2593a3b 100644 --- a/db/routines/vn/procedures/travel_moveRaids.sql +++ b/db/routines/vn/procedures/travel_moveRaids.sql @@ -9,15 +9,14 @@ BEGIN DECLARE vBuyerEmail VARCHAR(40); DECLARE vTravelLink TEXT; DECLARE vMailBody TEXT; - DECLARE vIsMovible BOOL; + DECLARE vDaysBetweenDates INT; DECLARE vSubject VARCHAR(30); DECLARE vTravels CURSOR FOR SELECT GROUP_CONCAT(DISTINCT travelLink ORDER BY id SEPARATOR '\n\r'), - buyerEmail, - isMovable + buyerEmail FROM tTravelToMove - GROUP BY isMovable, buyerEmail; + GROUP BY buyerEmail; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -29,20 +28,20 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tTravelToMove WITH travels AS ( - SELECT id , + SELECT id, CONCAT('https://salix.verdnatura.es/#!/travel/', id,'/summary') travelLink, util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded, - shipped <= util.VN_CURDATE() + INTERVAL daysInForward DAY isMovable - FROM travel + util.VN_CURDATE() - INTERVAL DATEDIFF(landed, shipped) + daysInForward DAY newShipped + FROM vn.travel WHERE isRaid AND daysInForward )SELECT t.*, CONCAT(u.name, '@verdnatura.es') buyerEmail FROM travels t - STRAIGHT_JOIN entry e ON e.travelFk = t.id - JOIN buy b ON b.entryFk = e.id - JOIN item i ON i.id = b.itemFk - JOIN itemType it ON it.id = i.typeFk + STRAIGHT_JOIN vn.entry e ON e.travelFk = t.id + JOIN vn.buy b ON b.entryFk = e.id + JOIN vn.item i ON i.id = b.itemFk + JOIN vn.itemType it ON it.id = i.typeFk JOIN account.user u ON u.id = it.workerFk GROUP BY t.id; @@ -50,28 +49,21 @@ BEGIN UPDATE travel tr JOIN tTravelToMove ttm ON ttm.id = tr.id - SET tr.landed = ttm.newLanded - WHERE ttm.isMovable; + SET tr.landed = ttm.newLanded, + tr.shipped = ttm.newShipped; OPEN vTravels; l: LOOP SET vDone = FALSE; - FETCH vTravels INTO vTravelLink, vBuyerEmail, vIsMovible; + FETCH vTravels INTO vTravelLink, vBuyerEmail; IF vDone THEN LEAVE l; END IF; - IF vIsMovible THEN - SET vSubject = 'Cambio de fecha en Redadas'; - SET vMailBody = 'Se ha movido los siguientes travels'; - ELSE - SET vSubject = 'ERROR al cambiar la fecha en Redadas'; - SET vMailBody = 'Ha ocurrido un error con las fechas al mover los siguiente travels'; - END IF; - - SET vMailBody = CONCAT(vMailBody, ': \n\r ', vTravelLink); + SET vSubject = 'Cambio de fecha en Redadas', + vMailBody = CONCAT('Se ha movido los siguientes travels: \n\r ', vTravelLink); CALL mail_insert(vBuyerEmail, 'noreply@verdnatura.es', vSubject, vMailBody); END LOOP; diff --git a/db/routines/vn/triggers/travel_beforeInsert.sql b/db/routines/vn/triggers/travel_beforeInsert.sql index 50331ba6a..5356ed537 100644 --- a/db/routines/vn/triggers/travel_beforeInsert.sql +++ b/db/routines/vn/triggers/travel_beforeInsert.sql @@ -9,6 +9,10 @@ BEGIN CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk); + IF NEW.isRaid IS NOT NULL OR NEW.daysInForward IS NOT NULL THEN + CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward); + END IF; + IF NEW.awbFk IS NOT NULL THEN CALL travel_throwAwb(NEW.id); END IF; diff --git a/db/routines/vn/triggers/travel_beforeUpdate.sql b/db/routines/vn/triggers/travel_beforeUpdate.sql index 256dd35f8..5a27b43b4 100644 --- a/db/routines/vn/triggers/travel_beforeUpdate.sql +++ b/db/routines/vn/triggers/travel_beforeUpdate.sql @@ -20,6 +20,10 @@ BEGIN CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk); END IF; + IF NOT (NEW.isRaid <=> OLD.isRaid) OR NOT (NEW.daysInForward <=> OLD.daysInForward) THEN + CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward); + END IF; + IF NOT (NEW.awbFk <=> OLD.awbFk)THEN SELECT COUNT(*) INTO vHasAnyInvoiceBooked FROM travel t From 202ed47963dad41ed96efce4197225113feb2c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 29 Nov 2024 17:20:14 +0100 Subject: [PATCH 060/219] fix: refs #8087 refs#8087 errores travel_moveRaids --- db/routines/vn/procedures/travel_moveRaids.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/travel_moveRaids.sql b/db/routines/vn/procedures/travel_moveRaids.sql index 7f2593a3b..17d7ecc4c 100644 --- a/db/routines/vn/procedures/travel_moveRaids.sql +++ b/db/routines/vn/procedures/travel_moveRaids.sql @@ -35,7 +35,10 @@ BEGIN FROM vn.travel WHERE isRaid AND daysInForward - )SELECT t.*, + )SELECT t.id, + t.travelLink, + t.newLanded, + t.newShipped, CONCAT(u.name, '@verdnatura.es') buyerEmail FROM travels t STRAIGHT_JOIN vn.entry e ON e.travelFk = t.id From a17e434df1068c8333bb3ab080d3e160f20b1542 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 2 Dec 2024 06:59:01 +0100 Subject: [PATCH 061/219] fix: refs #7266 Buy label barcode, minor barcode width --- print/templates/reports/buy-label-barcode/buy-label-barcode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/print/templates/reports/buy-label-barcode/buy-label-barcode.js b/print/templates/reports/buy-label-barcode/buy-label-barcode.js index a0359acc9..37b618f09 100755 --- a/print/templates/reports/buy-label-barcode/buy-label-barcode.js +++ b/print/templates/reports/buy-label-barcode/buy-label-barcode.js @@ -20,7 +20,7 @@ module.exports = { xmlDocument: document, format: 'code128', displayValue: false, - width: 3.8, + width: 3.5, height: 75, margin: 0 }); From cf862202ffa468d8a54fa7b7b222273763110a11 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 2 Dec 2024 10:12:56 +0100 Subject: [PATCH 062/219] fix: hotfix 7323 createAbsence --- .../11372-azureMedeola/00-firstScript.sql | 2 ++ loopback/locale/en.json | 4 +-- loopback/locale/es.json | 3 +- .../back/methods/worker/createAbsence.js | 6 ++++ .../worker/specs/createAbsence.spec.js | 29 +++++++++++++++++++ 5 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 db/versions/11372-azureMedeola/00-firstScript.sql diff --git a/db/versions/11372-azureMedeola/00-firstScript.sql b/db/versions/11372-azureMedeola/00-firstScript.sql new file mode 100644 index 000000000..b98701509 --- /dev/null +++ b/db/versions/11372-azureMedeola/00-firstScript.sql @@ -0,0 +1,2 @@ +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Worker','isHr','WRITE','ALLOW','ROLE','hr'); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index fdd39325b..c52da615a 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -245,6 +245,6 @@ "Invalid or expired verification code": "Invalid or expired verification code", "Payment method is required": "Payment method is required", "The raid information is not correct": "The raid information is not correct", - "Sales already moved": "Sales already moved" - + "Sales already moved": "Sales already moved", + "Holidays to past days not available": "Holidays to past days not available" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 4e691f375..782b2504a 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -388,5 +388,6 @@ "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}", "The web user's email already exists": "El correo del usuario web ya existe", "Sales already moved": "Ya han sido transferidas", - "The raid information is not correct": "La información de la redada no es correcta" + "The raid information is not correct": "La información de la redada no es correcta", + "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles" } diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 0397886cf..264de4dd3 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -54,6 +54,7 @@ module.exports = Self => { try { const isSubordinate = await models.Worker.isSubordinate(ctx, id, myOptions); const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); + const isHr = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isHr', 'WRITE'); if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); @@ -113,6 +114,11 @@ module.exports = Self => { if ((holiday && isFestive) && (workCenter.workcenterFk === holiday.workCenterFk)) throw new UserError(`Cannot add holidays on this day`); + const newDate = new Date(ctx.args.dated).getTime(); + const nowDate = now.getTime(); + if ((nowDate > newDate) && !isHr) + throw new UserError(`Holidays to past days not available`); + const absence = await models.Calendar.create({ businessFk: labour.businessFk, dayOffTypeFk: args.absenceTypeId, diff --git a/modules/worker/back/methods/worker/specs/createAbsence.spec.js b/modules/worker/back/methods/worker/specs/createAbsence.spec.js index fcb1c1633..1c7efcd28 100644 --- a/modules/worker/back/methods/worker/specs/createAbsence.spec.js +++ b/modules/worker/back/methods/worker/specs/createAbsence.spec.js @@ -162,4 +162,33 @@ describe('Worker createAbsence()', () => { expect(error.message).toEqual(`The worker has hours recorded that day`); }); + + it(`Should throw an error when adding a "Vacation" absence on a past day`, async() => { + const ctx = { + req: {accessToken: {userId: 19}}, + args: { + id: 1110, + businessFk: 1110, + absenceTypeId: 1, + dated: '2000-12-27T23:00:00.000Z', + } + }; + const workerId = 19; + + const tx = await app.models.Calendar.beginTransaction({}); + + let error; + try { + const options = {transaction: tx}; + + await app.models.Worker.createAbsence(ctx, workerId, options); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toEqual(`Holidays to past days not available`); + }); }); From 4e6b83809b21ba4ab74fe448b4eb7a19998958c7 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 2 Dec 2024 10:29:12 +0100 Subject: [PATCH 063/219] fix: workerHoliday hr --- db/versions/11372-azureMedeola/00-firstScript.sql | 2 +- modules/worker/back/methods/worker/createAbsence.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/versions/11372-azureMedeola/00-firstScript.sql b/db/versions/11372-azureMedeola/00-firstScript.sql index b98701509..53295e9f8 100644 --- a/db/versions/11372-azureMedeola/00-firstScript.sql +++ b/db/versions/11372-azureMedeola/00-firstScript.sql @@ -1,2 +1,2 @@ INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('Worker','isHr','WRITE','ALLOW','ROLE','hr'); + VALUES ('Worker','canCreateAbsenceInPast','WRITE','ALLOW','ROLE','hr'); diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 264de4dd3..dad02d0dc 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -54,7 +54,7 @@ module.exports = Self => { try { const isSubordinate = await models.Worker.isSubordinate(ctx, id, myOptions); const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); - const isHr = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isHr', 'WRITE'); + const canCreateAbsenceInPast = await models.ACL.checkAccessAcl(ctx, 'Worker', 'canCreateAbsenceInPast', 'WRITE'); if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); @@ -116,7 +116,7 @@ module.exports = Self => { const newDate = new Date(ctx.args.dated).getTime(); const nowDate = now.getTime(); - if ((nowDate > newDate) && !isHr) + if ((nowDate > newDate) && !canCreateAbsenceInPast) throw new UserError(`Holidays to past days not available`); const absence = await models.Calendar.create({ From fb40e25c7c334ef76aba966ac24dde3f26de3da3 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 2 Dec 2024 10:47:44 +0100 Subject: [PATCH 064/219] fix: remove ctx --- modules/worker/back/methods/worker/createAbsence.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index dad02d0dc..495997f29 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -54,11 +54,11 @@ module.exports = Self => { try { const isSubordinate = await models.Worker.isSubordinate(ctx, id, myOptions); const isTeamBoss = await models.ACL.checkAccessAcl(ctx, 'Worker', 'isTeamBoss', 'WRITE'); - const canCreateAbsenceInPast = await models.ACL.checkAccessAcl(ctx, 'Worker', 'canCreateAbsenceInPast', 'WRITE'); if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); + const canCreateAbsenceInPast = await models.ACL.checkAccessAcl(ctx, 'Worker', 'canCreateAbsenceInPast', 'WRITE'); const labour = await models.WorkerLabour.findById(args.businessFk, { include: {relation: 'department'} }, myOptions); @@ -114,7 +114,7 @@ module.exports = Self => { if ((holiday && isFestive) && (workCenter.workcenterFk === holiday.workCenterFk)) throw new UserError(`Cannot add holidays on this day`); - const newDate = new Date(ctx.args.dated).getTime(); + const newDate = new Date(args.dated).getTime(); const nowDate = now.getTime(); if ((nowDate > newDate) && !canCreateAbsenceInPast) throw new UserError(`Holidays to past days not available`); From 30da83a88cc0b0d4235b21487dd54914504b6a7e Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 2 Dec 2024 11:52:05 +0100 Subject: [PATCH 065/219] fix: refs #244936 sale redirect catalog to lilium --- modules/ticket/front/sale/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 4f8494ed0..9937ce4c2 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -387,9 +387,8 @@ class Controller extends Section { } newOrderFromTicket() { - this.$http.post(`Orders/newFromTicket`, {ticketFk: this.ticket.id}).then(res => { - const path = this.$state.href('order.card.catalog', {id: res.data}); - window.open(path, '_blank'); + this.$http.post(`Orders/newFromTicket`, {ticketFk: this.ticket.id}).then(async res => { + window.location.href = await this.vnApp.getUrl(`order/${res.data}/catalog`); this.vnApp.showSuccess(this.$t('Order created')); }); From d355b320b424b4aeba647b9ac4679fa1d2aeb413 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 2 Dec 2024 12:25:27 +0100 Subject: [PATCH 066/219] test: refs #244936 remove window.open called --- modules/ticket/front/sale/index.js | 3 ++- modules/ticket/front/sale/index.spec.js | 4 ---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/ticket/front/sale/index.js b/modules/ticket/front/sale/index.js index 9937ce4c2..3672c467d 100644 --- a/modules/ticket/front/sale/index.js +++ b/modules/ticket/front/sale/index.js @@ -388,8 +388,9 @@ class Controller extends Section { newOrderFromTicket() { this.$http.post(`Orders/newFromTicket`, {ticketFk: this.ticket.id}).then(async res => { - window.location.href = await this.vnApp.getUrl(`order/${res.data}/catalog`); + const path = await this.vnApp.getUrl(`order/${res.data}/catalog`); + window.open(path, '_blank'); this.vnApp.showSuccess(this.$t('Order created')); }); } diff --git a/modules/ticket/front/sale/index.spec.js b/modules/ticket/front/sale/index.spec.js index 931776619..8ff9aa624 100644 --- a/modules/ticket/front/sale/index.spec.js +++ b/modules/ticket/front/sale/index.spec.js @@ -567,14 +567,10 @@ describe('Ticket', () => { const expectedResponse = {id: 123}; window.open = jasmine.createSpy('open'); - controller.$state.href = jasmine.createSpy('href') - .and.returnValue('/somePath'); $httpBackend.expect('POST', `Orders/newFromTicket`, expectedParams).respond(expectedResponse); controller.newOrderFromTicket(); $httpBackend.flush(); - - expect(window.open).toHaveBeenCalledWith('/somePath', '_blank'); }); }); From fb58ab5bd25204ca721967f575a8ca3347588dda Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 2 Dec 2024 12:54:36 +0100 Subject: [PATCH 067/219] fix: refs #7266 Created buy_getLastWihoutInventory proc --- .../functions/buy_getLastWihoutInventory.sql | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 db/routines/vn/functions/buy_getLastWihoutInventory.sql diff --git a/db/routines/vn/functions/buy_getLastWihoutInventory.sql b/db/routines/vn/functions/buy_getLastWihoutInventory.sql new file mode 100644 index 000000000..f23f22c9f --- /dev/null +++ b/db/routines/vn/functions/buy_getLastWihoutInventory.sql @@ -0,0 +1,32 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getLastWihoutInventory`( + vItemFk INT, + vWarehouseFk INT +) + RETURNS int(11) + DETERMINISTIC +BEGIN +/** + * Retorna la última compra que no sea inventario. + * + * @param vItemFk Id del artículo + * @param vWarehouseFk Id del almacén + * @return Id de compra + */ + DECLARE vBuyFk INT; + + SELECT b.id INTO vBuyFk + FROM vn.buy b + JOIN vn.entry e ON e.id = b.entryFk + JOIN vn.travel t ON t.id = e.travelFk + WHERE e.id <> (SELECT defaultEntry FROM vn.entryConfig) + AND e.supplierFk <> (SELECT supplierFk FROM vn.inventoryConfig) + AND e.typeFk <> 'inventory' + AND b.itemFk = vItemFk + AND (t.warehouseInFk = vWarehouseFk OR t.warehouseInFk IS NULL) + ORDER BY ABS(DATEDIFF(util.VN_CURDATE(), t.landed)), e.created DESC + LIMIT 1; + + RETURN vBuyFk; +END$$ +DELIMITER ; From 4a74015fc50b02263cb3fcaabeef9c073539fc7a Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 2 Dec 2024 12:57:34 +0100 Subject: [PATCH 068/219] fix: refs #7266 Minor changes --- .../vn/functions/buy_getLastWihoutInventory.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/functions/buy_getLastWihoutInventory.sql b/db/routines/vn/functions/buy_getLastWihoutInventory.sql index f23f22c9f..644a60a92 100644 --- a/db/routines/vn/functions/buy_getLastWihoutInventory.sql +++ b/db/routines/vn/functions/buy_getLastWihoutInventory.sql @@ -16,11 +16,11 @@ BEGIN DECLARE vBuyFk INT; SELECT b.id INTO vBuyFk - FROM vn.buy b - JOIN vn.entry e ON e.id = b.entryFk - JOIN vn.travel t ON t.id = e.travelFk - WHERE e.id <> (SELECT defaultEntry FROM vn.entryConfig) - AND e.supplierFk <> (SELECT supplierFk FROM vn.inventoryConfig) + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE e.id <> (SELECT defaultEntry FROM entryConfig) + AND e.supplierFk <> (SELECT supplierFk FROM inventoryConfig) AND e.typeFk <> 'inventory' AND b.itemFk = vItemFk AND (t.warehouseInFk = vWarehouseFk OR t.warehouseInFk IS NULL) From fc4f5b55f7f56b342d5f9bc930593e7c2e8f34b2 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 2 Dec 2024 12:59:37 +0100 Subject: [PATCH 069/219] fix: refs #6818 update country & channel --- db/dump/fixtures.before.sql | 5 +++-- db/versions/11373-pinkMastic/00-firstScript.sql | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 db/versions/11373-pinkMastic/00-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 878f146d1..f28bd4cd5 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4028,7 +4028,8 @@ INSERT INTO srt.buffer (id, x, y, `size`, `length`, stateFk, typeFk, isActive, c INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) VALUES (19, '1169'), - (8, '1183'); + (8, '1183'), + (1, '1320'); INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) - VALUES ('saysimle-url-mock', 1320); + VALUES ('saysimle-url-mock', '1819'); diff --git a/db/versions/11373-pinkMastic/00-firstScript.sql b/db/versions/11373-pinkMastic/00-firstScript.sql new file mode 100644 index 000000000..48816aae6 --- /dev/null +++ b/db/versions/11373-pinkMastic/00-firstScript.sql @@ -0,0 +1,6 @@ +INSERT IGNORE INTO vn.saySimpleCountry + SET countryFk = 1, + channel = '1320'; + +UPDATE vn.saySimpleConfig + SET defaultChannel = '1819'; \ No newline at end of file From 508908bf855d208db542c90691b1f1fab7412691 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 2 Dec 2024 13:01:12 +0100 Subject: [PATCH 070/219] fix: refs #7266 Minor changes --- ...tLastWihoutInventory.sql => buy_getLastWithoutInventory.sql} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename db/routines/vn/functions/{buy_getLastWihoutInventory.sql => buy_getLastWithoutInventory.sql} (97%) diff --git a/db/routines/vn/functions/buy_getLastWihoutInventory.sql b/db/routines/vn/functions/buy_getLastWithoutInventory.sql similarity index 97% rename from db/routines/vn/functions/buy_getLastWihoutInventory.sql rename to db/routines/vn/functions/buy_getLastWithoutInventory.sql index 644a60a92..ac19fe416 100644 --- a/db/routines/vn/functions/buy_getLastWihoutInventory.sql +++ b/db/routines/vn/functions/buy_getLastWithoutInventory.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getLastWihoutInventory`( +CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getLastWithoutInventory`( vItemFk INT, vWarehouseFk INT ) From 66a87f1997caf3cf14ccc34e12454a5c7d907db5 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 2 Dec 2024 13:33:39 +0100 Subject: [PATCH 071/219] feat: refs #6818 add current country prefix --- db/dump/fixtures.before.sql | 4 +- .../11373-pinkMastic/00-firstScript.sql | 103 +++++++++++++++++- 2 files changed, 104 insertions(+), 3 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index f28bd4cd5..6e19f7539 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2037,10 +2037,10 @@ INSERT INTO `vn`.`ticketService`(`id`, `description`, `quantity`, `price`, `taxC (4, 'Documentos', 1, 2.00, 1, 9, 1), (5, 'Documentos', 1, 2.00, 1, 8, 1); -INSERT INTO `pbx`.`config` (id,defaultPrefix) +INSERT IGNORE INTO `pbx`.`config` (id,defaultPrefix) VALUES (1,'0034'); -INSERT INTO `pbx`.`prefix` (country, prefix) +INSERT IGNORE INTO `pbx`.`prefix` (country, prefix) VALUES ('es', '0034'), ('fr', '0033'), diff --git a/db/versions/11373-pinkMastic/00-firstScript.sql b/db/versions/11373-pinkMastic/00-firstScript.sql index 48816aae6..2d7cd4dc7 100644 --- a/db/versions/11373-pinkMastic/00-firstScript.sql +++ b/db/versions/11373-pinkMastic/00-firstScript.sql @@ -3,4 +3,105 @@ INSERT IGNORE INTO vn.saySimpleCountry channel = '1320'; UPDATE vn.saySimpleConfig - SET defaultChannel = '1819'; \ No newline at end of file + SET defaultChannel = '1819'; + +INSERT IGNORE INTO pbx.prefix (country, prefix) VALUES + ('ES', '0034'), + ('IT', '0039'), + ('DE', '0049'), + ('RO', '0040'), + ('NL', '0031'), + ('BE', '0032'), + ('RU', '007'), + ('PT', '00351'), + ('LT', '00370'), + ('UA', '00380'), + ('CO', '0057'), + ('FI', '00358'), + ('EC', '00593'), + ('LB', '00961'), + ('IL', '00972'), + ('TH', '0066'), + ('PA', '00507'), + ('GB', '0044'), + ('FR', '0033'), + ('PL', '0048'), + ('MX', '0052'), + ('MA', '00212'), + ('AI', '001268'), + ('GH', '00233'), + ('SE', '0046'), + ('AE', '00971'), + ('KE', '00254'), + ('AD', '00376'), + ('AO', '00244'), + ('LU', '00352'), + ('BY', '00375'), + ('MD', '00373'), + ('DK', '0045'), + ('ET', '00251'), + ('AU', '0061'), + ('CA', '0001'), + ('CL', '0056'), + ('CN', '0086'), + ('CR', '00506'), + ('GT', '00502'), + ('CI', '00225'), + ('PE', '0051'), + ('LK', '0094'), + ('ZA', '0027'), + ('TR', '0090'), + ('ZW', '00263'), + ('MY', '0060'), + ('NZ', '0064'), + ('IE', '00353'), + ('MN', '00976'), + ('SV', '00503'), + ('ZM', '00260'), + ('JP', '0081'), + ('RW', '00250'), + ('AL', '00355'), + ('KW', '00965'), + ('SG', '0065'), + ('SR', '00597'), + ('KR', '0082'), + ('US', '0001'), + ('RS', '00381'), + ('AT', '0043'), + ('EG', '0020'), + ('LV', '00371'), + ('CY', '00357'), + ('CZ', '00420'), + ('BB', '001246'), + ('SK', '00421'), + ('IN', '0091'), + ('DZ', '00213'), + ('BR', '0055'), + ('GR', '0030'), + ('MC', '00377'), + ('SI', '00386'), + ('GP', '00590'), + ('NO', '0047'), + ('CH', '0041'), + ('AR', '0054'), + ('CU', '0053'), + ('GQ', '00240'), + ('GN', '00224'), + ('HN', '00504'), + ('ML', '00223'), + ('NI', '00505'), + ('PK', '0092'), + ('PY', '00595'), + ('SN', '00221'), + ('UY', '00598'), + ('VE', '0058'), + ('BG', '00359'), + ('GE', '00995'), + ('EE', '00372'), + ('SA', '00966'), + ('RN', '00234'), + ('HK', '00852'), + ('GI', '00350'), + ('CM', '00237'), + ('HU', '0036'), + ('AM', '00374'); \ No newline at end of file From fd05ce0915a3ec7748e7f6e578752aebe96b722d Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 2 Dec 2024 13:45:04 +0100 Subject: [PATCH 072/219] fix: refs #8222 fix prDeleteZone --- loopback/locale/en.json | 4 ++-- loopback/locale/es.json | 3 ++- modules/zone/back/methods/zone/deleteZone.js | 6 +++--- .../zone/back/methods/zone/specs/deleteZone.spec.js | 11 ++++++----- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index fdd39325b..b1cfd737f 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -245,6 +245,6 @@ "Invalid or expired verification code": "Invalid or expired verification code", "Payment method is required": "Payment method is required", "The raid information is not correct": "The raid information is not correct", - "Sales already moved": "Sales already moved" - + "Sales already moved": "Sales already moved", + "There are tickets to be invoiced": "There are tickets to be invoiced for this zone, please delete them first" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 4e691f375..6cd158eed 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -388,5 +388,6 @@ "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}", "The web user's email already exists": "El correo del usuario web ya existe", "Sales already moved": "Ya han sido transferidas", - "The raid information is not correct": "La información de la redada no es correcta" + "The raid information is not correct": "La información de la redada no es correcta", + "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero" } diff --git a/modules/zone/back/methods/zone/deleteZone.js b/modules/zone/back/methods/zone/deleteZone.js index 7432475b3..e2e01a949 100644 --- a/modules/zone/back/methods/zone/deleteZone.js +++ b/modules/zone/back/methods/zone/deleteZone.js @@ -51,9 +51,9 @@ module.exports = Self => { }; const ticketList = await models.Ticket.find(filter, myOptions); - - if (ticketList.length > 0) - throw new UserError('There are tickets for this area, delete them first'); + const hasRefFk = ticketList.some(ticket => ticket.refFk); + if (hasRefFk) + throw new UserError('There are tickets to be invoiced'); await models.Zone.destroyById(id, myOptions); diff --git a/modules/zone/back/methods/zone/specs/deleteZone.spec.js b/modules/zone/back/methods/zone/specs/deleteZone.spec.js index aef7fd290..510713f9e 100644 --- a/modules/zone/back/methods/zone/specs/deleteZone.spec.js +++ b/modules/zone/back/methods/zone/specs/deleteZone.spec.js @@ -8,14 +8,14 @@ describe('zone deletezone()', () => { __: value => value }; const ctx = {req: activeCtx}; - const zoneId = 4; - const zoneId2 = 3; let ticketIDs; beforeAll(async() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ active: activeCtx }); + + const zoneId = 4; const originalTickets = await models.Ticket.find({ where: { zoneFk: zoneId @@ -29,7 +29,7 @@ describe('zone deletezone()', () => { it('should delete a zone and update their tickets', async() => { const tx = await models.Zone.beginTransaction({}); - + const zoneId = 4; try { const options = {transaction: tx}; await models.Zone.deleteZone(ctx, zoneId, options); @@ -47,17 +47,18 @@ describe('zone deletezone()', () => { it('should not delete the zone if it has tickets', async() => { const tx = await models.Zone.beginTransaction({}); + const zoneId = 1; let error; try { const options = {transaction: tx}; - await models.Zone.deleteZone(ctx, zoneId2, options); + await models.Zone.deleteZone(ctx, zoneId, options); await tx.rollback(); } catch (e) { error = e.message; await tx.rollback(); } - expect(error).toEqual('There are tickets for this area, delete them first'); + expect(error).toEqual('There are tickets to be invoiced'); }); }); From 13387beed97d04411dd71f5cf2d380617fd079f9 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 2 Dec 2024 14:31:06 +0100 Subject: [PATCH 073/219] feat: refs #6818 add PbxConfig model --- back/model-config.json | 3 +++ back/models/pbx-config.json | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 back/models/pbx-config.json diff --git a/back/model-config.json b/back/model-config.json index e0bc92200..55c34ff64 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -130,6 +130,9 @@ "Payment": { "dataSource": "vn" }, + "PbxConfig": { + "dataSource": "vn" + }, "Postcode": { "dataSource": "vn" }, diff --git a/back/models/pbx-config.json b/back/models/pbx-config.json new file mode 100644 index 000000000..44137b55d --- /dev/null +++ b/back/models/pbx-config.json @@ -0,0 +1,27 @@ +{ + "name": "PbxConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "pbx.config" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "defaultPrefix": { + "type": "string" + } + }, + "acls": [ + { + "property": "*", + "accessType": "READ", + "principalType": "ROLE", + "principalId": "employee", + "permission": "ALLOW" + } + ] +} \ No newline at end of file From 9573090318e06dff2a3bd7ea73f90f85a5600e7e Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 2 Dec 2024 14:49:35 +0100 Subject: [PATCH 074/219] chore: refs #6818 rollback --- db/dump/fixtures.before.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 6e19f7539..658eb88c7 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -2037,7 +2037,7 @@ INSERT INTO `vn`.`ticketService`(`id`, `description`, `quantity`, `price`, `taxC (4, 'Documentos', 1, 2.00, 1, 9, 1), (5, 'Documentos', 1, 2.00, 1, 8, 1); -INSERT IGNORE INTO `pbx`.`config` (id,defaultPrefix) +INSERT INTO `pbx`.`config` (id,defaultPrefix) VALUES (1,'0034'); INSERT IGNORE INTO `pbx`.`prefix` (country, prefix) From 5b04debfb157b6240e4e1ba2f6bf32814930b91b Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 2 Dec 2024 17:48:40 +0100 Subject: [PATCH 075/219] refactor: refs #7936 add transaction & tests --- .../invoice-in/specs/invoiceIn.spec.js | 7 +- .../invoice-in/specs/invoiceInTax.spec.js | 74 +++++++++++++++++++ .../invoiceIn/back/models/invoice-in-tax.js | 6 +- modules/invoiceIn/back/models/invoice-in.js | 2 +- 4 files changed, 80 insertions(+), 9 deletions(-) create mode 100644 modules/invoiceIn/back/methods/invoice-in/specs/invoiceInTax.spec.js diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js index 69038d9fd..a83aad3b2 100644 --- a/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js +++ b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceIn.spec.js @@ -9,9 +9,8 @@ describe('invoiceIn', () => { const companyId = 442; beforeEach(async() => { - options = {transaction: tx}; tx = await models.InvoiceIn.beginTransaction({}); - options.transaction = tx; + options = {transaction: tx}; }); afterEach(async() => { @@ -45,7 +44,6 @@ describe('invoiceIn', () => { error = err; } - expect(error).toBeDefined(); expect(error.message).toBe('InvoiceIn is already booked'); }); @@ -60,7 +58,6 @@ describe('invoiceIn', () => { error = err; } - expect(error).toBeDefined(); - expect(error.sqlMessage).toBe('InvoiceIn is already booked'); + expect(error.message).toBe('InvoiceIn is already booked'); }); }); diff --git a/modules/invoiceIn/back/methods/invoice-in/specs/invoiceInTax.spec.js b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceInTax.spec.js new file mode 100644 index 000000000..e822189bd --- /dev/null +++ b/modules/invoiceIn/back/methods/invoice-in/specs/invoiceInTax.spec.js @@ -0,0 +1,74 @@ +const models = require('vn-loopback/server/server').models; + +describe('invoiceInTax', () => { + let options; + let tx; + const invoiceInId = 1; + const invoiceInTaxId = 1; + beforeEach(async() => { + tx = await models.InvoiceInTax.beginTransaction({}); + options = {transaction: tx}; + }); + + afterEach(async() => { + await tx.rollback(); + }); + + it('should throw an error if trying to save a tax from a booked invoice', async() => { + const invoiceIn = await models.InvoiceIn.findById(invoiceInId, null, options); + await invoiceIn.updateAttributes({isBooked: true}, options); + const invoiceInTax = await models.InvoiceInTax.findById(invoiceInTaxId, null, options); + let error; + try { + await invoiceInTax.updateAttribute('taxableBase', 100, options); + } catch (err) { + error = err; + } + + expect(error.message).toBe('InvoiceIn is already booked'); + }); + + it('should allow save if the invoice is not booked', async() => { + const invoiceIn = await models.InvoiceIn.findById(invoiceInId, null, options); + await invoiceIn.updateAttribute('isBooked', false, options); + + const invoiceInTax = await models.InvoiceInTax.findById(invoiceInTaxId, null, options); + await invoiceInTax.updateAttribute('taxableBase', 100, options); + + const updatedInvoiceInTax = await models.InvoiceInTax.findById(invoiceInTaxId, null, options); + + expect(updatedInvoiceInTax.taxableBase).toBe(100); + }); + + it('should throw an error if trying to delete a tax from a booked invoice', async() => { + const invoiceIn = await models.InvoiceIn.findById(invoiceInId, null, options); + await invoiceIn.updateAttribute('isBooked', true, options); + + let error; + try { + await models.InvoiceInTax.destroyById(invoiceInTaxId, options); + } catch (err) { + error = err; + } + + expect(error).toBeDefined(); + expect(error.message).toBe('InvoiceIn is already booked'); + }); + + it('should allow delete if the invoice is not booked', async() => { + const invoiceIn = await models.InvoiceIn.findById(invoiceInId, null, options); + await invoiceIn.updateAttribute('isBooked', false, options); + + let error; + try { + await models.InvoiceInTax.destroyById(invoiceInTaxId, options); + } catch (err) { + error = err; + } + + const deletedInvoiceInTax = await models.InvoiceInTax.findById(invoiceInTaxId, null, options); + + expect(error).toBeUndefined(); + expect(deletedInvoiceInTax).toBeNull(); + }); +}); diff --git a/modules/invoiceIn/back/models/invoice-in-tax.js b/modules/invoiceIn/back/models/invoice-in-tax.js index 0449d7719..ce33fe18f 100644 --- a/modules/invoiceIn/back/models/invoice-in-tax.js +++ b/modules/invoiceIn/back/models/invoice-in-tax.js @@ -5,14 +5,14 @@ module.exports = Self => { if (ctx.isNewInstance) return; const models = Self.app.models; - const invoiceIn = await models.InvoiceIn.findById(ctx.currentInstance.invoiceInFk); + const invoiceIn = await models.InvoiceIn.findById(ctx.currentInstance.invoiceInFk, null, ctx.options); if (invoiceIn.isBooked) throw new UserError('InvoiceIn is already booked'); }); Self.observe('before delete', async function(ctx) { const models = Self.app.models; - const invoiceInTax = await models.InvoiceInTax.findById(ctx.where.id); - const invoiceIn = await models.InvoiceIn.findById(invoiceInTax.invoiceInFk); + const invoiceInTax = await Self.findById(ctx.where.id, null, ctx.options); + const invoiceIn = await models.InvoiceIn.findById(invoiceInTax.invoiceInFk, null, ctx.options); if (invoiceIn.isBooked) throw new UserError('InvoiceIn is already booked'); }); }; diff --git a/modules/invoiceIn/back/models/invoice-in.js b/modules/invoiceIn/back/models/invoice-in.js index ac197e904..ca506b54d 100644 --- a/modules/invoiceIn/back/models/invoice-in.js +++ b/modules/invoiceIn/back/models/invoice-in.js @@ -36,7 +36,7 @@ module.exports = Self => { }); Self.observe('before delete', async function(ctx) { - const invoiceIn = await Self.findById(ctx.where.id); + const invoiceIn = await Self.findById(ctx.where.id, null, ctx.options); if (invoiceIn.isBooked) throw new UserError('InvoiceIn is already booked'); }); }; From 14892042bda2e09e0b85f027674946b9c186f265 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 3 Dec 2024 08:31:49 +0100 Subject: [PATCH 076/219] chore: refs #8267 pullinfo --- db/.pullinfo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/.pullinfo.json b/db/.pullinfo.json index 5b75584d1..b890ffc31 100644 --- a/db/.pullinfo.json +++ b/db/.pullinfo.json @@ -9,7 +9,7 @@ }, "vn": { "view": { - "expeditionPallet_Print": "99f75145ac2e7b612a6d71e74b6e55f194a465780fd9875a15eb01e6596b447e" + "expeditionPallet_Print": "04fc5f2967ce53bfbb85f7f48b9a3dca4a4f7111ac41e1775f4cc7d6538774b2" } } } From a85d797edc8eb25a8e83a049b4ab808ae20762af Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 3 Dec 2024 08:40:26 +0100 Subject: [PATCH 077/219] chore: pullinfo --- db/.pullinfo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/.pullinfo.json b/db/.pullinfo.json index 5b75584d1..b890ffc31 100644 --- a/db/.pullinfo.json +++ b/db/.pullinfo.json @@ -9,7 +9,7 @@ }, "vn": { "view": { - "expeditionPallet_Print": "99f75145ac2e7b612a6d71e74b6e55f194a465780fd9875a15eb01e6596b447e" + "expeditionPallet_Print": "04fc5f2967ce53bfbb85f7f48b9a3dca4a4f7111ac41e1775f4cc7d6538774b2" } } } From 0f0c8250a1e905c75734879499dca71999092751 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 3 Dec 2024 08:44:00 +0100 Subject: [PATCH 078/219] fix: fix sql --- db/versions/11375-navyIvy/00-firstScript.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/versions/11375-navyIvy/00-firstScript.sql diff --git a/db/versions/11375-navyIvy/00-firstScript.sql b/db/versions/11375-navyIvy/00-firstScript.sql new file mode 100644 index 000000000..a90aaf519 --- /dev/null +++ b/db/versions/11375-navyIvy/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.ticket DROP FOREIGN KEY tickets_zone_fk; +ALTER TABLE vn.ticket ADD CONSTRAINT tickets_zone_fk FOREIGN KEY (zoneFk) REFERENCES vn.`zone`(id) ON DELETE SET NULL ON UPDATE CASCADE; From 226794236853f5e1125f086530d39cd9e47d2b7d Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 3 Dec 2024 10:25:40 +0100 Subject: [PATCH 079/219] fix: fix invoiceOut filter --- modules/invoiceOut/back/methods/invoiceOut/filter.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/invoiceOut/back/methods/invoiceOut/filter.js b/modules/invoiceOut/back/methods/invoiceOut/filter.js index 99a80c169..764fdbb78 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/filter.js +++ b/modules/invoiceOut/back/methods/invoiceOut/filter.js @@ -14,6 +14,12 @@ module.exports = Self => { description: 'Filter defining where, order, offset, and limit - must be a JSON-encoded string', http: {source: 'query'} }, + { + arg: 'id', + type: 'number', + description: 'The invoiceOut id', + http: {source: 'query'} + }, { arg: 'search', type: 'string', @@ -106,6 +112,8 @@ module.exports = Self => { return {'i.created': value}; case 'clientFk': return {'i.clientFk': value}; + case 'id': + return {'i.id': value}; case 'fi': return {'c.fi': value}; case 'amount': From 01d8f15d2f92920888baaa43c49b564820a656a9 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 3 Dec 2024 12:07:55 +0100 Subject: [PATCH 080/219] fix: refs #4948 expedition_selfConsumptionPackaging --- .../vn/procedures/expedition_selfConsumptionPackaging.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql b/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql index 327934a43..166ec476c 100644 --- a/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql +++ b/db/routines/vn/procedures/expedition_selfConsumptionPackaging.sql @@ -54,7 +54,9 @@ proc:BEGIN WHERE shipped BETWEEN vCreated AND util.dayEnd(vCreated) AND clientFk = vClientFk AND addressFk = vAddressFk - AND warehouseFk = vWarehouseFk; + AND warehouseFk = vWarehouseFk + AND nickname = 'CAJAS AUTOCONSUMO' + LIMIT 1; IF vTicketFk IS NULL AND vAction = 'add' THEN INSERT INTO ticket(clientFk, warehouseFk, shipped, nickname, addressFk) From 424a0c80794f622cf6e481116a3db2688582dd58 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 3 Dec 2024 12:25:39 +0100 Subject: [PATCH 081/219] fix: refs #6389 packing --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 5eba78887..acd5635f6 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -161,8 +161,7 @@ module.exports = Self => { param = `t.${param}`; return {[param]: value}; case 'packing': - param = `i.${param}`; - return {[param]: value}; + return {'packing': value}; } }); From 104bef43c1077bbf13a1dd7064793baac603e540 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 3 Dec 2024 14:03:08 +0100 Subject: [PATCH 082/219] feat: add country id filter to sales monitor --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 927f49999..a0c1fd427 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -88,6 +88,11 @@ module.exports = Self => { arg: 'alertLevel', type: 'number', description: `The alert level of the tickets` + }, + { + arg: 'countryFk', + type: 'number', + description: 'The country id filter' } ], returns: { @@ -182,6 +187,7 @@ module.exports = Self => { t.totalWithVat, io.id invoiceOutId, a.provinceFk, + p.countryFk, p.name province, w.name warehouse, am.name agencyMode, @@ -360,6 +366,7 @@ module.exports = Self => { } case 'agencyModeFk': case 'warehouseFk': + case 'countryFk': param = `f.${param}`; return {[param]: value}; } From 71da7772d9636976dfefce8915be7d00df2c23fc Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 3 Dec 2024 14:33:42 +0100 Subject: [PATCH 083/219] build: new version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ef1dd8f89..4e823eaad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.50.0", + "version": "24.52.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From d7af439787a9362ec0999fd9d9a1d9a5db2cde30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Tue, 3 Dec 2024 17:49:48 +0000 Subject: [PATCH 084/219] Actualizar modules/travel/back/methods/travel/extraCommunityFilter.js --- .../methods/travel/extraCommunityFilter.js | 50 +++++++++---------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/modules/travel/back/methods/travel/extraCommunityFilter.js b/modules/travel/back/methods/travel/extraCommunityFilter.js index dcb704ff5..164da93af 100644 --- a/modules/travel/back/methods/travel/extraCommunityFilter.js +++ b/modules/travel/back/methods/travel/extraCommunityFilter.js @@ -1,4 +1,3 @@ - const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const buildFilter = require('vn-loopback/util/filter').buildFilter; const mergeFilters = require('vn-loopback/util/filter').mergeFilters; @@ -112,45 +111,42 @@ module.exports = Self => { let stmt; stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.travel'); stmt = new ParameterizedSQL( - `CREATE TEMPORARY TABLE tmp.travel + `CREATE TEMPORARY TABLE tmp.travel (INDEX (id)) ENGINE = MEMORY - SELECT - t.id, + SELECT t.id, t.ref, t.shipped, t.landed, t.kg, - am.id AS agencyModeFk, - am.name AS agencyModeName, - wo.id AS warehouseOutFk, - wo.name AS warehouseOutName, - w.name AS warehouseInFk, - w.name AS warehouseInName, - SUM(b.stickers) AS stickers, - s.id AS cargoSupplierFk, - s.nickname AS cargoSupplierNickname, - s.name AS supplierName, - CAST(SUM(b.weight * b.stickers) as DECIMAL(10,0)) as loadedKg, + am.id agencyModeFk, + am.name agencyModeName, + wo.id warehouseOutFk, + wo.name warehouseOutName, + w.name warehouseInFk, + w.name warehouseInName, + SUM(b.stickers) stickers, + s.id cargoSupplierFk, + s.nickname cargoSupplierNickname, + s.name supplierName, + CAST(SUM(b.weight * b.stickers) AS DECIMAL(10,0)) loadedKg, CAST( SUM( vc.aerealVolumetricDensity * b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 - ) as DECIMAL(10,0) - ) as volumeKg, - GREATEST( - CAST(SUM(b.weight * b.stickers) AS INT), - CAST( + ) AS DECIMAL(10,0) + ) volumeKg, + CAST( + GREATEST( + SUM(b.weight * b.stickers) , SUM(vc.aerealVolumetricDensity * b.stickers * - IF(pkg.volume, - pkg.volume, - pkg.width * pkg.depth * pkg.height - ) / 1000000 - ) AS INT - ) - / t.kg * 100, 0) percentageKg + IF(pkg.volume, + pkg.volume, + pkg.width * pkg.depth * pkg.height) / 1000000) + ) / t.kg * 100 AS INT + ) percentageKg FROM travel t LEFT JOIN supplier s ON s.id = t.cargoSupplierFk LEFT JOIN entry e ON e.travelFk = t.id From 123c0db1267763302c808aa9f44f60593d69c7b6 Mon Sep 17 00:00:00 2001 From: Jon Date: Wed, 4 Dec 2024 11:58:17 +0100 Subject: [PATCH 085/219] feat: modified data to be equal as the updated back --- db/dump/.dump/data.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index 4700d0066..a1d9a44a7 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -2110,7 +2110,7 @@ INSERT INTO `ACL` VALUES (746,'Claim','getSummary','READ','ALLOW','ROLE','claimV INSERT INTO `ACL` VALUES (747,'CplusRectificationType','*','READ','ALLOW','ROLE','administrative',NULL); INSERT INTO `ACL` VALUES (748,'SiiTypeInvoiceOut','*','READ','ALLOW','ROLE','salesPerson',NULL); INSERT INTO `ACL` VALUES (749,'InvoiceCorrectionType','*','READ','ALLOW','ROLE','salesPerson',NULL); -INSERT INTO `ACL` VALUES (750,'InvoiceOut','transferInvoice','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (750,'InvoiceOut','transfer','WRITE','ALLOW','ROLE','administrative',NULL); INSERT INTO `ACL` VALUES (751,'Application','executeProc','*','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (752,'Application','executeFunc','*','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (753,'NotificationSubscription','getList','READ','ALLOW','ROLE','employee',NULL); From fad6f33b7c981536f23ce4d85cd397ee6c61e8c2 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 4 Dec 2024 12:33:17 +0100 Subject: [PATCH 086/219] fix: refs #7031 remove check --- db/versions/11376-pinkBamboo/00-firstScript.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 db/versions/11376-pinkBamboo/00-firstScript.sql diff --git a/db/versions/11376-pinkBamboo/00-firstScript.sql b/db/versions/11376-pinkBamboo/00-firstScript.sql new file mode 100644 index 000000000..607a22b4d --- /dev/null +++ b/db/versions/11376-pinkBamboo/00-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE `zone` MODIFY COLUMN `price` DECIMAL(10,2) NOT NULL DEFAULT 0.00 CHECK (`price` > 0); + From 41a3f9ae949f87186f2e2e52f625539cda16a421 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 4 Dec 2024 13:19:14 +0100 Subject: [PATCH 087/219] refactor: refs #8272 delete bi.rotacion --- db/routines/bi/views/rotacion.sql | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 db/routines/bi/views/rotacion.sql diff --git a/db/routines/bi/views/rotacion.sql b/db/routines/bi/views/rotacion.sql deleted file mode 100644 index 65a5db923..000000000 --- a/db/routines/bi/views/rotacion.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE OR REPLACE DEFINER=`root`@`localhost` - SQL SECURITY DEFINER - VIEW `bi`.`rotacion` -AS SELECT `ic`.`itemFk` AS `Id_Article`, - `ic`.`warehouseFk` AS `warehouse_id`, - `ic`.`quantity` AS `total`, - `ic`.`rotation` AS `rotacion`, - `ic`.`cm3` AS `cm3`, - `ic`.`storage` AS `almacenaje`, - `ic`.`handling` AS `manipulacion`, - `ic`.`extraCharge` AS `auxiliar`, - `ic`.`wasted` AS `mermas`, - `ic`.`cm3delivery` AS `cm3reparto`, - `ic`.`grams` AS `grams` -FROM `vn`.`itemCost` `ic` From 187cd226c44efc9089adc26d8f7d597aff864267 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 5 Dec 2024 06:56:18 +0100 Subject: [PATCH 088/219] feat: refs #7644 Added distinct total label count --- modules/entry/back/methods/entry/buyLabelSupplier.js | 4 ++++ modules/entry/back/methods/entry/labelSupplier.js | 3 +-- .../buy-label-supplier/buy-label-supplier.html | 2 +- .../reports/buy-label-supplier/buy-label-supplier.js | 11 ++++++++++- .../templates/reports/buy-label-supplier/sql/buy.sql | 7 +++++-- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/modules/entry/back/methods/entry/buyLabelSupplier.js b/modules/entry/back/methods/entry/buyLabelSupplier.js index 61938f2f8..23806f561 100644 --- a/modules/entry/back/methods/entry/buyLabelSupplier.js +++ b/modules/entry/back/methods/entry/buyLabelSupplier.js @@ -9,6 +9,10 @@ module.exports = Self => { required: true, description: 'The entry id', http: {source: 'path'} + }, { + arg: 'showEntryLines', + type: 'boolean', + required: false } ], returns: [ diff --git a/modules/entry/back/methods/entry/labelSupplier.js b/modules/entry/back/methods/entry/labelSupplier.js index 32d80c427..07107d032 100644 --- a/modules/entry/back/methods/entry/labelSupplier.js +++ b/modules/entry/back/methods/entry/labelSupplier.js @@ -47,8 +47,7 @@ module.exports = Self => { for (const buy of buys) { if (buy.stickers < 1) continue; - ctx.args.id = buy.id; - ctx.args.copies = buy.stickers; + ctx.args = {...ctx.args, id: buy.id, showEntryLines: true}; const pdfBuffer = await models.Entry.buyLabelSupplier(ctx, myOptions); await merger.add(new Uint8Array(pdfBuffer[0])); } diff --git a/print/templates/reports/buy-label-supplier/buy-label-supplier.html b/print/templates/reports/buy-label-supplier/buy-label-supplier.html index 5777d34de..31fef38f7 100644 --- a/print/templates/reports/buy-label-supplier/buy-label-supplier.html +++ b/print/templates/reports/buy-label-supplier/buy-label-supplier.html @@ -86,7 +86,7 @@ diff --git a/print/templates/reports/buy-label-supplier/buy-label-supplier.js b/print/templates/reports/buy-label-supplier/buy-label-supplier.js index 3cef5f295..5e59472eb 100755 --- a/print/templates/reports/buy-label-supplier/buy-label-supplier.js +++ b/print/templates/reports/buy-label-supplier/buy-label-supplier.js @@ -9,7 +9,7 @@ module.exports = { mixins: [vnReport], async serverPrefetch() { const buy = await models.Buy.findById(this.id, null); - this.buys = await this.rawSqlFromDef('buy', [buy.entryFk, buy.entryFk, buy.entryFk, this.id]); + this.buys = await this.rawSqlFromDef('buy', [buy.entryFk, buy.entryFk, buy.entryFk, this.id, this.id]); const date = new Date(); this.weekNum = moment(date).isoWeek(); this.dayNum = moment(date).day(); @@ -27,6 +27,11 @@ module.exports = { height: 115, }); return new XMLSerializer().serializeToString(svgNode); + }, + getTotal(buy) { + return (this.showEntryLines) ? + `${buy.entryLabelNum} / ${buy.entryLabels}` : + `${buy.buyLabelNum} / ${buy.buyLabels}`; } }, props: { @@ -34,6 +39,10 @@ module.exports = { type: Number, required: true, description: 'The entry id' + }, + showEntryLines: { + type: Boolean, + required: false } } }; diff --git a/print/templates/reports/buy-label-supplier/sql/buy.sql b/print/templates/reports/buy-label-supplier/sql/buy.sql index 26efeb06e..fe001ff10 100644 --- a/print/templates/reports/buy-label-supplier/sql/buy.sql +++ b/print/templates/reports/buy-label-supplier/sql/buy.sql @@ -10,7 +10,7 @@ WITH RECURSIVE numbers AS ( ) ), labels AS ( - SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) labelNum, + SELECT ROW_NUMBER() OVER(ORDER BY b.id, num.n) entryLabelNum, i.name, i.`size`, i.category, @@ -33,6 +33,9 @@ labels AS ( WHERE b.entryFk = ? AND num.n <= b.stickers ) -SELECT *, (SELECT SUM(stickers) FROM buy WHERE entryFk = ?) maxLabelNum +SELECT *, + ROW_NUMBER() OVER(ORDER BY entryLabelNum) buyLabelNum, + (SELECT SUM(stickers) FROM buy WHERE entryFk = ?) entryLabels, + (SELECT stickers FROM buy WHERE id = ?) buyLabels FROM labels WHERE id = ? \ No newline at end of file From 483966501a2b6e46ade7e13d79c334df1fa9d565 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 5 Dec 2024 08:31:09 +0100 Subject: [PATCH 089/219] fix: refs #7031 fix vnPrice --- db/versions/11376-pinkBamboo/00-firstScript.sql | 2 +- loopback/locale/en.json | 7 ++++--- loopback/locale/es.json | 10 +++++----- modules/zone/back/models/zone.js | 14 ++++++++++++++ 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/db/versions/11376-pinkBamboo/00-firstScript.sql b/db/versions/11376-pinkBamboo/00-firstScript.sql index 607a22b4d..0c1e71a2f 100644 --- a/db/versions/11376-pinkBamboo/00-firstScript.sql +++ b/db/versions/11376-pinkBamboo/00-firstScript.sql @@ -1,2 +1,2 @@ -ALTER TABLE `zone` MODIFY COLUMN `price` DECIMAL(10,2) NOT NULL DEFAULT 0.00 CHECK (`price` > 0); +ALTER TABLE vn.`zone` MODIFY COLUMN `price` DECIMAL(10,2); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index ff0281d4a..af07b29fa 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -246,6 +246,7 @@ "ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}", "The raid information is not correct": "The raid information is not correct", "Payment method is required": "Payment method is required", - "Sales already moved": "Sales already moved", - "There are tickets to be invoiced": "There are tickets to be invoiced for this zone, please delete them first" -} + "Sales already moved": "Sales already moved", + "There are tickets to be invoiced": "There are tickets to be invoiced for this zone, please delete them first", + "Price cannot be blank": "Price cannot be blank" +} \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 1eb953d89..37572de03 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -388,8 +388,8 @@ "You do not have permission to modify the booked field": "No tienes permisos para modificar el campo contabilizada", "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}", "The web user's email already exists": "El correo del usuario web ya existe", - "Sales already moved": "Ya han sido transferidas", - "The raid information is not correct": "La información de la redada no es correcta", - "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero" -} - + "Sales already moved": "Ya han sido transferidas", + "The raid information is not correct": "La información de la redada no es correcta", + "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", + "Price cannot be blank": "Price cannot be blank" +} \ No newline at end of file diff --git a/modules/zone/back/models/zone.js b/modules/zone/back/models/zone.js index 6d5a6cdca..7b5cb4301 100644 --- a/modules/zone/back/models/zone.js +++ b/modules/zone/back/models/zone.js @@ -14,4 +14,18 @@ module.exports = Self => { Self.validatesPresenceOf('agencyModeFk', { message: `Agency cannot be blank` }); + + Self.validatesPresenceOf('price', { + message: 'Price cannot be blank' + }); + Self.validateAsync('price', priceIsValid, { + message: 'Price must be greater than 0' + }); + + async function priceIsValid(err, done) { + if (this.price <= 0) + err(); + + done(); + } }; From 7b2439cb39ed1d4aaffaef12e2f2a30733941d2f Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 5 Dec 2024 08:47:28 +0100 Subject: [PATCH 090/219] feat: refs #8248 Added beta in jenkinsfile --- Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 19f47c5b0..055cf858f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,7 +7,8 @@ def RUN_BUILD def BRANCH_ENV = [ test: 'test', - master: 'production' + master: 'production', + beta: 'production' ] node { @@ -18,7 +19,8 @@ node { PROTECTED_BRANCH = [ 'dev', 'test', - 'master' + 'master', + 'beta' ].contains(env.BRANCH_NAME) FROM_GIT = env.JOB_NAME.startsWith('gitea/') From 97f08542be35bbac00c38ba5d6c5b3e94107c75a Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 5 Dec 2024 10:28:57 +0100 Subject: [PATCH 091/219] feat: added translations and show error in item-type --- loopback/locale/es.json | 3 ++- modules/item/back/locale/item-minimum-quantity/en.yml | 5 +++++ modules/item/back/locale/item-minimum-quantity/es.yml | 5 +++++ modules/item/back/locale/item/en.yml | 2 +- modules/item/back/locale/item/es.yml | 2 +- modules/item/back/models/item-type.js | 9 +++++++++ 6 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 modules/item/back/locale/item-minimum-quantity/en.yml create mode 100644 modules/item/back/locale/item-minimum-quantity/es.yml create mode 100644 modules/item/back/models/item-type.js diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 1eb953d89..e4bdd035e 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -390,6 +390,7 @@ "The web user's email already exists": "El correo del usuario web ya existe", "Sales already moved": "Ya han sido transferidas", "The raid information is not correct": "La información de la redada no es correcta", - "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero" + "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", + "An item type with the same code already exists": "Un tipo con el mismo código ya existe" } diff --git a/modules/item/back/locale/item-minimum-quantity/en.yml b/modules/item/back/locale/item-minimum-quantity/en.yml new file mode 100644 index 000000000..206b1d96b --- /dev/null +++ b/modules/item/back/locale/item-minimum-quantity/en.yml @@ -0,0 +1,5 @@ +name: Minimum Quantity +columns: + ended: Ended + code: Code + started: Started \ No newline at end of file diff --git a/modules/item/back/locale/item-minimum-quantity/es.yml b/modules/item/back/locale/item-minimum-quantity/es.yml new file mode 100644 index 000000000..68c67eeff --- /dev/null +++ b/modules/item/back/locale/item-minimum-quantity/es.yml @@ -0,0 +1,5 @@ +name: Cantidad Mínima +columns: + ended: Finaliza + quantity: Cantidad + started: Comienza diff --git a/modules/item/back/locale/item/en.yml b/modules/item/back/locale/item/en.yml index ea40fd34b..f5e6fcf9a 100644 --- a/modules/item/back/locale/item/en.yml +++ b/modules/item/back/locale/item/en.yml @@ -46,4 +46,4 @@ columns: itemFk: item density: density compression: compression - + minQuantity: min quantity diff --git a/modules/item/back/locale/item/es.yml b/modules/item/back/locale/item/es.yml index 973f5e94f..68020d452 100644 --- a/modules/item/back/locale/item/es.yml +++ b/modules/item/back/locale/item/es.yml @@ -46,4 +46,4 @@ columns: itemFk: artículo density: densidad compression: compresión - + minQuantity: Cantidad mínima diff --git a/modules/item/back/models/item-type.js b/modules/item/back/models/item-type.js new file mode 100644 index 000000000..4dc8adfc9 --- /dev/null +++ b/modules/item/back/models/item-type.js @@ -0,0 +1,9 @@ +let UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.rewriteDbError(function(err) { + if (err.code === 'ER_DUP_ENTRY') + return new UserError(`An item type with the same code already exists`); + return err; + }); +}; From 5db8ae53acb4c2e751acacc1576e78111886f84d Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 5 Dec 2024 12:39:20 +0100 Subject: [PATCH 092/219] feat: refs #8188 refs#8188 orderPicking --- back/models/production-config.json | 3 + db/dump/fixtures.before.sql | 3 +- .../11377-pinkCarnation/00-firstScript.sql | 4 + .../item-shelving/getItemsByReviewOrder.js | 79 +++++++++++ .../specs/getItemsByReviewOrder.spec.js | 123 ++++++++++++++++++ modules/item/back/models/item-shelving.js | 1 + 6 files changed, 212 insertions(+), 1 deletion(-) create mode 100644 db/versions/11377-pinkCarnation/00-firstScript.sql create mode 100644 modules/item/back/methods/item-shelving/getItemsByReviewOrder.js create mode 100644 modules/item/back/methods/item-shelving/specs/getItemsByReviewOrder.spec.js diff --git a/back/models/production-config.json b/back/models/production-config.json index 2fc6d71ff..048264e8c 100644 --- a/back/models/production-config.json +++ b/back/models/production-config.json @@ -20,6 +20,9 @@ }, "backupPrinterNotificationDelay": { "type": "string" + }, + "itemOrderReviewHours": { + "type": "number" } } } \ No newline at end of file diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index eb3ae97ef..663705ff5 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3772,7 +3772,8 @@ VALUES (999992, 18, 50, '2023-09-21', NULL, 1, NULL, 103, NULL), (1000000, 18, 25, '2023-09-21', 25, 500, NULL, 103, NULL), (999996, 19, 5, '2023-09-27', 1, 5, NULL, 103, NULL), - (999997, 21, 10, '2023-09-27', 5, 100, NULL, 103, NULL); + (999997, 21, 10, '2023-09-27', 5, 100, NULL, 103, NULL), + (1000000, 16, 25, '2023-08-21',25, 500, NULL, NULL, NULL); -- Previous for Bolas de madera INSERT IGNORE INTO vn.sectorCollection diff --git a/db/versions/11377-pinkCarnation/00-firstScript.sql b/db/versions/11377-pinkCarnation/00-firstScript.sql new file mode 100644 index 000000000..0082a744d --- /dev/null +++ b/db/versions/11377-pinkCarnation/00-firstScript.sql @@ -0,0 +1,4 @@ +-- Place your SQL code here + + +ALTER TABLE vn.productionConfig ADD itemOrderReviewHours int(11) DEFAULT 24 NULL COMMENT 'Horas que se tienen cuen cuenta para comprobar orden en el almacén, null para desactivar revisión'; diff --git a/modules/item/back/methods/item-shelving/getItemsByReviewOrder.js b/modules/item/back/methods/item-shelving/getItemsByReviewOrder.js new file mode 100644 index 000000000..96a3c9969 --- /dev/null +++ b/modules/item/back/methods/item-shelving/getItemsByReviewOrder.js @@ -0,0 +1,79 @@ +module.exports = Self => { + const models = require('vn-loopback/server/server').models; + Self.remoteMethod('getItemsByReviewOrder', { + description: + 'Get list items if they are ordered by pickingOrder and their created regarding where they will be parked', + accessType: 'READ', + accepts: [{ + arg: 'shelving', + type: 'string', + required: true, + description: 'Shelving code' + }, + { + arg: 'parking', + type: 'string', + required: true, + description: 'Parking code' + }, + { + arg: 'itemFk', + type: 'number', + description: 'Item id' + }, + ], + returns: { + type: 'Array', + root: true + }, + http: { + path: `/getItemsByReviewOrder`, + verb: 'GET' + } + }); + + Self.getItemsByReviewOrder = async(shelving, parking, itemFk, options) => { + const myOptions = {}; + if (typeof options == 'object') + Object.assign(myOptions, options); + + const config = await models.ProductionConfig.findOne(); + const hoursToCompare = config['itemOrderReviewHours']; + if (!hoursToCompare) return []; + + const parkingItem = await models.Parking.findOne({where: {code: parking}}, myOptions); + if (!parkingItem) return []; + const pickingOrderToCompare = parkingItem['pickingOrder']; + + const result = await Self.rawSql(` + WITH currentItemShelving AS( + SELECT is2.created + INTERVAL ? HOUR created, is2.itemFk, sh.code + FROM vn.itemShelving is2 + JOIN vn.shelving sh ON sh.id = is2.shelvingFk + LEFT JOIN vn.parking p ON p.id = sh.parkingFk + LEFT JOIN vn.sector s ON s.id = p.sectorFk + WHERE sh.code = ? AND (? IS NULL OR is2.itemFk = ?) + ) + ,itemShelvings AS ( + SELECT is2.itemFk, is2.created, sh.code, p.pickingOrder,p.code parkingFk + FROM vn.itemShelving is2 + JOIN currentItemShelving ai ON is2.itemfk = ai.itemFk + JOIN vn.shelving sh ON sh.id = is2.shelvingFk AND ai.code <> sh.code + JOIN vn.parking p ON p.id = sh.parkingFk + JOIN vn.sector s ON s.id = p.sectorFk) + ,parkingDestiny AS ( + SELECT ? pickingOrder) + SELECT ish.*, + CASE + WHEN ish.pickingOrder < d.pickingOrder AND aish.created < ish.created THEN "new" + WHEN ish.pickingOrder > d.pickingOrder AND aish.created > ish.created THEN "old" + END AS itemCreated + FROM itemShelvings ish + JOIN parkingDestiny d + JOIN currentItemShelving aish + WHERE ish.pickingOrder < d.pickingOrder AND aish.created < ish.created OR + ish.pickingOrder > d.pickingOrder AND aish.created > ish.created;`, + [hoursToCompare, shelving, itemFk, itemFk, pickingOrderToCompare], myOptions); + return result; + }; +}; diff --git a/modules/item/back/methods/item-shelving/specs/getItemsByReviewOrder.spec.js b/modules/item/back/methods/item-shelving/specs/getItemsByReviewOrder.spec.js new file mode 100644 index 000000000..c16e155c9 --- /dev/null +++ b/modules/item/back/methods/item-shelving/specs/getItemsByReviewOrder.spec.js @@ -0,0 +1,123 @@ + +const {models} = require('vn-loopback/server/server'); + +describe('itemShelving getItemsByReviewOrder()', () => { + fit('should return empty because hoursToReview = 0', async() => { + const shelving = 'NBB'; + const parking = '700-01'; + + const tx = await models.Sector.beginTransaction({}); + const myOptions = {transaction: tx}; + + try { + const config = await models.ProductionConfig.findOne(); + await config.updateAttributes({ + itemOrderReviewHours: null, + }); + + const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, myOptions); + + expect(result.length).toEqual(0); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + fit('should return an item because you are trying parking a shelving and there is an older item', async() => { + const shelving = 'NBB'; + const parking = 'K-26-2'; + const itemFk = 1000000; + + const tx = await models.Sector.beginTransaction({}); + const myOptions = {transaction: tx}; + + try { + const config = await models.ProductionConfig.findOne(); + await config.updateAttributes({ + itemOrderReviewHours: 24, + }); + + const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, itemFk, myOptions); + + expect(result.length).toEqual(1); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + fit('should return an item because you are trying parking a shelving and there is an newer item', async() => { + const shelving = 'NBB'; + const parking = 'K-26-2'; + const itemFk = 1000000; + + const tx = await models.Sector.beginTransaction({}); + const myOptions = {transaction: tx}; + + try { + const config = await models.ProductionConfig.findOne(); + await config.updateAttributes({ + itemOrderReviewHours: 24, + }); + + const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, itemFk, myOptions); + + expect(result.length).toEqual(1); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + fit('should return a item list because you are trying parking a shelving and there is an newer item', async() => { + const shelving = 'NCC'; + const parking = 'K-26-2'; + const itemFk = 1000000; + + const tx = await models.Sector.beginTransaction({}); + const myOptions = {transaction: tx}; + + try { + const config = await models.ProductionConfig.findOne(); + await config.updateAttributes({ + itemOrderReviewHours: 24, + }); + + const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, itemFk, myOptions); + + expect(result.length).toEqual(2); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + fit('should return empty list because all order is correct', async() => { + const shelving = 'NCC'; + const parking = 'A-01-1'; + const itemFk = 1000000; + + const tx = await models.Sector.beginTransaction({}); + const myOptions = {transaction: tx}; + + try { + const config = await models.ProductionConfig.findOne(); + await config.updateAttributes({ + itemOrderReviewHours: 24, + }); + + const result = await models.ItemShelving.getItemsByReviewOrder(shelving, parking, itemFk, myOptions); + + expect(result.length).toEqual(0); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); +}); diff --git a/modules/item/back/models/item-shelving.js b/modules/item/back/models/item-shelving.js index be72dac37..34e18f23f 100644 --- a/modules/item/back/models/item-shelving.js +++ b/modules/item/back/models/item-shelving.js @@ -5,4 +5,5 @@ module.exports = Self => { require('../methods/item-shelving/getAlternative')(Self); require('../methods/item-shelving/updateFromSale')(Self); require('../methods/item-shelving/getListItemNewer')(Self); + require('../methods/item-shelving/getItemsByReviewOrder')(Self); }; From d17566107e92e99ba16b6f2eeb9b748290695c21 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 5 Dec 2024 12:42:17 +0100 Subject: [PATCH 093/219] feat: refs #8188 refs#8188 orderPicking --- .../item-shelving/specs/getItemsByReviewOrder.spec.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/item/back/methods/item-shelving/specs/getItemsByReviewOrder.spec.js b/modules/item/back/methods/item-shelving/specs/getItemsByReviewOrder.spec.js index c16e155c9..8f368b57c 100644 --- a/modules/item/back/methods/item-shelving/specs/getItemsByReviewOrder.spec.js +++ b/modules/item/back/methods/item-shelving/specs/getItemsByReviewOrder.spec.js @@ -2,7 +2,7 @@ const {models} = require('vn-loopback/server/server'); describe('itemShelving getItemsByReviewOrder()', () => { - fit('should return empty because hoursToReview = 0', async() => { + it('should return empty because hoursToReview = 0', async() => { const shelving = 'NBB'; const parking = '700-01'; @@ -25,7 +25,7 @@ describe('itemShelving getItemsByReviewOrder()', () => { } }); - fit('should return an item because you are trying parking a shelving and there is an older item', async() => { + it('should return an item because you are trying parking a shelving and there is an older item', async() => { const shelving = 'NBB'; const parking = 'K-26-2'; const itemFk = 1000000; @@ -49,7 +49,7 @@ describe('itemShelving getItemsByReviewOrder()', () => { } }); - fit('should return an item because you are trying parking a shelving and there is an newer item', async() => { + it('should return an item because you are trying parking a shelving and there is an newer item', async() => { const shelving = 'NBB'; const parking = 'K-26-2'; const itemFk = 1000000; @@ -73,7 +73,7 @@ describe('itemShelving getItemsByReviewOrder()', () => { } }); - fit('should return a item list because you are trying parking a shelving and there is an newer item', async() => { + it('should return a item list because you are trying parking a shelving and there is an newer item', async() => { const shelving = 'NCC'; const parking = 'K-26-2'; const itemFk = 1000000; @@ -97,7 +97,7 @@ describe('itemShelving getItemsByReviewOrder()', () => { } }); - fit('should return empty list because all order is correct', async() => { + it('should return empty list because all order is correct', async() => { const shelving = 'NCC'; const parking = 'A-01-1'; const itemFk = 1000000; From f8e5b76a6f4b79cb3cd75ce77e57e58983458596 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Thu, 5 Dec 2024 13:56:06 +0100 Subject: [PATCH 094/219] feat: refs #8188 refs#8188 orderPicking --- db/versions/11377-pinkCarnation/00-firstScript.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/versions/11377-pinkCarnation/00-firstScript.sql b/db/versions/11377-pinkCarnation/00-firstScript.sql index 0082a744d..4511c1b7e 100644 --- a/db/versions/11377-pinkCarnation/00-firstScript.sql +++ b/db/versions/11377-pinkCarnation/00-firstScript.sql @@ -1,4 +1,5 @@ -- Place your SQL code here -ALTER TABLE vn.productionConfig ADD itemOrderReviewHours int(11) DEFAULT 24 NULL COMMENT 'Horas que se tienen cuen cuenta para comprobar orden en el almacén, null para desactivar revisión'; +ALTER TABLE vn.productionConfig ADD itemOrderReviewHours int(11) DEFAULT 24 NULL +COMMENT 'Horas que no se tienen en cuenta para comprobar orden en el almacén, null para desactivar revisión'; From 04a96e87d644c66124436b07c421a089b1df6479 Mon Sep 17 00:00:00 2001 From: guillermo Date: Sun, 8 Dec 2024 07:28:29 +0100 Subject: [PATCH 095/219] refactor: refs #7882 Deleted quadminds files --- .../quadminds-api-config/sendOrders.js | 88 ------------------- back/methods/quadminds-api-config/sendPois.js | 87 ------------------ back/model-config.json | 3 - back/models/quadminds-api-config.js | 4 - back/models/quadminds-api-config.json | 34 ------- .../11378-orangeAsparagus/00-firstScript.sql | 1 + 6 files changed, 1 insertion(+), 216 deletions(-) delete mode 100644 back/methods/quadminds-api-config/sendOrders.js delete mode 100644 back/methods/quadminds-api-config/sendPois.js delete mode 100644 back/models/quadminds-api-config.js delete mode 100644 back/models/quadminds-api-config.json create mode 100644 db/versions/11378-orangeAsparagus/00-firstScript.sql diff --git a/back/methods/quadminds-api-config/sendOrders.js b/back/methods/quadminds-api-config/sendOrders.js deleted file mode 100644 index 760d622b6..000000000 --- a/back/methods/quadminds-api-config/sendOrders.js +++ /dev/null @@ -1,88 +0,0 @@ -const axios = require('axios'); -const UserError = require('vn-loopback/util/user-error'); -const moment = require('moment'); - -module.exports = Self => { - Self.remoteMethod('sendOrders', { - description: 'Sends a set of orders', - accessType: 'WRITE', - accepts: [{ - arg: 'tickets', - type: ['number'], - required: true - } - ], - returns: { - type: 'string', - root: true - }, - http: { - path: `/sendOrders`, - verb: 'POST' - } - }); - Self.sendOrders = async tickets => { - const config = await Self.app.models.QuadmindsApiConfig.findOne(); - if (!config) throw new UserError('Config params not set'); - - if (tickets.length > config.maxObjects) - throw new UserError(`Quadminds does not support more than ${config.maxObjects} tickets`); - - let poisData = []; - let isOk; - for (let offset = 0; !isOk; offset = offset + config.limit) { - const pois = await axios.get(`${config.url}pois/search?limit=${config.limit}&offset=${offset}`, { - headers: { - 'Accept': 'application/json', - 'X-Saas-Apikey': config.key - } - }); - pois.data.data.length ? poisData.push(...pois.data.data) : isOk = true; - } - - const poiMap = new Map(poisData.map(poi => [poi.code, poi._id])); - - let orders = await Self.rawSql(` - SELECT a.id poiCode, - t.id code, - t.shipped date, - 'PEDIDO' operation, - t.totalWithVat totalAmount, - t.totalWithoutVat totalAmountWithoutTaxes, - SUM(sv.volume) volume - FROM ticket t - JOIN address a ON a.id = t.addressFk - JOIN saleVolume sv ON sv.ticketFk = t.id - WHERE t.id IN (?) - GROUP BY t.id - `, [tickets]); - - // Transformo code en string ya que lo obtenermos como integer - orders = orders.map(order => { - return { - ...order, - poiId: poiMap.get(order.poiCode.toString()) || undefined, - code: order.code.toString(), - date: moment(order.date).format('YYYY-MM-DD'), - totalAmount: order.totalAmount || undefined, - totalAmountWithoutTaxes: order.totalAmountWithoutTaxes || undefined, - timeWindow: [{ - from: config.orderTimeFrom, - to: config.orderTimeTo - }], - orderMeasures: [{ - constraintId: 3, // Volumen - value: order.volume - }] - }; - }); - - await axios.post(`${config.url}orders`, orders, { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'X-Saas-Apikey': config.key - } - }); - }; -}; diff --git a/back/methods/quadminds-api-config/sendPois.js b/back/methods/quadminds-api-config/sendPois.js deleted file mode 100644 index cb5eef93e..000000000 --- a/back/methods/quadminds-api-config/sendPois.js +++ /dev/null @@ -1,87 +0,0 @@ -const axios = require('axios'); -const UserError = require('vn-loopback/util/user-error'); - -module.exports = Self => { - Self.remoteMethod('sendPois', { - description: 'Sends a set of pois', - accessType: 'WRITE', - accepts: [{ - arg: 'tickets', - type: ['number'], - required: true - } - ], - returns: { - type: 'string', - root: true - }, - http: { - path: `/sendPois`, - verb: 'POST' - } - }); - Self.sendPois = async tickets => { - const config = await Self.app.models.QuadmindsApiConfig.findOne(); - if (!config) throw new UserError('Config params not set'); - - if (tickets.length > config.maxObjects) - throw new UserError(`Quadminds does not support more than ${config.maxObjects} tickets`); - - let pois = await Self.rawSql(` - WITH deliveryNotes AS ( - SELECT t.id, t.routeFk, tn.description - FROM ticket t - JOIN ticketObservation tn ON tn.ticketFk = t.id - JOIN observationType ot ON ot.id = tn.observationTypeFk - WHERE ot.code = 'delivery' - ) - SELECT a.id code, - c.socialName name, - IF(ABS(a.latitude - ROUND(a.latitude)) < 0.000001, NULL, a.latitude) latitude, - IF(ABS(a.longitude - ROUND(a.longitude)) < 0.000001, NULL, a.longitude) longitude, - a.street, - a.city locality, - p.name state, - co.name country, - CONCAT_WS(', ', IFNULL(a.street, ''), IFNULL(a.city, ''), IFNULL(p.name, '')) longAddress, - CONCAT(IFNULL(a.mobile, c.mobile)) phoneNumber, - dn.description poiDeliveryComments, - c.email email - FROM ticket t - JOIN address a ON a.id = t.addressFk - JOIN province p ON p.id = a.provinceFk - JOIN country co ON co.id = p.countryFk - JOIN client c ON c.id = t.clientFk - LEFT JOIN deliveryNotes dn ON dn.id = t.id - WHERE t.id IN (?) - GROUP BY t.id - `, [tickets]); - - // Transformo code en string ya que lo obtenermos como integer - pois = pois.map(poi => { - return { - ...poi, - code: poi.code.toString(), - latitude: poi.latitude || undefined, - longitude: poi.longitude || undefined, - address: { - street: poi.street || undefined, - locality: poi.locality || undefined, - state: poi.state || undefined, - country: poi.country || undefined - }, - poiDeliveryComments: poi.poiDeliveryComments || undefined, - phoneNumber: poi.phoneNumber || undefined, - email: poi.email || undefined - }; - }); - - await axios.post(`${config.url}pois`, pois, { - headers: { - 'Accept': 'application/json', - 'Content-Type': 'application/json', - 'X-Saas-Apikey': config.key - } - }); - }; -}; diff --git a/back/model-config.json b/back/model-config.json index 55c34ff64..c1682f29a 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -121,9 +121,6 @@ "Province": { "dataSource": "vn" }, - "QuadmindsApiConfig": { - "dataSource": "vn" - }, "Autonomy": { "dataSource": "vn" }, diff --git a/back/models/quadminds-api-config.js b/back/models/quadminds-api-config.js deleted file mode 100644 index c2773fa0b..000000000 --- a/back/models/quadminds-api-config.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = Self => { - require('../methods/quadminds-api-config/sendPois')(Self); - require('../methods/quadminds-api-config/sendOrders')(Self); -}; diff --git a/back/models/quadminds-api-config.json b/back/models/quadminds-api-config.json deleted file mode 100644 index 4001badf3..000000000 --- a/back/models/quadminds-api-config.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "QuadmindsApiConfig", - "base": "VnModel", - "options": { - "mysql": { - "table": "quadmindsApiConfig" - } - }, - "properties": { - "id": { - "type": "number", - "id": true, - "required": true - }, - "url": { - "type": "string" - }, - "key": { - "type": "string" - }, - "maxObjects": { - "type": "number" - }, - "limit": { - "type": "number" - }, - "orderTimeFrom": { - "type": "string" - }, - "orderTimeTo": { - "type": "string" - } - } -} diff --git a/db/versions/11378-orangeAsparagus/00-firstScript.sql b/db/versions/11378-orangeAsparagus/00-firstScript.sql new file mode 100644 index 000000000..a030b7e05 --- /dev/null +++ b/db/versions/11378-orangeAsparagus/00-firstScript.sql @@ -0,0 +1 @@ +DROP TABLE vn.quadmindsApiConfig; From 8960b546649da0a6ff99df0836d76784bdd25509 Mon Sep 17 00:00:00 2001 From: guillermo Date: Sun, 8 Dec 2024 14:30:05 +0100 Subject: [PATCH 096/219] feat: refs #7882 Added locationiq service --- back/methods/locationiq-config/optimize.js | 77 +++++++++++++++++++ back/model-config.json | 3 + back/models/locationiq-config.js | 4 + back/models/locationiq-config.json | 28 +++++++ .../11379-yellowCordyline/00-firstScript.sql | 8 ++ loopback/locale/es.json | 11 +-- 6 files changed, 126 insertions(+), 5 deletions(-) create mode 100644 back/methods/locationiq-config/optimize.js create mode 100644 back/models/locationiq-config.js create mode 100644 back/models/locationiq-config.json create mode 100644 db/versions/11379-yellowCordyline/00-firstScript.sql diff --git a/back/methods/locationiq-config/optimize.js b/back/methods/locationiq-config/optimize.js new file mode 100644 index 000000000..cd1f6e7ff --- /dev/null +++ b/back/methods/locationiq-config/optimize.js @@ -0,0 +1,77 @@ +const UserError = require('vn-loopback/util/user-error'); +const axios = require('axios'); + +module.exports = Self => { + Self.remoteMethod('optimize', { + description: 'Return optimized coords', + accessType: 'READ', + accepts: [{ + arg: 'addressIds', + type: 'array', + required: true + }], + returns: { + type: 'string', + root: true + }, + http: { + path: `/optimize`, + verb: 'GET' + } + }); + + Self.optimize = async addressIds => { + const models = Self.app.models; + try { + const locationiqConfig = await models.LocationiqConfig.findOne(); + if (!locationiqConfig) throw new UserError(`LocationIQ service is not configured`); + + let coords = []; + for (const addressId of addressIds) { + const address = await models.Address.findById(addressId); + coords.push({ + addressId, + latitude: address.latitude.toFixed(6), + longitude: address.longitude.toFixed(6) + }); + } + const concatCoords = coords + .map(coord => `${coord.longitude},${coord.latitude}`) + .join(';'); + const response = await axios.post(`${locationiqConfig.url}${concatCoords}?key=${locationiqConfig.key}`); + const tolerance = locationiqConfig.tolerance; + + for (waypoint of response.data.waypoints) { + const longitude = waypoint.location[0]; + const latitude = waypoint.location[1]; + + const matchedAddress = coords.find(coord => + Math.abs(coord.latitude - latitude) <= tolerance && + Math.abs(coord.longitude - longitude) <= tolerance + ); + if (matchedAddress) matchedAddress.position = waypoint.waypoint_index; + } + coords.sort((a, b) => { + const posA = a.position !== undefined ? a.position : Infinity; + const posB = b.position !== undefined ? b.position : Infinity; + return posA - posB; + }); + // Temporal para abrir en maps + const coordsString = coords + .map(item => `${item.latitude},${item.longitude}`) + .join('/'); + console.log(`https://www.google.es/maps/dir/${coordsString}`); + // --------- + return coords; + } catch (err) { + switch (err.response?.data?.code) { + case 'NoTrips': + throw new UserError('No trips found because input coordinates are not connected'); + case 'NotImplemented': + throw new UserError('This request is not supported'); + default: + throw err; + } + } + }; +}; diff --git a/back/model-config.json b/back/model-config.json index c1682f29a..f48e5f2eb 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -88,6 +88,9 @@ "Language": { "dataSource": "vn" }, + "LocationiqConfig": { + "dataSource": "vn" + }, "Machine": { "dataSource": "vn" }, diff --git a/back/models/locationiq-config.js b/back/models/locationiq-config.js new file mode 100644 index 000000000..e0fe736bb --- /dev/null +++ b/back/models/locationiq-config.js @@ -0,0 +1,4 @@ +module.exports = Self => { + require('../methods/locationiq-config/optimize')(Self); +}; + diff --git a/back/models/locationiq-config.json b/back/models/locationiq-config.json new file mode 100644 index 000000000..624341615 --- /dev/null +++ b/back/models/locationiq-config.json @@ -0,0 +1,28 @@ +{ + "name": "LocationiqConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "locationiqConfig" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "required": true + }, + "url": { + "type": "string", + "required": true + }, + "key": { + "type": "string", + "required": true + }, + "tolerance": { + "type": "number", + "required": false + } + } +} diff --git a/db/versions/11379-yellowCordyline/00-firstScript.sql b/db/versions/11379-yellowCordyline/00-firstScript.sql new file mode 100644 index 000000000..001ef6049 --- /dev/null +++ b/db/versions/11379-yellowCordyline/00-firstScript.sql @@ -0,0 +1,8 @@ +CREATE TABLE `vn`.`locationiqConfig` ( + `id` int(10) unsigned NOT NULL, + `url` varchar(100) NOT NULL, + `key` varchar(100) NOT NULL, + `tolerance` decimal(6,6) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + CONSTRAINT `locationiqConfig_check` CHECK (`id` = 1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 1eb953d89..fb495dfb1 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -388,8 +388,9 @@ "You do not have permission to modify the booked field": "No tienes permisos para modificar el campo contabilizada", "ticketLostExpedition": "El ticket [{{ticketId}}]({{{ticketUrl}}}) tiene la siguiente expedición perdida:{{ expeditionId }}", "The web user's email already exists": "El correo del usuario web ya existe", - "Sales already moved": "Ya han sido transferidas", - "The raid information is not correct": "La información de la redada no es correcta", - "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero" -} - + "Sales already moved": "Ya han sido transferidas", + "The raid information is not correct": "La información de la redada no es correcta", + "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", + "No trips found because input coordinates are not connected": "No se encontraron rutas porque las coordenadas de entrada no están conectadas", + "This request is not supported": "Esta solicitud no es compatible" +} \ No newline at end of file From 0bb9282953cacb199b6451e778fb22bda28baeae Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Dec 2024 09:11:55 +0100 Subject: [PATCH 097/219] feat: refs #7882 Added locationiq service --- back/methods/locationiq-config/optimize.js | 18 +++++++++++++----- .../11379-yellowCordyline/00-firstScript.sql | 7 ++++--- loopback/locale/es.json | 3 ++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/back/methods/locationiq-config/optimize.js b/back/methods/locationiq-config/optimize.js index cd1f6e7ff..97ea33089 100644 --- a/back/methods/locationiq-config/optimize.js +++ b/back/methods/locationiq-config/optimize.js @@ -38,7 +38,9 @@ module.exports = Self => { const concatCoords = coords .map(coord => `${coord.longitude},${coord.latitude}`) .join(';'); - const response = await axios.post(`${locationiqConfig.url}${concatCoords}?key=${locationiqConfig.key}`); + const response = await axios.post(` + ${locationiqConfig.url}optimize/driving/${concatCoords}?key=${locationiqConfig.key} + `); const tolerance = locationiqConfig.tolerance; for (waypoint of response.data.waypoints) { @@ -46,10 +48,14 @@ module.exports = Self => { const latitude = waypoint.location[1]; const matchedAddress = coords.find(coord => + !coord.position && Math.abs(coord.latitude - latitude) <= tolerance && Math.abs(coord.longitude - longitude) <= tolerance ); - if (matchedAddress) matchedAddress.position = waypoint.waypoint_index; + if (matchedAddress) + matchedAddress.position = waypoint.waypoint_index; + else + console.log(`Las coordenadas no se han podido asociar: ${latitude} | ${longitude}`); } coords.sort((a, b) => { const posA = a.position !== undefined ? a.position : Infinity; @@ -58,9 +64,9 @@ module.exports = Self => { }); // Temporal para abrir en maps const coordsString = coords - .map(item => `${item.latitude},${item.longitude}`) - .join('/'); - console.log(`https://www.google.es/maps/dir/${coordsString}`); + .map(item => `point=${item.latitude},${item.longitude}`) + .join('&'); + console.log(`https://graphhopper.com/maps/?${coordsString}&profile=small_truck`); // --------- return coords; } catch (err) { @@ -69,6 +75,8 @@ module.exports = Self => { throw new UserError('No trips found because input coordinates are not connected'); case 'NotImplemented': throw new UserError('This request is not supported'); + case 'InvalidOptions': + throw new UserError('Invalid options or too many coordinates'); default: throw err; } diff --git a/db/versions/11379-yellowCordyline/00-firstScript.sql b/db/versions/11379-yellowCordyline/00-firstScript.sql index 001ef6049..363c32dfa 100644 --- a/db/versions/11379-yellowCordyline/00-firstScript.sql +++ b/db/versions/11379-yellowCordyline/00-firstScript.sql @@ -1,8 +1,9 @@ CREATE TABLE `vn`.`locationiqConfig` ( `id` int(10) unsigned NOT NULL, - `url` varchar(100) NOT NULL, - `key` varchar(100) NOT NULL, - `tolerance` decimal(6,6) NOT NULL DEFAULT 0, + `url` varchar(100) NOT NULL COMMENT 'Dirección base de la API', + `key` varchar(100) NOT NULL COMMENT 'Access token', + `tolerance` decimal(6,6) NOT NULL DEFAULT 0 COMMENT 'Tolerancia entre las coordenadas enviadas y las retornadas', + `maxCoordsRequest` int(10) unsigned DEFAULT NULL COMMENT 'Número máximo de coordenadas por petición', PRIMARY KEY (`id`), CONSTRAINT `locationiqConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index fb495dfb1..8013a7fe6 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -392,5 +392,6 @@ "The raid information is not correct": "La información de la redada no es correcta", "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", "No trips found because input coordinates are not connected": "No se encontraron rutas porque las coordenadas de entrada no están conectadas", - "This request is not supported": "Esta solicitud no es compatible" + "This request is not supported": "Esta solicitud no es compatible", + "Invalid options or too many coordinates": "Opciones invalidas o demasiadas coordenadas" } \ No newline at end of file From e279cc4b471c8e2d2efe85d32e25897d615a860d Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Dec 2024 10:01:59 +0100 Subject: [PATCH 098/219] feat: refs #7882 Added osrm service --- .../{locationiq-config => osrm-config}/optimize.js | 9 ++++----- back/model-config.json | 2 +- back/models/locationiq-config.js | 4 ---- back/models/osrm-config.js | 4 ++++ back/models/{locationiq-config.json => osrm-config.json} | 8 ++------ db/versions/11379-yellowCordyline/00-firstScript.sql | 6 ++---- 6 files changed, 13 insertions(+), 20 deletions(-) rename back/methods/{locationiq-config => osrm-config}/optimize.js (89%) delete mode 100644 back/models/locationiq-config.js create mode 100644 back/models/osrm-config.js rename back/models/{locationiq-config.json => osrm-config.json} (69%) diff --git a/back/methods/locationiq-config/optimize.js b/back/methods/osrm-config/optimize.js similarity index 89% rename from back/methods/locationiq-config/optimize.js rename to back/methods/osrm-config/optimize.js index 97ea33089..9440800f6 100644 --- a/back/methods/locationiq-config/optimize.js +++ b/back/methods/osrm-config/optimize.js @@ -23,8 +23,8 @@ module.exports = Self => { Self.optimize = async addressIds => { const models = Self.app.models; try { - const locationiqConfig = await models.LocationiqConfig.findOne(); - if (!locationiqConfig) throw new UserError(`LocationIQ service is not configured`); + const osrmConfig = await models.OsrmConfig.findOne(); + if (!osrmConfig) throw new UserError(`OSRM service is not configured`); let coords = []; for (const addressId of addressIds) { @@ -39,10 +39,9 @@ module.exports = Self => { .map(coord => `${coord.longitude},${coord.latitude}`) .join(';'); const response = await axios.post(` - ${locationiqConfig.url}optimize/driving/${concatCoords}?key=${locationiqConfig.key} + ${osrmConfig.url}/trip/v1/driving/${concatCoords} `); - const tolerance = locationiqConfig.tolerance; - + const tolerance = osrmConfig.tolerance; for (waypoint of response.data.waypoints) { const longitude = waypoint.location[0]; const latitude = waypoint.location[1]; diff --git a/back/model-config.json b/back/model-config.json index f48e5f2eb..2ced867f7 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -88,7 +88,7 @@ "Language": { "dataSource": "vn" }, - "LocationiqConfig": { + "OsrmConfig": { "dataSource": "vn" }, "Machine": { diff --git a/back/models/locationiq-config.js b/back/models/locationiq-config.js deleted file mode 100644 index e0fe736bb..000000000 --- a/back/models/locationiq-config.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = Self => { - require('../methods/locationiq-config/optimize')(Self); -}; - diff --git a/back/models/osrm-config.js b/back/models/osrm-config.js new file mode 100644 index 000000000..f738f305c --- /dev/null +++ b/back/models/osrm-config.js @@ -0,0 +1,4 @@ +module.exports = Self => { + require('../methods/osrm-config/optimize')(Self); +}; + diff --git a/back/models/locationiq-config.json b/back/models/osrm-config.json similarity index 69% rename from back/models/locationiq-config.json rename to back/models/osrm-config.json index 624341615..ae712ba05 100644 --- a/back/models/locationiq-config.json +++ b/back/models/osrm-config.json @@ -1,9 +1,9 @@ { - "name": "LocationiqConfig", + "name": "OsrmConfig", "base": "VnModel", "options": { "mysql": { - "table": "locationiqConfig" + "table": "osrmConfig" } }, "properties": { @@ -16,10 +16,6 @@ "type": "string", "required": true }, - "key": { - "type": "string", - "required": true - }, "tolerance": { "type": "number", "required": false diff --git a/db/versions/11379-yellowCordyline/00-firstScript.sql b/db/versions/11379-yellowCordyline/00-firstScript.sql index 363c32dfa..6c0263f7f 100644 --- a/db/versions/11379-yellowCordyline/00-firstScript.sql +++ b/db/versions/11379-yellowCordyline/00-firstScript.sql @@ -1,9 +1,7 @@ -CREATE TABLE `vn`.`locationiqConfig` ( +CREATE TABLE `vn`.`osrmConfig` ( `id` int(10) unsigned NOT NULL, `url` varchar(100) NOT NULL COMMENT 'Dirección base de la API', - `key` varchar(100) NOT NULL COMMENT 'Access token', `tolerance` decimal(6,6) NOT NULL DEFAULT 0 COMMENT 'Tolerancia entre las coordenadas enviadas y las retornadas', - `maxCoordsRequest` int(10) unsigned DEFAULT NULL COMMENT 'Número máximo de coordenadas por petición', PRIMARY KEY (`id`), - CONSTRAINT `locationiqConfig_check` CHECK (`id` = 1) + CONSTRAINT `osrmConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; \ No newline at end of file From 85baf151d9a8cab26aa57116a040232cd10a0d32 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Dec 2024 10:21:23 +0100 Subject: [PATCH 099/219] feat: refs #7882 Fixed problems osrm service --- back/methods/osrm-config/optimize.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/back/methods/osrm-config/optimize.js b/back/methods/osrm-config/optimize.js index 9440800f6..a7c81f33a 100644 --- a/back/methods/osrm-config/optimize.js +++ b/back/methods/osrm-config/optimize.js @@ -47,27 +47,26 @@ module.exports = Self => { const latitude = waypoint.location[1]; const matchedAddress = coords.find(coord => - !coord.position && + coord.position === undefined && Math.abs(coord.latitude - latitude) <= tolerance && Math.abs(coord.longitude - longitude) <= tolerance ); if (matchedAddress) matchedAddress.position = waypoint.waypoint_index; - else - console.log(`Las coordenadas no se han podido asociar: ${latitude} | ${longitude}`); } coords.sort((a, b) => { const posA = a.position !== undefined ? a.position : Infinity; const posB = b.position !== undefined ? b.position : Infinity; return posA - posB; }); - // Temporal para abrir en maps + const coordsString = coords .map(item => `point=${item.latitude},${item.longitude}`) .join('&'); - console.log(`https://graphhopper.com/maps/?${coordsString}&profile=small_truck`); - // --------- - return coords; + return { + coords, + view: `https://graphhopper.com/maps/?${coordsString}&profile=small_truck` + }; } catch (err) { switch (err.response?.data?.code) { case 'NoTrips': From f63d850ea3ba7a1bdec4db6fcd13596783c66deb Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 9 Dec 2024 11:37:01 +0100 Subject: [PATCH 100/219] refactor: refs #7366 rename ref to reference --- modules/travel/back/methods/travel/extraCommunityFilter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/travel/back/methods/travel/extraCommunityFilter.js b/modules/travel/back/methods/travel/extraCommunityFilter.js index 164da93af..f1586f804 100644 --- a/modules/travel/back/methods/travel/extraCommunityFilter.js +++ b/modules/travel/back/methods/travel/extraCommunityFilter.js @@ -86,7 +86,7 @@ module.exports = Self => { return /^\d+$/.test(value) ? {'t.id': value} : {'t.ref': {like: `%${value}%`}}; - case 'ref': + case 'reference': return {'t.ref': {like: `%${value}%`}}; case 'shippedFrom': return {'t.shipped': {gte: value}}; @@ -111,7 +111,7 @@ module.exports = Self => { let stmt; stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.travel'); stmt = new ParameterizedSQL( - `CREATE TEMPORARY TABLE tmp.travel + `CREATE TEMPORARY TABLE tmp.travel (INDEX (id)) ENGINE = MEMORY SELECT t.id, From 22e9a9104ab61083cbf60440534934b3fbb23fcb Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 9 Dec 2024 13:20:55 +0100 Subject: [PATCH 101/219] feat: refs #8188 refs#8188 orderPicking --- .../item-shelving/getItemsByReviewOrder.js | 66 +++++++++++-------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/modules/item/back/methods/item-shelving/getItemsByReviewOrder.js b/modules/item/back/methods/item-shelving/getItemsByReviewOrder.js index 96a3c9969..7a960a8c8 100644 --- a/modules/item/back/methods/item-shelving/getItemsByReviewOrder.js +++ b/modules/item/back/methods/item-shelving/getItemsByReviewOrder.js @@ -46,34 +46,44 @@ module.exports = Self => { const pickingOrderToCompare = parkingItem['pickingOrder']; const result = await Self.rawSql(` - WITH currentItemShelving AS( - SELECT is2.created + INTERVAL ? HOUR created, is2.itemFk, sh.code - FROM vn.itemShelving is2 - JOIN vn.shelving sh ON sh.id = is2.shelvingFk - LEFT JOIN vn.parking p ON p.id = sh.parkingFk - LEFT JOIN vn.sector s ON s.id = p.sectorFk - WHERE sh.code = ? AND (? IS NULL OR is2.itemFk = ?) - ) - ,itemShelvings AS ( - SELECT is2.itemFk, is2.created, sh.code, p.pickingOrder,p.code parkingFk - FROM vn.itemShelving is2 - JOIN currentItemShelving ai ON is2.itemfk = ai.itemFk - JOIN vn.shelving sh ON sh.id = is2.shelvingFk AND ai.code <> sh.code - JOIN vn.parking p ON p.id = sh.parkingFk - JOIN vn.sector s ON s.id = p.sectorFk) - ,parkingDestiny AS ( - SELECT ? pickingOrder) - SELECT ish.*, - CASE - WHEN ish.pickingOrder < d.pickingOrder AND aish.created < ish.created THEN "new" - WHEN ish.pickingOrder > d.pickingOrder AND aish.created > ish.created THEN "old" - END AS itemCreated - FROM itemShelvings ish - JOIN parkingDestiny d - JOIN currentItemShelving aish - WHERE ish.pickingOrder < d.pickingOrder AND aish.created < ish.created OR - ish.pickingOrder > d.pickingOrder AND aish.created > ish.created;`, - [hoursToCompare, shelving, itemFk, itemFk, pickingOrderToCompare], myOptions); + WITH currentItemShelving AS ( + SELECT is2.created, is2.itemFk, sh.code + FROM vn.itemShelving is2 + JOIN vn.shelving sh ON sh.id = is2.shelvingFk + LEFT JOIN vn.parking p ON p.id = sh.parkingFk + LEFT JOIN vn.sector s ON s.id = p.sectorFk + WHERE sh.code = ? AND (? IS NULL OR is2.itemFk = ?) + ), + itemShelvings AS ( + SELECT is2.itemFk, is2.created, sh.code, p.pickingOrder, p.code AS parkingFk + FROM vn.itemShelving is2 + JOIN currentItemShelving ai ON is2.itemFk = ai.itemFk + JOIN vn.shelving sh ON sh.id = is2.shelvingFk AND ai.code <> sh.code + JOIN vn.parking p ON p.id = sh.parkingFk + JOIN vn.sector s ON s.id = p.sectorFk + ), + parkingDestiny AS ( + SELECT ? AS pickingOrder + ) + SELECT ish.*, + CASE + WHEN ish.pickingOrder < d.pickingOrder AND aish.created < ish.created + AND ABS(TIMESTAMPDIFF(HOUR, aish.created, ish.created)) > ? THEN "old" + WHEN ish.pickingOrder > d.pickingOrder AND aish.created > ish.created + AND ABS(TIMESTAMPDIFF(HOUR, aish.created, ish.created)) > ? THEN "new" + END AS itemCreated + FROM itemShelvings ish + JOIN parkingDestiny d ON d.pickingOrder IS NOT NULL + JOIN currentItemShelving aish ON ish.itemFk = aish.itemFk + WHERE ABS(TIMESTAMPDIFF(HOUR, aish.created, ish.created)) > ? + AND ( + (ish.pickingOrder < d.pickingOrder AND aish.created < ish.created) + OR + (ish.pickingOrder > d.pickingOrder AND aish.created > ish.created) + ); + `, + [shelving, itemFk, itemFk, pickingOrderToCompare, + hoursToCompare, hoursToCompare, hoursToCompare, hoursToCompare], myOptions); return result; }; }; From f69dfbd5aa89463c52e315f9a6c35e8c863524d3 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 9 Dec 2024 14:03:45 +0100 Subject: [PATCH 102/219] refactor: refs #7936 remove schema --- db/routines/vn/triggers/invoiceIn_afterUpdate.sql | 2 +- db/versions/11368-whiteAspidistra/00-firstScript.sql | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql index 8f0a63465..8c2785e38 100644 --- a/db/routines/vn/triggers/invoiceIn_afterUpdate.sql +++ b/db/routines/vn/triggers/invoiceIn_afterUpdate.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`invoiceIn_afterUpdate` BEGIN DECLARE vIsEuro BOOL; - SELECT if(`code` = 'EUR', TRUE, FALSE) INTO vIsEuro + SELECT `code` = 'EUR' INTO vIsEuro FROM currency WHERE id = NEW.currencyFk; diff --git a/db/versions/11368-whiteAspidistra/00-firstScript.sql b/db/versions/11368-whiteAspidistra/00-firstScript.sql index 333fa1315..f36832805 100644 --- a/db/versions/11368-whiteAspidistra/00-firstScript.sql +++ b/db/versions/11368-whiteAspidistra/00-firstScript.sql @@ -2,13 +2,13 @@ DROP TRIGGER IF EXISTS invoiceIn_beforeUpdate; - UPDATE vn.invoiceIn + UPDATE invoiceIn SET cplusRectificationTypeFk = NULL WHERE cplusRectificationTypeFk = 1; - DELETE IGNORE FROM vn.cplusRectificationType WHERE id = 1; + DELETE IGNORE FROM cplusRectificationType WHERE id = 1; - UPDATE vn.cplusRectificationType + UPDATE cplusRectificationType SET id = 1 WHERE id = 3; @@ -25,7 +25,7 @@ BEGIN SET NEW.editorFk = account.myUser_getId(); - IF (SELECT COUNT(*) FROM vn.invoiceIn + IF (SELECT COUNT(*) FROM invoiceIn WHERE supplierRef = NEW.supplierRef AND supplierFk = NEW.supplierFk AND YEAR(issued) = YEAR(NEW.issued) @@ -37,7 +37,7 @@ BEGIN IF NEW.supplierFk != OLD.supplierFk THEN CALL supplier_checkIsActive(NEW.supplierFk); SELECT withholdingSageFk INTO vWithholdingSageFk - FROM vn.supplier + FROM supplier WHERE id = NEW.supplierFk; SET NEW.withholdingSageFk = vWithholdingSageFk; END IF; From eaa62909ff5a3241f0a7f4ce5143f8adcb84a7f7 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 9 Dec 2024 14:30:45 +0100 Subject: [PATCH 103/219] chore: simplify --- modules/worker/back/methods/worker/createAbsence.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 34dcd1f59..e46ce9577 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -62,9 +62,8 @@ module.exports = Self => { await models.ACL.checkAccessAcl(ctx, 'Worker', 'canCreateAbsenceInPast', 'WRITE'); const now = Date.vnNew(); const newDate = new Date(args.dated).getTime(); - const nowDate = now.getTime(); - if ((nowDate > newDate) && !canCreateAbsenceInPast) + if ((now.getTime() > newDate) && !canCreateAbsenceInPast) throw new UserError(`Holidays to past days not available`); const labour = await models.WorkerLabour.findById(args.businessFk, From cba5d88c5e36c92f7a35d6c48091cc0754f8e83f Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 9 Dec 2024 14:45:31 +0100 Subject: [PATCH 104/219] feat: refs #7882 Osrm service --- back/methods/osrm-config/optimize.js | 20 ++++++++++++--- .../route/back/methods/route/optimizeStops.js | 25 +++++++++++++++++++ modules/route/back/models/route.js | 1 + 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 modules/route/back/methods/route/optimizeStops.js diff --git a/back/methods/osrm-config/optimize.js b/back/methods/osrm-config/optimize.js index a7c81f33a..0c570b95a 100644 --- a/back/methods/osrm-config/optimize.js +++ b/back/methods/osrm-config/optimize.js @@ -27,19 +27,31 @@ module.exports = Self => { if (!osrmConfig) throw new UserError(`OSRM service is not configured`); let coords = []; - for (const addressId of addressIds) { - const address = await models.Address.findById(addressId); + + const address = await models.Address.findById(32308); // Aquí irá el address asociada a la zona + if (address.latitude && address.longitude) { coords.push({ - addressId, + addressId: address.id, latitude: address.latitude.toFixed(6), longitude: address.longitude.toFixed(6) }); } + + for (const addressId of addressIds) { + const address = await models.Address.findById(addressId); + if (address.latitude && address.longitude) { + coords.push({ + addressId, + latitude: address.latitude.toFixed(6), + longitude: address.longitude.toFixed(6) + }); + } + } const concatCoords = coords .map(coord => `${coord.longitude},${coord.latitude}`) .join(';'); const response = await axios.post(` - ${osrmConfig.url}/trip/v1/driving/${concatCoords} + ${osrmConfig.url}/trip/v1/driving/${concatCoords}?source=first&roundtrip=true `); const tolerance = osrmConfig.tolerance; for (waypoint of response.data.waypoints) { diff --git a/modules/route/back/methods/route/optimizeStops.js b/modules/route/back/methods/route/optimizeStops.js new file mode 100644 index 000000000..9666f201e --- /dev/null +++ b/modules/route/back/methods/route/optimizeStops.js @@ -0,0 +1,25 @@ +module.exports = Self => { + Self.remoteMethod('optimizeStops', { + description: 'Updates the ticket priority of tickets without priority', + accepts: [ + { + arg: 'routeFk', + type: 'number', + required: true + } + ], + returns: { + type: 'object', + root: true + }, + http: { + path: '/optimizeStops', + verb: 'post' + } + }); + + Self.optimizeStops = async(routeFk, options) => { + return; + }; +}; + diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js index cd8685cec..e28b19a61 100644 --- a/modules/route/back/models/route.js +++ b/modules/route/back/models/route.js @@ -16,4 +16,5 @@ module.exports = Self => { require('../methods/route/downloadZip')(Self); require('../methods/route/getExpeditionSummary')(Self); require('../methods/route/getByWorker')(Self); + require('../methods/route/optimizeStops')(Self); }; From 46448d5fc20d5346c1cd0a70888b00f91f5d3172 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 10 Dec 2024 10:27:35 +0100 Subject: [PATCH 105/219] fix: refs #7936 change type --- modules/invoiceIn/back/models/invoice-in-tax.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/invoiceIn/back/models/invoice-in-tax.json b/modules/invoiceIn/back/models/invoice-in-tax.json index 53b5548b6..256ee0553 100644 --- a/modules/invoiceIn/back/models/invoice-in-tax.json +++ b/modules/invoiceIn/back/models/invoice-in-tax.json @@ -22,12 +22,11 @@ "type": "number" }, "expenseFk": { - "type": "number" + "type": "string" }, "created": { "type": "date" } - }, "relations": { "invoiceIn": { @@ -51,4 +50,4 @@ "foreignKey": "transactionTypeSageFk" } } -} +} \ No newline at end of file From 2f47d7d76eb30d744b896222be2752363dfe3817 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 10 Dec 2024 10:30:43 +0100 Subject: [PATCH 106/219] build: refs #8282 dump db --- db/dump/.dump/data.sql | 205 +++++++---- db/dump/.dump/privileges.sql | 16 +- db/dump/.dump/structure.sql | 685 ++++++++++------------------------- db/dump/.dump/triggers.sql | 109 +----- myt.config.yml | 1 + 5 files changed, 342 insertions(+), 674 deletions(-) diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index 4700d0066..f45773735 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -4,7 +4,7 @@ USE `util`; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -INSERT INTO `version` VALUES ('vn-database','11358','45f7b60f1b43b24505a3e9abc6738dc484ad4fd5','2024-11-26 12:27:58','11365'); +INSERT INTO `version` VALUES ('vn-database','11377','d3fe5098277c3935c434838b53facb271f84ebec','2024-12-10 07:22:33','11379'); INSERT INTO `versionLog` VALUES ('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL); @@ -1072,21 +1072,25 @@ INSERT INTO `versionLog` VALUES ('vn-database','11300','00-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','11302','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:57',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11308','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2024-10-23 12:41:55',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11311','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 08:00:57',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11312','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11314','00-restrictedAsterisk.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11315','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11316','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11317','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11319','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11321','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11322','00-entryAcl.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11324','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-13 10:49:47',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11325','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11326','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11330','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11331','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11332','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11336','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11337','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11338','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-12 09:14:12',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11339','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11341','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11342','00-itemShelving.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:06:34',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11342','01-itemShelving.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:06:35',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11342','02-itemShelving.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:06:37',NULL,NULL); @@ -1105,10 +1109,26 @@ INSERT INTO `versionLog` VALUES ('vn-database','11347','00-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','11348','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:14',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11349','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:14',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11350','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:14',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11351','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11353','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:14',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11354','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11355','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:14',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11357','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:16',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11358','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:21',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11359','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11362','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-28 08:52:33',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11363','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11366','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11367','00-deprecate.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11369','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:05',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11371','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:05',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11371','01-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:47',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11371','02-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:22:29',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11371','03-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:22:31',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11372','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-09 13:30:30',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11373','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-02 16:09:01',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11375','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-03 08:58:20',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11377','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:22:31',NULL,NULL); /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; @@ -1666,7 +1686,6 @@ INSERT INTO `ACL` VALUES (209,'Ticket','recalculateComponents','WRITE','ALLOW',' INSERT INTO `ACL` VALUES (211,'TravelLog','*','READ','ALLOW','ROLE','buyer',NULL); INSERT INTO `ACL` VALUES (212,'Thermograph','*','*','ALLOW','ROLE','buyer',NULL); INSERT INTO `ACL` VALUES (213,'TravelThermograph','*','WRITE','ALLOW','ROLE','buyer',NULL); -INSERT INTO `ACL` VALUES (214,'Entry','*','*','ALLOW','ROLE','buyer',NULL); INSERT INTO `ACL` VALUES (216,'TravelThermograph','*','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (218,'Intrastat','*','*','ALLOW','ROLE','buyer',NULL); INSERT INTO `ACL` VALUES (221,'UserConfig','getUserConfig','READ','ALLOW','ROLE','guest',NULL); @@ -1695,7 +1714,6 @@ INSERT INTO `ACL` VALUES (258,'PayDem','*','READ','ALLOW','ROLE','employee',NULL INSERT INTO `ACL` VALUES (259,'Client','createReceipt','*','ALLOW','ROLE','salesAssistant',NULL); INSERT INTO `ACL` VALUES (260,'PrintServerQueue','*','WRITE','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (261,'SupplierAccount','*','WRITE','ALLOW','ROLE','administrative',783); -INSERT INTO `ACL` VALUES (262,'Entry','*','*','ALLOW','ROLE','administrative',NULL); INSERT INTO `ACL` VALUES (263,'InvoiceIn','*','READ','ALLOW','ROLE','administrative',NULL); INSERT INTO `ACL` VALUES (264,'StarredModule','*','*','ALLOW','ROLE','$authenticated',NULL); INSERT INTO `ACL` VALUES (265,'ItemBotanical','*','WRITE','ALLOW','ROLE','logisticBoss',NULL); @@ -2012,7 +2030,7 @@ INSERT INTO `ACL` VALUES (605,'Ticket','sendSms','WRITE','ALLOW','ROLE','employe INSERT INTO `ACL` VALUES (606,'Ticket','isLocked','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (607,'Ticket','freightCost','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (608,'Ticket','getComponentsSum','READ','ALLOW','ROLE','employee',NULL); -INSERT INTO `ACL` VALUES (609,'Ticket','updateAttributes','WRITE','ALLOW','ROLE','deliveryAssistant',10578); +INSERT INTO `ACL` VALUES (609,'Ticket','updateAttributes','WRITE','ALLOW','ROLE','delivery',19295); INSERT INTO `ACL` VALUES (610,'Ticket','deliveryNoteCsv','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (611,'State','find','READ','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (612,'State','findById','READ','ALLOW','ROLE','employee',NULL); @@ -2248,9 +2266,9 @@ INSERT INTO `ACL` VALUES (895,'ItemShelvingLog','*','READ','ALLOW','ROLE','produ INSERT INTO `ACL` VALUES (901,'WorkerTimeControl','sendMail','WRITE','ALLOW','ROLE','system',NULL); INSERT INTO `ACL` VALUES (902,'Entry','filter','READ','ALLOW','ROLE','supplier',NULL); INSERT INTO `ACL` VALUES (903,'Entry','getBuys','READ','ALLOW','ROLE','supplier',NULL); -INSERT INTO `ACL` VALUES (904,'Entry','buyLabelSupplier','READ','ALLOW','ROLE','supplier',10578); +INSERT INTO `ACL` VALUES (904,'Entry','buyLabelSupplier','READ','ALLOW','ROLE','supplier',19295); INSERT INTO `ACL` VALUES (905,'AddressWaste','*','READ','ALLOW','ROLE','production',NULL); -INSERT INTO `ACL` VALUES (906,'Entry','print','READ','ALLOW','ROLE','supplier',NULL); +INSERT INTO `ACL` VALUES (906,'Entry','labelSupplier','READ','ALLOW','ROLE','supplier',19295); INSERT INTO `ACL` VALUES (907,'Expedition_PrintOut','*','*','ALLOW','ROLE','production',NULL); INSERT INTO `ACL` VALUES (908,'Docuware','upload','WRITE','ALLOW','ROLE','hrBuyer',13657); INSERT INTO `ACL` VALUES (909,'Entry','getBuysCsv','READ','ALLOW','ROLE','supplier',19295); @@ -2298,6 +2316,59 @@ INSERT INTO `ACL` VALUES (953,'RouteAction','find','READ','ALLOW','ROLE','delive INSERT INTO `ACL` VALUES (954,'RouteComplement','find','READ','ALLOW','ROLE','delivery',10578); INSERT INTO `ACL` VALUES (955,'RouteComplement','create','WRITE','ALLOW','ROLE','delivery',10578); INSERT INTO `ACL` VALUES (956,'RouteComplement','deleteById','WRITE','ALLOW','ROLE','delivery',10578); +INSERT INTO `ACL` VALUES (957,'SaleGroup','find','READ','ALLOW','ROLE','production',10578); +INSERT INTO `ACL` VALUES (958,'Worker','canCreateAbsenceInPast','WRITE','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (959,'WorkerRelative','updateAttributes','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (960,'WorkerRelative','crud','WRITE','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (961,'WorkerRelative','findById','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (962,'WorkerRelative','find','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (963,'WorkerRelative','upsert','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (964,'WorkerRelative','filter','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (965,'WorkerIrpf','updateAttributes','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (966,'WorkerIrpf','crud','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (967,'WorkerIrpf','findById','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (968,'WorkerIrpf','find','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (969,'WorkerIrpf','upsert','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (970,'WorkerIrpf','filter','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (971,'DisabilityGrade','updateAttributes','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (972,'DisabilityGrade','crud','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (973,'DisabilityGrade','findById','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (974,'DisabilityGrade','find','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (975,'DisabilityGrade','upsert','*','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (976,'Entry','upsert','WRITE','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (977,'Entry','updateAttributes','WRITE','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (978,'Entry','isBooked','READ','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (979,'Entry','findById','READ','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (980,'Entry','find','READ','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (981,'Entry','filter','READ','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (982,'Entry','count','READ','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (983,'Entry','getEntry','READ','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (984,'Entry','getBuys','READ','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (985,'Entry','findOne','READ','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (986,'Entry','deleteBuys','WRITE','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (987,'Entry','editLatestBuys','WRITE','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (988,'Entry','importBuys','WRITE','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (989,'Entry','importBuysPreview','READ','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (990,'Entry','lastItemBuys','READ','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (991,'Entry','latestBuysFilter','READ','ALLOW','ROLE','administrative',10578); +INSERT INTO `ACL` VALUES (992,'Entry','upsert','WRITE','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (993,'Entry','updateAttributes','WRITE','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (994,'Entry','findById','READ','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (995,'Entry','find','READ','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (996,'Entry','filter','READ','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (997,'Entry','count','READ','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (998,'Entry','getEntry','READ','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (999,'Entry','getBuys','READ','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (1000,'Entry','findOne','READ','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (1001,'Entry','deleteBuys','WRITE','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (1002,'Entry','editLatestBuys','WRITE','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (1003,'Entry','importBuys','WRITE','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (1004,'Entry','importBuysPreview','READ','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (1005,'Entry','lastItemBuys','READ','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (1006,'Entry','latestBuysFilter','READ','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (1007,'ItemShelving','getItemsByReviewOrder','READ','ALLOW','ROLE','production',19294); +INSERT INTO `ACL` VALUES (1008,'Entry','buyLabelSupplier','READ','ALLOW','ROLE','employee',19295); +INSERT INTO `ACL` VALUES (1009,'Entry','buyLabel','READ','ALLOW','ROLE','supplier',19295); INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee'); INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee'); @@ -2472,70 +2543,47 @@ INSERT INTO `cplusTaxBreak` VALUES (7,'E6 - Exenta por otros'); INSERT INTO `claimResponsible` VALUES (1,'Compradores',0,'buy'); INSERT INTO `claimResponsible` VALUES (2,'Proveedor',0,'sup'); -INSERT INTO `claimResponsible` VALUES (3,'Entradores',0,'ent'); INSERT INTO `claimResponsible` VALUES (4,'Camareros',0,'bar'); INSERT INTO `claimResponsible` VALUES (6,'Sacadores',0,'pic'); INSERT INTO `claimResponsible` VALUES (7,'Revisadores',0,'chk'); -INSERT INTO `claimResponsible` VALUES (8,'Calidad general',0,'qas'); INSERT INTO `claimResponsible` VALUES (9,'Encajadores',0,'pck'); INSERT INTO `claimResponsible` VALUES (10,'Clima',0,'wea'); INSERT INTO `claimResponsible` VALUES (11,'Comerciales',1,'com'); INSERT INTO `claimResponsible` VALUES (12,'Clientes',1,'cli'); -INSERT INTO `claimResponsible` VALUES (13,'Administración',0,'adm'); INSERT INTO `claimResponsible` VALUES (14,'Agencia',0,'age'); INSERT INTO `claimResponsible` VALUES (15,'Repartidores',0,'del'); INSERT INTO `claimResponsible` VALUES (16,'Informatica',0,'ite'); INSERT INTO `claimResponsible` VALUES (17,'Transp.origen',0,'tra'); INSERT INTO `claimResponsible` VALUES (18,'Confeccion',0,'con'); INSERT INTO `claimResponsible` VALUES (19,'OTROS',0,'oth'); -INSERT INTO `claimResponsible` VALUES (21,'Gerencia',0,'man'); INSERT INTO `claimResponsible` VALUES (22,'Paletizadores',0,'pal'); INSERT INTO `claimResponsible` VALUES (23,'Preparación Previa',0,'pre'); -INSERT INTO `claimResponsible` VALUES (24,'Almacén PCA',0,'war'); INSERT INTO `claimResponsible` VALUES (25,'Huelga',0,'str'); -INSERT INTO `claimResponsible` VALUES (27,'Prep. por caja',0,''); +INSERT INTO `claimResponsible` VALUES (27,'Prep. por caja',0,'pbb'); INSERT INTO `claimResponsible` VALUES (45,'Negativo',0,'neg'); -INSERT INTO `claimReason` VALUES (1,'Prisas',0); -INSERT INTO `claimReason` VALUES (2,'Novato',0); INSERT INTO `claimReason` VALUES (3,'Exceso de confianza',0); -INSERT INTO `claimReason` VALUES (4,'Exceso de celo',0); -INSERT INTO `claimReason` VALUES (5,'Indiferencia',0); INSERT INTO `claimReason` VALUES (6,'Extraviado o Hurto',0); INSERT INTO `claimReason` VALUES (7,'Incompetencia',0); -INSERT INTO `claimReason` VALUES (8,'Ubicación erronea',0); -INSERT INTO `claimReason` VALUES (9,'Dat.Inctos/Pak.conf',0); -INSERT INTO `claimReason` VALUES (10,'Datos duplicados',0); -INSERT INTO `claimReason` VALUES (11,'Fallo stock',0); -INSERT INTO `claimReason` VALUES (12,'Innovación',0); INSERT INTO `claimReason` VALUES (13,'Distracción',1); -INSERT INTO `claimReason` VALUES (15,'Portes indebidos',0); INSERT INTO `claimReason` VALUES (16,'Baja calidad',0); INSERT INTO `claimReason` VALUES (17,'Defectuoso',0); -INSERT INTO `claimReason` VALUES (19,'Endiñado',0); INSERT INTO `claimReason` VALUES (20,'Calor',0); INSERT INTO `claimReason` VALUES (21,'Frio',0); INSERT INTO `claimReason` VALUES (22,'Cambiado',0); -INSERT INTO `claimReason` VALUES (24,'Cansancio',1); INSERT INTO `claimReason` VALUES (25,'Mal etiquetado',1); -INSERT INTO `claimReason` VALUES (26,'Cantidad malentendido',0); -INSERT INTO `claimReason` VALUES (30,'No revisado',1); INSERT INTO `claimReason` VALUES (34,'Error fotografia',0); INSERT INTO `claimReason` VALUES (40,'Fallo Personal VN',0); -INSERT INTO `claimReason` VALUES (41,'Fallo Personal Cliente',0); INSERT INTO `claimReason` VALUES (42,'Otros',0); INSERT INTO `claimReason` VALUES (43,'Precio alto',0); -INSERT INTO `claimReason` VALUES (44,'Abuso de confianza',0); INSERT INTO `claimReason` VALUES (45,'Retraso Agencia',0); INSERT INTO `claimReason` VALUES (46,'Delicado',0); -INSERT INTO `claimReason` VALUES (47,'Seco',0); INSERT INTO `claimReason` VALUES (48,'Retraso Reparto',0); INSERT INTO `claimReason` VALUES (49,'Mal Embalado',0); INSERT INTO `claimReason` VALUES (50,'Tumbado',0); INSERT INTO `claimReason` VALUES (51,'Enfermo/Plaga',0); INSERT INTO `claimReason` VALUES (52,'Mala gestión comercial',0); INSERT INTO `claimReason` VALUES (53,'Mala gestión comprador',0); -INSERT INTO `claimReason` VALUES (54,'A2',0); INSERT INTO `claimReason` VALUES (55,'Entrega 48h o más',0); INSERT INTO `claimReason` VALUES (56,'Error cliente',0); INSERT INTO `claimReason` VALUES (57,'A2/B1',0); @@ -2549,7 +2597,6 @@ INSERT INTO `claimRedelivery` VALUES (5,'Tour'); INSERT INTO `claimRedelivery` VALUES (6,'Fuera Peninsula'); INSERT INTO `claimRedelivery` VALUES (7,'Francia'); -INSERT INTO `claimResult` VALUES (1,'Otros daños'); INSERT INTO `claimResult` VALUES (2,'Roces'); INSERT INTO `claimResult` VALUES (3,'Humedad'); INSERT INTO `claimResult` VALUES (4,'Deshidratacion'); @@ -2558,26 +2605,20 @@ INSERT INTO `claimResult` VALUES (6,'Incompleto (Faltas)'); INSERT INTO `claimResult` VALUES (7,'Error packing'); INSERT INTO `claimResult` VALUES (8,'Error color'); INSERT INTO `claimResult` VALUES (9,'Error medida'); -INSERT INTO `claimResult` VALUES (10,'Error origen'); INSERT INTO `claimResult` VALUES (11,'Envejecido'); -INSERT INTO `claimResult` VALUES (12,'Venta Perdida'); INSERT INTO `claimResult` VALUES (13,'Duplicacion'); INSERT INTO `claimResult` VALUES (14,'Rechazado'); INSERT INTO `claimResult` VALUES (15,'Rotura'); INSERT INTO `claimResult` VALUES (16,'Deterioro/Estropeado'); INSERT INTO `claimResult` VALUES (17,'Podrido'); -INSERT INTO `claimResult` VALUES (18,'Baboso'); -INSERT INTO `claimResult` VALUES (19,'Cocido'); INSERT INTO `claimResult` VALUES (20,'Congelado'); INSERT INTO `claimResult` VALUES (21,'Machacado'); -INSERT INTO `claimResult` VALUES (22,'Error precio'); INSERT INTO `claimResult` VALUES (23,'Manchado'); INSERT INTO `claimResult` VALUES (24,'No entregado'); -INSERT INTO `claimResult` VALUES (25,'Cobro indebido'); INSERT INTO `claimResult` VALUES (26,'Decepcion/Esperaba mas'); INSERT INTO `claimResult` VALUES (27,'Otros'); INSERT INTO `claimResult` VALUES (28,'Baboso/Cocido'); -INSERT INTO `claimResult` VALUES (29,'Video Camara'); +INSERT INTO `claimResult` VALUES (29,'Videocámaras'); INSERT INTO `component` VALUES (10,'Precios Especiales',4,NULL,NULL,1,'specialPrices',0); INSERT INTO `component` VALUES (14,'porte extra por dia semana',6,NULL,NULL,1,'extraCostPerWeekDay',0); @@ -2625,64 +2666,71 @@ INSERT INTO `continent` VALUES (3,'África','AF'); INSERT INTO `continent` VALUES (4,'Europa','EU'); INSERT INTO `continent` VALUES (5,'Oceanía','OC'); -INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,116,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (1,'VN','VERDNATURA',1,130,763,0,0,0,0,26,NULL,'/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (22,'shopping','COMPRAS',2,5,NULL,72,0,0,1,1,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (23,'CMA','CAMARA',15,16,NULL,72,1,1,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,'PREVIOUS'); INSERT INTO `department` VALUES (31,'it','INFORMATICA',6,7,NULL,72,0,0,1,0,1,'/1/','informatica-cau',1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (34,'accounting','CONTABILIDAD',8,9,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (35,'finance','FINANZAS',10,11,NULL,0,0,0,1,0,1,'/1/',NULL,1,'begonya@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (36,'labor','LABORAL',12,13,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (36,'labor','LABORAL',12,13,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (37,'PROD','PRODUCCION',14,37,NULL,72,1,1,1,11,1,'/1/',NULL,0,NULL,0,1,1,1,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (38,'picking','SACADO',17,18,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,1,NULL,NULL,NULL,'ON_PREPARATION'); INSERT INTO `department` VALUES (39,'packing','ENCAJADO',19,20,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'PACKING'); INSERT INTO `department` VALUES (41,'administration','ADMINISTRACION',38,39,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,1,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (43,'VT','VENTAS',40,75,NULL,0,0,0,1,17,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (44,'management','GERENCIA',76,77,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',78,79,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (46,'delivery','REPARTO',80,81,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,'DELIVERY'); -INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',82,83,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'STORAGE'); -INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',84,85,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',86,87,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (43,'VT','VENTAS',40,89,NULL,0,0,0,1,24,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (44,'management','GERENCIA',90,91,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (45,'logistic','LOGISTICA',92,93,NULL,72,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (46,'delivery','REPARTO',94,95,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,'DELIVERY'); +INSERT INTO `department` VALUES (48,'storage','ALMACENAJE',96,97,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'STORAGE'); +INSERT INTO `department` VALUES (49,NULL,'PROPIEDAD',98,99,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (52,NULL,'CARGA AEREA',100,101,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (53,'marketing','MARKETING Y COMUNICACIÓN',41,42,NULL,72,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',88,89,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (54,NULL,'ORNAMENTALES',102,103,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (55,NULL,'TALLER NATURAL',21,22,14548,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1118,NULL,NULL,NULL); INSERT INTO `department` VALUES (56,NULL,'TALLER ARTIFICIAL',23,24,8470,72,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,1927,NULL,NULL,NULL); -INSERT INTO `department` VALUES (58,'CMP','CAMPOS',90,93,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'FIELD'); -INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',94,95,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (58,'CMP','CAMPOS',104,107,NULL,72,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'FIELD'); +INSERT INTO `department` VALUES (59,'maintenance','MANTENIMIENTO',108,109,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (60,'claims','RECLAMACIONES',43,44,NULL,72,0,0,2,0,43,'/1/43/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,'CLAIM'); -INSERT INTO `department` VALUES (61,NULL,'VNH',96,99,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',100,101,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (61,NULL,'VNH',110,113,NULL,73,0,0,1,1,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (66,NULL,'VERDNAMADRID',114,115,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (68,NULL,'COMPLEMENTOS',25,26,NULL,72,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',102,103,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (80,'spainTeam5','EQUIPO ESPAÑA 5',45,46,4250,0,0,0,2,0,43,'/1/43/','es5_equipo',1,'es5@verdnatura.es',0,0,0,0,NULL,NULL,'5300',NULL); -INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',104,105,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (89,NULL,'COORDINACION',106,107,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (90,NULL,'TRAILER',97,98,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (69,NULL,'VERDNABARNA',116,117,NULL,74,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (80,'spainTeam5','EQUIPO ESPAÑA 5',45,46,4250,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (86,NULL,'LIMPIEZA',118,119,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (89,NULL,'COORDINACION',120,121,NULL,0,1,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (90,NULL,'TRAILER',111,112,NULL,0,0,0,2,0,61,'/1/61/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (91,'artificial','ARTIFICIAL',27,28,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'PREVIOUS'); INSERT INTO `department` VALUES (92,NULL,'EQUIPO SILVERIO',47,48,1203,0,0,0,2,0,43,'/1/43/','sdc_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',49,50,3797,0,0,0,2,0,43,'/1/43/','es2_equipo',1,'es2@verdnatura.es',0,0,0,0,NULL,NULL,'5100',NULL); -INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',51,52,24065,0,0,0,2,0,43,'/1/43/','es1_equipo',1,'es1@verdnatura.es',0,0,0,0,NULL,NULL,'5000',NULL); +INSERT INTO `department` VALUES (94,'spainTeam2','EQUIPO ESPAÑA 2',49,50,3797,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (95,'spainTeam1','EQUIPO ESPAÑA 1',51,52,24065,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (96,NULL,'EQUIPO C LOPEZ',53,54,4661,0,0,0,2,0,43,'/1/43/','cla_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (115,NULL,'EQUIPO CLAUDI',55,56,3810,0,0,0,2,0,43,'/1/43/','csr_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (123,NULL,'EQUIPO ELENA BASCUÑANA',57,58,7102,0,0,0,2,0,43,'/1/43/','ebt_equipo',0,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',108,109,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (125,'spainTeam3','EQUIPO ESPAÑA 3',59,60,1118,0,0,0,2,0,43,'/1/43/','es3_equipo',1,'es3@verdnatura.es',0,0,0,0,NULL,NULL,'5200',NULL); +INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',122,123,NULL,72,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (125,'spainTeam3','EQUIPO ESPAÑA 3',59,60,1118,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (126,NULL,'PRESERVADO',29,30,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',31,32,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'PALLETIZING'); INSERT INTO `department` VALUES (130,NULL,'REVISION',33,34,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'ON_CHECKING'); -INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',91,92,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',105,106,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',61,62,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (133,'franceTeam','EQUIPO FRANCIA',63,64,1731,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL); -INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',65,66,6264,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL); -INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',110,111,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',112,113,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (137,'sorter','SORTER',114,115,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (139,'spainTeam4','EQUIPO ESPAÑA 4',67,68,3803,0,0,0,2,0,43,'/1/43/','es4_equipo',1,'es4@verdnatura.es',0,0,0,0,NULL,NULL,'5400',NULL); +INSERT INTO `department` VALUES (133,'franceTeamManagement','EQUIPO GESTIÓN FRANCIA',63,64,9751,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL); +INSERT INTO `department` VALUES (134,'portugalTeam','EQUIPO PORTUGAL',65,66,8964,0,0,0,2,0,43,'/1/43/','pt_equipo',1,'portugal@verdnatura.es',0,0,0,0,NULL,NULL,'3500',NULL); +INSERT INTO `department` VALUES (135,'routers','ENRUTADORES',124,125,NULL,0,0,0,1,0,1,'/1/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (136,'heavyVehicles','VEHICULOS PESADOS',126,127,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (137,'sorter','SORTER',128,129,NULL,0,0,0,1,0,1,'/1/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); +INSERT INTO `department` VALUES (139,'spainTeam4','EQUIPO ESPAÑA 4',67,68,3803,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (140,'internationalTeam','EQUIPO INTERNACIONAL',69,70,24065,0,0,0,2,0,43,'/1/43/','int_equipo',1,'international@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (141,NULL,'PREVIA',35,36,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'PREVIOUS'); INSERT INTO `department` VALUES (146,NULL,'VERDNACOLOMBIA',3,4,NULL,72,0,0,2,0,22,'/1/22/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,NULL); -INSERT INTO `department` VALUES (147,'spainTeamAsia','EQUIPO ESPAÑA ASIA',71,72,40214,0,0,0,2,0,43,'/1/43/','esA_equipo',0,'esA@verdnatura.es',0,0,0,0,NULL,NULL,'5500',NULL); -INSERT INTO `department` VALUES (148,NULL,'CAPTATION FRANCIA',73,74,NULL,0,0,0,2,0,43,'/1/43/',NULL,0,NULL,0,0,0,0,NULL,NULL,'6000',NULL); +INSERT INTO `department` VALUES (147,'spainTeamAsia','EQUIPO ESPAÑA ASIA',71,72,40214,0,0,0,2,0,43,'/1/43/','esA_equipo',1,'esA@verdnatura.es',0,0,0,0,NULL,NULL,'5500',NULL); +INSERT INTO `department` VALUES (148,'franceTeamCatchment','EQUIPO CAPTACIÓN FRANCIA',73,74,25178,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,'6000',NULL); +INSERT INTO `department` VALUES (149,'spainTeamCatchment','EQUIPO ESPAÑA CAPTACIÓN',75,76,1203,0,0,0,2,0,43,'/1/43/','es_captacion_equipo',1,'es_captacion@verdnatura.es',0,0,0,0,NULL,NULL,'5700',NULL); +INSERT INTO `department` VALUES (150,'spainTeamLevanteIslands','EQUIPO ESPAÑA LEVANTE/ISLAS',77,78,1118,0,0,0,2,0,43,'/1/43/','es_levanteislas_equipo',1,'levanteislas.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5000',NULL); +INSERT INTO `department` VALUES (151,'spainTeamNorthwest','EQUIPO ESPAÑA NOROESTE',79,80,7102,0,0,0,2,0,43,'/1/43/','es_noroeste_equipo',1,'noroeste.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5300',NULL); +INSERT INTO `department` VALUES (152,'spainTeamNortheast','EQUIPO ESPAÑA NORESTE',81,82,1118,0,0,0,2,0,43,'/1/43/','es_noreste_equipo',1,'noreste.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5200',NULL); +INSERT INTO `department` VALUES (153,'spainTeamSouth','EQUIPO ESPAÑA SUR',83,84,36578,0,0,0,2,0,43,'/1/43/','es_sur_equipo',1,'sur.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5400',NULL); +INSERT INTO `department` VALUES (154,'spainTeamCenter','EQUIPO ESPAÑA CENTRO',85,86,4661,0,0,0,2,0,43,'/1/43/','es_centro_equipo',1,'centro.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5100',NULL); +INSERT INTO `department` VALUES (155,'spainTeamVip','EQUIPO ESPAÑA VIP',87,88,5432,0,0,0,2,0,43,'/1/43/','es_vip_equipo',1,'vip.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5600',NULL); INSERT INTO `docuware` VALUES (1,'deliveryNote','Albaranes cliente','find','find','N__ALBAR_N',NULL); INSERT INTO `docuware` VALUES (2,'deliveryNote','Albaranes cliente','store','Archivar','N__ALBAR_N',NULL); @@ -2784,7 +2832,6 @@ INSERT INTO `state` VALUES (7,'Sin Acabar',1,0,'NOT_READY',7,0,0,0,0,0,0,4,1,'al INSERT INTO `state` VALUES (8,'Revisado',8,2,'CHECKED',8,0,1,0,3,0,0,1,0,'warning'); INSERT INTO `state` VALUES (9,'Encajando',9,3,'PACKING',9,0,1,0,0,0,0,1,0,NULL); INSERT INTO `state` VALUES (10,'Encajado',10,3,'PACKED',10,0,1,0,0,0,0,0,0,NULL); -INSERT INTO `state` VALUES (11,'Facturado',0,4,'INVOICED',11,0,1,0,0,0,0,0,0,NULL); INSERT INTO `state` VALUES (12,'Bloqueado',0,0,'BLOCKED',12,0,0,0,0,0,0,4,1,'alert'); INSERT INTO `state` VALUES (13,'En Reparto',11,4,'ON_DELIVERY',13,0,1,0,0,0,0,0,0,NULL); INSERT INTO `state` VALUES (14,'Preparado',6,2,'PREPARED',14,0,1,0,2,0,0,1,0,'warning'); @@ -2797,19 +2844,15 @@ INSERT INTO `state` VALUES (23,'URGENTE',5,2,'LAST_CALL',23,1,0,1,0,0,0,4,1,'suc INSERT INTO `state` VALUES (24,'Encadenado',4,0,'CHAINED',24,0,0,0,0,0,0,3,1,'success'); INSERT INTO `state` VALUES (25,'Embarcando',3,0,'BOARDING',25,1,0,0,0,0,0,3,0,'alert'); INSERT INTO `state` VALUES (26,'Prep Previa',5,0,'PREVIOUS_PREPARATION',28,1,0,0,1,0,0,2,0,'warning'); -INSERT INTO `state` VALUES (27,'Prep Asistida',5,2,'ASSISTED_PREPARATION',27,0,0,0,0,0,0,2,0,'success'); INSERT INTO `state` VALUES (28,'Previa OK',3,0,'OK PREVIOUS',28,1,0,1,1,1,1,3,0,'warning'); INSERT INTO `state` VALUES (29,'Previa Impreso',4,0,'PRINTED PREVIOUS',29,1,0,1,0,0,1,2,0,'success'); -INSERT INTO `state` VALUES (30,'Embarcado',4,2,'BOARD',30,0,0,0,2,0,0,3,0,'success'); INSERT INTO `state` VALUES (31,'Polizon Impreso',4,2,'PRINTED STOWAWAY',29,1,0,1,0,0,1,2,0,'success'); -INSERT INTO `state` VALUES (32,'Polizon OK',3,2,'OK STOWAWAY',31,1,0,0,1,1,1,3,0,'warning'); INSERT INTO `state` VALUES (33,'Auto_Impreso',4,0,'PRINTED_AUTO',29,1,0,1,0,0,1,2,0,'success'); INSERT INTO `state` VALUES (34,'Pte Pago',3,0,'WAITING_FOR_PAYMENT',34,0,0,0,0,0,0,4,1,'alert'); INSERT INTO `state` VALUES (35,'Semi-Encajado',9,3,'HALF_PACKED',10,0,1,0,0,0,0,1,0,NULL); INSERT INTO `state` VALUES (36,'Previa Revisando',3,0,'PREVIOUS_CONTROL',37,1,0,0,4,0,1,2,0,'warning'); INSERT INTO `state` VALUES (37,'Previa Revisado',3,0,'PREVIOUS_CONTROLLED',29,1,0,1,0,0,1,2,0,'warning'); INSERT INTO `state` VALUES (38,'Prep Cámara',6,2,'COOLER_PREPARATION',14,0,0,0,2,0,0,2,0,'warning'); -INSERT INTO `state` VALUES (41,'Prep Parcial',6,2,'PARTIAL_PREPARATION',14,0,0,0,2,0,0,2,0,'warning'); INSERT INTO `state` VALUES (42,'Entregado en parte',13,3,'PARTIAL_DELIVERED',16,0,1,0,0,0,0,0,0,NULL); INSERT INTO `state` VALUES (43,'Preparación por caja',6,2,'BOX_PICKING',42,0,0,0,2,0,0,2,0,'warning'); @@ -2820,6 +2863,17 @@ INSERT INTO `ticketCanAdvanceConfig` VALUES (1,5); INSERT INTO `volumeConfig` VALUES (2.67,1.60,0.8,150,0.30,120,57,2.0,50,200,10,167.0); +INSERT INTO `workerActivityType` VALUES ('CLAIM','RECLAMACIONES'); +INSERT INTO `workerActivityType` VALUES ('DELIVERY','REPARTO'); +INSERT INTO `workerActivityType` VALUES ('FIELD','CAMPOS'); +INSERT INTO `workerActivityType` VALUES ('ON_CHECKING','REVISION'); +INSERT INTO `workerActivityType` VALUES ('ON_PREPARATION','SACADO'); +INSERT INTO `workerActivityType` VALUES ('PACKING','ENCAJADO'); +INSERT INTO `workerActivityType` VALUES ('PALLETIZING','PALETIZADO'); +INSERT INTO `workerActivityType` VALUES ('PREVIOUS','ARTIFICIAL-CÁMARA'); +INSERT INTO `workerActivityType` VALUES ('STOP','PARADA'); +INSERT INTO `workerActivityType` VALUES ('STORAGE','ALMACENAJE'); + INSERT INTO `workCenter` VALUES (1,'Silla',20,859,1,'Av espioca 100',552703,NULL); INSERT INTO `workCenter` VALUES (2,'Mercaflor',19,NULL,NULL,NULL,NULL,NULL); INSERT INTO `workCenter` VALUES (3,'Marjales',26,20008,NULL,NULL,NULL,NULL); @@ -3149,6 +3203,7 @@ USE `sage`; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; INSERT INTO `TiposIva` VALUES (2,0,'Operaciones no sujetas',0.0000000000,0.0000000000,0.0000000000,'','4770000020','','','','','','','95B21A93-5910-489D-83BB-C32788C9B19D','','','','','','','','','',0); +INSERT INTO `TiposIva` VALUES (3,0,'IVA ESPECIAL 2%',0.0000000000,2.0000000000,0.0000000000,'4720000002','4770000012','','','','','','','9E6160D5-984E-4643-ACBC-1EBC3BF73360','','','','','','','','','',0); INSERT INTO `TiposIva` VALUES (4,0,'I.V.A. 4%',0.0000000000,4.0000000000,0.0000000000,'4720000004','4770000004','','6310000000','','','','','9E6160D5-984E-4643-ACBC-1EBC3BF73360','','','','','','','','','',0); INSERT INTO `TiposIva` VALUES (5,0,'I.V.A. 4% y R.E. 0.5%',0.0000000000,4.0000000000,0.5000000000,'','4770000504','4770000405','','','','','','DBEFA562-63FB-4FFC-8171-64F0C6F065FF','','','','','','','','','',0); INSERT INTO `TiposIva` VALUES (6,0,'H.P. IVA 4% CEE',0.0000000000,4.0000000000,0.0000000000,'4721000004','4771000004','','','','','','','DD0ECBA8-2EF5-425E-911B-623580BADA77','','','','','','','','','',0); diff --git a/db/dump/.dump/privileges.sql b/db/dump/.dump/privileges.sql index d754e62c5..f608d0e8a 100644 --- a/db/dump/.dump/privileges.sql +++ b/db/dump/.dump/privileges.sql @@ -805,7 +805,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','edi','grafana','supplyResponse','ju INSERT IGNORE INTO `tables_priv` VALUES ('','cache','customer','last_buy','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','client','carlosap@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','invoiceInTax','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','workerTeam','juan@10.5.1.2','0000-00-00 00:00:00','Select,Insert,Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesAssistant','workerTeam','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','profile_type','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','postgresql','hr','profile_media','alexm@%','0000-00-00 00:00:00','Select,Insert',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','recovery','alexm@%','0000-00-00 00:00:00','Select',''); @@ -835,7 +835,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','bi','salesPerson','tarifa_component INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','expeditionLog','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','bs','salesPerson','clientNewBorn','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleItemShelving__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesBoss','workerTeam','juan@10.5.1.2','0000-00-00 00:00:00','Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','srt','employee','expedition','alexm@%','0000-00-00 00:00:00','Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemShelvingStock','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','saleParking__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); @@ -887,7 +886,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','ticketDms','alexm@% INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','ektEntryAssign','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','intrastat','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','supplierAgencyTerm','alexm@%','0000-00-00 00:00:00','Update',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','entryConfig','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','packager','franceExpressConfig','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','manager','ticketLog','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','ticketCollection','alexm@%','0000-00-00 00:00:00','Delete',''); @@ -945,7 +943,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','role','alexm@%','00 INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','clientCredit','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','worker','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','coolerAssist','workerAppTester','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','propertyGroup','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financial','propertyGroup','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','worker','alexm@%','0000-00-00 00:00:00','Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerBusinessType','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','workerDepartment','alexm@%','0000-00-00 00:00:00','Select',''); @@ -964,7 +962,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','workerMana','alexm@%', INSERT IGNORE INTO `tables_priv` VALUES ('','vn','salesPerson','workerMana','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','ticketPackaging','alexm@%','0000-00-00 00:00:00','Insert',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','ticketPackagingStartingStock','alexm@%','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','claimManager','entryConfig','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','officeBoss','ticketPackagingStartingStock','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','workerRelatives','guillermo@db-proxy1.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','productionAssi','ticketPackagingStartingStock','alexm@%','0000-00-00 00:00:00','Select',''); @@ -1246,6 +1243,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','bs','deliveryAssistant','m3','alexm INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','ticketDms','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','time','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','deliveryAssistant','v_Articles_botanical','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','inventoryConfig','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','workerDepartment','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','zoneEvent','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','bi','deliveryAssistant','rotacion','alexm@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); @@ -1418,6 +1416,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','financialBoss','accountDetail' INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','accountDetail','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBoss','project','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBoss','machineDetail','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerActivityType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerSalesAssistant','route','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workCenter','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerSalesAssistant','Rutas','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); @@ -1480,7 +1479,6 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemStateTag' INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','material','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','saleUnit','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','origin','alexm@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','itemType','jgallego@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','deliveryAssistant','delivery','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemFarmingTag','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemWrappingTag','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); @@ -1911,7 +1909,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','util','android','debugadd','PROCEDUR INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','copyComponentsFromSaleList','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaEntryValueUpdate','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','administrative','duaInvoiceInBooking','PROCEDURE','carlosap@db-proxy1.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','itemshelvinglog_get','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','production','expedition_getstate','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','srt','production','expedition_scan','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','productionBoss','saleSplit','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); @@ -2134,7 +2131,6 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','srt','delivery','buffer_settypebynam INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expedition_getstate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','srt','delivery','expedition_scan','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); -INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelvinglog_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_getsaledate','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemshelving_filterbuyer','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); @@ -2154,6 +2150,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','sectorcollection_new INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','sectorcollection_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','setparking','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','shelvingparking_get','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','buy_getLastWithoutInventory','FUNCTION','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','saletracking_addprevok','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','sectorcollectionsalegroup_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','saletracking_updateischecked','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); @@ -2162,6 +2159,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','travel_updatepacking INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','freelance_getinfo','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','company_getfiscaldata','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expedition_getfromroute','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','zone_getPostalCode','PROCEDURE','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','itemplacementsupplyaiming','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','delivery','expeditionstate_addbypallet','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','srt','delivery','expeditionloading_add','PROCEDURE','guillermo@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); @@ -2254,7 +2252,7 @@ INSERT IGNORE INTO `global_priv` VALUES ('','buyerBoss','{\"access\": 0, \"versi INSERT IGNORE INTO `global_priv` VALUES ('','buyerSalesAssistant','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','claimManager','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','cooler','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); -INSERT IGNORE INTO `global_priv` VALUES ('','coolerAssist','{\"access\":0,\"version_id\":100707,\"is_role\":true}'); +INSERT IGNORE INTO `global_priv` VALUES ('','coolerAssist','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','coolerBoss','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); INSERT IGNORE INTO `global_priv` VALUES ('','customer','{\"access\": 0, \"max_questions\": 0, \"max_updates\": 30000, \"max_connections\": 300000, \"max_user_connections\": 400, \"max_statement_time\": 0.000000, \"is_role\": true,\"version_id\":100707}'); INSERT IGNORE INTO `global_priv` VALUES ('','delivery','{\"access\":0,\"version_id\":101106,\"is_role\":true}'); diff --git a/db/dump/.dump/structure.sql b/db/dump/.dump/structure.sql index c3f622d5f..a4ae460b1 100644 --- a/db/dump/.dump/structure.sql +++ b/db/dump/.dump/structure.sql @@ -75,26 +75,6 @@ SET character_set_client = utf8; 1 AS `password` */; SET character_set_client = @saved_cs_client; --- --- Table structure for table `accountLog__` --- - -DROP TABLE IF EXISTS `accountLog__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `accountLog__` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `msg` varchar(255) NOT NULL, - `pid` varchar(255) NOT NULL, - `user` varchar(255) NOT NULL, - `host` varchar(255) NOT NULL, - `rhost` varchar(255) NOT NULL, - `time` varchar(255) NOT NULL, - `summaryId` varchar(30) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2024-09-02 refs #7819'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Temporary table structure for view `emailUser` -- @@ -3538,14 +3518,14 @@ BEGIN bultos) SELECT r.id, r.agencyModeFk, - r.created, + r.dated, SUM(sv.volume / ebv.m3) FROM vn.route r JOIN vn.ticket t ON t.routeFk = r.id LEFT JOIN vn.`zone` z ON z.id = t.zoneFk JOIN vn.saleVolume sv ON sv.ticketFk = t.id JOIN vn.expeditionBoxVol ebv ON ebv.code = 'transportBox' - WHERE r.created BETWEEN vDatedFrom AND vDatedTo + WHERE r.dated BETWEEN vDatedFrom AND vDatedTo AND z.isVolumetric GROUP BY r.id; @@ -3557,12 +3537,12 @@ BEGIN Bultos) SELECT r.id, r.agencyModeFk, - r.created, + r.dated, SUM(t.packages) FROM vn.route r JOIN vn.ticket t ON t.routeFk = r.id LEFT JOIN vn.`zone` z ON z.id = t.zoneFk - WHERE r.created BETWEEN vDatedFrom AND vDatedTo + WHERE r.dated BETWEEN vDatedFrom AND vDatedTo AND NOT z.isVolumetric GROUP BY r.id ON DUPLICATE KEY UPDATE Bultos = Bultos + VALUES(Bultos); @@ -3579,7 +3559,7 @@ BEGIN JOIN vn.component c ON c.id = sc.componentFk JOIN vn.componentType ct ON ct.id = c.typeFk WHERE ct.code = 'freight' - AND r.created BETWEEN vDatedFrom AND vDatedTo + AND r.dated BETWEEN vDatedFrom AND vDatedTo GROUP BY r.id ) sub ON sub.routeFk = r.Id_Ruta SET r.practico = IFNULL(sub.totalPractice / r.Bultos, 0); @@ -3596,7 +3576,7 @@ BEGIN JOIN vn.address ad ON ad.id = t.addressFk JOIN vn.client c ON c.id = ad.clientFk LEFT JOIN vn.`zone` z ON z.id = t.zoneFk - WHERE r.created BETWEEN vDatedFrom AND vDatedTo + WHERE r.dated BETWEEN vDatedFrom AND vDatedTo AND NOT z.isVolumetric GROUP BY t.routeFk ) sub ON r.Id_Ruta = sub.routeFk @@ -3612,7 +3592,7 @@ BEGIN JOIN vn.saleVolume sf ON sf.ticketFk = t.id JOIN vn.client c ON c.id = t.clientFk JOIN vn.`zone` z ON z.id = t.zoneFk - WHERE r.created BETWEEN vDatedFrom AND vDatedTo + WHERE r.dated BETWEEN vDatedFrom AND vDatedTo AND z.isVolumetric GROUP BY t.routeFk ) sub ON r.Id_Ruta = sub.routeFk @@ -3627,7 +3607,7 @@ BEGIN JOIN vn.route r ON r.id = t.routeFk JOIN vn.greuge g ON g.ticketFk = t.id JOIN vn.greugeType gt ON gt.id = g.greugeTypeFk - WHERE r.created BETWEEN vDatedFrom AND vDatedTo + WHERE r.dated BETWEEN vDatedFrom AND vDatedTo AND gt.code = 'freightDifference' GROUP BY t.routeFk ) sub ON r.Id_Ruta = sub.routeFk @@ -17523,7 +17503,7 @@ BEGIN DECLARE vCursor CURSOR FOR SELECT it.taxableBase, - CAST((( it.taxableBase / 100) * t.PorcentajeIva) AS DECIMAL (10,2)), + CAST(SUM((( it.taxableBase / 100) * t.PorcentajeIva)) AS DECIMAL (10,2)), t.PorcentajeIva, it.transactionTypeSageFk, it.taxTypeSageFk, @@ -17536,7 +17516,8 @@ BEGIN JOIN TiposTransacciones tt ON tt.CodigoTransaccion = it.transactionTypeSageFk LEFT JOIN vn.dua d ON d.id = vInvoiceInFk WHERE i.id = vInvoiceInFk - AND d.id IS NULL; + AND d.id IS NULL + GROUP BY it.taxTypeSageFk; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -22756,8 +22737,7 @@ BEGIN DROP TEMPORARY TABLE IF EXISTS tValues; CREATE TEMPORARY TABLE tValues ENGINE = MEMORY - SELECT - b.id buyFk, + SELECT b.id buyFk, e.id entryFk, t.id travelFk, b.itemFk, @@ -23439,8 +23419,6 @@ DROP TABLE IF EXISTS `config`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `config` ( `id` int(10) unsigned NOT NULL, - `dbVersion__` char(11) DEFAULT NULL COMMENT '@deprecated 2024-09-02 refs #7819', - `hasTriggersDisabled__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-09-02 refs #7819', `environment` varchar(45) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT 'The current Database environment', `lastDump` datetime DEFAULT NULL COMMENT 'Timestamp of the last data dump', `mockUtcTime` datetime DEFAULT NULL, @@ -26125,7 +26103,6 @@ CREATE TABLE `agencyMode` ( `inflation` decimal(5,2) NOT NULL DEFAULT 0.00 COMMENT 'Este valor se utiliza para aumentar el valor del componente porte.', `isVolumetric` tinyint(1) NOT NULL DEFAULT 0, `reportMail` varchar(100) DEFAULT NULL, - `showAgencyName__` tinyint(1) DEFAULT 1 COMMENT '@deprecated 2024-09-24', `isActive` tinyint(1) NOT NULL DEFAULT 1, `isExternalAgency` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'obsoleta', `flag` blob DEFAULT NULL COMMENT 'obsoleta', @@ -29075,13 +29052,11 @@ DROP TABLE IF EXISTS `creditInsurance`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `creditInsurance` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `creditClassification__` int(11) DEFAULT NULL COMMENT '@deprecated 2024-09-11', `credit` int(11) DEFAULT NULL, `creationDate` timestamp NOT NULL DEFAULT current_timestamp(), `grade` tinyint(1) DEFAULT NULL, `creditClassificationFk` int(11) DEFAULT NULL, PRIMARY KEY (`id`), - KEY `CreditInsurance_Fk1_idx` (`creditClassification__`), KEY `creditInsurance_creditClassificationFk` (`creditClassificationFk`), CONSTRAINT `creditInsurance_creditClassificationFk` FOREIGN KEY (`creditClassificationFk`) REFERENCES `creditClassification` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Detalla los clientes que tienen seguro de credito'; @@ -29803,7 +29778,7 @@ CREATE TABLE `duaInvoiceIn` ( `duaFk` int(11) NOT NULL, `invoiceInFk` mediumint(8) unsigned DEFAULT NULL, PRIMARY KEY (`id`), - UNIQUE KEY `duaFk_UNIQUE` (`duaFk`,`invoiceInFk`), + UNIQUE KEY `duaInvoiceIn_unique` (`invoiceInFk`), KEY `duaInvoiceIn_fk1_idx` (`duaFk`), KEY `duaInvoiceIn_fk2_idx` (`invoiceInFk`), CONSTRAINT `duaInvoiceIn_fk1` FOREIGN KEY (`duaFk`) REFERENCES `dua` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, @@ -32259,6 +32234,7 @@ CREATE TABLE `itemConfig` ( `defaultPriority` int(11) NOT NULL DEFAULT 2, `warehouseFk` smallint(6) unsigned DEFAULT NULL, `downloadMaxAttempts` tinyint(3) DEFAULT NULL COMMENT 'Intentos máximos para que se borre', + `defaultPackingTypeFk` varchar(1) DEFAULT 'H', PRIMARY KEY (`id`), KEY `itemConfig_FK` (`defaultTag`), CONSTRAINT `itemConfig_FK` FOREIGN KEY (`defaultTag`) REFERENCES `tag` (`id`), @@ -32706,13 +32682,13 @@ SET character_set_client = utf8; SET character_set_client = @saved_cs_client; -- --- Table structure for table `itemShelvingLog` +-- Table structure for table `itemShelvingLog__` -- -DROP TABLE IF EXISTS `itemShelvingLog`; +DROP TABLE IF EXISTS `itemShelvingLog__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `itemShelvingLog` ( +CREATE TABLE `itemShelvingLog__` ( `id` int(11) NOT NULL AUTO_INCREMENT, `itemShelvingFk` int(10) unsigned DEFAULT NULL, `workerFk` int(11) DEFAULT NULL, @@ -32730,7 +32706,7 @@ CREATE TABLE `itemShelvingLog` ( KEY `itemShelving_Log_FK` (`itemShelvingFk`), KEY `itemShelvingLog_itemFk_IDX` (`itemFk`) USING BTREE, KEY `itemShelvingLog_shelvingFk_IDX` (`shelvingFk`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2024-11-26'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -35429,6 +35405,7 @@ CREATE TABLE `productionConfig` ( `orderMode` enum('Location','Age') NOT NULL DEFAULT 'Location', `editorFk` int(10) unsigned DEFAULT NULL, `minPlantTrayLength` int(11) NOT NULL DEFAULT 53 COMMENT 'minimum length for plant tray restriction. Avoid to make collection of the ticket with this kind of item', + `itemOrderReviewHours` int(11) DEFAULT 24 COMMENT 'Horas que no se tienen en cuenta para comprobar orden en el almacén, null para desactivar revisión', PRIMARY KEY (`id`), KEY `productionConfig_FK` (`shortageAddressFk`), KEY `productionConfig_FK_1` (`clientSelfConsumptionFk`), @@ -36253,7 +36230,7 @@ CREATE TABLE `route` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `workerFk` int(10) unsigned DEFAULT NULL, `firstEditorFk` int(10) unsigned DEFAULT NULL, - `created` date NOT NULL, + `created` timestamp NOT NULL DEFAULT current_timestamp(), `vehicleFk` int(10) unsigned DEFAULT NULL, `agencyModeFk` int(11) DEFAULT NULL, `time` datetime DEFAULT NULL, @@ -36272,6 +36249,7 @@ CREATE TABLE `route` ( `beachFk` int(11) DEFAULT NULL, `commissionWorkCenterFk` int(11) DEFAULT NULL COMMENT 'WorkerCenter que gestiona la ruta', `editorFk` int(10) unsigned DEFAULT NULL, + `dated` date NOT NULL, PRIMARY KEY (`id`), KEY `Id_Agencia` (`agencyModeFk`), KEY `Fecha` (`created`), @@ -37564,23 +37542,6 @@ CREATE TABLE `siiTypeInvoiceOut` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tipo de Factura Emitidas en el suministro de inmediato'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `silexACL__` --- - -DROP TABLE IF EXISTS `silexACL__`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `silexACL__` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `module` varchar(50) NOT NULL, - `method` varchar(50) NOT NULL, - `role` varchar(20) NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `module_UNIQUE` (`module`,`method`) USING BTREE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='@deprecated 2024-08-05 refs #7820'; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `sinister` -- @@ -38628,7 +38589,7 @@ CREATE TABLE `ticket` ( CONSTRAINT `ticket_ibfk_8` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`), CONSTRAINT `ticket_ibfk_9` FOREIGN KEY (`routeFk`) REFERENCES `route` (`id`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `ticket_invoiceOut_FK` FOREIGN KEY (`refFk`) REFERENCES `invoiceOut` (`ref`) ON UPDATE CASCADE, - CONSTRAINT `tickets_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON UPDATE CASCADE + CONSTRAINT `tickets_zone_fk` FOREIGN KEY (`zoneFk`) REFERENCES `zone` (`id`) ON DELETE SET NULL ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -40329,6 +40290,8 @@ CREATE TABLE `workCenterCommission` ( `distributionM3Category2` decimal(5,2) DEFAULT NULL, `distributionCat4M3` decimal(5,2) DEFAULT NULL COMMENT 'Comisión por gestión de la distribución Cat IV', `distributionCat5M3` decimal(5,2) DEFAULT NULL COMMENT 'Comisión por gestión de la distribución Cat V', + `deliveryM3Cat4` decimal(5,2) DEFAULT NULL, + `deliveryM3Cat5` decimal(5,2) DEFAULT NULL, PRIMARY KEY (`workCenterFk`), CONSTRAINT `workCenterCommission_workCenterFk` FOREIGN KEY (`workCenterFk`) REFERENCES `workCenter` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -40370,7 +40333,6 @@ CREATE TABLE `worker` ( `hasMachineryAuthorized` tinyint(2) DEFAULT 0, `seniority` date DEFAULT NULL, `isTodayRelative` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Para el F11. Calcula los problemas de visiblidad en funcion del dia actual', - `isF11Allowed__` tinyint(1) NOT NULL DEFAULT 0 COMMENT '@deprecated 2024-09-22', `maritalStatus` enum('S','M') NOT NULL, `originCountryFk` mediumint(8) unsigned DEFAULT NULL COMMENT 'País de origen', `educationLevelFk` smallint(6) DEFAULT NULL, @@ -40922,9 +40884,7 @@ CREATE TABLE `workerRelatives` ( `updated` timestamp NULL DEFAULT current_timestamp(), PRIMARY KEY (`id`), KEY `workerRelatives_disabilityGradeFk` (`disabilityGradeFk`), - KEY `workerRelatives_workerFk` (`workerFk`), - CONSTRAINT `workerRelatives_disabilityGradeFk` FOREIGN KEY (`disabilityGradeFk`) REFERENCES `disabilityGrade` (`id`) ON UPDATE CASCADE, - CONSTRAINT `workerRelatives_workerFk` FOREIGN KEY (`workerFk`) REFERENCES `workerIrpf` (`workerFk`) ON DELETE CASCADE ON UPDATE CASCADE + KEY `workerRelatives_workerFk` (`workerFk`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Modelo 145 IRPF apartado 2 y 3'; /*!40101 SET character_set_client = @saved_cs_client */; @@ -41144,13 +41104,13 @@ CREATE TABLE `workerTimeControlMail` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `workerTimeControlParams` +-- Table structure for table `workerTimeControlParams__` -- -DROP TABLE IF EXISTS `workerTimeControlParams`; +DROP TABLE IF EXISTS `workerTimeControlParams__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `workerTimeControlParams` ( +CREATE TABLE `workerTimeControlParams__` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dayBreak` int(11) NOT NULL, `weekBreak` int(11) NOT NULL, @@ -41166,7 +41126,7 @@ CREATE TABLE `workerTimeControlParams` ( `mailErrorFolder` varchar(45) NOT NULL, `mailUser` varchar(45) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin COMMENT='All values in seconds'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin COMMENT='@deprecated 2024-11-19'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -42227,6 +42187,49 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; +/*!50003 DROP FUNCTION IF EXISTS `buy_getLastWithoutInventory` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8mb4 */ ; +/*!50003 SET character_set_results = utf8mb4 */ ; +/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; +DELIMITER ;; +CREATE DEFINER=`vn`@`localhost` FUNCTION `buy_getLastWithoutInventory`(vItemFk INT, + vWarehouseFk INT +) RETURNS int(11) + DETERMINISTIC +BEGIN +/** + * Retorna la última compra que no sea inventario. + * + * @param vItemFk Id del artículo + * @param vWarehouseFk Id del almacén + * @return Id de compra + */ + DECLARE vBuyFk INT; + + SELECT b.id INTO vBuyFk + FROM buy b + JOIN entry e ON e.id = b.entryFk + JOIN travel t ON t.id = e.travelFk + WHERE e.id <> (SELECT defaultEntry FROM entryConfig) + AND e.supplierFk <> (SELECT supplierFk FROM inventoryConfig) + AND e.typeFk <> 'inventory' + AND b.itemFk = vItemFk + AND (t.warehouseInFk = vWarehouseFk OR t.warehouseInFk IS NULL) + ORDER BY ABS(DATEDIFF(util.VN_CURDATE(), t.landed)), e.created DESC + LIMIT 1; + + RETURN vBuyFk; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `buy_getUltimate` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -44838,7 +44841,7 @@ BEGIN JOIN cache.zoneAgencyFriendship zf ON zf.agencyModeFk = r.agencyModeFk WHERE friendship >= vSignificativeFriendship AND zf.zoneFk = vZoneFk - AND r.created = vLanded + AND r.dated = vLanded ORDER BY friendship; -- Se eliminan aquellas que superan el volumen máximo @@ -44904,7 +44907,7 @@ BEGIN JOIN cache.zoneAgencyFriendship zf ON zf.agencyModeFk = r.agencyModeFk WHERE friendship >= vSignificativeFriendship AND zf.zoneFk = vZoneFk - AND r.created = vLanded + AND r.dated = vLanded ORDER BY friendship; -- Se eliminan aquellas que superan el volumen máximo @@ -45982,82 +45985,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP FUNCTION IF EXISTS `timeWorkerControl_getDirection` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` FUNCTION `timeWorkerControl_getDirection`(vUserFk INT, vTimed DATETIME) RETURNS varchar(6) CHARSET utf8mb3 COLLATE utf8mb3_unicode_ci - READS SQL DATA -BEGIN -/** - * Verifica la dirección de la fichada - * @param vUserFk Identificador del trabajador - * @param vTimed Hora de la fichada - * @return Retorna sentido de la fichada 'in, out, middle' - */ - - DECLARE vPrevious DATETIME ; - DECLARE vNext DATETIME ; - DECLARE vPreviousDirection VARCHAR(3) ; - DECLARE vNextDirection VARCHAR(3) ; - DECLARE vDayStayMax INT; - DECLARE vTimedSeconds INT; - DECLARE vLastTimeIn INT; - - SELECT UNIX_TIMESTAMP(vTimed) INTO vTimedSeconds; - - SELECT dayStayMax INTO vDayStayMax - FROM vn.workerTimeControlParams; - - SELECT timed, direction INTO vNext,vNextDirection - FROM vn.workerTimeControl - WHERE userFk = vUserFk - AND direction IN ('in','out') - AND timed > vTimed - ORDER BY timed ASC - LIMIT 1; - - SELECT timed, direction INTO vPrevious, vPreviousDirection - FROM vn.workerTimeControl - WHERE userFk = vUserFk - AND direction IN ('in','out') - AND timed < vTimed - ORDER BY timed DESC - LIMIT 1; - - IF (vTimedSeconds - UNIX_TIMESTAMP(vPrevious) + UNIX_TIMESTAMP(vNext) - vTimedSeconds)<= vDayStayMax AND vPreviousDirection = 'in' AND vNextDirection = 'out' THEN - RETURN 'middle'; - END IF; - - - IF (vTimedSeconds> UNIX_TIMESTAMP(vPrevious)) THEN - IF vPreviousDirection = 'in' THEN - RETURN 'out'; - ELSE - SELECT UNIX_TIMESTAMP(MAX(timed)) INTO vLastTimeIn - FROM vn.workerTimeControl - WHERE userFk = vUserFk - AND direction ='in' - AND timed < vPrevious; - IF vTimedSeconds - vLastTimeIn <= vDayStayMax THEN - RETURN 'out'; - END IF; - END IF; - END IF; - - RETURN 'in'; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP FUNCTION IF EXISTS `time_getSalesYear` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -55131,17 +55058,19 @@ BEGIN * * @param vSelf Id de entrada */ - DECLARE vIsEditable BOOL; + DECLARE vIsNotEditable BOOL DEFAULT FALSE; - SELECT e.isBooked INTO vIsEditable + SELECT TRUE INTO vIsNotEditable FROM `entry` e - JOIN entryType et ON et.code = e.typeFk - WHERE NOT et.isInformal - AND e.id = vSelf; + LEFT JOIN entryType et ON et.code = e.typeFk + WHERE e.id = vSelf + AND e.isBooked + AND (e.typeFk IS NULL OR NOT et.isInformal); - IF vIsEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN + IF vIsNotEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN CALL util.throw(CONCAT('Entry ', vSelf, ' is not editable')); END IF; + END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -55486,12 +55415,13 @@ BEGIN LEAST(bb.stickers, FLOOR(ish.visible / ish.packing)) ishStickers, bb.stickers buyStickers FROM itemShelving ish + JOIN shelving sh ON sh.id = ish.shelvingFk JOIN (SELECT b.id, b.itemFk, b.stickers FROM buy b WHERE b.entryFk = vFromEntryFk ORDER BY b.stickers DESC LIMIT 10000000000000000000) bb ON bb.itemFk = ish.itemFk - WHERE ish.shelvingFk = vShelvingCode COLLATE utf8_general_ci + WHERE sh.code = vShelvingCode COLLATE utf8_general_ci AND NOT ish.isSplit GROUP BY ish.id; @@ -56397,7 +56327,7 @@ BEGIN WHERE expeditionFk = e.id) LEFT JOIN expeditionState es2 ON es2.id = es.id WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE - ORDER BY r.created, t.priority DESC; + ORDER BY r.dated, t.priority DESC; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -56539,7 +56469,9 @@ proc:BEGIN WHERE shipped BETWEEN vCreated AND util.dayEnd(vCreated) AND clientFk = vClientFk AND addressFk = vAddressFk - AND warehouseFk = vWarehouseFk; + AND warehouseFk = vWarehouseFk + AND nickname = 'CAJAS AUTOCONSUMO' + LIMIT 1; IF vTicketFk IS NULL AND vAction = 'add' THEN INSERT INTO ticket(clientFk, warehouseFk, shipped, nickname, addressFk) @@ -58171,7 +58103,7 @@ BEGIN ) eWithheld ON TRUE WHERE tii.taxTypeSageFk IS NOT NULL AND (tii.taxCode IS NULL OR tii.taxCode NOT IN ('import10', 'import21')) - GROUP BY tii.PorcentajeIva, tii.expenseFk; + GROUP BY tii.CuentaIvaRepercutido; -- Línea iva inversor sujeto pasivo INSERT INTO XDiario( @@ -58236,7 +58168,7 @@ BEGIN AND NOT(tii.isVies AND c.nontaxableTransactionTypeFk = tii.transactionTypeSageFk AND tii.taxCode = 'nonTaxable') - GROUP BY tii.PorcentajeIva, tii.expenseFk; + GROUP BY tii.CuentaIvaRepercutido; -- Actualización del registro original UPDATE invoiceIn ii @@ -59843,55 +59775,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `itemShelvingLog_get` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` PROCEDURE `itemShelvingLog_get`( - vShelvingCode VARCHAR(10) -) -BEGIN -/** - * Devuelve el log de los item en cada carro - * - * @param vShelvingCode Matrícula del carro - * - */ - SELECT isl.itemShelvingFk, - isl.created, - isl.accion, - isl.itemFk, - isl.shelvingFk, - isl.quantity, - isl.visible, - isl.available, - isl.grouping, - isl.packing, - isl.stars, - item.longName, - item.size, - item.subName, - worker.code, - isl.accion - FROM item - JOIN itemShelvingLog isl ON item.id = isl.itemFk - JOIN worker ON isl.workerFk = worker.id - JOIN shelving sh ON sh.id = isl.shelvingFk - WHERE sh.code = vShelvingCode COLLATE utf8mb3_unicode_ci - OR isl.itemFk = vShelvingCode -- ?? Respeto porque ya estaba - ORDER BY isl.created DESC; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `itemShelvingMatch` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -68021,7 +67904,7 @@ BEGIN rm.ticketFree = 0, rm.ticketProduction = 0, rm.ticketPacked = 0, - rm.dated = r.created; + rm.dated = r.dated; UPDATE routesMonitor rm JOIN ( @@ -68181,7 +68064,7 @@ BEGIN DECLARE vIsKmTruckRate BOOL; DECLARE vCountryFk INT; - SELECT r.created >= rc.cutoffDated INTO vIsUpdatable + SELECT r.dated >= rc.cutoffDated INTO vIsUpdatable FROM route r JOIN routeConfig rc WHERE r.id = vSelf; @@ -68190,14 +68073,15 @@ BEGIN DELETE FROM routeCommission WHERE routeFk = vSelf; - SELECT w.isFreelance, v.isKmTruckRate, c.countryFk INTO vIsFreelance, vIsKmTruckRate, vCountryFk + SELECT w.isFreelance, v.isKmTruckRate, p.countryFk INTO vIsFreelance, vIsKmTruckRate, vCountryFk FROM route r JOIN worker w ON w.id = r.workerFk JOIN vehicle v ON v.id = r.vehicleFk LEFT JOIN ticket t ON t.routeFk = r.id - LEFT JOIN client c ON c.id = t.clientFk + LEFT JOIN address a ON a.id = t.addressFk + LEFT JOIN province p ON p.id = a.provinceFk WHERE r.id = vSelf - GROUP BY c.countryFk + GROUP BY p.countryFk ORDER BY COUNT(*) DESC LIMIT 1; @@ -68257,7 +68141,9 @@ BEGIN (r.kmEnd - r.kmStart) * IF(v.isKmTruckRate, rc.kmHeavy, rc.kmLight), IFNULL(r.m3, 0) * - IF(v.isKmTruckRate, rc.deliveryM3Cat5, rc.deliveryM3Cat4), + IF(v.isKmTruckRate, + IFNULL(wc.deliveryM3Cat5, rc.deliveryM3Cat5), + IFNULL(wc.deliveryM3Cat4, rc.deliveryM3Cat4)), (r.kmEnd - r.kmStart) * rc.kmYearly, IFNULL(r.m3, 0) * rc.m3Yearly, IFNULL(wc.distributionCat4M3, rc.distributionCat4M3) * IFNULL(r.m3, 0), @@ -76663,123 +76549,123 @@ CREATE DEFINER=`vn`@`localhost` PROCEDURE `ticket_splitItemPackingType`( ) BEGIN /** - * Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado. - * Respeta el id inicial para el tipo propuesto. + * Separa en diferentes tickets según el tipo de empaquetado + * El ticket original conserva las líneas del tipo de empaquetado especificado + * Las líneas sin tipo de empaquetado se asignan al ticket del tipo por defecto. * - * @param vSelf Id ticket - * @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original + * @param vSelf Id del ticket original + * @param vOriginalItemPackingTypeFk Tipo de empaquetado a mantener en el ticket original * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) */ - DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H'; + DECLARE vIsDone BOOLEAN DEFAULT FALSE; + DECLARE vCurrentPackingType VARCHAR(1); + DECLARE vDefaultPackingType VARCHAR(1); + DECLARE vHasOriginalPackingType BOOLEAN; DECLARE vNewTicketFk INT; - DECLARE vPackingTypesToSplit INT; - DECLARE vDone INT DEFAULT FALSE; + DECLARE vTicketFk INT; - DECLARE vSaleGroup CURSOR FOR - SELECT itemPackingTypeFk - FROM tSaleGroup - WHERE itemPackingTypeFk IS NOT NULL - ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC; + DECLARE vItemPackingTypes CURSOR FOR + SELECT DISTINCT itemPackingTypeFk FROM tSalesToMove; - DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET vIsDone = TRUE; + + DECLARE EXIT HANDLER FOR SQLEXCEPTION + BEGIN + ROLLBACK; + RESIGNAL; + END; + + CREATE OR REPLACE TEMPORARY TABLE tSalesToMove ( + ticketFk INT, + saleFk INT, + itemPackingTypeFk VARCHAR(1) + ) ENGINE=MEMORY; + + SELECT COALESCE(MAX(ic.defaultPackingTypeFk), MAX(i.itemPackingTypeFk)) INTO vDefaultPackingType + FROM vn.sale s + JOIN item i ON i.id = s.itemFk + LEFT JOIN itemConfig ic ON ic.defaultPackingTypeFk = i.itemPackingTypeFk + WHERE s.ticketFk = vSelf + GROUP BY s.ticketFk; + + SELECT EXISTS ( + SELECT TRUE + FROM sale s + JOIN item i ON i.id = s.itemFk + WHERE s.ticketFk = vSelf + AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk + ) INTO vHasOriginalPackingType; + + IF vOriginalItemPackingTypeFk IS NULL OR NOT vHasOriginalPackingType THEN + SET vOriginalItemPackingTypeFk = vDefaultPackingType; + END IF; START TRANSACTION; - SELECT id - FROM sale - WHERE ticketFk = vSelf - AND NOT quantity + SELECT t.id INTO vTicketFk + FROM ticket t + JOIN sale s ON s.id = t.id + WHERE t.id = vSelf FOR UPDATE; - DELETE FROM sale - WHERE NOT quantity - AND ticketFk = vSelf; - - CREATE OR REPLACE TEMPORARY TABLE tSale - (PRIMARY KEY (id)) - ENGINE = MEMORY - SELECT s.id, i.itemPackingTypeFk, IFNULL(sv.litros, 0) litros + INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk) + SELECT s.id, i.itemPackingTypeFk FROM sale s JOIN item i ON i.id = s.itemFk - LEFT JOIN saleVolume sv ON sv.saleFk = s.id - WHERE s.ticketFk = vSelf; + WHERE s.ticketFk = vSelf + AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk; - CREATE OR REPLACE TEMPORARY TABLE tSaleGroup - ENGINE = MEMORY - SELECT itemPackingTypeFk, SUM(litros) totalLitros - FROM tSale - GROUP BY itemPackingTypeFk; + OPEN vItemPackingTypes; + l: LOOP + SET vIsDone = FALSE; + FETCH vItemPackingTypes INTO vCurrentPackingType; - SELECT COUNT(*) INTO vPackingTypesToSplit - FROM tSaleGroup - WHERE itemPackingTypeFk IS NOT NULL; + IF vIsDone THEN + LEAVE l; + END IF; - CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT( - ticketFk INT, - itemPackingTypeFk VARCHAR(1) - ) ENGINE = MEMORY; + CALL ticket_Clone(vSelf, vNewTicketFk); - CASE vPackingTypesToSplit - WHEN 0 THEN - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vSelf, vItemPackingTypeFk); - WHEN 1 THEN - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - SELECT vSelf, itemPackingTypeFk - FROM tSaleGroup - WHERE itemPackingTypeFk IS NOT NULL; - ELSE - OPEN vSaleGroup; - FETCH vSaleGroup INTO vItemPackingTypeFk; + SELECT id INTO vTicketFk + FROM ticket t + WHERE t.id = vNewTicketFk + FOR UPDATE; - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vSelf, vItemPackingTypeFk); + UPDATE tSalesToMove + SET ticketFk = vNewTicketFk + WHERE itemPackingTypeFk = vCurrentPackingType; - l: LOOP - SET vDone = FALSE; - FETCH vSaleGroup INTO vItemPackingTypeFk; + IF vCurrentPackingType = vDefaultPackingType THEN + INSERT INTO tSalesToMove (ticketFk, saleFk, itemPackingTypeFk) + SELECT vNewTicketFk, s.id, i.itemPackingTypeFk + FROM sale s + JOIN item i ON i.id = s.itemFk + WHERE s.ticketFk = vSelf + AND i.itemPackingTypeFk IS NULL; + END IF; - IF vDone THEN - LEAVE l; - END IF; + END LOOP; + CLOSE vItemPackingTypes; - CALL ticket_Clone(vSelf, vNewTicketFk); + UPDATE sale s + JOIN tSalesToMove t ON t.saleFk = s.id + SET s.ticketFk = t.ticketFk; - INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) - VALUES(vNewTicketFk, vItemPackingTypeFk); - END LOOP; - - CLOSE vSaleGroup; - - SELECT s.id - FROM sale s - JOIN tSale ts ON ts.id = s.id - JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk - FOR UPDATE; - - UPDATE sale s - JOIN tSale ts ON ts.id = s.id - JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = ts.itemPackingTypeFk - SET s.ticketFk = t.ticketFk; - - SELECT itemPackingTypeFk INTO vItemPackingTypeFk - FROM tSaleGroup sg - WHERE sg.itemPackingTypeFk IS NOT NULL - ORDER BY sg.itemPackingTypeFk - LIMIT 1; - - UPDATE sale s - JOIN tSale ts ON ts.id = s.id - JOIN tmp.ticketIPT t ON t.itemPackingTypeFk = vItemPackingTypeFk - SET s.ticketFk = t.ticketFk - WHERE ts.itemPackingTypeFk IS NULL; - END CASE; + CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT + ENGINE=MEMORY + SELECT s.ticketFk, MAX(i.itemPackingTypeFk) itemPackingTypeFk + FROM sale s + JOIN item i ON i.id = s.itemFk + WHERE s.ticketFk = vSelf + GROUP BY s.ticketFk + UNION + SELECT ticketFk, MAX(itemPackingTypeFk) + FROM tSalesToMove + GROUP BY ticketFk; COMMIT; - DROP TEMPORARY TABLE - tSale, - tSaleGroup; + DROP TEMPORARY TABLE tSalesToMove; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -79744,187 +79630,6 @@ DELIMITER ; /*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_check` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` PROCEDURE `workerTimeControl_check`(vUserFk INT, vDated DATE,vTabletFk VARCHAR(100)) -proc: BEGIN -/** - * Verifica si el empleado puede fichar en el momento actual, si puede fichar llama a workerTimeControlAdd - * - * @param vUserFk Identificador del trabajador - * @return Retorna si encuentra un problema 'odd','maxTimeWork','breakDay','breakWeek' ; - * En caso de tener algun problema retorna el primero que encuentra - */ - DECLARE vLastIn DATETIME ; - DECLARE vLastOut DATETIME ; - DECLARE vDayWorkMax INT; - DECLARE vDayBreak INT; - DECLARE vWeekBreak INT ; - DECLARE vWeekScope INT; - DECLARE vDayStayMax INT; - DECLARE vProblem VARCHAR(20) DEFAULT NULL; - DECLARE vTimedWorked INT; - DECLARE vCalendarStateType VARCHAR(20) DEFAULT NULL; - DECLARE vDepartmentFk INT; - DECLARE vTo VARCHAR(50) DEFAULT NULL; - DECLARE vUserName VARCHAR(50) DEFAULT NULL; - DECLARE vBody VARCHAR(255) DEFAULT NULL; - - SELECT dayBreak, weekBreak, weekScope, dayWorkMax, dayStayMax - INTO vDayBreak, vWeekBreak, vWeekScope, vDayWorkMax, vDayStayMax - FROM workerTimeControlParams; - - SELECT MAX(timed) INTO vLastIn - FROM workerTimeControl - WHERE userFk = vUserFk - AND direction = 'in'; - - SELECT MAX(timed) INTO vLastOut - FROM workerTimeControl - WHERE userFk = vUserFk - AND direction = 'out'; - - SELECT CONCAT(u.name,'@verdnatura.es') INTO vTo - FROM account.user u - WHERE u.id = (SELECT bossFk FROM worker WHERE id = vUserFk); - - SELECT CONCAT(firstName,' ',lastName) INTO vUserName - FROM worker w - WHERE w.id = vUserFk; - - - IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastIn) > vDayStayMax THEN -- NUEVA JORNADA - - -- VERIFICAR DESCANSO DIARIO - IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vDayBreak THEN - SELECT "Descansos 12 h" AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 12 h") INTO vBody; - CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - END IF; - - -- VERIFICAR FICHADAS IMPARES DEL ÚLTIMO DÍA QUE SE FICHÓ - IF (SELECT MOD(COUNT(*),2) -- <>0 - FROM workerTimeControl - WHERE userFk = vUserFk - AND timed >= vLastIn - ) THEN - SELECT "Dias con fichadas impares" AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Dias con fichadas impares") INTO vBody; - CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - END IF; - - -- VERIFICAR VACACIONES - SELECT at2.name INTO vCalendarStateType - FROM calendar c - JOIN business b ON b.id = c.businessFk - JOIN absenceType at2 ON at2.id = c.dayOffTypeFk - WHERE c.dated = util.VN_CURDATE() - AND at2.isAllowedToWork = FALSE - AND b.workerFk = vUserFk - LIMIT 1; - - IF(LENGTH(vCalendarStateType)) THEN - SELECT vCalendarStateType AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Vacaciones") INTO vBody; - CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - - END IF; - - -- VERIFICAR CONTRATO EN VIGOR - IF (SELECT COUNT(*) - FROM business b - WHERE b.workerFk = vUserFk - AND b.started <= vDated - AND IFNULL(b.ended, vDated) >= vDated - ) = 0 THEN - SELECT "No hay un contrato en vigor" AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"No hay un contrato en vigor") INTO vBody; - CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - - END IF; - - -- VERIFICAR DESCANSO SEMANAL - SET @vHasBreakWeek:= FALSE; - SET @vLastTimed:= UNIX_TIMESTAMP((util.VN_NOW() - INTERVAL vWeekScope SECOND)); - - DROP TEMPORARY TABLE IF EXISTS tmp.trash; - CREATE TEMPORARY TABLE tmp.trash - SELECT IF(vWeekBreak-(UNIX_TIMESTAMP(timed)-@vLastTimed) <= 0, @vHasBreakWeek:=TRUE, TRUE) alias, - @vLastTimed:= UNIX_TIMESTAMP(timed) - FROM workerTimeControl - WHERE timed>= (util.VN_NOW() - INTERVAL vWeekScope SECOND) - AND userFk= vUserFk - AND direction IN ('in','out') - ORDER BY timed ASC; - - IF UNIX_TIMESTAMP(util.VN_NOW()) - UNIX_TIMESTAMP(vLastOut) < vWeekBreak AND @vHasBreakWeek = FALSE THEN -- REVISA SI EL DESCANSO SE HA REALIZADO DESPUÉS DE LA ÚLTIMA FICHADA - SELECT "Descansos 36 h" AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Descansos 36 h") INTO vBody; - CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - END IF; - - DROP TEMPORARY TABLE tmp.trash; - - ELSE -- DIA ACTUAL - - -- VERIFICA QUE EL TIEMPO EFECTIVO NO SUPERE EL MÁXIMO - SELECT IFNULL(SUM(if( mod(wtc.order,2)=1, -UNIX_TIMESTAMP(timed), UNIX_TIMESTAMP(timed))),0) - IF( MOD(COUNT(*),2), UNIX_TIMESTAMP(util.VN_NOW()), 0) INTO vTimedWorked - FROM workerTimeControl wtc - WHERE userFk = vUserFk - AND timed >= vLastIn - ORDER BY timed; - - IF vTimedWorked > vDayWorkMax THEN - SELECT "Jornadas" AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No ha podido fichar por el siguiente problema: ',"Jornadas") INTO vBody; - CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - END IF; - - END IF; - - -- VERIFICAR DEPARTAMENTO - /* IF vTabletFk IS NOT NULL THEN - SELECT wtcu.departmentFk INTO vDepartmentFk - FROM workerTimeControlUserInfo wtcu - WHERE wtcu.userFk = vUserFk; - IF (SELECT COUNT(td.tabletFk) - FROM tabletDepartment td - WHERE td.tabletFk = vTabletFk AND td.departmentFk = vDepartmentFk - ) = 0 THEN - SELECT "No perteneces a este departamento." AS problem; - -- ENVIAMOS CORREO AL BOSSFK - SELECT CONCAT(vUserName,' No a podido fichar por el siguiente problema: ',"No perteneces a este departamento.") INTO vBody; - CALL mail_insert(vTo,vTo,'error al fichar',vBody); - LEAVE proc; - END IF; - END IF;*/ - -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; /*!50003 DROP PROCEDURE IF EXISTS `workerTimeControl_checkBreak` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -87336,7 +87041,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionPallet_Print` AS select `rs2`.`description` AS `truck`,`t`.`routeFk` AS `routeFk`,`r`.`description` AS `zone`,count(`es`.`id`) AS `eti`,`ep`.`id` AS `palletFk`,`rs`.`id` <=> `rm`.`roadmapStopFk` AS `isMatch`,`t`.`warehouseFk` AS `warehouseFk`,if(`r`.`created` > `util`.`VN_CURDATE`() + interval 1 day,ucase(dayname(`r`.`created`)),NULL) AS `nombreDia` from (((((((`roadmapStop` `rs` join `expeditionPallet` `ep` on(`ep`.`truckFk` = `rs`.`id`)) join `expeditionScan` `es` on(`es`.`palletFk` = `ep`.`id`)) join `expedition` `e` on(`e`.`id` = `es`.`expeditionFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `route` `r` on(`r`.`id` = `t`.`routeFk`)) left join `routesMonitor` `rm` on(`rm`.`routeFk` = `r`.`id`)) left join `roadmapStop` `rs2` on(`rs2`.`id` = `rm`.`roadmapStopFk`)) group by `ep`.`id`,`t`.`routeFk` */; +/*!50001 VIEW `expeditionPallet_Print` AS select `rs2`.`description` AS `truck`,`t`.`routeFk` AS `routeFk`,`r`.`description` AS `zone`,count(`es`.`id`) AS `eti`,`ep`.`id` AS `palletFk`,`rs`.`id` <=> `rm`.`roadmapStopFk` AS `isMatch`,`t`.`warehouseFk` AS `warehouseFk`,if(`r`.`dated` > `util`.`VN_CURDATE`() + interval 1 day,ucase(dayname(`r`.`dated`)),NULL) AS `nombreDia` from (((((((`roadmapStop` `rs` join `expeditionPallet` `ep` on(`ep`.`truckFk` = `rs`.`id`)) join `expeditionScan` `es` on(`es`.`palletFk` = `ep`.`id`)) join `expedition` `e` on(`e`.`id` = `es`.`expeditionFk`)) join `ticket` `t` on(`t`.`id` = `e`.`ticketFk`)) join `route` `r` on(`r`.`id` = `t`.`routeFk`)) left join `routesMonitor` `rm` on(`rm`.`routeFk` = `r`.`id`)) left join `roadmapStop` `rs2` on(`rs2`.`id` = `rm`.`roadmapStopFk`)) group by `ep`.`id`,`t`.`routeFk` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -87354,7 +87059,7 @@ USE `vn`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`vn`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `expeditionRoute_Monitor` AS select `r`.`id` AS `routeFk`,count(distinct if(`e`.`id` is null,`t`.`id`,NULL)) AS `tickets`,count(distinct `e`.`id`) AS `expeditions`,count(distinct `es`.`id`) AS `scanned`,max(`e`.`created`) AS `lastPacked`,`r`.`created` AS `created` from (((((`route` `r` left join `routesMonitor` `rm` on(`r`.`id` = `rm`.`routeFk`)) left join `roadmapStop` `rs` on(`rs`.`id` = `rm`.`roadmapStopFk`)) join `ticket` `t` on(`t`.`routeFk` = `r`.`id`)) left join `expedition` `e` on(`e`.`ticketFk` = `t`.`id`)) left join `expeditionScan` `es` on(`es`.`expeditionFk` = `e`.`id`)) where `r`.`created` >= `util`.`yesterday`() group by `r`.`id` */; +/*!50001 VIEW `expeditionRoute_Monitor` AS select `r`.`id` AS `routeFk`,count(distinct if(`e`.`id` is null,`t`.`id`,NULL)) AS `tickets`,count(distinct `e`.`id`) AS `expeditions`,count(distinct `es`.`id`) AS `scanned`,max(`e`.`created`) AS `lastPacked`,`r`.`dated` AS `created` from (((((`route` `r` left join `routesMonitor` `rm` on(`r`.`id` = `rm`.`routeFk`)) left join `roadmapStop` `rs` on(`rs`.`id` = `rm`.`roadmapStopFk`)) join `ticket` `t` on(`t`.`routeFk` = `r`.`id`)) left join `expedition` `e` on(`e`.`ticketFk` = `t`.`id`)) left join `expeditionScan` `es` on(`es`.`expeditionFk` = `e`.`id`)) where `r`.`dated` >= `util`.`yesterday`() group by `r`.`id` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -89394,7 +89099,7 @@ USE `vn2008`; /*!50001 SET collation_connection = utf8mb4_unicode_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `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` */; +/*!50001 VIEW `Rutas` AS select `r`.`id` AS `Id_Ruta`,`r`.`workerFk` AS `Id_Trabajador`,`r`.`dated` 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` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -91244,4 +90949,4 @@ USE `vn2008`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-11-26 12:08:52 +-- Dump completed on 2024-12-10 8:17:51 diff --git a/db/dump/.dump/triggers.sql b/db/dump/.dump/triggers.sql index 8f8fe9670..3299aea37 100644 --- a/db/dump/.dump/triggers.sql +++ b/db/dump/.dump/triggers.sql @@ -6447,7 +6447,7 @@ BEGIN JOIN vn.route r ON r.id = t.routeFk WHERE r.isOk = FALSE AND ic.itemFk = NEW.itemFk - AND r.created >= util.VN_CURDATE() + AND r.dated >= util.VN_CURDATE() GROUP BY r.id; IF NEW.cm3Delivery = 0 AND NEW.warehouseFk = 60 THEN CALL mail_insert( @@ -6546,36 +6546,6 @@ BEGIN SET NEW.userFk = account.myUser_getId(); SET NEW.available = NEW.visible; -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_afterInsert` - AFTER INSERT ON `itemShelving` - FOR EACH ROW -BEGIN - INSERT INTO itemShelvingLog - SET itemShelvingFk = NEW.id, - workerFk = account.myUser_getId(), - accion = 'CREA REGISTRO', - itemFk = NEW.itemFk, - shelvingFk = NEW.shelvingFk, - visible = NEW.visible, - `grouping` = NEW.`grouping`, - packing = NEW.packing, - available = NEW.available; - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -6619,63 +6589,6 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_afterUpdate` - AFTER UPDATE ON `itemShelving` - FOR EACH ROW -BEGIN - INSERT INTO itemShelvingLog - SET itemShelvingFk = NEW.id, - workerFk = account.myUser_getId(), - accion = 'CAMBIO', - itemFk = NEW.itemFk, - shelvingFk = NEW.shelvingFk, - visible = NEW.visible, - `grouping` = NEW.`grouping`, - packing = NEW.packing, - available = NEW.available; - -END */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; -/*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_beforeDelete` - BEFORE DELETE ON `itemShelving` - FOR EACH ROW -INSERT INTO vn.itemShelvingLog(itemShelvingFk, - workerFk, - accion, - shelvingFk, - itemFk) - VALUES( OLD.id, - account.myUser_getId(), - 'ELIMINADO', - OLD.shelvingFk, - OLD.itemFk) */;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -DELIMITER ;; /*!50003 CREATE*/ /*!50017 DEFINER=`vn`@`localhost`*/ /*!50003 TRIGGER `vn`.`itemShelving_afterDelete` AFTER DELETE ON `itemShelving` FOR EACH ROW @@ -8138,7 +8051,7 @@ BEGIN SELECT IFNULL(b.workCenterFK, r.defaultWorkCenterFk) FROM vn.routeConfig r LEFT JOIN vn.business b ON b.workerFk = vUserFk - AND NEW.created BETWEEN b.started AND IFNULL(b.ended, NEW.created)); + AND NEW.dated BETWEEN b.started AND IFNULL(b.ended, NEW.dated)); IF ISNULL(NEW.agencyModeFk) THEN SELECT r.agencyModeFk INTO vDefaultAgencyModeFk @@ -8400,7 +8313,7 @@ BEGIN JOIN vn.route r ON r.id = t.routeFk WHERE r.isOk = FALSE AND s.id = NEW.id - AND r.created >= util.VN_CURDATE() + AND r.dated >= util.VN_CURDATE() GROUP BY r.id; END IF; END */;; @@ -8508,7 +8421,7 @@ BEGIN JOIN vn.route r ON r.id = t.routeFk WHERE r.isOk = FALSE AND s.id = NEW.id - AND r.created >= util.VN_CURDATE() + AND r.dated >= util.VN_CURDATE() GROUP BY r.id; END IF; @@ -8550,7 +8463,7 @@ BEGIN JOIN vn.route r ON r.id = t.routeFk WHERE r.isOk = FALSE AND s.id = OLD.id - AND r.created >= util.VN_CURDATE() + AND r.dated >= util.VN_CURDATE() GROUP BY r.id; END IF; END */;; @@ -9657,7 +9570,7 @@ BEGIN FROM `route` WHERE NOT isOk AND id IN (OLD.routeFk, NEW.routeFk) - AND created >= util.VN_CURDATE() + AND dated >= util.VN_CURDATE() GROUP BY id; END IF; @@ -9680,7 +9593,7 @@ BEGIN JOIN vn.route r ON r.id = t.routeFk WHERE r.isOk = FALSE AND t.id = NEW.id - AND r.created >= util.VN_CURDATE() + AND r.dated >= util.VN_CURDATE() GROUP BY r.id; SET NEW.shipped = DATE_FORMAT(NEW.shipped, '2000-%m-%d %T'); SET NEW.landed = DATE_FORMAT(NEW.landed, '2000-%m-%d %T'); @@ -9759,7 +9672,7 @@ BEGIN FROM vn.route r WHERE r.isOk = FALSE AND r.id = OLD.routeFk - AND r.created >= util.VN_CURDATE() + AND r.dated >= util.VN_CURDATE() GROUP BY r.id; DELETE FROM sale WHERE ticketFk = OLD.id; @@ -10669,10 +10582,6 @@ BEGIN CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk); END IF; - IF NOT (NEW.isRaid <=> OLD.isRaid) OR NOT (NEW.daysInForward <=> OLD.daysInForward) THEN - CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward); - END IF; - IF NOT (NEW.awbFk <=> OLD.awbFk)THEN SELECT COUNT(*) INTO vHasAnyInvoiceBooked FROM travel t @@ -11579,4 +11488,4 @@ USE `vn2008`; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-11-26 12:09:13 +-- Dump completed on 2024-12-10 8:18:11 diff --git a/myt.config.yml b/myt.config.yml index 209686fd4..a947405b3 100755 --- a/myt.config.yml +++ b/myt.config.yml @@ -71,6 +71,7 @@ fixtures: - ticketUpdateAction - ticketCanAdvanceConfig - volumeConfig + - workerActivityType - workCenter - workerTimeControlError cache: From b258de42522290ecee6bd39844e1be4524482fc1 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 10 Dec 2024 10:38:53 +0100 Subject: [PATCH 107/219] test: refs #8282 fix workerActivity add fixtures --- back/methods/workerActivity/specs/add.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/back/methods/workerActivity/specs/add.spec.js b/back/methods/workerActivity/specs/add.spec.js index 352d67723..751cce009 100644 --- a/back/methods/workerActivity/specs/add.spec.js +++ b/back/methods/workerActivity/specs/add.spec.js @@ -10,10 +10,10 @@ describe('workerActivity insert()', () => { try { await models.WorkerActivityType.create( - {'code': 'STOP', 'description': 'STOP'}, options + {'code': 'TEST', 'description': 'TEST'}, options ); - await models.WorkerActivity.add(ctx, 'STOP', 'APP', options); + await models.WorkerActivity.add(ctx, 'TEST', 'APP', options); count = await models.WorkerActivity.count( {'workerFK': 1106}, options From f6ac55d9d7c197b7325948392cf85b7bf301520a Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 10 Dec 2024 11:01:52 +0100 Subject: [PATCH 108/219] fix: fix back --- .../ticket/back/methods/ticket-request/filter.js | 14 +++++++++++++- modules/worker/back/models/worker-irpf.json | 10 ++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/modules/ticket/back/methods/ticket-request/filter.js b/modules/ticket/back/methods/ticket-request/filter.js index 53f90b98f..c2edcae81 100644 --- a/modules/ticket/back/methods/ticket-request/filter.js +++ b/modules/ticket/back/methods/ticket-request/filter.js @@ -64,6 +64,11 @@ module.exports = Self => { arg: 'myTeam', type: 'boolean', description: `Team partners` + }, + { + arg: 'daysOnward', + type: 'number', + description: 'The days onward' } ], returns: { @@ -104,6 +109,9 @@ module.exports = Self => { teamMembersId.push(userId); } + const today = Date.vnNew(); + const future = Date.vnNew(); + let where = buildFilter(ctx.args, (param, value) => { switch (param) { case 'search': @@ -140,9 +148,13 @@ module.exports = Self => { return {'tr.requesterFk': {inq: teamMembersId}}; else return {'tr.requesterFk': {nin: teamMembersId}}; + case 'daysOnward': + today.setHours(0, 0, 0, 0); + future.setDate(today.getDate() + value); + future.setHours(23, 59, 59, 999); + return {'t.shipped': {between: [today, future]}}; } }); - if (!where) where = {}; where['tw.ticketFk'] = null; diff --git a/modules/worker/back/models/worker-irpf.json b/modules/worker/back/models/worker-irpf.json index 65f72a1fd..eafda0596 100644 --- a/modules/worker/back/models/worker-irpf.json +++ b/modules/worker/back/models/worker-irpf.json @@ -23,7 +23,7 @@ "type" : "number" }, "isDependend": { - "type" : "number" + "type" : "boolean" }, "familySituation": { "type" : "number" @@ -35,15 +35,17 @@ "type" : "number" }, "hasHousingPaymentBefore": { - "type" : "number" + "type" : "boolean" }, "hasHousingPaymentAfter": { - "type" : "number" + "type" : "boolean" }, "updated": { "type" : "date" + }, + "hasExtendedWorking": { + "type" : "boolean" } - }, "relations": { "disabilityGrade": { From dfbe1ef5560b15ab297a390d2f6f855bb465e790 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 10 Dec 2024 11:05:57 +0100 Subject: [PATCH 109/219] fix: refs #8285 Fix pipeline version --- Jenkinsfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 055cf858f..322a715e7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -93,6 +93,20 @@ pipeline { } } } + stage('Version') { + when { + expression { RUN_BUILD } + } + steps { + script { + def packageJson = readJSON file: 'package.json' + def version = "${packageJson.version}-build${env.BUILD_ID}" + writeFile(file: 'VERSION.txt', text: version) + def readVersion = readFile(file: 'VERSION.txt').trim() + echo "VERSION: ${readVersion}" + } + } + } stage('Stack') { parallel { stage('Back') { From 15d3f7ee60d34d5273af57ec1045ea75b7adfe85 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 10 Dec 2024 11:13:38 +0100 Subject: [PATCH 110/219] fix: refs #8285 Fix pipeline version --- Jenkinsfile | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 322a715e7..5422173f1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -102,8 +102,6 @@ pipeline { def packageJson = readJSON file: 'package.json' def version = "${packageJson.version}-build${env.BUILD_ID}" writeFile(file: 'VERSION.txt', text: version) - def readVersion = readFile(file: 'VERSION.txt').trim() - echo "VERSION: ${readVersion}" } } } @@ -134,11 +132,10 @@ pipeline { when { expression { RUN_BUILD } } + environment { + VERSION = readFile 'VERSION.txt' + } steps { - script { - def packageJson = readJSON file: 'package.json' - env.VERSION = "${packageJson.version}-build${env.BUILD_ID}" - } sh 'docker-compose build back' } } @@ -172,11 +169,10 @@ pipeline { when { expression { RUN_BUILD } } + environment { + VERSION = readFile 'VERSION.txt' + } steps { - script { - def packageJson = readJSON file: 'package.json' - env.VERSION = "${packageJson.version}-build${env.BUILD_ID}" - } sh 'gulp build' sh 'docker-compose build front' } @@ -191,12 +187,9 @@ pipeline { } environment { CREDENTIALS = credentials('docker-registry') + VERSION = readFile 'VERSION.txt' } steps { - script { - def packageJson = readJSON file: 'package.json' - env.VERSION = "${packageJson.version}-build${env.BUILD_ID}" - } sh 'docker login --username $CREDENTIALS_USR --password $CREDENTIALS_PSW $REGISTRY' sh 'docker-compose push' } @@ -223,11 +216,10 @@ pipeline { when { expression { FROM_GIT } } + environment { + VERSION = readFile 'VERSION.txt' + } steps { - script { - def packageJson = readJSON file: 'package.json' - env.VERSION = "${packageJson.version}-build${env.BUILD_ID}" - } withKubeConfig([ serverUrl: "$KUBERNETES_API", credentialsId: 'kubernetes', From 9e01313facce715326ff90227f6845f5a6ac8432 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Tue, 10 Dec 2024 11:18:21 +0100 Subject: [PATCH 111/219] ci(Jenkinsfile): refs #8285 Move version step to begining --- Jenkinsfile | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5422173f1..06addc940 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -64,6 +64,18 @@ pipeline { PROJECT_NAME = 'salix' } stages { + stage('Version') { + when { + expression { RUN_BUILD } + } + steps { + script { + def packageJson = readJSON file: 'package.json' + def version = "${packageJson.version}-build${env.BUILD_ID}" + writeFile(file: 'VERSION.txt', text: version) + } + } + } stage('Install') { environment { NODE_ENV = '' @@ -93,18 +105,6 @@ pipeline { } } } - stage('Version') { - when { - expression { RUN_BUILD } - } - steps { - script { - def packageJson = readJSON file: 'package.json' - def version = "${packageJson.version}-build${env.BUILD_ID}" - writeFile(file: 'VERSION.txt', text: version) - } - } - } stage('Stack') { parallel { stage('Back') { From 391f1d8c975d8740563e6182f73c103f1fca9f14 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 10 Dec 2024 12:04:03 +0100 Subject: [PATCH 112/219] fix: refs #7028 fix confirm deny --- .../back/methods/ticket-request/confirm.js | 15 +++-- .../back/methods/ticket-request/deny.js | 56 ++++++++++++------- 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/modules/ticket/back/methods/ticket-request/confirm.js b/modules/ticket/back/methods/ticket-request/confirm.js index 7c17d0010..56ee14a73 100644 --- a/modules/ticket/back/methods/ticket-request/confirm.js +++ b/modules/ticket/back/methods/ticket-request/confirm.js @@ -54,9 +54,17 @@ module.exports = Self => { throw new UserError(`That item doesn't exists`); const request = await models.TicketRequest.findById(ctx.args.id, { - include: {relation: 'ticket'} + include: { + relation: 'ticket', + scope: { + include: { + relation: 'client', + scope: { + fields: ['id', 'name', 'salesPersonFk'] + } + } + }} }, myOptions); - const itemStock = await models.Item.getVisibleAvailable( ctx.args.itemFk, request.ticket().warehouseFk, @@ -90,8 +98,7 @@ module.exports = Self => { await Self.rawSql(query, [sale.id], myOptions); const url = await Self.app.models.Url.getUrl(); - const requesterId = request.requesterFk; - + const requesterId = request.ticket().client().salesPersonFk; const message = $t('Bought units from buy request', { quantity: sale.quantity, concept: sale.concept, diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index 44f1e48a1..cb13c2728 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -1,18 +1,21 @@ module.exports = Self => { Self.remoteMethodCtx('deny', { - description: 'sets a ticket request to denied and returns the changes', + description: 'Sets a ticket request to denied and returns the changes', accessType: 'WRITE', - accepts: [{ - arg: 'id', - type: 'number', - required: true, - description: 'The request ID', - }, { - arg: 'observation', - type: 'String', - required: true, - description: 'The request observation', - }], + accepts: [ + { + arg: 'id', + type: 'number', + required: true, + description: 'The request ID', + }, + { + arg: 'observation', + type: 'string', + required: true, + description: 'The request observation', + } + ], returns: { type: 'number', root: true @@ -29,7 +32,7 @@ module.exports = Self => { const myOptions = {}; let tx; - if (typeof options == 'object') + if (typeof options === 'object') Object.assign(myOptions, options); if (!myOptions.transaction) { @@ -39,7 +42,8 @@ module.exports = Self => { try { const userId = ctx.req.accessToken.userId; - const worker = await Self.app.models.Worker.findOne({where: {id: userId}}, myOptions); + const worker = await models.Worker.findOne({where: {id: userId}}, myOptions); + if (!worker) throw new Error('Worker not found'); const params = { isOk: false, @@ -47,19 +51,33 @@ module.exports = Self => { response: ctx.args.observation, }; - const request = await Self.app.models.TicketRequest.findById(ctx.args.id, null, myOptions); - await request.updateAttributes(params, myOptions); + const request = await models.TicketRequest.findById(ctx.args.id, { + include: { + relation: 'ticket', + scope: { + include: { + relation: 'client', + scope: { + fields: ['id', 'name', 'salesPersonFk'] + } + } + } + } + }, myOptions); - const url = await Self.app.models.Url.getUrl(); - const requesterId = request.requesterFk; + if (!request || !request.ticket() || !request.ticket().client()) + throw new Error('Invalid request or related ticket/client data'); + const url = await models.Url.getUrl(); + const requesterId = request.ticket().client().salesPersonFk; const message = $t('Deny buy request', { ticketId: request.ticketFk, url: `${url}ticket/${request.ticketFk}/request/index`, observation: params.response }); - await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); + await models.Chat.sendCheckingPresence(ctx, requesterId, message); + await request.updateAttributes(params, myOptions); if (tx) await tx.commit(); From 10558853a2b2304c8732cfe1854e2bcb7ccbd211 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Tue, 10 Dec 2024 13:41:45 +0100 Subject: [PATCH 113/219] feat: refs #8174 create table simsupplier --- .../11327-maroonOak/00-firstScript.sql | 159 ++++++++++++++++++ 1 file changed, 159 insertions(+) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index 973050fba..2ad44f700 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -17,3 +17,162 @@ MODIFY `simSerialNumber` VARCHAR(25); ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_simSupplier_FK FOREIGN KEY (simSerialNumber) REFERENCES vn.simSupplier(sim); +INSERT IGNORE INTO `vn`.`simSupplier` (`line`, `ext`, `pin`, `sim`, `puk`, `statusWeb`) +VALUES +(621188151, 2209, 1486, 3456985220092508,14213470, 'OK'), +(621188152, 2210, 8765, 3456985220092509,99473093, 'OK'), +(621188153, 2211, 3064, 3456985220092510,52967210, 'OK'), +(621188759, 2081, 3700, 3456985220123637,56600999, 'OK'), +(621188760, 2082, 3259, 345698522023638,87492404, 'OK'), +(621188761, 2083, 2790, 3456985220123639,94009456, 'OK'), +(621188762, 2084, 2480, 3456985220123644,1484999, 'OK'), +(621188763, 2085, 6876, 3456985220123641,36577064, 'OK'), +(621188766, 2086, 7775, 3456985220123642,80761698, 'OK'), +(621188769, 2088, 4027, 3456985220123643,37921712, 'OK'), +(621188771, 2089, 8797, 3456985220123640,63092540, 'OK'), +(621188772, 2090, 8404, 3456985220123645,21014997, 'OK'), +(621188773, 2091, 5481, 3456985220123646,16317277, 'OK'), +(621188774, 2092, 9632, 3456985220123647,22235994, 'OK'), +(621188775, 2093, 4654, 3456985220123648,28506486, 'OK'), +(621188838, 2094, 1392, 3456985220123649,29498627, 'OK'), +(621188839, 2095, 7774, 3456985220123650,46263490, 'OK'), +(621188840, 2096, 7304, 3456985220123658,8212044, 'OK'), +(621188841, 2097, 5569, 3456985220123652,81597658, 'OK'), +(621188842, 2098, 4944, 3456985220123653,24961501, 'OK'), +(621188843, 2099, 5142, 3456985220123654,17035634, 'OK'), +(621188844, 2111, 7245, 3456985220123655,90231951, 'OK'), +(621188846, 2110, 6590, 3456985220123656,72201537, 'OK'), +(667680207, 2564, 4042, 34569832200759166,48401979, 'OK'), +(667680315, 2565, 7143, 34569832200759372,32143252, 'OK'), +(667680318, 2566, 6342, 34569832200759364,39597112, 'OK'), +(667680413, 2567, 5580, 34569832200759356,32786992, 'OK'), +(667680463, 2568, 0171, 34569832200759349,34240853, 'OK'), +(667688217, 2569, 2500, 34569832200759331,5687589, 'OK'), +(633603945, 2212, 7129, 34569832200759323,51554019, 'OK'), +(622130186, 2213, 4826, 34569832200759307,19623551, 'OK'), +(633973424, 2214, 8535, 34569832200759299,94619307, 'OK'), +(633703828, 2215, 8628, 34569832200759281,22468012, 'OK'), +(622025110, 2216, 2399, 34569832200759273,34602918, 'OK'), +(622924867, 2217, 5665, 34569832200759265,26920216, 'OK'), +(722409630, 2218, 5211, 34569832200759240,93750137, 'OK'), +(623590529, 2219, 0493, 34569832200759208,47077088, 'OK'), +(633243462, 2220, 6902, 34569832200759174,6421962, 'OK'), +(633047286, 2221, 5592, 34569832200759182,32069439, 'OK'), +(744716801, 2112, 9184, 34569832200759190,57049814, 'OK'), +(655995021, 2131, 8896, 34569852202049093,19497356, 'OK'), +(685522718, 2132, 1955, 34569852202049101,28519879, 'OK'), +(674587213, 2994, 2006, 34569332200223743,62360135, 'OK'), +(674587227, 2993, 9271, 34569332200223750,81628192, 'OK'), +(674587229, 2993, 0900, 34569332200223768,91119071, 'OK'), +(674587231, 2992, 5007, 34569332200223776,45826232, 'OK'), +(674587234, 2991, 1378, 34569332200223784,91245744, 'OK'), +(674587240, 2990, 0905, 34569332200223792,13083224, 'OK'), +(674587245, 2989, 9059, 34569332200223800,15291807, 'OK'), +(674587250, 2988, 8188, 34569332200223818,83017918, 'OK'), +(674587254, 2987, 2962, 34569332200223826,92809271, 'OK'), +(674587256, 2986, 0358, 34569332200223834,81067040, 'OK'), +(674592713, 2570, 2537, 34569332200230672,82325850, 'OK'), +(697832478, 2579, 0936, 34568732200494825,49658372, 'OK'), +(697832176, 2571, 5944, 34568732200494742,19039461, 'OK'), +(697832477, 2572, 5138, 34568732200494759,25712504, 'OK'), +(697832178, 2573, 4597, 34568732200494767,66241760, 'OK'), +(697832182, 2574, 9241, 34568732200494775,07342562, 'OK'), +(697832196, 2575, 2995, 34568732200494783,53929026, 'OK'), +(697832214, 2576, 7434, 34568732200494791,49698432, 'OK'), +(697832230, 2577, 7004, 34568732200494809,21578612, 'OK'), +(697832235, 2578, 9674, 34568732200494817,93090700, 'OK'), +(673420375, 2599, 5430, 34562052300117259,35911412, 'OK'), +(673420367, 2598, 8402, 34562052300117242,924654, 'OK'), +(673420361, 2597, 5125, 34562052300117234,12027970, 'OK'), +(673420355, 2596, 5069, 34562052300117226,34978149, 'OK'), +(673420348, 2595, 8911, 34562052300117218,4228121, 'OK'), +(673420346, 2594, 2461, 34562052300117200,67670772, 'OK'), +(673420345, 2593, 2226, 34562052300117192,90586404, 'OK'), +(673420306, 2592, 3355, 34562052300117184,97850017, 'OK'), +(673420257, 2591, 9395, 34562052300117176,50713786, 'OK'), +(673420231, 2590, 1378, 34562052300117168,50151763, 'OK'), +(673420223, 2589, 9580, 34562052300117150,99534550, 'OK'), +(673420216, 2588, 4955, 34562052300117143,317554, 'OK'), +(673420203, 2587, 6742, 34562052300117135,69321531, 'OK'), +(673420201, 2586, 1659, 34562052300117127,54720480, 'OK'), +(673420199, 2585, 7823, 34562052300117119,22923796, 'OK'), +(673420198, 2584, 1787, 34562052300117101,54414630, 'OK'), +(673420168, 2583, 6334, 34562052300117093,50694894, 'OK'), +(673420147, 2582, 8951, 34562052300117085,1402535, 'OK'), +(673420125, 2581, 3068, 34562052300117077,86216200, 'OK'), +(673420124, 2580, 9517, 34562052300117069,42504099, 'OK'), +(600294609, 2715, 7474, 34569832304894588,55923317, 'OK'), +(600084713, 2703, 8342, 34569832304894570,8392636, 'OK'), +(600084732, 2704, 1625, 34569832304894513,75477452, 'OK'), +(600084850, 2705, 9896, 34569832304894653,28589813, 'OK'), +(600084951, 2706, 5520, 34569832304894661,75353012, 'OK'), +(600084978, 2707, 2698, 34569832304894679,9005523, 'OK'), +(600085403, 2708, 0837, 34569832304894646,77051152, 'OK'), +(600085513, 2709, 3106, 34569832304894687,41571002, 'OK'), +(600293916, 2712, 8990, 34569832304894620,95188676, 'OK'), +(600294160, 2714, 6376, 34569832304894703,79879896, 'OK'), +(671919529, 2975, 9184, 34569832304806236,7535392, 'OK'), +(671919942, 2981, 0328, 34569832304806269,31052894, 'OK'), +(671919530, 2976, 0344, 34569832304806251,89860304, 'OK'), +(671919533, 2977, 0668, 34569832304806244,42921771, 'OK'), +(671919535, 2978, 0105, 34569832304806277,31009417, 'OK'), +(671919537, 2979, 0881, 34569832304806285,33479769, 'OK'), +(671919540, 2980, 9874, 34569832304806293,14103929, 'OK'), +(671919525, 2972, 2089, 34569832304806301,45903729, 'OK'), +(671919527, 2973, 8206, 34569832304806368,1586035, 'OK'), +(671919528, 2974, 2532, 34569832304806327,62310124, 'OK'), +(673668717, 2836, 7973, 34562032301044223,15635496, 'OK'), +(673668734, 2837, 4457, 34562032301044231,18313118, 'OK'), +(673668738, 2824, 2911, 34562032301044249,30875583, 'OK'), +(673668745, 2838, 7253, 34562032301044256,62754222, 'OK'), +(673668796, 2839, 0068, 34562032301044264,15556829, 'OK'), +(673668803, 2840, 2386, 34562032301044272,17572287, 'OK'), +(673669591, 2850, 3833, 34562032301044280,34828896, 'OK'), +(673668808, 2841, 3584, 34562032301044298,16234497, 'OK'), +(673670102, 2851, 3554, 34562032301044306,23652625, 'OK'), +(673670131, 2852, 4412, 34562032301044314,88611709, 'OK'), +(673670135, 2827, 6058, 34562032301044322,53918579, 'OK'), +(673670201, 2828, 8066, 34562032301044330,92369343, 'OK'), +(673670225, 2829, 4592, 34562032301044348,24126635, 'OK'), +(673670236, 2830, 2974, 34562032301044355,88608465, 'OK'), +(673671485, 2849, 0349, 34562032301044363,44944874, 'OK'), +(673461977, 2871, 1728, 34562032400157090,46975780, 'OK'), +(673461975, 2870, 4734, 34562032400157082,69628432, 'OK'), +(673461972, 2867, 6276, 34562032400157058,53338365, 'OK'), +(673461979, 2872, 6043, 34562032400157108,36525197, 'OK'), +(673461958, 2859, 3164, 34562032400156977,58947831, 'OK'), +(673461957, 2857, 8685, 34562032400156969,15826386, 'OK'), +(673461944, 2853, 1073, 34562032400156910,20452195, 'OK'), +(673461974, 2869, 7121, 34562032400157074,32044645, 'OK'), +(673461973, 2868, 8022, 34562032400157066,29282044, 'OK'), +(673461971, 2866, 3089, 34562032400157041,66149978, 'OK'), +(673461969, 2865, 7555, 34562032400157033,78391293, 'OK'), +(673461960, 2860, 5203, 34562032400156985,37138232, 'OK'), +(673461952, 2855, 6915, 34562032400156936,62724661, 'OK'), +(673461949, 2854, 8706, 34562032400156928,5594345, 'OK'), +(673461966, 2863, 2496, 34562032400157017,93450666, 'OK'), +(673461968, 2864, 3703, 34562032400157025,23208841, 'OK'), +(673461963, 2862, 9364, 34562032400157009,29712130, 'OK'), +(673462719, 2873, 9387, 34562032400156951,50434348, 'OK'), +(673461962, 2861, 8441, 34562032400156993,39686909, 'OK'), +(673461956, 2826, 5392, 34562032400156944,5496107, 'OK'), +(673465284, 2694, 1523, 34562032400171349,14554994, 'OK'), +(673465282, 2692, 4645, 34562032400171323,24871187, 'OK'), +(673465283, 2693, 5253, 34562032400171331,28303238, 'OK'), +(673465841, 2696, 0849, 34562032400171257,21673222, 'OK'), +(673465258, 2679, 4140, 34562032400171174,39793881, 'OK'), +(673465263, 2680, 6922, 34562032400171182,12253261, 'OK'), +(673465265, 2681, 9112, 34562032400171190,93894366, 'OK'), +(673465267, 2682, 3259, 34562032400171208,2342189, 'OK'), +(673465268, 2683, 8540, 34562032400171216,63886925, 'OK'), +(673465285, 2695, 4167, 34562032400171356,79227618, 'OK'), +(673465270, 2684, 4292, 34562032400171224,19216349, 'OK'), +(673465272, 2685, 4007, 34562032400171232,14396903, 'OK'), +(673465273, 2686, 6894, 34562032400171240,13569394, 'OK'), +(673465274, 2687, 5268, 34562032400171265,59453667, 'OK'), +(673465275, 2688, 0232, 34562032400171273,62324713, 'OK'), +(673465276, 2689, 2720, 34562032400171281,65977200, 'OK'), +(673465843, 2698, 4773, 34562032400171364,78387158, 'OK'), +(673465842, 2697, 3729, 34562032400171315,94201789, 'OK'), +(673465280, 2691, 0503, 34562032400171307,12298533, 'OK'), +(673465279, 2690, 8239, 34562032400171299,76183877, 'OK'); \ No newline at end of file From 87976351012fa275b41a4c46e2a31299ebe77f9f Mon Sep 17 00:00:00 2001 From: Jbreso Date: Tue, 10 Dec 2024 13:46:03 +0100 Subject: [PATCH 114/219] feat: refs #8174 fix --- db/versions/11327-maroonOak/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index 2ad44f700..eda1f5e97 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -11,7 +11,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`simSupplier` ( ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -ALTER TABLE `deviceProductionUser` +ALTER TABLE `vn`.`deviceProductionUser` MODIFY `simSerialNumber` VARCHAR(25); ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_simSupplier_FK From 31692ddd3b86ec1613f46565b23e95f2c5898627 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 11 Dec 2024 07:15:40 +0100 Subject: [PATCH 115/219] fix: refs #8188 refs#8188 add IfNotExists --- db/versions/11377-pinkCarnation/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11377-pinkCarnation/00-firstScript.sql b/db/versions/11377-pinkCarnation/00-firstScript.sql index 4511c1b7e..fdbd7e836 100644 --- a/db/versions/11377-pinkCarnation/00-firstScript.sql +++ b/db/versions/11377-pinkCarnation/00-firstScript.sql @@ -1,5 +1,5 @@ -- Place your SQL code here -ALTER TABLE vn.productionConfig ADD itemOrderReviewHours int(11) DEFAULT 24 NULL +ALTER TABLE vn.productionConfig ADD IF NOT EXISTS itemOrderReviewHours int(11) DEFAULT 24 NULL COMMENT 'Horas que no se tienen en cuenta para comprobar orden en el almacén, null para desactivar revisión'; From c8ec94bed9116fa3242c566e36eb1335b51834d0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 11 Dec 2024 09:03:14 +0100 Subject: [PATCH 116/219] feat: refs #7882 Osrm service --- back/methods/osrm-config/optimize.js | 28 +++-- .../11379-yellowCordyline/00-firstScript.sql | 25 +++- loopback/locale/es.json | 3 +- .../back/methods/route/optimizePriority.js | 119 ++++++++++++++++++ .../route/back/methods/route/optimizeStops.js | 25 ---- modules/route/back/models/route.js | 2 +- modules/zone/back/model-config.json | 3 + modules/zone/back/models/zone-config.json | 28 +++++ modules/zone/back/models/zone.json | 37 +++--- 9 files changed, 211 insertions(+), 59 deletions(-) create mode 100644 modules/route/back/methods/route/optimizePriority.js delete mode 100644 modules/route/back/methods/route/optimizeStops.js create mode 100644 modules/zone/back/models/zone-config.json diff --git a/back/methods/osrm-config/optimize.js b/back/methods/osrm-config/optimize.js index 0c570b95a..c03b70315 100644 --- a/back/methods/osrm-config/optimize.js +++ b/back/methods/osrm-config/optimize.js @@ -9,9 +9,13 @@ module.exports = Self => { arg: 'addressIds', type: 'array', required: true + }, { + arg: 'firstAddressId', + type: 'number', + required: false }], returns: { - type: 'string', + type: 'object', root: true }, http: { @@ -20,21 +24,22 @@ module.exports = Self => { } }); - Self.optimize = async addressIds => { + Self.optimize = async(addressIds, firstAddressId) => { const models = Self.app.models; try { const osrmConfig = await models.OsrmConfig.findOne(); if (!osrmConfig) throw new UserError(`OSRM service is not configured`); let coords = []; - - const address = await models.Address.findById(32308); // Aquí irá el address asociada a la zona - if (address.latitude && address.longitude) { - coords.push({ - addressId: address.id, - latitude: address.latitude.toFixed(6), - longitude: address.longitude.toFixed(6) - }); + if (firstAddressId) { + const firstAddress = await models.Address.findById(firstAddressId); + if (firstAddress.latitude && firstAddress.longitude) { + coords.push({ + addressId: firstAddress.id, + latitude: firstAddress.latitude.toFixed(6), + longitude: firstAddress.longitude.toFixed(6) + }); + } } for (const addressId of addressIds) { @@ -47,6 +52,9 @@ module.exports = Self => { }); } } + + if (!coords.length) throw new UserError('No address has coordinates'); + const concatCoords = coords .map(coord => `${coord.longitude},${coord.latitude}`) .join(';'); diff --git a/db/versions/11379-yellowCordyline/00-firstScript.sql b/db/versions/11379-yellowCordyline/00-firstScript.sql index 6c0263f7f..8d90ee90c 100644 --- a/db/versions/11379-yellowCordyline/00-firstScript.sql +++ b/db/versions/11379-yellowCordyline/00-firstScript.sql @@ -1,7 +1,20 @@ CREATE TABLE `vn`.`osrmConfig` ( - `id` int(10) unsigned NOT NULL, - `url` varchar(100) NOT NULL COMMENT 'Dirección base de la API', - `tolerance` decimal(6,6) NOT NULL DEFAULT 0 COMMENT 'Tolerancia entre las coordenadas enviadas y las retornadas', - PRIMARY KEY (`id`), - CONSTRAINT `osrmConfig_check` CHECK (`id` = 1) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; \ No newline at end of file + `id` int(10) unsigned NOT NULL, + `url` varchar(100) NOT NULL COMMENT 'Dirección base de la API', + `tolerance` decimal(6,6) NOT NULL DEFAULT 0 COMMENT 'Tolerancia entre las coordenadas enviadas y las retornadas', + PRIMARY KEY (`id`), + CONSTRAINT `osrmConfig_check` CHECK (`id` = 1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +-- Para que no de error al añadir la FK de zone +UPDATE vn.zone + SET price = 0.1 + WHERE price = 0; + +ALTER TABLE vn.`zone` + ADD addressFk int(11) DEFAULT NULL COMMENT 'Punto de distribución de donde salen para repartir', + ADD CONSTRAINT zone_address_FK FOREIGN KEY (addressFk) REFERENCES vn.address(id) ON DELETE RESTRICT ON UPDATE CASCADE; + +ALTER TABLE vn.zoneConfig + ADD defaultAddressFk int(11) DEFAULT NULL NULL COMMENT 'Punto de distribución por defecto', + ADD CONSTRAINT zoneConfig_address_FK FOREIGN KEY (defaultAddressFk) REFERENCES vn.address(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 8013a7fe6..03cccbe1a 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -393,5 +393,6 @@ "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", "No trips found because input coordinates are not connected": "No se encontraron rutas porque las coordenadas de entrada no están conectadas", "This request is not supported": "Esta solicitud no es compatible", - "Invalid options or too many coordinates": "Opciones invalidas o demasiadas coordenadas" + "Invalid options or too many coordinates": "Opciones invalidas o demasiadas coordenadas", + "No address has coordinates": "Ninguna dirección tiene coordenadas" } \ No newline at end of file diff --git a/modules/route/back/methods/route/optimizePriority.js b/modules/route/back/methods/route/optimizePriority.js new file mode 100644 index 000000000..f84af50f8 --- /dev/null +++ b/modules/route/back/methods/route/optimizePriority.js @@ -0,0 +1,119 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.remoteMethod('optimizePriority', { + description: 'Updates the ticket priority of tickets without priority', + accepts: { + arg: 'id', + type: 'number', + required: true, + description: 'Route id', + http: {source: 'path'} + }, + returns: { + type: 'object', + root: true + }, + http: { + path: '/:id/optimizePriority', + verb: 'POST' + } + }); + + Self.optimizePriority = async(id, options) => { + const models = Self.app.models; + const myOptions = {}; + let tx; + + if (typeof options == 'object') + Object.assign(myOptions, options); + + const ticketsIds = await models.Ticket.find({ + where: {routeFk: id} + }, myOptions); + + let ticketAddress = []; + for (const ticketId of ticketsIds) { + ticketAddress.push({ + ticketId: ticketId.id, + addressId: ticketId.addressFk, + zoneId: ticketId.zoneFk, + priority: ticketId.priority + }); + } + + // Igualamos los priority del mismo addressId + const addressPriorityMap = ticketAddress.reduce((acc, {addressId, priority}) => { + if (priority !== null) { + acc[addressId] = acc[addressId] === undefined + ? priority + : Math.max(acc[addressId], priority); + } + return acc; + }); + ticketAddress.forEach(item => { + const maxPriority = addressPriorityMap[item.addressId]; + if (maxPriority) item.priority = maxPriority; + }); + + // Añadimos las direcciones a optimizar + let addressIds = []; + ticketAddress.forEach(h => { + if (!addressIds.includes(h.addressId) && !h.priority) + addressIds.push(h.addressId); + }); + if (!addressIds.length) throw new UserError('All tickets have a route order'); + + // Obtenemos el zoneId más frecuente + const zoneFrequency = ticketAddress.reduce((acc, {zoneId}) => { + if (zoneId != null) acc[zoneId] = (acc[zoneId] || 0) + 1; + return acc; + }, {}); + const [mostFrequentZoneId] = Object.entries(zoneFrequency) + .reduce((maxEntry, entry) => entry[1] > maxEntry[1] ? entry : maxEntry, [null, 0]); + const zone = await models.Zone.findById(mostFrequentZoneId, myOptions); + let firstAddress = zone.addressFk; + if (!firstAddress) firstAddress = (await models.ZoneConfig.findOne()).defaultAddressFk; + + // Revisamos las coincidencias y actualizamos la prioridad en el array + const addressPositions = await models.OsrmConfig.optimize(addressIds, firstAddress, myOptions); + const maxPosition = Math.max(...ticketAddress.map(g => g.priority)); + await Promise.all(ticketAddress.map(async i => { + const foundPosition = addressPositions.coords.find(item => item.addressId === i.addressId); + if (foundPosition) i.priority = foundPosition.position + (maxPosition + 1); + })); + + // Suavizado de prioridad para que no hayan escalones + const allPriorities = ticketAddress + .map(item => item.priority) + .filter(p => p !== null); + const uniquePriorities = [...new Set(allPriorities)].sort((a, b) => a - b); + const priorityMap = {}; + uniquePriorities.forEach((p, index) => { + priorityMap[p] = index + 1; + }); + ticketAddress.forEach(item => { + if (item.priority !== null) item.priority = priorityMap[item.priority]; + }); + + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } + + // Realizamos el update en la base de datos + try { + await Promise.all(ticketAddress.map(async y => { + if (y.priority) { + const ticket = await models.Ticket.findById(y.ticketId); + await ticket.updateAttribute('priority', y.priority, myOptions); + } + })); + if (tx) await tx.commit(); + return; + } catch (err) { + if (tx) await tx.rollback(); + throw err; + } + }; +}; diff --git a/modules/route/back/methods/route/optimizeStops.js b/modules/route/back/methods/route/optimizeStops.js deleted file mode 100644 index 9666f201e..000000000 --- a/modules/route/back/methods/route/optimizeStops.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('optimizeStops', { - description: 'Updates the ticket priority of tickets without priority', - accepts: [ - { - arg: 'routeFk', - type: 'number', - required: true - } - ], - returns: { - type: 'object', - root: true - }, - http: { - path: '/optimizeStops', - verb: 'post' - } - }); - - Self.optimizeStops = async(routeFk, options) => { - return; - }; -}; - diff --git a/modules/route/back/models/route.js b/modules/route/back/models/route.js index e28b19a61..f73ff3e51 100644 --- a/modules/route/back/models/route.js +++ b/modules/route/back/models/route.js @@ -16,5 +16,5 @@ module.exports = Self => { require('../methods/route/downloadZip')(Self); require('../methods/route/getExpeditionSummary')(Self); require('../methods/route/getByWorker')(Self); - require('../methods/route/optimizeStops')(Self); + require('../methods/route/optimizePriority')(Self); }; diff --git a/modules/zone/back/model-config.json b/modules/zone/back/model-config.json index 3bbbe0d1b..2cd3f9d01 100644 --- a/modules/zone/back/model-config.json +++ b/modules/zone/back/model-config.json @@ -17,6 +17,9 @@ "ZoneClosure": { "dataSource": "vn" }, + "ZoneConfig": { + "dataSource": "vn" + }, "ZoneEvent": { "dataSource": "vn" }, diff --git a/modules/zone/back/models/zone-config.json b/modules/zone/back/models/zone-config.json new file mode 100644 index 000000000..a5da7fe55 --- /dev/null +++ b/modules/zone/back/models/zone-config.json @@ -0,0 +1,28 @@ +{ + "name": "ZoneConfig", + "options": { + "mysql": { + "table": "zoneConfig" + } + }, + "properties": { + "id": { + "type": "number", + "id": true, + "description": "Identifier" + }, + "scope": { + "type": "number" + }, + "forwardDays": { + "type": "number" + } + }, + "relations": { + "address": { + "type": "belongsTo", + "model": "Address", + "foreignKey": "defaultAddressFk" + } + } +} diff --git a/modules/zone/back/models/zone.json b/modules/zone/back/models/zone.json index 5b25e40d1..141b28750 100644 --- a/modules/zone/back/models/zone.json +++ b/modules/zone/back/models/zone.json @@ -1,9 +1,9 @@ { "name": "Zone", "base": "VnModel", - "mixins": { - "Loggable": true - }, + "mixins": { + "Loggable": true + }, "options": { "mysql": { "table": "zone" @@ -48,30 +48,35 @@ } }, "relations": { - "agencyMode": { - "type": "belongsTo", - "model": "AgencyMode", - "foreignKey": "agencyModeFk" + "agencyMode": { + "type": "belongsTo", + "model": "AgencyMode", + "foreignKey": "agencyModeFk" }, "events": { - "type": "hasMany", - "model": "ZoneEvent", - "foreignKey": "zoneFk" - }, + "type": "hasMany", + "model": "ZoneEvent", + "foreignKey": "zoneFk" + }, "exclusions": { - "type": "hasMany", - "model": "ZoneExclusion", + "type": "hasMany", + "model": "ZoneExclusion", "foreignKey": "zoneFk" }, "warehouses": { "type": "hasMany", "model": "ZoneWarehouse", "foreignKey": "zoneFk" - }, + }, "closures": { "type": "hasMany", "model": "ZoneClosure", "foreignKey": "zoneFk" - } - } + }, + "address": { + "type": "belongsTo", + "model": "Address", + "foreignKey": "addressFk" + } + } } From 34da78e1ba11e89dc613952519b55b10f4d7cd7f Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 11 Dec 2024 09:58:51 +0100 Subject: [PATCH 117/219] fix: refs #6389 back --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 44eafc8c8..6c98f6cd7 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -166,7 +166,7 @@ module.exports = Self => { param = `t.${param}`; return {[param]: value}; case 'packing': - return {'packing': value}; + return {'i.itemPackingTypeFk': value}; } }); From 28ab6b2266620feace9b03ffb66c83f7a5cd167e Mon Sep 17 00:00:00 2001 From: Jbreso Date: Wed, 11 Dec 2024 11:20:15 +0100 Subject: [PATCH 118/219] feat: refs #8174 fix --- .../11327-maroonOak/00-firstScript.sql | 327 +++++++++--------- 1 file changed, 163 insertions(+), 164 deletions(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index eda1f5e97..250a2fc8b 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -1,11 +1,10 @@ CREATE TABLE IF NOT EXISTS `vn`.`simSupplier` ( - `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `line` int(9) unsigned DEFAULT NULL, - `ext` int(10) unsigned DEFAULT NULL, - `pin` int(4) unsigned DEFAULT NULL, + `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `line` INT(9) unsigned NOT NULL, + `ext` CHAR(4) NOT NULL CHECK (ext REGEXP '^[0-9]{4}$'), + `pin` CHAR(4) NOT NULL CHECK (pin REGEXP '^[0-9]{4}$'), `sim` VARCHAR(25), - `puk` int(10) unsigned DEFAULT NULL, - `statusWeb` varchar(50) DEFAULT NULL, + `puk` INT(10) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `sim_UNIQUE` (`sim`) ) ENGINE=InnoDB AUTO_INCREMENT=1 @@ -17,162 +16,162 @@ MODIFY `simSerialNumber` VARCHAR(25); ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_simSupplier_FK FOREIGN KEY (simSerialNumber) REFERENCES vn.simSupplier(sim); -INSERT IGNORE INTO `vn`.`simSupplier` (`line`, `ext`, `pin`, `sim`, `puk`, `statusWeb`) +INSERT IGNORE INTO `vn`.`simSupplier` (`line`, `ext`, `pin`, `sim`, `puk`) VALUES -(621188151, 2209, 1486, 3456985220092508,14213470, 'OK'), -(621188152, 2210, 8765, 3456985220092509,99473093, 'OK'), -(621188153, 2211, 3064, 3456985220092510,52967210, 'OK'), -(621188759, 2081, 3700, 3456985220123637,56600999, 'OK'), -(621188760, 2082, 3259, 345698522023638,87492404, 'OK'), -(621188761, 2083, 2790, 3456985220123639,94009456, 'OK'), -(621188762, 2084, 2480, 3456985220123644,1484999, 'OK'), -(621188763, 2085, 6876, 3456985220123641,36577064, 'OK'), -(621188766, 2086, 7775, 3456985220123642,80761698, 'OK'), -(621188769, 2088, 4027, 3456985220123643,37921712, 'OK'), -(621188771, 2089, 8797, 3456985220123640,63092540, 'OK'), -(621188772, 2090, 8404, 3456985220123645,21014997, 'OK'), -(621188773, 2091, 5481, 3456985220123646,16317277, 'OK'), -(621188774, 2092, 9632, 3456985220123647,22235994, 'OK'), -(621188775, 2093, 4654, 3456985220123648,28506486, 'OK'), -(621188838, 2094, 1392, 3456985220123649,29498627, 'OK'), -(621188839, 2095, 7774, 3456985220123650,46263490, 'OK'), -(621188840, 2096, 7304, 3456985220123658,8212044, 'OK'), -(621188841, 2097, 5569, 3456985220123652,81597658, 'OK'), -(621188842, 2098, 4944, 3456985220123653,24961501, 'OK'), -(621188843, 2099, 5142, 3456985220123654,17035634, 'OK'), -(621188844, 2111, 7245, 3456985220123655,90231951, 'OK'), -(621188846, 2110, 6590, 3456985220123656,72201537, 'OK'), -(667680207, 2564, 4042, 34569832200759166,48401979, 'OK'), -(667680315, 2565, 7143, 34569832200759372,32143252, 'OK'), -(667680318, 2566, 6342, 34569832200759364,39597112, 'OK'), -(667680413, 2567, 5580, 34569832200759356,32786992, 'OK'), -(667680463, 2568, 0171, 34569832200759349,34240853, 'OK'), -(667688217, 2569, 2500, 34569832200759331,5687589, 'OK'), -(633603945, 2212, 7129, 34569832200759323,51554019, 'OK'), -(622130186, 2213, 4826, 34569832200759307,19623551, 'OK'), -(633973424, 2214, 8535, 34569832200759299,94619307, 'OK'), -(633703828, 2215, 8628, 34569832200759281,22468012, 'OK'), -(622025110, 2216, 2399, 34569832200759273,34602918, 'OK'), -(622924867, 2217, 5665, 34569832200759265,26920216, 'OK'), -(722409630, 2218, 5211, 34569832200759240,93750137, 'OK'), -(623590529, 2219, 0493, 34569832200759208,47077088, 'OK'), -(633243462, 2220, 6902, 34569832200759174,6421962, 'OK'), -(633047286, 2221, 5592, 34569832200759182,32069439, 'OK'), -(744716801, 2112, 9184, 34569832200759190,57049814, 'OK'), -(655995021, 2131, 8896, 34569852202049093,19497356, 'OK'), -(685522718, 2132, 1955, 34569852202049101,28519879, 'OK'), -(674587213, 2994, 2006, 34569332200223743,62360135, 'OK'), -(674587227, 2993, 9271, 34569332200223750,81628192, 'OK'), -(674587229, 2993, 0900, 34569332200223768,91119071, 'OK'), -(674587231, 2992, 5007, 34569332200223776,45826232, 'OK'), -(674587234, 2991, 1378, 34569332200223784,91245744, 'OK'), -(674587240, 2990, 0905, 34569332200223792,13083224, 'OK'), -(674587245, 2989, 9059, 34569332200223800,15291807, 'OK'), -(674587250, 2988, 8188, 34569332200223818,83017918, 'OK'), -(674587254, 2987, 2962, 34569332200223826,92809271, 'OK'), -(674587256, 2986, 0358, 34569332200223834,81067040, 'OK'), -(674592713, 2570, 2537, 34569332200230672,82325850, 'OK'), -(697832478, 2579, 0936, 34568732200494825,49658372, 'OK'), -(697832176, 2571, 5944, 34568732200494742,19039461, 'OK'), -(697832477, 2572, 5138, 34568732200494759,25712504, 'OK'), -(697832178, 2573, 4597, 34568732200494767,66241760, 'OK'), -(697832182, 2574, 9241, 34568732200494775,07342562, 'OK'), -(697832196, 2575, 2995, 34568732200494783,53929026, 'OK'), -(697832214, 2576, 7434, 34568732200494791,49698432, 'OK'), -(697832230, 2577, 7004, 34568732200494809,21578612, 'OK'), -(697832235, 2578, 9674, 34568732200494817,93090700, 'OK'), -(673420375, 2599, 5430, 34562052300117259,35911412, 'OK'), -(673420367, 2598, 8402, 34562052300117242,924654, 'OK'), -(673420361, 2597, 5125, 34562052300117234,12027970, 'OK'), -(673420355, 2596, 5069, 34562052300117226,34978149, 'OK'), -(673420348, 2595, 8911, 34562052300117218,4228121, 'OK'), -(673420346, 2594, 2461, 34562052300117200,67670772, 'OK'), -(673420345, 2593, 2226, 34562052300117192,90586404, 'OK'), -(673420306, 2592, 3355, 34562052300117184,97850017, 'OK'), -(673420257, 2591, 9395, 34562052300117176,50713786, 'OK'), -(673420231, 2590, 1378, 34562052300117168,50151763, 'OK'), -(673420223, 2589, 9580, 34562052300117150,99534550, 'OK'), -(673420216, 2588, 4955, 34562052300117143,317554, 'OK'), -(673420203, 2587, 6742, 34562052300117135,69321531, 'OK'), -(673420201, 2586, 1659, 34562052300117127,54720480, 'OK'), -(673420199, 2585, 7823, 34562052300117119,22923796, 'OK'), -(673420198, 2584, 1787, 34562052300117101,54414630, 'OK'), -(673420168, 2583, 6334, 34562052300117093,50694894, 'OK'), -(673420147, 2582, 8951, 34562052300117085,1402535, 'OK'), -(673420125, 2581, 3068, 34562052300117077,86216200, 'OK'), -(673420124, 2580, 9517, 34562052300117069,42504099, 'OK'), -(600294609, 2715, 7474, 34569832304894588,55923317, 'OK'), -(600084713, 2703, 8342, 34569832304894570,8392636, 'OK'), -(600084732, 2704, 1625, 34569832304894513,75477452, 'OK'), -(600084850, 2705, 9896, 34569832304894653,28589813, 'OK'), -(600084951, 2706, 5520, 34569832304894661,75353012, 'OK'), -(600084978, 2707, 2698, 34569832304894679,9005523, 'OK'), -(600085403, 2708, 0837, 34569832304894646,77051152, 'OK'), -(600085513, 2709, 3106, 34569832304894687,41571002, 'OK'), -(600293916, 2712, 8990, 34569832304894620,95188676, 'OK'), -(600294160, 2714, 6376, 34569832304894703,79879896, 'OK'), -(671919529, 2975, 9184, 34569832304806236,7535392, 'OK'), -(671919942, 2981, 0328, 34569832304806269,31052894, 'OK'), -(671919530, 2976, 0344, 34569832304806251,89860304, 'OK'), -(671919533, 2977, 0668, 34569832304806244,42921771, 'OK'), -(671919535, 2978, 0105, 34569832304806277,31009417, 'OK'), -(671919537, 2979, 0881, 34569832304806285,33479769, 'OK'), -(671919540, 2980, 9874, 34569832304806293,14103929, 'OK'), -(671919525, 2972, 2089, 34569832304806301,45903729, 'OK'), -(671919527, 2973, 8206, 34569832304806368,1586035, 'OK'), -(671919528, 2974, 2532, 34569832304806327,62310124, 'OK'), -(673668717, 2836, 7973, 34562032301044223,15635496, 'OK'), -(673668734, 2837, 4457, 34562032301044231,18313118, 'OK'), -(673668738, 2824, 2911, 34562032301044249,30875583, 'OK'), -(673668745, 2838, 7253, 34562032301044256,62754222, 'OK'), -(673668796, 2839, 0068, 34562032301044264,15556829, 'OK'), -(673668803, 2840, 2386, 34562032301044272,17572287, 'OK'), -(673669591, 2850, 3833, 34562032301044280,34828896, 'OK'), -(673668808, 2841, 3584, 34562032301044298,16234497, 'OK'), -(673670102, 2851, 3554, 34562032301044306,23652625, 'OK'), -(673670131, 2852, 4412, 34562032301044314,88611709, 'OK'), -(673670135, 2827, 6058, 34562032301044322,53918579, 'OK'), -(673670201, 2828, 8066, 34562032301044330,92369343, 'OK'), -(673670225, 2829, 4592, 34562032301044348,24126635, 'OK'), -(673670236, 2830, 2974, 34562032301044355,88608465, 'OK'), -(673671485, 2849, 0349, 34562032301044363,44944874, 'OK'), -(673461977, 2871, 1728, 34562032400157090,46975780, 'OK'), -(673461975, 2870, 4734, 34562032400157082,69628432, 'OK'), -(673461972, 2867, 6276, 34562032400157058,53338365, 'OK'), -(673461979, 2872, 6043, 34562032400157108,36525197, 'OK'), -(673461958, 2859, 3164, 34562032400156977,58947831, 'OK'), -(673461957, 2857, 8685, 34562032400156969,15826386, 'OK'), -(673461944, 2853, 1073, 34562032400156910,20452195, 'OK'), -(673461974, 2869, 7121, 34562032400157074,32044645, 'OK'), -(673461973, 2868, 8022, 34562032400157066,29282044, 'OK'), -(673461971, 2866, 3089, 34562032400157041,66149978, 'OK'), -(673461969, 2865, 7555, 34562032400157033,78391293, 'OK'), -(673461960, 2860, 5203, 34562032400156985,37138232, 'OK'), -(673461952, 2855, 6915, 34562032400156936,62724661, 'OK'), -(673461949, 2854, 8706, 34562032400156928,5594345, 'OK'), -(673461966, 2863, 2496, 34562032400157017,93450666, 'OK'), -(673461968, 2864, 3703, 34562032400157025,23208841, 'OK'), -(673461963, 2862, 9364, 34562032400157009,29712130, 'OK'), -(673462719, 2873, 9387, 34562032400156951,50434348, 'OK'), -(673461962, 2861, 8441, 34562032400156993,39686909, 'OK'), -(673461956, 2826, 5392, 34562032400156944,5496107, 'OK'), -(673465284, 2694, 1523, 34562032400171349,14554994, 'OK'), -(673465282, 2692, 4645, 34562032400171323,24871187, 'OK'), -(673465283, 2693, 5253, 34562032400171331,28303238, 'OK'), -(673465841, 2696, 0849, 34562032400171257,21673222, 'OK'), -(673465258, 2679, 4140, 34562032400171174,39793881, 'OK'), -(673465263, 2680, 6922, 34562032400171182,12253261, 'OK'), -(673465265, 2681, 9112, 34562032400171190,93894366, 'OK'), -(673465267, 2682, 3259, 34562032400171208,2342189, 'OK'), -(673465268, 2683, 8540, 34562032400171216,63886925, 'OK'), -(673465285, 2695, 4167, 34562032400171356,79227618, 'OK'), -(673465270, 2684, 4292, 34562032400171224,19216349, 'OK'), -(673465272, 2685, 4007, 34562032400171232,14396903, 'OK'), -(673465273, 2686, 6894, 34562032400171240,13569394, 'OK'), -(673465274, 2687, 5268, 34562032400171265,59453667, 'OK'), -(673465275, 2688, 0232, 34562032400171273,62324713, 'OK'), -(673465276, 2689, 2720, 34562032400171281,65977200, 'OK'), -(673465843, 2698, 4773, 34562032400171364,78387158, 'OK'), -(673465842, 2697, 3729, 34562032400171315,94201789, 'OK'), -(673465280, 2691, 0503, 34562032400171307,12298533, 'OK'), -(673465279, 2690, 8239, 34562032400171299,76183877, 'OK'); \ No newline at end of file +(621188151, '2209', '1486', 3456985220092508,14213470), +(621188152, '2210', '8765', 3456985220092509,99473093), +(621188153, '2211', '3064', 3456985220092510,52967210), +(621188759, '2081', '3700', 3456985220123637,56600999), +(621188760, '2082', '3259', 345698522023638,87492404), +(621188761, '2083', '2790', 3456985220123639,94009456), +(621188762, '2084', '2480', 3456985220123644,1484999), +(621188763, '2085', '6876', 3456985220123641,36577064), +(621188766, '2086', '7775', 3456985220123642,80761698), +(621188769, '2088', '4027', 3456985220123643,37921712), +(621188771, '2089', '8797', 3456985220123640,63092540), +(621188772, '2090', '8404', 3456985220123645,21014997), +(621188773, '2091', '5481', 3456985220123646,16317277), +(621188774, '2092', '9632', 3456985220123647,22235994), +(621188775, '2093', '4654', 3456985220123648,28506486), +(621188838, '2094', '1392', 3456985220123649,29498627), +(621188839, '2095', '7774', 3456985220123650,46263490), +(621188840, '2096', '7304', 3456985220123658,8212044), +(621188841, '2097', '5569', 3456985220123652,81597658), +(621188842, '2098', '4944', 3456985220123653,24961501), +(621188843, '2099', '5142', 3456985220123654,17035634), +(621188844, '2111', '7245', 3456985220123655,90231951), +(621188846, '2110', '6590', 3456985220123656,72201537), +(667680207, '2564', '4042', 34569832200759166,48401979), +(667680315, '2565', '7143', 34569832200759372,32143252), +(667680318, '2566', '6342', 34569832200759364,39597112), +(667680413, '2567', '5580', 34569832200759356,32786992), +(667680463, '2568', '0171', 34569832200759349,34240853), +(667688217, '2569', '2500', 34569832200759331,5687589), +(633603945, '2212', '7129', 34569832200759323,51554019), +(622130186, '2213', '4826', 34569832200759307,19623551), +(633973424, '2214', '8535', 34569832200759299,94619307), +(633703828, '2215', '8628', 34569832200759281,22468012), +(622025110, '2216', '2399', 34569832200759273,34602918), +(622924867, '2217', '5665', 34569832200759265,26920216), +(722409630, '2218', '5211', 34569832200759240,93750137), +(623590529, '2219', '0493', 34569832200759208,47077088), +(633243462, '2220', '6902', 34569832200759174,6421962), +(633047286, '2221', '5592', 34569832200759182,32069439), +(744716801, '2112', '9184', 34569832200759190,57049814), +(655995021, '2131', '8896', 34569852202049093,19497356), +(685522718, '2132', '1955', 34569852202049101,28519879), +(674587213, '2994', '2006', 34569332200223743,62360135), +(674587227, '2993', '9271', 34569332200223750,81628192), +(674587229, '2993', '0900', 34569332200223768,91119071), +(674587231, '2992', '5007', 34569332200223776,45826232), +(674587234, '2991', '1378', 34569332200223784,91245744), +(674587240, '2990', '0905', 34569332200223792,13083224), +(674587245, '2989', '9059', 34569332200223800,15291807), +(674587250, '2988', '8188', 34569332200223818,83017918), +(674587254, '2987', '2962', 34569332200223826,92809271), +(674587256, '2986', '0358', 34569332200223834,81067040), +(674592713, '2570', '2537', 34569332200230672,82325850), +(697832478, '2579', '0936', 34568732200494825,49658372), +(697832176, '2571', '5944', 34568732200494742,19039461), +(697832477, '2572', '5138', 34568732200494759,25712504), +(697832178, '2573', '4597', 34568732200494767,66241760), +(697832182, '2574', '9241', 34568732200494775,07342562), +(697832196, '2575', '2995', 34568732200494783,53929026), +(697832214, '2576', '7434', 34568732200494791,49698432), +(697832230, '2577', '7004', 34568732200494809,21578612), +(697832235, '2578', '9674', 34568732200494817,93090700), +(673420375, '2599', '5430', 34562052300117259,35911412), +(673420367, '2598', '8402', 34562052300117242,924654), +(673420361, '2597', '5125', 34562052300117234,12027970), +(673420355, '2596', '5069', 34562052300117226,34978149), +(673420348, '2595', '8911', 34562052300117218,4228121), +(673420346, '2594', '2461', 34562052300117200,67670772), +(673420345, '2593', '2226', 34562052300117192,90586404), +(673420306, '2592', '3355', 34562052300117184,97850017), +(673420257, '2591', '9395', 34562052300117176,50713786), +(673420231, '2590', '1378', 34562052300117168,50151763), +(673420223, '2589', '9580', 34562052300117150,99534550), +(673420216, '2588', '4955', 34562052300117143,317554), +(673420203, '2587', '6742', 34562052300117135,69321531), +(673420201, '2586', '1659', 34562052300117127,54720480), +(673420199, '2585', '7823', 34562052300117119,22923796), +(673420198, '2584', '1787', 34562052300117101,54414630), +(673420168, '2583', '6334', 34562052300117093,50694894), +(673420147, '2582', '8951', 34562052300117085,1402535), +(673420125, '2581', '3068', 34562052300117077,86216200), +(673420124, '2580', '9517', 34562052300117069,42504099), +(600294609, '2715', '7474', 34569832304894588,55923317), +(600084713, '2703', '8342', 34569832304894570,8392636), +(600084732, '2704', '1625', 34569832304894513,75477452), +(600084850, '2705', '9896', 34569832304894653,28589813), +(600084951, '2706', '5520', 34569832304894661,75353012), +(600084978, '2707', '2698', 34569832304894679,9005523), +(600085403, '2708', '0837', 34569832304894646,77051152), +(600085513, '2709', '3106', 34569832304894687,41571002), +(600293916, '2712', '8990', 34569832304894620,95188676), +(600294160, '2714', '6376', 34569832304894703,79879896), +(671919529, '2975', '9184', 34569832304806236,7535392), +(671919942, '2981', '0328', 34569832304806269,31052894), +(671919530, '2976', '0344', 34569832304806251,89860304), +(671919533, '2977', '0668', 34569832304806244,42921771), +(671919535, '2978', '0105', 34569832304806277,31009417), +(671919537, '2979', '0881', 34569832304806285,33479769), +(671919540, '2980', '9874', 34569832304806293,14103929), +(671919525, '2972', '2089', 34569832304806301,45903729), +(671919527, '2973', '8206', 34569832304806368,1586035), +(671919528, '2974', '2532', 34569832304806327,62310124), +(673668717, '2836', '7973', 34562032301044223,15635496), +(673668734, '2837', '4457', 34562032301044231,18313118), +(673668738, '2824', '2911', 34562032301044249,30875583), +(673668745, '2838', '7253', 34562032301044256,62754222), +(673668796, '2839', '0068', 34562032301044264,15556829), +(673668803, '2840', '2386', 34562032301044272,17572287), +(673669591, '2850', '3833', 34562032301044280,34828896), +(673668808, '2841', '3584', 34562032301044298,16234497), +(673670102, '2851', '3554', 34562032301044306,23652625), +(673670131, '2852', '4412', 34562032301044314,88611709), +(673670135, '2827', '6058', 34562032301044322,53918579), +(673670201, '2828', '8066', 34562032301044330,92369343), +(673670225, '2829', '4592', 34562032301044348,24126635), +(673670236, '2830', '2974', 34562032301044355,88608465), +(673671485, '2849', '0349', 34562032301044363,44944874), +(673461977, '2871', '1728', 34562032400157090,46975780), +(673461975, '2870', '4734', 34562032400157082,69628432), +(673461972, '2867', '6276', 34562032400157058,53338365), +(673461979, '2872', '6043', 34562032400157108,36525197), +(673461958, '2859', '3164', 34562032400156977,58947831), +(673461957, '2857', '8685', 34562032400156969,15826386), +(673461944, '2853', '1073', 34562032400156910,20452195), +(673461974, '2869', '7121', 34562032400157074,32044645), +(673461973, '2868', '8022', 34562032400157066,29282044), +(673461971, '2866', '3089', 34562032400157041,66149978), +(673461969, '2865', '7555', 34562032400157033,78391293), +(673461960, '2860', '5203', 34562032400156985,37138232), +(673461952, '2855', '6915', 34562032400156936,62724661), +(673461949, '2854', '8706', 34562032400156928,5594345), +(673461966, '2863', '2496', 34562032400157017,93450666), +(673461968, '2864', '3703', 34562032400157025,23208841), +(673461963, '2862', '9364', 34562032400157009,29712130), +(673462719, '2873', '9387', 34562032400156951,50434348), +(673461962, '2861', '8441', 34562032400156993,39686909), +(673461956, '2826', '5392', 34562032400156944,5496107), +(673465284, '2694', '1523', 34562032400171349,14554994), +(673465282, '2692', '4645', 34562032400171323,24871187), +(673465283, '2693', '5253', 34562032400171331,28303238), +(673465841, '2696', '0849', 34562032400171257,21673222), +(673465258, '2679', '4140', 34562032400171174,39793881), +(673465263, '2680', '6922', 34562032400171182,12253261), +(673465265, '2681', '9112', 34562032400171190,93894366), +(673465267, '2682', '3259', 34562032400171208,2342189), +(673465268, '2683', '8540', 34562032400171216,63886925), +(673465285, '2695', '4167', 34562032400171356,79227618), +(673465270, '2684', '4292', 34562032400171224,19216349), +(673465272, '2685', '4007', 34562032400171232,14396903), +(673465273, '2686', '6894', 34562032400171240,13569394), +(673465274, '2687', '5268', 34562032400171265,59453667), +(673465275, '2688', '0232', 34562032400171273,62324713), +(673465276, '2689', '2720', 34562032400171281,65977200), +(673465843, '2698', '4773', 34562032400171364,78387158), +(673465842, '2697', '3729', 34562032400171315,94201789), +(673465280, '2691', '0503', 34562032400171307,12298533), +(673465279, '2690', '8239', 34562032400171299,76183877); \ No newline at end of file From 252a029c988453229b53008e1902d2b276414ce3 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 11 Dec 2024 11:41:42 +0100 Subject: [PATCH 119/219] feat: refs #7882 Osrm service --- modules/client/back/methods/client/updateAddress.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/client/back/methods/client/updateAddress.js b/modules/client/back/methods/client/updateAddress.js index 7342b28f1..797aefe11 100644 --- a/modules/client/back/methods/client/updateAddress.js +++ b/modules/client/back/methods/client/updateAddress.js @@ -72,6 +72,14 @@ module.exports = function(Self) { { arg: 'isLogifloraAllowed', type: 'boolean' + }, + { + arg: 'longitude', + type: 'number', + }, + { + arg: 'latitude', + type: 'number', } ], returns: { From 093fdb6cb328aadaf1e3b6d20d4392f64f0db483 Mon Sep 17 00:00:00 2001 From: carlossa Date: Wed, 11 Dec 2024 11:50:16 +0100 Subject: [PATCH 120/219] fix: refs #6389 back --- modules/monitor/back/methods/sales-monitor/salesFilter.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 6c98f6cd7..95713f9fb 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -165,8 +165,6 @@ module.exports = Self => { case 'clientFk': param = `t.${param}`; return {[param]: value}; - case 'packing': - return {'i.itemPackingTypeFk': value}; } }); @@ -380,6 +378,7 @@ module.exports = Self => { } case 'agencyModeFk': case 'warehouseFk': + case 'packing': case 'countryFk': param = `f.${param}`; return {[param]: value}; From fbd6178c06826c62e08387beb319050cdd8cac51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 11 Dec 2024 13:16:39 +0100 Subject: [PATCH 121/219] fix: refs #8149 taxableBase invoiceIn --- db/routines/sage/procedures/invoiceIn_add.sql | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/db/routines/sage/procedures/invoiceIn_add.sql b/db/routines/sage/procedures/invoiceIn_add.sql index 1d411cfd0..76618ce50 100644 --- a/db/routines/sage/procedures/invoiceIn_add.sql +++ b/db/routines/sage/procedures/invoiceIn_add.sql @@ -25,7 +25,7 @@ BEGIN DECLARE vIsInformativeExportation BOOL DEFAULT FALSE; DECLARE vCursor CURSOR FOR - SELECT it.taxableBase, + SELECT SUM(it.taxableBase), CAST(SUM((( it.taxableBase / 100) * t.PorcentajeIva)) AS DECIMAL (10,2)), t.PorcentajeIva, it.transactionTypeSageFk, @@ -204,17 +204,17 @@ BEGIN FROM vn.invoiceInCorrection WHERE correctingFk = vInvoiceInFk; - IF vInvoiceInOriginalFk THEN + IF vInvoiceInOriginalFk THEN UPDATE movContaIVA mci JOIN vn.invoiceInRefund iir ON iir.invoiceInRefundFk = vInvoiceInFk JOIN (SELECT issued, - SUM(sub.taxableBase) taxableBase, + SUM(sub.taxableBase) taxableBase, SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat FROM(SELECT issued, - SUM(iit.taxableBase) taxableBase, + SUM(iit.taxableBase) taxableBase, ti.PorcentajeIva - FROM vn.invoiceIn i + FROM vn.invoiceIn i JOIN vn.invoiceInTax iit ON iit.invoiceInFk = i.id JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk WHERE i.id = vInvoiceInOriginalFk @@ -222,7 +222,7 @@ BEGIN )invoiceInOriginal JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa' SET mci.TipoRectificativa = iir.refundCategoryFk, - mci.ClaseAbonoRectificativas = iir.refundType, + mci.ClaseAbonoRectificativas = iir.refundType, mci.FechaFacturaOriginal = invoiceInOriginal.issued, mci.FechaOperacion = invoiceInOriginal.issued, mci.BaseImponibleOriginal = invoiceInOriginal.taxableBase, @@ -232,4 +232,4 @@ BEGIN END IF; END$$ -DELIMITER ; \ No newline at end of file +DELIMITER ; From 3e92aca6ff0ad18c521e7b7fa31d9754fe15e51c Mon Sep 17 00:00:00 2001 From: robert Date: Wed, 11 Dec 2024 14:32:08 +0100 Subject: [PATCH 122/219] feat: refs #249272 message updateQuantity --- modules/ticket/back/methods/sale/updateQuantity.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/sale/updateQuantity.js b/modules/ticket/back/methods/sale/updateQuantity.js index 36d75ffed..4de1bcbd6 100644 --- a/modules/ticket/back/methods/sale/updateQuantity.js +++ b/modules/ticket/back/methods/sale/updateQuantity.js @@ -82,7 +82,7 @@ module.exports = Self => { const message = $t('Changed sale quantity', { ticketId: sale.ticket().id, - changes: change, + changes: JSON.stringify(change), ticketUrl: `${url}ticket/${sale.ticket().id}/sale`, }); From 186ef5251832650c939f7437fd6d740857801370 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 11 Dec 2024 14:55:26 +0100 Subject: [PATCH 123/219] feat: refs #7882 Osrm service --- back/methods/osrm-config/optimize.js | 15 +++++++++++++-- loopback/locale/es.json | 6 +++--- .../route/back/methods/route/optimizePriority.js | 13 ++++++++----- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/back/methods/osrm-config/optimize.js b/back/methods/osrm-config/optimize.js index c03b70315..ae700d1cc 100644 --- a/back/methods/osrm-config/optimize.js +++ b/back/methods/osrm-config/optimize.js @@ -24,7 +24,7 @@ module.exports = Self => { } }); - Self.optimize = async(addressIds, firstAddressId) => { + Self.optimize = async(addressIds, firstAddressId, lastAddressId) => { const models = Self.app.models; try { const osrmConfig = await models.OsrmConfig.findOne(); @@ -53,13 +53,24 @@ module.exports = Self => { } } + if (lastAddressId) { + const firstAddress = await models.Address.findById(lastAddressId); + if (firstAddress.latitude && firstAddress.longitude) { + coords.push({ + addressId: firstAddress.id, + latitude: firstAddress.latitude.toFixed(6), + longitude: firstAddress.longitude.toFixed(6) + }); + } + } + if (!coords.length) throw new UserError('No address has coordinates'); const concatCoords = coords .map(coord => `${coord.longitude},${coord.latitude}`) .join(';'); const response = await axios.post(` - ${osrmConfig.url}/trip/v1/driving/${concatCoords}?source=first&roundtrip=true + ${osrmConfig.url}/trip/v1/driving/${concatCoords}?source=first&destination=last&roundtrip=true `); const tolerance = osrmConfig.tolerance; for (waypoint of response.data.waypoints) { diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 7e2253059..5f595e1ae 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -396,6 +396,6 @@ "Invalid options or too many coordinates": "Opciones invalidas o demasiadas coordenadas", "No address has coordinates": "Ninguna dirección tiene coordenadas", "An item type with the same code already exists": "Un tipo con el mismo código ya existe", - "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles" -} - + "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", + "All tickets have a route order": "Todos los tickets tienen orden de ruta" +} \ No newline at end of file diff --git a/modules/route/back/methods/route/optimizePriority.js b/modules/route/back/methods/route/optimizePriority.js index f84af50f8..c31913c66 100644 --- a/modules/route/back/methods/route/optimizePriority.js +++ b/modules/route/back/methods/route/optimizePriority.js @@ -71,13 +71,16 @@ module.exports = Self => { }, {}); const [mostFrequentZoneId] = Object.entries(zoneFrequency) .reduce((maxEntry, entry) => entry[1] > maxEntry[1] ? entry : maxEntry, [null, 0]); - const zone = await models.Zone.findById(mostFrequentZoneId, myOptions); - let firstAddress = zone.addressFk; - if (!firstAddress) firstAddress = (await models.ZoneConfig.findOne()).defaultAddressFk; + + // Obtenemos los address inicio y fin + const maxPosition = Math.max(...ticketAddress.map(g => g.priority)); + let firstAddress = (await models.Zone.findById(mostFrequentZoneId, myOptions))?.addressFk + || (await models.ZoneConfig.findOne())?.defaultAddressFk; + const lastAddress = firstAddress; + if (maxPosition) firstAddress = ticketAddress.find(g => g.priority === maxPosition)?.addressId; // Revisamos las coincidencias y actualizamos la prioridad en el array - const addressPositions = await models.OsrmConfig.optimize(addressIds, firstAddress, myOptions); - const maxPosition = Math.max(...ticketAddress.map(g => g.priority)); + const addressPositions = await models.OsrmConfig.optimize(addressIds, firstAddress, lastAddress, myOptions); await Promise.all(ticketAddress.map(async i => { const foundPosition = addressPositions.coords.find(item => item.addressId === i.addressId); if (foundPosition) i.priority = foundPosition.position + (maxPosition + 1); From addb093b6b37a76c19bce6b299cd0eb25c65b589 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 11 Dec 2024 17:42:03 +0100 Subject: [PATCH 124/219] feat: refs #7936 add minimum due date --- modules/invoiceIn/back/methods/invoice-in/filter.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/filter.js b/modules/invoiceIn/back/methods/invoice-in/filter.js index c549769ab..f081368e4 100644 --- a/modules/invoiceIn/back/methods/invoice-in/filter.js +++ b/modules/invoiceIn/back/methods/invoice-in/filter.js @@ -189,7 +189,8 @@ module.exports = Self => { s.account, SUM(iid.amount) amount, sub.code awbCode, - c.code + c.code, + MIN(iid.dueDated) dueDated FROM invoiceIn ii JOIN supplier s ON s.id = ii.supplierFk LEFT JOIN invoiceInDueDay iid ON iid.invoiceInFk = ii.id From aba2bf60828eec96019c90d728c259b687677fb3 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 12 Dec 2024 08:12:16 +0100 Subject: [PATCH 125/219] fix: refs #8251 add eng template --- .../incoterms-authorization/locale/en.yml | 6 +++ .../balance-compensation/locale/en.yml | 16 ++++++++ .../incoterms-authorization/locale/en.yml | 39 +++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 print/templates/email/incoterms-authorization/locale/en.yml create mode 100644 print/templates/reports/balance-compensation/locale/en.yml create mode 100644 print/templates/reports/incoterms-authorization/locale/en.yml diff --git a/print/templates/email/incoterms-authorization/locale/en.yml b/print/templates/email/incoterms-authorization/locale/en.yml new file mode 100644 index 000000000..7e1402575 --- /dev/null +++ b/print/templates/email/incoterms-authorization/locale/en.yml @@ -0,0 +1,6 @@ +subject: Incoterms Authorization +title: Incoterms Authorization +description: + dear: Dear customer + instructions: Please find attached the Incoterms authorization form, which you must complete and sign. + conclusion: Thank you for your attention! diff --git a/print/templates/reports/balance-compensation/locale/en.yml b/print/templates/reports/balance-compensation/locale/en.yml new file mode 100644 index 000000000..824127482 --- /dev/null +++ b/print/templates/reports/balance-compensation/locale/en.yml @@ -0,0 +1,16 @@ +reportName: balance-compensation +Place: Algemesí, on +Compensation: Compensation of debtor and creditor balances +In one hand: On one hand +CIF: with CIF +NIF: with NIF +Home: and address located at +In other hand: On the other hand +Sr: Mr./Ms. +Agree: Agree +Date: On the date of +Compensate: the balance of has been compensated +From client: from the client/supplier +Against the balance of: against the balance of +Reception: Please confirm receipt of this compensation at the email +Greetings: Best regards, diff --git a/print/templates/reports/incoterms-authorization/locale/en.yml b/print/templates/reports/incoterms-authorization/locale/en.yml new file mode 100644 index 000000000..eb6a8a513 --- /dev/null +++ b/print/templates/reports/incoterms-authorization/locale/en.yml @@ -0,0 +1,39 @@ +reportName: autorization-incoterms +description: '{socialName} a duly constituted and responsible company limited +and registered under corporate law {country} and here represented by {socialName}, with address in {address}, +CIF {fiscalID}. Hereinafter referred to as {name}.' +issued: 'In {0}, on {1} of {2} of {3}' +client: 'Customer {0}' +declaration: '{socialName} hereby declares that:' +declarations: + - 'All purchases made by {socialName} with {companyName} They are delivered according to the conditions defined in the Incoterm.' + - '{socialName} recognizes that it is important for {companyName} have +proof of intra-community delivery of the goods to {destinationCountry} to +be able to invoice with 0% VAT.' + - 'Therefore, by signing this agreement, {socialName} declares that all goods +purchased from {companyName} will be delivered to {destinationCountry}.' + - 'Besides, {socialName} shall, at the first request of {companyName}, +provide proof that all products purchased from {companyName} have +been delivered in {destinationCountry}.' + - 'In addition to the above, {companyName} will provide to {socialName} +a monthly summary that includes all bills (and corresponding deliveries). +{socialName} will sign and return the monthly summary to {companyName}, +S.L. within 5 days of receiving the summary.' +signer: + representative: Representative + representativeRole: Position of the representative + signed: Date of signature +manager: Manager +months: + - 'January' + - 'February' + - 'March' + - 'April' + - 'May' + - 'June' + - 'July' + - 'August' + - 'September' + - 'October' + - 'November' + - 'December' From 65e195d77d7bd51c451677e45d162fd5ef08d7b0 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 12 Dec 2024 08:23:02 +0100 Subject: [PATCH 126/219] feat: refs #7882 Requested changes --- back/methods/osrm-config/optimize.js | 12 ++++++------ modules/client/back/methods/client/updateAddress.js | 4 ++-- modules/route/back/methods/route/optimizePriority.js | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/back/methods/osrm-config/optimize.js b/back/methods/osrm-config/optimize.js index ae700d1cc..3a68c7ef4 100644 --- a/back/methods/osrm-config/optimize.js +++ b/back/methods/osrm-config/optimize.js @@ -32,12 +32,12 @@ module.exports = Self => { let coords = []; if (firstAddressId) { - const firstAddress = await models.Address.findById(firstAddressId); - if (firstAddress.latitude && firstAddress.longitude) { + const address = await models.Address.findById(firstAddressId); + if (address.latitude && address.longitude) { coords.push({ - addressId: firstAddress.id, - latitude: firstAddress.latitude.toFixed(6), - longitude: firstAddress.longitude.toFixed(6) + addressId: address.id, + latitude: address.latitude.toFixed(6), + longitude: address.longitude.toFixed(6) }); } } @@ -73,7 +73,7 @@ module.exports = Self => { ${osrmConfig.url}/trip/v1/driving/${concatCoords}?source=first&destination=last&roundtrip=true `); const tolerance = osrmConfig.tolerance; - for (waypoint of response.data.waypoints) { + for (const waypoint of response.data.waypoints) { const longitude = waypoint.location[0]; const latitude = waypoint.location[1]; diff --git a/modules/client/back/methods/client/updateAddress.js b/modules/client/back/methods/client/updateAddress.js index 797aefe11..efef83d6b 100644 --- a/modules/client/back/methods/client/updateAddress.js +++ b/modules/client/back/methods/client/updateAddress.js @@ -75,11 +75,11 @@ module.exports = function(Self) { }, { arg: 'longitude', - type: 'number', + type: 'any', }, { arg: 'latitude', - type: 'number', + type: 'any', } ], returns: { diff --git a/modules/route/back/methods/route/optimizePriority.js b/modules/route/back/methods/route/optimizePriority.js index c31913c66..f0ac76d8a 100644 --- a/modules/route/back/methods/route/optimizePriority.js +++ b/modules/route/back/methods/route/optimizePriority.js @@ -28,17 +28,17 @@ module.exports = Self => { if (typeof options == 'object') Object.assign(myOptions, options); - const ticketsIds = await models.Ticket.find({ + const tickets = await models.Ticket.find({ where: {routeFk: id} }, myOptions); let ticketAddress = []; - for (const ticketId of ticketsIds) { + for (const ticket of tickets) { ticketAddress.push({ - ticketId: ticketId.id, - addressId: ticketId.addressFk, - zoneId: ticketId.zoneFk, - priority: ticketId.priority + ticketId: ticket.id, + addressId: ticket.addressFk, + zoneId: ticket.zoneFk, + priority: ticket.priority }); } From c8f26bbbab67cc82117baa7846a4bf5c2ef1417d Mon Sep 17 00:00:00 2001 From: Jtubau Date: Thu, 12 Dec 2024 08:42:10 +0100 Subject: [PATCH 127/219] refactor: refs #8266 changed expedition item name --- modules/ticket/back/methods/expedition/filter.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/expedition/filter.js b/modules/ticket/back/methods/expedition/filter.js index 43be14349..bd2012668 100644 --- a/modules/ticket/back/methods/expedition/filter.js +++ b/modules/ticket/back/methods/expedition/filter.js @@ -49,7 +49,8 @@ module.exports = Self => { es.workerFk expeditionScanWorkerFk, su.name scannerUserName, es.scanned, - est.description state + est.description state, + de.longName FROM vn.expedition e LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk INNER JOIN vn.item i1 ON i1.id = e.freightItemFk @@ -59,6 +60,7 @@ module.exports = Self => { LEFT JOIN account.user u ON u.id = e.workerFk LEFT JOIN vn.expeditionScan es ON es.expeditionFk = e.id LEFT JOIN account.user su ON su.id = es.workerFk + LEFT JOIN dipole.expedition_PrintOut de ON de.expeditionFk = e.id ) e `); stmt.merge(conn.makeWhere(filter.where)); From b5d4d31abbefcc2fa0ef44ab57d87cc374c31cf5 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 12 Dec 2024 09:25:51 +0100 Subject: [PATCH 128/219] fix: refs #7301 update ACL insertion to use INSERT IGNORE and refine property value --- db/versions/11352-blackErica/00-firstScript.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/versions/11352-blackErica/00-firstScript.sql b/db/versions/11352-blackErica/00-firstScript.sql index 4e17c94c5..659f50161 100644 --- a/db/versions/11352-blackErica/00-firstScript.sql +++ b/db/versions/11352-blackErica/00-firstScript.sql @@ -1,3 +1,3 @@ -- Place your SQL code here -INSERT INTO salix.ACL (model, property, accessType, permission, principalType, principalId, editorFk) - VALUES('InventoryConfig', '*', 'READ', 'ALLOW', 'ROLE', 'buyer', 100); \ No newline at end of file +INSERT IGNORE INTO salix.ACL (model, property, accessType, permission, principalType, principalId) + VALUES('InventoryConfig', 'find', 'READ', 'ALLOW', 'ROLE', 'buyer'); \ No newline at end of file From efcf4d225b5e0aae5f9f68957bd2defd0e913bf5 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 12 Dec 2024 09:30:22 +0100 Subject: [PATCH 129/219] fix: refs #7028 fix pr --- loopback/locale/es.json | 3 ++- modules/ticket/back/methods/ticket-request/deny.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 0dc8e53a8..b4b5ee7c6 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -392,6 +392,7 @@ "The raid information is not correct": "La información de la redada no es correcta", "There are tickets to be invoiced": "Hay tickets para esta zona, borralos primero", "An item type with the same code already exists": "Un tipo con el mismo código ya existe", - "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles" + "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", + "Worker not found": "Trabajador no encontrado" } diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index cb13c2728..2f710ad3a 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -42,7 +42,7 @@ module.exports = Self => { try { const userId = ctx.req.accessToken.userId; - const worker = await models.Worker.findOne({where: {id: userId}}, myOptions); + const worker = await models.Worker.findById({where: {id: userId}}, myOptions); if (!worker) throw new Error('Worker not found'); const params = { @@ -76,7 +76,7 @@ module.exports = Self => { observation: params.response }); - await models.Chat.sendCheckingPresence(ctx, requesterId, message); + await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); await request.updateAttributes(params, myOptions); if (tx) await tx.commit(); From 1970b9c0db6cb4c5f6285c2e9cbca9a1c83822a5 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 12 Dec 2024 10:04:31 +0100 Subject: [PATCH 130/219] fix: refs #7028 fix tback findById --- modules/ticket/back/methods/ticket-request/deny.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index 2f710ad3a..f151afd6b 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -42,7 +42,7 @@ module.exports = Self => { try { const userId = ctx.req.accessToken.userId; - const worker = await models.Worker.findById({where: {id: userId}}, myOptions); + const worker = await models.Worker.findById(userId, myOptions); if (!worker) throw new Error('Worker not found'); const params = { From cd214b3526d204581562730405e17451b7897122 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 12 Dec 2024 11:11:22 +0100 Subject: [PATCH 131/219] fix: refs #7028 fix userError --- loopback/locale/es.json | 4 +++- modules/ticket/back/methods/ticket-request/deny.js | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index e0b180544..d7fcb8805 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -394,5 +394,7 @@ "Price cannot be blank": "Price cannot be blank", "An item type with the same code already exists": "Un tipo con el mismo código ya existe", "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", - "Worker not found": "Trabajador no encontrado" + "Worker not found": "Trabajador no encontrado", + "Invalid request or related ticket/client data": "Solicitud no válida o datos de ticket/cliente relacionados" + } diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index f151afd6b..c6a1d35af 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -1,3 +1,4 @@ +const UserError = require('vn-loopback/util/user-error'); module.exports = Self => { Self.remoteMethodCtx('deny', { description: 'Sets a ticket request to denied and returns the changes', @@ -43,7 +44,7 @@ module.exports = Self => { try { const userId = ctx.req.accessToken.userId; const worker = await models.Worker.findById(userId, myOptions); - if (!worker) throw new Error('Worker not found'); + if (!worker) throw new UserError('Worker not found'); const params = { isOk: false, @@ -66,7 +67,7 @@ module.exports = Self => { }, myOptions); if (!request || !request.ticket() || !request.ticket().client()) - throw new Error('Invalid request or related ticket/client data'); + throw new UserError('Invalid request or related ticket/client data'); const url = await models.Url.getUrl(); const requesterId = request.ticket().client().salesPersonFk; From c83f34859a02228e273b267e0e8717c5cc87df9e Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 12 Dec 2024 11:20:23 +0100 Subject: [PATCH 132/219] feat: refs #7936 return country code & is vies fields --- modules/invoiceIn/back/methods/invoice-in/summary.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/invoiceIn/back/methods/invoice-in/summary.js b/modules/invoiceIn/back/methods/invoice-in/summary.js index fe198b2b4..b3fd9ee97 100644 --- a/modules/invoiceIn/back/methods/invoice-in/summary.js +++ b/modules/invoiceIn/back/methods/invoice-in/summary.js @@ -37,7 +37,13 @@ module.exports = Self => { { relation: 'supplier', scope: { - fields: ['id', 'name'] + fields: ['id', 'name', 'isVies', 'countryFk'], + include: [{ + relation: 'country', + scope: { + fields: ['id', 'code'] + } + }] } }, { From 05ba85219b5f91a2351eb4256c11f3211bad0838 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 12 Dec 2024 14:35:58 +0100 Subject: [PATCH 133/219] feat: refs #7882 Osrm service --- back/methods/osrm-config/optimize.js | 8 +------- db/dump/fixtures.before.sql | 3 +++ modules/route/back/methods/route/optimizePriority.js | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/back/methods/osrm-config/optimize.js b/back/methods/osrm-config/optimize.js index 3a68c7ef4..5d2ade935 100644 --- a/back/methods/osrm-config/optimize.js +++ b/back/methods/osrm-config/optimize.js @@ -91,13 +91,7 @@ module.exports = Self => { return posA - posB; }); - const coordsString = coords - .map(item => `point=${item.latitude},${item.longitude}`) - .join('&'); - return { - coords, - view: `https://graphhopper.com/maps/?${coordsString}&profile=small_truck` - }; + return coords; } catch (err) { switch (err.response?.data?.code) { case 'NoTrips': diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 663705ff5..84e007695 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4035,3 +4035,6 @@ INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) INSERT INTO vn.workerIrpf (workerFk,spouseNif, geographicMobilityDate) VALUES (1106,'26493101E','2019-09-20'); + +INSERT INTO vn.osrmConfig (id,url,tolerance) + VALUES (1,'https://router.project-osrm.org', 0.002); diff --git a/modules/route/back/methods/route/optimizePriority.js b/modules/route/back/methods/route/optimizePriority.js index f0ac76d8a..56db4ffb5 100644 --- a/modules/route/back/methods/route/optimizePriority.js +++ b/modules/route/back/methods/route/optimizePriority.js @@ -82,7 +82,7 @@ module.exports = Self => { // Revisamos las coincidencias y actualizamos la prioridad en el array const addressPositions = await models.OsrmConfig.optimize(addressIds, firstAddress, lastAddress, myOptions); await Promise.all(ticketAddress.map(async i => { - const foundPosition = addressPositions.coords.find(item => item.addressId === i.addressId); + const foundPosition = addressPositions.find(item => item.addressId === i.addressId); if (foundPosition) i.priority = foundPosition.position + (maxPosition + 1); })); From 00b5333ab7edbb02d04df8ca053217462e79147b Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 13 Dec 2024 08:07:13 +0100 Subject: [PATCH 134/219] feat: refs #7882 Added tests --- .../osrm-config/specs/optimize.spec.js | 33 +++++++++++++++++ db/dump/fixtures.before.sql | 10 +++--- .../route/specs/optimizePriority.spec.js | 36 +++++++++++++++++++ 3 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 back/methods/osrm-config/specs/optimize.spec.js create mode 100644 modules/route/back/methods/route/specs/optimizePriority.spec.js diff --git a/back/methods/osrm-config/specs/optimize.spec.js b/back/methods/osrm-config/specs/optimize.spec.js new file mode 100644 index 000000000..9f2adccc6 --- /dev/null +++ b/back/methods/osrm-config/specs/optimize.spec.js @@ -0,0 +1,33 @@ +const models = require('vn-loopback/server/server').models; + +describe('osrmConfig optimize()', function() { + it('should send coords, receive OSRM response, and return a correctly ordered result', async function() { + const result = await models.OsrmConfig.optimize([4, 3], 1, 2); + + // Verifications + expect(Array.isArray(result)).toBe(true); + expect(result.length).toBe(4); + + // Check the order + expect(result[0].addressId).toBe(1); + expect(result[1].addressId).toBe(4); + expect(result[2].addressId).toBe(3); + expect(result[3].addressId).toBe(2); + + // Check the coordinates format + expect(result[0].latitude).toBe('10.111111'); + expect(result[0].longitude).toBe('-74.111111'); + }); + + it('should throw an error if no addresses are provided', async function() { + let error; + try { + await models.OsrmConfig.optimize([], null); + } catch (e) { + error = e; + } + + expect(error).toBeDefined(); + expect(error.message).toBe('No address has coordinates'); + }); +}); diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index d3823a5b7..c108bc0f6 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -428,10 +428,10 @@ INSERT INTO `vn`.`clientConfig`(`id`, `riskTolerance`, `maxCreditRows`, `maxPric INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `provinceFk`, `phone`, `mobile`, `isActive`, `clientFk`, `agencyModeFk`, `longitude`, `latitude`, `isEqualizated`, `isDefaultAddress`) VALUES - (1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 1), - (2, 'Petter Parker', '20 Ingram Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 1), - (3, 'Clark Kent', '344 Clinton Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 1), - (4, 'Tony Stark', '10880 Malibu Point', 'Gotham', 46460, 1, 1111111111, 222222222, 1 , 1104, 2, NULL, NULL, 0, 1), + (1, 'Bruce Wayne', '1007 Mountain Drive, Gotham', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, -74.1111111, 10.1111111, 0, 1), + (2, 'Petter Parker', '20 Ingram Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, -74.2222222, 10.2222222, 0, 1), + (3, 'Clark Kent', '344 Clinton Street', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, -74.3333333, 10.3333333, 0, 1), + (4, 'Tony Stark', '10880 Malibu Point', 'Gotham', 46460, 1, 1111111111, 222222222, 1 , 1104, 2, -74.4444444, 10.4444444, 0, 1), (5, 'Max Eisenhardt', 'Unknown Whereabouts', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 1), (6, 'DavidCharlesHaller', 'Evil hideout', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 1), (7, 'Hank Pym', 'Anthill', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1107, 2, NULL, NULL, 0, 1), @@ -462,7 +462,7 @@ INSERT INTO `vn`.`address`(`id`, `nickname`, `street`, `city`, `postalCode`, `pr (120, 'Somewhere in Montortal', 'address 20', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1109, 2, NULL, NULL, 0, 0), (121, 'the bat cave', 'address 21', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1101, 2, NULL, NULL, 0, 0), (122, 'NY roofs', 'address 22', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1102, 2, NULL, NULL, 0, 0), - (123, 'The phone box', 'address 23', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, NULL, NULL, 0, 0), + (123, 'The phone box', 'address 23', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1103, 2, -74.555555, 10.555555, 0, 0), (124, 'Stark tower Gotham', 'address 24', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1104, 2, NULL, NULL, 0, 0), (125, 'The plastic cell', 'address 25', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1105, 2, NULL, NULL, 0, 0), (126, 'Many places', 'address 26', 'Gotham', 46460, 1, 1111111111, 222222222, 1, 1106, 2, NULL, NULL, 0, 0), diff --git a/modules/route/back/methods/route/specs/optimizePriority.spec.js b/modules/route/back/methods/route/specs/optimizePriority.spec.js new file mode 100644 index 000000000..c1c2dc45e --- /dev/null +++ b/modules/route/back/methods/route/specs/optimizePriority.spec.js @@ -0,0 +1,36 @@ +const models = require('vn-loopback/server/server').models; +const routeId = 1; + +describe('route optimizePriority())', function() { + it('should execute without throwing errors', async function() { + const tx = await models.Route.beginTransaction({}); + let error; + try { + const options = {transaction: tx}; + await models.Ticket.updateAll( + {routeFk: routeId}, + {priority: null}, + options + ); + await models.Route.optimizePriority(routeId, options); + await tx.rollback(); + } catch (e) { + error = e; + await tx.rollback(); + } + + expect(error).toBeUndefined(); + }); + + it('should execute with error', async function() { + let error; + try { + await models.Route.optimizePriority(routeId); + } catch (e) { + error = e; + } + + expect(error).toBeDefined(); + expect(error.message).toBe('All tickets have a route order'); + }); +}); From 452ec3d7319491df73c9416ea671341a80f2a695 Mon Sep 17 00:00:00 2001 From: guillermo Date: Fri, 13 Dec 2024 08:29:14 +0100 Subject: [PATCH 135/219] fix: refs #247552 ticket 247552 claimRatio_add --- db/routines/vn/procedures/claimRatio_add.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/claimRatio_add.sql b/db/routines/vn/procedures/claimRatio_add.sql index 8c3213644..5e2e66a8e 100644 --- a/db/routines/vn/procedures/claimRatio_add.sql +++ b/db/routines/vn/procedures/claimRatio_add.sql @@ -46,7 +46,7 @@ BEGIN JOIN claimDestination cd ON cd.id = ce.claimDestinationFk JOIN claim c ON c.id = ce.claimFk JOIN claimState cs ON cs.id = c.claimStateFk - WHERE cd.description NOT IN ('Bueno', 'Corregido') + WHERE cd.code NOT IN ('good', 'corrected', 'supplierClaim') AND NOT ce.isGreuge AND cs.code = 'resolved'; @@ -71,7 +71,7 @@ BEGIN JOIN claimDestination cd ON cd.id = ce.claimDestinationFk JOIN claim c ON c.id = ce.claimFk JOIN claimState cs ON cs.id = c.claimStateFk - WHERE cd.description NOT IN ('Bueno', 'Corregido') + WHERE cd.code NOT IN ('good', 'corrected', 'supplierClaim') AND NOT ce.isGreuge AND cs.code = 'resolved' AND c.isChargedToMana; @@ -82,7 +82,7 @@ BEGIN JOIN claim c ON c.id = ce.claimFk JOIN claimState cs ON cs.id = c.claimStateFk SET ce.isGreuge = TRUE - WHERE cd.description NOT IN ('Bueno', 'Corregido') + WHERE cd.code NOT IN ('good', 'corrected', 'supplierClaim') AND NOT ce.isGreuge AND cs.code = 'resolved'; @@ -161,7 +161,7 @@ BEGIN JOIN claimDestination cd ON cd.id = ce.claimDestinationFk JOIN claim c ON c.id = ce.claimFk JOIN claimState cs ON cs.id = c.claimStateFk - WHERE cd.description NOT IN ('Bueno', 'Corregido') + WHERE cd.code NOT IN ('good', 'corrected', 'supplierClaim') AND cs.code = 'resolved' AND c.ticketCreated >= util.VN_CURDATE() - INTERVAL 1 YEAR GROUP BY c.clientFk From e748e9a0127bb25bb62ecdcc9a0390b4281d2d7e Mon Sep 17 00:00:00 2001 From: jgallego Date: Fri, 13 Dec 2024 08:30:23 +0100 Subject: [PATCH 136/219] feat: refs #7235 add serialType parameter to getInvoiceDate and implement corresponding tests --- modules/account/back/methods/account/sync.js | 4 +- .../back/methods/invoiceOut/getInvoiceDate.js | 15 ++++--- .../invoiceOut/specs/getInvoiceDate.spec.js | 39 +++++++++++++++++++ 3 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 modules/invoiceOut/back/methods/invoiceOut/specs/getInvoiceDate.spec.js diff --git a/modules/account/back/methods/account/sync.js b/modules/account/back/methods/account/sync.js index 1026c5020..b38e4dd37 100644 --- a/modules/account/back/methods/account/sync.js +++ b/modules/account/back/methods/account/sync.js @@ -29,14 +29,14 @@ module.exports = Self => { 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 user = await models.VnUser.findOne({ diff --git a/modules/invoiceOut/back/methods/invoiceOut/getInvoiceDate.js b/modules/invoiceOut/back/methods/invoiceOut/getInvoiceDate.js index dcc1fa6e8..493f19aa7 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/getInvoiceDate.js +++ b/modules/invoiceOut/back/methods/invoiceOut/getInvoiceDate.js @@ -7,7 +7,12 @@ module.exports = Self => { arg: 'companyFk', type: 'number', required: true - } + }, + { + arg: 'serialType', + type: 'string', + required: true + }, ], returns: { type: ['object'], @@ -19,16 +24,16 @@ module.exports = Self => { } }); - Self.getInvoiceDate = async companyFk => { + Self.getInvoiceDate = async(companyFk, serialType) => { const models = Self.app.models; const [invoiceDate] = await models.InvoiceOut.rawSql( `SELECT MAX(io.issued) issued FROM invoiceOut io JOIN invoiceOutSerial ios ON ios.code = io.serial - WHERE ios.type = 'global' - AND io.issued + WHERE ios.type = ? + AND io.issued AND io.companyFk = ?`, - [companyFk] + [serialType, companyFk] ); return invoiceDate; }; diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/getInvoiceDate.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/getInvoiceDate.spec.js new file mode 100644 index 000000000..830402250 --- /dev/null +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/getInvoiceDate.spec.js @@ -0,0 +1,39 @@ +const models = require('vn-loopback/server/server').models; +const moment = require('moment'); + +describe('getInvoiceDate()', () => { + const companyFk = 442; + let tx; + let options; + + beforeEach(async() => { + tx = await models.InvoiceOut.beginTransaction({}); + options = {transaction: tx}; + }); + + afterEach(async() => { + await tx.rollback(); + }); + + it('should return a correct date for serialType "global"', async() => { + const serialType = 'global'; + const result = await models.InvoiceOut.getInvoiceDate(companyFk, serialType, options); + + expect(moment(result.issued).format('YYYY-MM-DD')).toEqual('2000-12-01'); + }); + + it('should return null for serialType "multiple"', async() => { + const serialType = 'multiple'; + const result = await models.InvoiceOut.getInvoiceDate(companyFk, serialType, options); + + expect(result.issued).toBeNull(); + }); + + it('should return correct date for serialType "quick"', async() => { + const serialType = 'quick'; + const result = await models.InvoiceOut.getInvoiceDate(companyFk, serialType, options); + + expect(moment(result.issued).format('YYYY-MM-DD')).toEqual('2001-01-01'); + }); +}); + From ec2b6dd0c2fbf3605cd594e7a00375ff43cdf5ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 13 Dec 2024 14:55:03 +0000 Subject: [PATCH 137/219] Actualizar db/versions/11327-maroonOak/00-firstScript.sql --- db/versions/11327-maroonOak/00-firstScript.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index 250a2fc8b..35ec989e7 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -13,9 +13,6 @@ CREATE TABLE IF NOT EXISTS `vn`.`simSupplier` ( ALTER TABLE `vn`.`deviceProductionUser` MODIFY `simSerialNumber` VARCHAR(25); -ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_simSupplier_FK - FOREIGN KEY (simSerialNumber) REFERENCES vn.simSupplier(sim); - INSERT IGNORE INTO `vn`.`simSupplier` (`line`, `ext`, `pin`, `sim`, `puk`) VALUES (621188151, '2209', '1486', 3456985220092508,14213470), @@ -174,4 +171,7 @@ VALUES (673465843, '2698', '4773', 34562032400171364,78387158), (673465842, '2697', '3729', 34562032400171315,94201789), (673465280, '2691', '0503', 34562032400171307,12298533), -(673465279, '2690', '8239', 34562032400171299,76183877); \ No newline at end of file +(673465279, '2690', '8239', 34562032400171299,76183877); + +ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_simSupplier_FK + FOREIGN KEY (simSerialNumber) REFERENCES vn.simSupplier(sim) ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file From 233f45a07a1e45493dd8a360d83758e06bcbc2fb Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Dec 2024 07:15:47 +0100 Subject: [PATCH 138/219] feat: refs #7882 Reequested changes --- back/methods/osrm-config/optimize.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/back/methods/osrm-config/optimize.js b/back/methods/osrm-config/optimize.js index 5d2ade935..e0412c74c 100644 --- a/back/methods/osrm-config/optimize.js +++ b/back/methods/osrm-config/optimize.js @@ -13,6 +13,10 @@ module.exports = Self => { arg: 'firstAddressId', type: 'number', required: false + }, { + arg: 'lastAddressId', + type: 'number', + required: false }], returns: { type: 'object', From 1d7e69cb25f809ca2d26c1fa2e90facff815cbc4 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 16 Dec 2024 07:40:49 +0100 Subject: [PATCH 139/219] feat: refs #7584 workerTimeControl_afterDelete --- .../vn/triggers/workerTimeControl_afterDelete.sql | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/triggers/workerTimeControl_afterDelete.sql b/db/routines/vn/triggers/workerTimeControl_afterDelete.sql index 27432fccb..762754591 100644 --- a/db/routines/vn/triggers/workerTimeControl_afterDelete.sql +++ b/db/routines/vn/triggers/workerTimeControl_afterDelete.sql @@ -3,10 +3,12 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerTimeControl_after AFTER DELETE ON `workerTimeControl` FOR EACH ROW BEGIN - INSERT INTO workerLog - SET `action` = 'delete', - `changedModel` = 'WorkerTimeControl', - `changedModelId` = OLD.id, - `userFk` = account.myUser_getId(); + IF account.myUser_getId() THEN + INSERT INTO workerLog + SET `action` = 'delete', + `changedModel` = 'WorkerTimeControl', + `changedModelId` = OLD.id, + `userFk` = account.myUser_getId(); + END IF; END$$ DELIMITER ; From b14268ef1bfd0091526255e390255ad664f3839a Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 16 Dec 2024 08:15:14 +0100 Subject: [PATCH 140/219] fix: hotfix createAbsence --- modules/worker/back/methods/worker/createAbsence.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index e46ce9577..93ca7fd89 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -128,7 +128,10 @@ module.exports = Self => { const account = await models.VnUser.findById(userId, null, myOptions); const subordinated = await models.VnUser.findById(id, null, myOptions); const worker = await models.Worker.findById(subordinated.id, null, myOptions); - const departmentBoss = await models.VnUser.findById(worker.bossFk, null, myOptions); + const receiver = await models.EmailUser.findOne({ + fields: ['email'], + where: {userFk: worker.bossFk} + }, myOptions); const url = await Self.app.models.Url.getUrl(); const body = $t('Created absence', { author: account.nickname, @@ -140,7 +143,7 @@ module.exports = Self => { await models.Mail.create({ subject: $t('Absence change notification on the labour calendar'), body: body, - receiver: departmentBoss.email + receiver: receiver.email }, myOptions); if (tx) await tx.commit(); From 9c32dc5707630b5c67a183409465015946348e61 Mon Sep 17 00:00:00 2001 From: Jtubau Date: Mon, 16 Dec 2024 08:34:53 +0100 Subject: [PATCH 141/219] feat: refs #8293 include zone data --- modules/claim/back/methods/claim/filter.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/claim/back/methods/claim/filter.js b/modules/claim/back/methods/claim/filter.js index f60b6572e..bacdd4021 100644 --- a/modules/claim/back/methods/claim/filter.js +++ b/modules/claim/back/methods/claim/filter.js @@ -80,6 +80,12 @@ module.exports = Self => { description: 'The claimResponsible id', http: {source: 'query'} }, + { + arg: 'zoneFk', + type: 'string', + description: 'The zone name', + http: {source: 'query'} + }, { arg: 'myTeam', type: 'boolean', @@ -174,6 +180,8 @@ module.exports = Self => { to.setHours(23, 59, 59, 999); return {'cl.created': {between: [value, to]}}; + case 'zoneFk': + return {'t.zoneFk': value}; case 'myTeam': if (value) return {'cl.workerFk': {inq: teamMembersId}}; @@ -195,11 +203,15 @@ module.exports = Self => { u.name AS workerName, cs.code stateCode, cs.description stateDescription, - cl.created + cl.created, + z.name zoneName, + z.id zoneId FROM claim cl LEFT JOIN client c ON c.id = cl.clientFk LEFT JOIN account.user u ON u.id = cl.workerFk - LEFT JOIN claimState cs ON cs.id = cl.claimStateFk` + LEFT JOIN claimState cs ON cs.id = cl.claimStateFk + LEFT JOIN ticket t ON t.id = cl.ticketFk + LEFT JOIN zone z ON z.id = t.zoneFk` ); stmt.merge(conn.makeSuffix(filter)); From 57c3cc854622b3f64c721fa78b049d19e8549a75 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Dec 2024 09:01:10 +0100 Subject: [PATCH 142/219] feat: refs #8174 Created table sim --- .../11327-maroonOak/00-firstScript.sql | 354 +++++++++--------- 1 file changed, 180 insertions(+), 174 deletions(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index 35ec989e7..7c9d8e6e8 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -1,177 +1,183 @@ -CREATE TABLE IF NOT EXISTS `vn`.`simSupplier` ( - `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, - `line` INT(9) unsigned NOT NULL, - `ext` CHAR(4) NOT NULL CHECK (ext REGEXP '^[0-9]{4}$'), - `pin` CHAR(4) NOT NULL CHECK (pin REGEXP '^[0-9]{4}$'), - `sim` VARCHAR(25), - `puk` INT(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `sim_UNIQUE` (`sim`) -) ENGINE=InnoDB AUTO_INCREMENT=1 - DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +CREATE TABLE IF NOT EXISTS `vn`.`sim` ( + `id` BIGINT UNSIGNED, + `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), + `ext` INT(4) NOT NULL, + `pin` INT(4) NOT NULL, + `puk` INT(15) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -ALTER TABLE `vn`.`deviceProductionUser` -MODIFY `simSerialNumber` VARCHAR(25); +ALTER TABLE vn.deviceProductionUser CHANGE simSerialNumber simFk BIGINT unsigned DEFAULT NULL NULL; +ALTER TABLE vn.deviceProductionUser MODIFY COLUMN simFk BIGINT unsigned DEFAULT NULL NULL; -INSERT IGNORE INTO `vn`.`simSupplier` (`line`, `ext`, `pin`, `sim`, `puk`) -VALUES -(621188151, '2209', '1486', 3456985220092508,14213470), -(621188152, '2210', '8765', 3456985220092509,99473093), -(621188153, '2211', '3064', 3456985220092510,52967210), -(621188759, '2081', '3700', 3456985220123637,56600999), -(621188760, '2082', '3259', 345698522023638,87492404), -(621188761, '2083', '2790', 3456985220123639,94009456), -(621188762, '2084', '2480', 3456985220123644,1484999), -(621188763, '2085', '6876', 3456985220123641,36577064), -(621188766, '2086', '7775', 3456985220123642,80761698), -(621188769, '2088', '4027', 3456985220123643,37921712), -(621188771, '2089', '8797', 3456985220123640,63092540), -(621188772, '2090', '8404', 3456985220123645,21014997), -(621188773, '2091', '5481', 3456985220123646,16317277), -(621188774, '2092', '9632', 3456985220123647,22235994), -(621188775, '2093', '4654', 3456985220123648,28506486), -(621188838, '2094', '1392', 3456985220123649,29498627), -(621188839, '2095', '7774', 3456985220123650,46263490), -(621188840, '2096', '7304', 3456985220123658,8212044), -(621188841, '2097', '5569', 3456985220123652,81597658), -(621188842, '2098', '4944', 3456985220123653,24961501), -(621188843, '2099', '5142', 3456985220123654,17035634), -(621188844, '2111', '7245', 3456985220123655,90231951), -(621188846, '2110', '6590', 3456985220123656,72201537), -(667680207, '2564', '4042', 34569832200759166,48401979), -(667680315, '2565', '7143', 34569832200759372,32143252), -(667680318, '2566', '6342', 34569832200759364,39597112), -(667680413, '2567', '5580', 34569832200759356,32786992), -(667680463, '2568', '0171', 34569832200759349,34240853), -(667688217, '2569', '2500', 34569832200759331,5687589), -(633603945, '2212', '7129', 34569832200759323,51554019), -(622130186, '2213', '4826', 34569832200759307,19623551), -(633973424, '2214', '8535', 34569832200759299,94619307), -(633703828, '2215', '8628', 34569832200759281,22468012), -(622025110, '2216', '2399', 34569832200759273,34602918), -(622924867, '2217', '5665', 34569832200759265,26920216), -(722409630, '2218', '5211', 34569832200759240,93750137), -(623590529, '2219', '0493', 34569832200759208,47077088), -(633243462, '2220', '6902', 34569832200759174,6421962), -(633047286, '2221', '5592', 34569832200759182,32069439), -(744716801, '2112', '9184', 34569832200759190,57049814), -(655995021, '2131', '8896', 34569852202049093,19497356), -(685522718, '2132', '1955', 34569852202049101,28519879), -(674587213, '2994', '2006', 34569332200223743,62360135), -(674587227, '2993', '9271', 34569332200223750,81628192), -(674587229, '2993', '0900', 34569332200223768,91119071), -(674587231, '2992', '5007', 34569332200223776,45826232), -(674587234, '2991', '1378', 34569332200223784,91245744), -(674587240, '2990', '0905', 34569332200223792,13083224), -(674587245, '2989', '9059', 34569332200223800,15291807), -(674587250, '2988', '8188', 34569332200223818,83017918), -(674587254, '2987', '2962', 34569332200223826,92809271), -(674587256, '2986', '0358', 34569332200223834,81067040), -(674592713, '2570', '2537', 34569332200230672,82325850), -(697832478, '2579', '0936', 34568732200494825,49658372), -(697832176, '2571', '5944', 34568732200494742,19039461), -(697832477, '2572', '5138', 34568732200494759,25712504), -(697832178, '2573', '4597', 34568732200494767,66241760), -(697832182, '2574', '9241', 34568732200494775,07342562), -(697832196, '2575', '2995', 34568732200494783,53929026), -(697832214, '2576', '7434', 34568732200494791,49698432), -(697832230, '2577', '7004', 34568732200494809,21578612), -(697832235, '2578', '9674', 34568732200494817,93090700), -(673420375, '2599', '5430', 34562052300117259,35911412), -(673420367, '2598', '8402', 34562052300117242,924654), -(673420361, '2597', '5125', 34562052300117234,12027970), -(673420355, '2596', '5069', 34562052300117226,34978149), -(673420348, '2595', '8911', 34562052300117218,4228121), -(673420346, '2594', '2461', 34562052300117200,67670772), -(673420345, '2593', '2226', 34562052300117192,90586404), -(673420306, '2592', '3355', 34562052300117184,97850017), -(673420257, '2591', '9395', 34562052300117176,50713786), -(673420231, '2590', '1378', 34562052300117168,50151763), -(673420223, '2589', '9580', 34562052300117150,99534550), -(673420216, '2588', '4955', 34562052300117143,317554), -(673420203, '2587', '6742', 34562052300117135,69321531), -(673420201, '2586', '1659', 34562052300117127,54720480), -(673420199, '2585', '7823', 34562052300117119,22923796), -(673420198, '2584', '1787', 34562052300117101,54414630), -(673420168, '2583', '6334', 34562052300117093,50694894), -(673420147, '2582', '8951', 34562052300117085,1402535), -(673420125, '2581', '3068', 34562052300117077,86216200), -(673420124, '2580', '9517', 34562052300117069,42504099), -(600294609, '2715', '7474', 34569832304894588,55923317), -(600084713, '2703', '8342', 34569832304894570,8392636), -(600084732, '2704', '1625', 34569832304894513,75477452), -(600084850, '2705', '9896', 34569832304894653,28589813), -(600084951, '2706', '5520', 34569832304894661,75353012), -(600084978, '2707', '2698', 34569832304894679,9005523), -(600085403, '2708', '0837', 34569832304894646,77051152), -(600085513, '2709', '3106', 34569832304894687,41571002), -(600293916, '2712', '8990', 34569832304894620,95188676), -(600294160, '2714', '6376', 34569832304894703,79879896), -(671919529, '2975', '9184', 34569832304806236,7535392), -(671919942, '2981', '0328', 34569832304806269,31052894), -(671919530, '2976', '0344', 34569832304806251,89860304), -(671919533, '2977', '0668', 34569832304806244,42921771), -(671919535, '2978', '0105', 34569832304806277,31009417), -(671919537, '2979', '0881', 34569832304806285,33479769), -(671919540, '2980', '9874', 34569832304806293,14103929), -(671919525, '2972', '2089', 34569832304806301,45903729), -(671919527, '2973', '8206', 34569832304806368,1586035), -(671919528, '2974', '2532', 34569832304806327,62310124), -(673668717, '2836', '7973', 34562032301044223,15635496), -(673668734, '2837', '4457', 34562032301044231,18313118), -(673668738, '2824', '2911', 34562032301044249,30875583), -(673668745, '2838', '7253', 34562032301044256,62754222), -(673668796, '2839', '0068', 34562032301044264,15556829), -(673668803, '2840', '2386', 34562032301044272,17572287), -(673669591, '2850', '3833', 34562032301044280,34828896), -(673668808, '2841', '3584', 34562032301044298,16234497), -(673670102, '2851', '3554', 34562032301044306,23652625), -(673670131, '2852', '4412', 34562032301044314,88611709), -(673670135, '2827', '6058', 34562032301044322,53918579), -(673670201, '2828', '8066', 34562032301044330,92369343), -(673670225, '2829', '4592', 34562032301044348,24126635), -(673670236, '2830', '2974', 34562032301044355,88608465), -(673671485, '2849', '0349', 34562032301044363,44944874), -(673461977, '2871', '1728', 34562032400157090,46975780), -(673461975, '2870', '4734', 34562032400157082,69628432), -(673461972, '2867', '6276', 34562032400157058,53338365), -(673461979, '2872', '6043', 34562032400157108,36525197), -(673461958, '2859', '3164', 34562032400156977,58947831), -(673461957, '2857', '8685', 34562032400156969,15826386), -(673461944, '2853', '1073', 34562032400156910,20452195), -(673461974, '2869', '7121', 34562032400157074,32044645), -(673461973, '2868', '8022', 34562032400157066,29282044), -(673461971, '2866', '3089', 34562032400157041,66149978), -(673461969, '2865', '7555', 34562032400157033,78391293), -(673461960, '2860', '5203', 34562032400156985,37138232), -(673461952, '2855', '6915', 34562032400156936,62724661), -(673461949, '2854', '8706', 34562032400156928,5594345), -(673461966, '2863', '2496', 34562032400157017,93450666), -(673461968, '2864', '3703', 34562032400157025,23208841), -(673461963, '2862', '9364', 34562032400157009,29712130), -(673462719, '2873', '9387', 34562032400156951,50434348), -(673461962, '2861', '8441', 34562032400156993,39686909), -(673461956, '2826', '5392', 34562032400156944,5496107), -(673465284, '2694', '1523', 34562032400171349,14554994), -(673465282, '2692', '4645', 34562032400171323,24871187), -(673465283, '2693', '5253', 34562032400171331,28303238), -(673465841, '2696', '0849', 34562032400171257,21673222), -(673465258, '2679', '4140', 34562032400171174,39793881), -(673465263, '2680', '6922', 34562032400171182,12253261), -(673465265, '2681', '9112', 34562032400171190,93894366), -(673465267, '2682', '3259', 34562032400171208,2342189), -(673465268, '2683', '8540', 34562032400171216,63886925), -(673465285, '2695', '4167', 34562032400171356,79227618), -(673465270, '2684', '4292', 34562032400171224,19216349), -(673465272, '2685', '4007', 34562032400171232,14396903), -(673465273, '2686', '6894', 34562032400171240,13569394), -(673465274, '2687', '5268', 34562032400171265,59453667), -(673465275, '2688', '0232', 34562032400171273,62324713), -(673465276, '2689', '2720', 34562032400171281,65977200), -(673465843, '2698', '4773', 34562032400171364,78387158), -(673465842, '2697', '3729', 34562032400171315,94201789), -(673465280, '2691', '0503', 34562032400171307,12298533), -(673465279, '2690', '8239', 34562032400171299,76183877); +INSERT IGNORE INTO `vn`.`sim` (`line`, `ext`, `pin`, `id`, `puk`) VALUES + ('621188151', 2209, 1486, 3456985220092508,14213470), + ('621188152', 2210, 8765, 3456985220092509,99473093), + ('621188153', 2211, 3064, 3456985220092510,52967210), + ('621188759', 2081, 3700, 3456985220123637,56600999), + ('621188760', 2082, 3259, 345698522023638,87492404), + ('621188761', 2083, 2790, 3456985220123639,94009456), + ('621188762', 2084, 2480, 3456985220123644,1484999), + ('621188763', 2085, 6876, 3456985220123641,36577064), + ('621188766', 2086, 7775, 3456985220123642,80761698), + ('621188769', 2088, 4027, 3456985220123643,37921712), + ('621188771', 2089, 8797, 3456985220123640,63092540), + ('621188772', 2090, 8404, 3456985220123645,21014997), + ('621188773', 2091, 5481, 3456985220123646,16317277), + ('621188774', 2092, 9632, 3456985220123647,22235994), + ('621188775', 2093, 4654, 3456985220123648,28506486), + ('621188838', 2094, 1392, 3456985220123649,29498627), + ('621188839', 2095, 7774, 3456985220123650,46263490), + ('621188840', 2096, 7304, 3456985220123658,8212044), + ('621188841', 2097, 5569, 3456985220123652,81597658), + ('621188842', 2098, 4944, 3456985220123653,24961501), + ('621188843', 2099, 5142, 3456985220123654,17035634), + ('621188844', 2111, 7245, 3456985220123655,90231951), + ('621188846', 2110, 6590, 3456985220123656,72201537), + ('667680207', 2564, 4042, 34569832200759166,48401979), + ('667680315', 2565, 7143, 34569832200759372,32143252), + ('667680318', 2566, 6342, 34569832200759364,39597112), + ('667680413', 2567, 5580, 34569832200759356,32786992), + ('667680463', 2568, 0171, 34569832200759349,34240853), + ('667688217', 2569, 2500, 34569832200759331,5687589), + ('633603945', 2212, 7129, 34569832200759323,51554019), + ('622130186', 2213, 4826, 34569832200759307,19623551), + ('633973424', 2214, 8535, 34569832200759299,94619307), + ('633703828', 2215, 8628, 34569832200759281,22468012), + ('622025110', 2216, 2399, 34569832200759273,34602918), + ('622924867', 2217, 5665, 34569832200759265,26920216), + ('722409630', 2218, 5211, 34569832200759240,93750137), + ('623590529', 2219, 0493, 34569832200759208,47077088), + ('633243462', 2220, 6902, 34569832200759174,6421962), + ('633047286', 2221, 5592, 34569832200759182,32069439), + ('744716801', 2112, 9184, 34569832200759190,57049814), + ('655995021', 2131, 8896, 34569852202049093,19497356), + ('685522718', 2132, 1955, 34569852202049101,28519879), + ('674587213', 2994, 2006, 34569332200223743,62360135), + ('674587227', 2993, 9271, 34569332200223750,81628192), + ('674587229', 2993, 0900, 34569332200223768,91119071), + ('674587231', 2992, 5007, 34569332200223776,45826232), + ('674587234', 2991, 1378, 34569332200223784,91245744), + ('674587240', 2990, 0905, 34569332200223792,13083224), + ('674587245', 2989, 9059, 34569332200223800,15291807), + ('674587250', 2988, 8188, 34569332200223818,83017918), + ('674587254', 2987, 2962, 34569332200223826,92809271), + ('674587256', 2986, 0358, 34569332200223834,81067040), + ('674592713', 2570, 2537, 34569332200230672,82325850), + ('697832478', 2579, 0936, 34568732200494825,49658372), + ('697832176', 2571, 5944, 34568732200494742,19039461), + ('697832477', 2572, 5138, 34568732200494759,25712504), + ('697832178', 2573, 4597, 34568732200494767,66241760), + ('697832182', 2574, 9241, 34568732200494775,07342562), + ('697832196', 2575, 2995, 34568732200494783,53929026), + ('697832214', 2576, 7434, 34568732200494791,49698432), + ('697832230', 2577, 7004, 34568732200494809,21578612), + ('697832235', 2578, 9674, 34568732200494817,93090700), + ('673420375', 2599, 5430, 34562052300117259,35911412), + ('673420367', 2598, 8402, 34562052300117242,924654), + ('673420361', 2597, 5125, 34562052300117234,12027970), + ('673420355', 2596, 5069, 34562052300117226,34978149), + ('673420348', 2595, 8911, 34562052300117218,4228121), + ('673420346', 2594, 2461, 34562052300117200,67670772), + ('673420345', 2593, 2226, 34562052300117192,90586404), + ('673420306', 2592, 3355, 34562052300117184,97850017), + ('673420257', 2591, 9395, 34562052300117176,50713786), + ('673420231', 2590, 1378, 34562052300117168,50151763), + ('673420223', 2589, 9580, 34562052300117150,99534550), + ('673420216', 2588, 4955, 34562052300117143,317554), + ('673420203', 2587, 6742, 34562052300117135,69321531), + ('673420201', 2586, 1659, 34562052300117127,54720480), + ('673420199', 2585, 7823, 34562052300117119,22923796), + ('673420198', 2584, 1787, 34562052300117101,54414630), + ('673420168', 2583, 6334, 34562052300117093,50694894), + ('673420147', 2582, 8951, 34562052300117085,1402535), + ('673420125', 2581, 3068, 34562052300117077,86216200), + ('673420124', 2580, 9517, 34562052300117069,42504099), + ('600294609', 2715, 7474, 34569832304894588,55923317), + ('600084713', 2703, 8342, 34569832304894570,8392636), + ('600084732', 2704, 1625, 34569832304894513,75477452), + ('600084850', 2705, 9896, 34569832304894653,28589813), + ('600084951', 2706, 5520, 34569832304894661,75353012), + ('600084978', 2707, 2698, 34569832304894679,9005523), + ('600085403', 2708, 0837, 34569832304894646,77051152), + ('600085513', 2709, 3106, 34569832304894687,41571002), + ('600293916', 2712, 8990, 34569832304894620,95188676), + ('600294160', 2714, 6376, 34569832304894703,79879896), + ('671919529', 2975, 9184, 34569832304806236,7535392), + ('671919942', 2981, 0328, 34569832304806269,31052894), + ('671919530', 2976, 0344, 34569832304806251,89860304), + ('671919533', 2977, 0668, 34569832304806244,42921771), + ('671919535', 2978, 0105, 34569832304806277,31009417), + ('671919537', 2979, 0881, 34569832304806285,33479769), + ('671919540', 2980, 9874, 34569832304806293,14103929), + ('671919525', 2972, 2089, 34569832304806301,45903729), + ('671919527', 2973, 8206, 34569832304806368,1586035), + ('671919528', 2974, 2532, 34569832304806327,62310124), + ('673668717', 2836, 7973, 34562032301044223,15635496), + ('673668734', 2837, 4457, 34562032301044231,18313118), + ('673668738', 2824, 2911, 34562032301044249,30875583), + ('673668745', 2838, 7253, 34562032301044256,62754222), + ('673668796', 2839, 0068, 34562032301044264,15556829), + ('673668803', 2840, 2386, 34562032301044272,17572287), + ('673669591', 2850, 3833, 34562032301044280,34828896), + ('673668808', 2841, 3584, 34562032301044298,16234497), + ('673670102', 2851, 3554, 34562032301044306,23652625), + ('673670131', 2852, 4412, 34562032301044314,88611709), + ('673670135', 2827, 6058, 34562032301044322,53918579), + ('673670201', 2828, 8066, 34562032301044330,92369343), + ('673670225', 2829, 4592, 34562032301044348,24126635), + ('673670236', 2830, 2974, 34562032301044355,88608465), + ('673671485', 2849, 0349, 34562032301044363,44944874), + ('673461977', 2871, 1728, 34562032400157090,46975780), + ('673461975', 2870, 4734, 34562032400157082,69628432), + ('673461972', 2867, 6276, 34562032400157058,53338365), + ('673461979', 2872, 6043, 34562032400157108,36525197), + ('673461958', 2859, 3164, 34562032400156977,58947831), + ('673461957', 2857, 8685, 34562032400156969,15826386), + ('673461944', 2853, 1073, 34562032400156910,20452195), + ('673461974', 2869, 7121, 34562032400157074,32044645), + ('673461973', 2868, 8022, 34562032400157066,29282044), + ('673461971', 2866, 3089, 34562032400157041,66149978), + ('673461969', 2865, 7555, 34562032400157033,78391293), + ('673461960', 2860, 5203, 34562032400156985,37138232), + ('673461952', 2855, 6915, 34562032400156936,62724661), + ('673461949', 2854, 8706, 34562032400156928,5594345), + ('673461966', 2863, 2496, 34562032400157017,93450666), + ('673461968', 2864, 3703, 34562032400157025,23208841), + ('673461963', 2862, 9364, 34562032400157009,29712130), + ('673462719', 2873, 9387, 34562032400156951,50434348), + ('673461962', 2861, 8441, 34562032400156993,39686909), + ('673461956', 2826, 5392, 34562032400156944,5496107), + ('673465284', 2694, 1523, 34562032400171349,14554994), + ('673465282', 2692, 4645, 34562032400171323,24871187), + ('673465283', 2693, 5253, 34562032400171331,28303238), + ('673465841', 2696, 0849, 34562032400171257,21673222), + ('673465258', 2679, 4140, 34562032400171174,39793881), + ('673465263', 2680, 6922, 34562032400171182,12253261), + ('673465265', 2681, 9112, 34562032400171190,93894366), + ('673465267', 2682, 3259, 34562032400171208,2342189), + ('673465268', 2683, 8540, 34562032400171216,63886925), + ('673465285', 2695, 4167, 34562032400171356,79227618), + ('673465270', 2684, 4292, 34562032400171224,19216349), + ('673465272', 2685, 4007, 34562032400171232,14396903), + ('673465273', 2686, 6894, 34562032400171240,13569394), + ('673465274', 2687, 5268, 34562032400171265,59453667), + ('673465275', 2688, 0232, 34562032400171273,62324713), + ('673465276', 2689, 2720, 34562032400171281,65977200), + ('673465843', 2698, 4773, 34562032400171364,78387158), + ('673465842', 2697, 3729, 34562032400171315,94201789), + ('673465280', 2691, 0503, 34562032400171307,12298533), + ('673465279', 2690, 8239, 34562032400171299,76183877); -ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_simSupplier_FK - FOREIGN KEY (simSerialNumber) REFERENCES vn.simSupplier(sim) ON DELETE CASCADE ON UPDATE CASCADE; \ No newline at end of file +UPDATE vn.deviceProductionUser + SET simFk = NULL + WHERE id IN ( + SELECT dpu.id + FROM vn.deviceProductionUser dpu + LEFT JOIN vn.sim s ON s.id = dpu.simFk + WHERE s.id IS NULL + AND dpu.simFk IS NOT NULL + ); + +ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_sim_FK + FOREIGN KEY (simFk) REFERENCES vn.sim(id) ON DELETE RESTRICT ON UPDATE CASCADE; From d42ff075472a29c6c65f1c2462a3d1ecddae5e30 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Dec 2024 09:20:27 +0100 Subject: [PATCH 143/219] feat: refs #8174 Changed datatype incompatibility access --- .../11327-maroonOak/00-firstScript.sql | 332 +++++++++--------- 1 file changed, 167 insertions(+), 165 deletions(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index 7c9d8e6e8..570f393cf 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -1,183 +1,185 @@ CREATE TABLE IF NOT EXISTS `vn`.`sim` ( - `id` BIGINT UNSIGNED, + `code` VARCHAR(25) COMMENT 'No se ha puesto BIGINT por incompatibilidad con Access', `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), `ext` INT(4) NOT NULL, `pin` INT(4) NOT NULL, `puk` INT(15) NOT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -ALTER TABLE vn.deviceProductionUser CHANGE simSerialNumber simFk BIGINT unsigned DEFAULT NULL NULL; -ALTER TABLE vn.deviceProductionUser MODIFY COLUMN simFk BIGINT unsigned DEFAULT NULL NULL; +ALTER TABLE vn.deviceProductionUser CHANGE simSerialNumber simFk VARCHAR(25) DEFAULT NULL NULL; +ALTER TABLE vn.deviceProductionUser MODIFY COLUMN simFk VARCHAR(25) DEFAULT NULL NULL; -INSERT IGNORE INTO `vn`.`sim` (`line`, `ext`, `pin`, `id`, `puk`) VALUES - ('621188151', 2209, 1486, 3456985220092508,14213470), - ('621188152', 2210, 8765, 3456985220092509,99473093), - ('621188153', 2211, 3064, 3456985220092510,52967210), - ('621188759', 2081, 3700, 3456985220123637,56600999), - ('621188760', 2082, 3259, 345698522023638,87492404), - ('621188761', 2083, 2790, 3456985220123639,94009456), - ('621188762', 2084, 2480, 3456985220123644,1484999), - ('621188763', 2085, 6876, 3456985220123641,36577064), - ('621188766', 2086, 7775, 3456985220123642,80761698), - ('621188769', 2088, 4027, 3456985220123643,37921712), - ('621188771', 2089, 8797, 3456985220123640,63092540), - ('621188772', 2090, 8404, 3456985220123645,21014997), - ('621188773', 2091, 5481, 3456985220123646,16317277), - ('621188774', 2092, 9632, 3456985220123647,22235994), - ('621188775', 2093, 4654, 3456985220123648,28506486), - ('621188838', 2094, 1392, 3456985220123649,29498627), - ('621188839', 2095, 7774, 3456985220123650,46263490), - ('621188840', 2096, 7304, 3456985220123658,8212044), - ('621188841', 2097, 5569, 3456985220123652,81597658), - ('621188842', 2098, 4944, 3456985220123653,24961501), - ('621188843', 2099, 5142, 3456985220123654,17035634), - ('621188844', 2111, 7245, 3456985220123655,90231951), - ('621188846', 2110, 6590, 3456985220123656,72201537), - ('667680207', 2564, 4042, 34569832200759166,48401979), - ('667680315', 2565, 7143, 34569832200759372,32143252), - ('667680318', 2566, 6342, 34569832200759364,39597112), - ('667680413', 2567, 5580, 34569832200759356,32786992), - ('667680463', 2568, 0171, 34569832200759349,34240853), - ('667688217', 2569, 2500, 34569832200759331,5687589), - ('633603945', 2212, 7129, 34569832200759323,51554019), - ('622130186', 2213, 4826, 34569832200759307,19623551), - ('633973424', 2214, 8535, 34569832200759299,94619307), - ('633703828', 2215, 8628, 34569832200759281,22468012), - ('622025110', 2216, 2399, 34569832200759273,34602918), - ('622924867', 2217, 5665, 34569832200759265,26920216), - ('722409630', 2218, 5211, 34569832200759240,93750137), - ('623590529', 2219, 0493, 34569832200759208,47077088), - ('633243462', 2220, 6902, 34569832200759174,6421962), - ('633047286', 2221, 5592, 34569832200759182,32069439), - ('744716801', 2112, 9184, 34569832200759190,57049814), - ('655995021', 2131, 8896, 34569852202049093,19497356), - ('685522718', 2132, 1955, 34569852202049101,28519879), - ('674587213', 2994, 2006, 34569332200223743,62360135), - ('674587227', 2993, 9271, 34569332200223750,81628192), - ('674587229', 2993, 0900, 34569332200223768,91119071), - ('674587231', 2992, 5007, 34569332200223776,45826232), - ('674587234', 2991, 1378, 34569332200223784,91245744), - ('674587240', 2990, 0905, 34569332200223792,13083224), - ('674587245', 2989, 9059, 34569332200223800,15291807), - ('674587250', 2988, 8188, 34569332200223818,83017918), - ('674587254', 2987, 2962, 34569332200223826,92809271), - ('674587256', 2986, 0358, 34569332200223834,81067040), - ('674592713', 2570, 2537, 34569332200230672,82325850), - ('697832478', 2579, 0936, 34568732200494825,49658372), - ('697832176', 2571, 5944, 34568732200494742,19039461), - ('697832477', 2572, 5138, 34568732200494759,25712504), - ('697832178', 2573, 4597, 34568732200494767,66241760), - ('697832182', 2574, 9241, 34568732200494775,07342562), - ('697832196', 2575, 2995, 34568732200494783,53929026), - ('697832214', 2576, 7434, 34568732200494791,49698432), - ('697832230', 2577, 7004, 34568732200494809,21578612), - ('697832235', 2578, 9674, 34568732200494817,93090700), - ('673420375', 2599, 5430, 34562052300117259,35911412), - ('673420367', 2598, 8402, 34562052300117242,924654), - ('673420361', 2597, 5125, 34562052300117234,12027970), - ('673420355', 2596, 5069, 34562052300117226,34978149), - ('673420348', 2595, 8911, 34562052300117218,4228121), - ('673420346', 2594, 2461, 34562052300117200,67670772), - ('673420345', 2593, 2226, 34562052300117192,90586404), - ('673420306', 2592, 3355, 34562052300117184,97850017), - ('673420257', 2591, 9395, 34562052300117176,50713786), - ('673420231', 2590, 1378, 34562052300117168,50151763), - ('673420223', 2589, 9580, 34562052300117150,99534550), - ('673420216', 2588, 4955, 34562052300117143,317554), - ('673420203', 2587, 6742, 34562052300117135,69321531), - ('673420201', 2586, 1659, 34562052300117127,54720480), - ('673420199', 2585, 7823, 34562052300117119,22923796), - ('673420198', 2584, 1787, 34562052300117101,54414630), - ('673420168', 2583, 6334, 34562052300117093,50694894), - ('673420147', 2582, 8951, 34562052300117085,1402535), - ('673420125', 2581, 3068, 34562052300117077,86216200), - ('673420124', 2580, 9517, 34562052300117069,42504099), - ('600294609', 2715, 7474, 34569832304894588,55923317), - ('600084713', 2703, 8342, 34569832304894570,8392636), - ('600084732', 2704, 1625, 34569832304894513,75477452), - ('600084850', 2705, 9896, 34569832304894653,28589813), - ('600084951', 2706, 5520, 34569832304894661,75353012), - ('600084978', 2707, 2698, 34569832304894679,9005523), - ('600085403', 2708, 0837, 34569832304894646,77051152), - ('600085513', 2709, 3106, 34569832304894687,41571002), - ('600293916', 2712, 8990, 34569832304894620,95188676), - ('600294160', 2714, 6376, 34569832304894703,79879896), - ('671919529', 2975, 9184, 34569832304806236,7535392), - ('671919942', 2981, 0328, 34569832304806269,31052894), - ('671919530', 2976, 0344, 34569832304806251,89860304), - ('671919533', 2977, 0668, 34569832304806244,42921771), - ('671919535', 2978, 0105, 34569832304806277,31009417), - ('671919537', 2979, 0881, 34569832304806285,33479769), - ('671919540', 2980, 9874, 34569832304806293,14103929), - ('671919525', 2972, 2089, 34569832304806301,45903729), - ('671919527', 2973, 8206, 34569832304806368,1586035), - ('671919528', 2974, 2532, 34569832304806327,62310124), - ('673668717', 2836, 7973, 34562032301044223,15635496), - ('673668734', 2837, 4457, 34562032301044231,18313118), - ('673668738', 2824, 2911, 34562032301044249,30875583), - ('673668745', 2838, 7253, 34562032301044256,62754222), - ('673668796', 2839, 0068, 34562032301044264,15556829), - ('673668803', 2840, 2386, 34562032301044272,17572287), - ('673669591', 2850, 3833, 34562032301044280,34828896), - ('673668808', 2841, 3584, 34562032301044298,16234497), - ('673670102', 2851, 3554, 34562032301044306,23652625), - ('673670131', 2852, 4412, 34562032301044314,88611709), - ('673670135', 2827, 6058, 34562032301044322,53918579), - ('673670201', 2828, 8066, 34562032301044330,92369343), - ('673670225', 2829, 4592, 34562032301044348,24126635), - ('673670236', 2830, 2974, 34562032301044355,88608465), - ('673671485', 2849, 0349, 34562032301044363,44944874), - ('673461977', 2871, 1728, 34562032400157090,46975780), - ('673461975', 2870, 4734, 34562032400157082,69628432), - ('673461972', 2867, 6276, 34562032400157058,53338365), - ('673461979', 2872, 6043, 34562032400157108,36525197), - ('673461958', 2859, 3164, 34562032400156977,58947831), - ('673461957', 2857, 8685, 34562032400156969,15826386), - ('673461944', 2853, 1073, 34562032400156910,20452195), - ('673461974', 2869, 7121, 34562032400157074,32044645), - ('673461973', 2868, 8022, 34562032400157066,29282044), - ('673461971', 2866, 3089, 34562032400157041,66149978), - ('673461969', 2865, 7555, 34562032400157033,78391293), - ('673461960', 2860, 5203, 34562032400156985,37138232), - ('673461952', 2855, 6915, 34562032400156936,62724661), - ('673461949', 2854, 8706, 34562032400156928,5594345), - ('673461966', 2863, 2496, 34562032400157017,93450666), - ('673461968', 2864, 3703, 34562032400157025,23208841), - ('673461963', 2862, 9364, 34562032400157009,29712130), - ('673462719', 2873, 9387, 34562032400156951,50434348), - ('673461962', 2861, 8441, 34562032400156993,39686909), - ('673461956', 2826, 5392, 34562032400156944,5496107), - ('673465284', 2694, 1523, 34562032400171349,14554994), - ('673465282', 2692, 4645, 34562032400171323,24871187), - ('673465283', 2693, 5253, 34562032400171331,28303238), - ('673465841', 2696, 0849, 34562032400171257,21673222), - ('673465258', 2679, 4140, 34562032400171174,39793881), - ('673465263', 2680, 6922, 34562032400171182,12253261), - ('673465265', 2681, 9112, 34562032400171190,93894366), - ('673465267', 2682, 3259, 34562032400171208,2342189), - ('673465268', 2683, 8540, 34562032400171216,63886925), - ('673465285', 2695, 4167, 34562032400171356,79227618), - ('673465270', 2684, 4292, 34562032400171224,19216349), - ('673465272', 2685, 4007, 34562032400171232,14396903), - ('673465273', 2686, 6894, 34562032400171240,13569394), - ('673465274', 2687, 5268, 34562032400171265,59453667), - ('673465275', 2688, 0232, 34562032400171273,62324713), - ('673465276', 2689, 2720, 34562032400171281,65977200), - ('673465843', 2698, 4773, 34562032400171364,78387158), - ('673465842', 2697, 3729, 34562032400171315,94201789), - ('673465280', 2691, 0503, 34562032400171307,12298533), - ('673465279', 2690, 8239, 34562032400171299,76183877); +INSERT IGNORE INTO `vn`.`sim` (`line`, `ext`, `pin`, `code`, `puk`) VALUES + ('621188151', 2209, 1486, '3456985220092508',14213470), + ('621188152', 2210, 8765, '3456985220092509',99473093), + ('621188153', 2211, 3064, '3456985220092510',52967210), + ('621188759', 2081, 3700, '3456985220123637',56600999), + ('621188760', 2082, 3259, '345698522023638',87492404), + ('621188761', 2083, 2790, '3456985220123639',94009456), + ('621188762', 2084, 2480, '3456985220123644',1484999), + ('621188763', 2085, 6876, '3456985220123641',36577064), + ('621188766', 2086, 7775, '3456985220123642',80761698), + ('621188769', 2088, 4027, '3456985220123643',37921712), + ('621188771', 2089, 8797, '3456985220123640',63092540), + ('621188772', 2090, 8404, '3456985220123645',21014997), + ('621188773', 2091, 5481, '3456985220123646',16317277), + ('621188774', 2092, 9632, '3456985220123647',22235994), + ('621188775', 2093, 4654, '3456985220123648',28506486), + ('621188838', 2094, 1392, '3456985220123649',29498627), + ('621188839', 2095, 7774, '3456985220123650',46263490), + ('621188840', 2096, 7304, '3456985220123658',8212044), + ('621188841', 2097, 5569, '3456985220123652',81597658), + ('621188842', 2098, 4944, '3456985220123653',24961501), + ('621188843', 2099, 5142, '3456985220123654',17035634), + ('621188844', 2111, 7245, '3456985220123655',90231951), + ('621188846', 2110, 6590, '3456985220123656',72201537), + ('667680207', 2564, 4042, '34569832200759166',48401979), + ('667680315', 2565, 7143, '34569832200759372',32143252), + ('667680318', 2566, 6342, '34569832200759364',39597112), + ('667680413', 2567, 5580, '34569832200759356',32786992), + ('667680463', 2568, 0171, '34569832200759349',34240853), + ('667688217', 2569, 2500, '34569832200759331',5687589), + ('633603945', 2212, 7129, '34569832200759323',51554019), + ('622130186', 2213, 4826, '34569832200759307',19623551), + ('633973424', 2214, 8535, '34569832200759299',94619307), + ('633703828', 2215, 8628, '34569832200759281',22468012), + ('622025110', 2216, 2399, '34569832200759273',34602918), + ('622924867', 2217, 5665, '34569832200759265',26920216), + ('722409630', 2218, 5211, '34569832200759240',93750137), + ('623590529', 2219, 0493, '34569832200759208',47077088), + ('633243462', 2220, 6902, '34569832200759174',6421962), + ('633047286', 2221, 5592, '34569832200759182',32069439), + ('744716801', 2112, 9184, '34569832200759190',57049814), + ('655995021', 2131, 8896, '34569852202049093',19497356), + ('685522718', 2132, 1955, '34569852202049101',28519879), + ('674587213', 2994, 2006, '34569332200223743',62360135), + ('674587227', 2993, 9271, '34569332200223750',81628192), + ('674587229', 2993, 0900, '34569332200223768',91119071), + ('674587231', 2992, 5007, '34569332200223776',45826232), + ('674587234', 2991, 1378, '34569332200223784',91245744), + ('674587240', 2990, 0905, '34569332200223792',13083224), + ('674587245', 2989, 9059, '34569332200223800',15291807), + ('674587250', 2988, 8188, '34569332200223818',83017918), + ('674587254', 2987, 2962, '34569332200223826',92809271), + ('674587256', 2986, 0358, '34569332200223834',81067040), + ('674592713', 2570, 2537, '34569332200230672',82325850), + ('697832478', 2579, 0936, '34568732200494825',49658372), + ('697832176', 2571, 5944, '34568732200494742',19039461), + ('697832477', 2572, 5138, '34568732200494759',25712504), + ('697832178', 2573, 4597, '34568732200494767',66241760), + ('697832182', 2574, 9241, '34568732200494775',07342562), + ('697832196', 2575, 2995, '34568732200494783',53929026), + ('697832214', 2576, 7434, '34568732200494791',49698432), + ('697832230', 2577, 7004, '34568732200494809',21578612), + ('697832235', 2578, 9674, '34568732200494817',93090700), + ('673420375', 2599, 5430, '34562052300117259',35911412), + ('673420367', 2598, 8402, '34562052300117242',924654), + ('673420361', 2597, 5125, '34562052300117234',12027970), + ('673420355', 2596, 5069, '34562052300117226',34978149), + ('673420348', 2595, 8911, '34562052300117218',4228121), + ('673420346', 2594, 2461, '34562052300117200',67670772), + ('673420345', 2593, 2226, '34562052300117192',90586404), + ('673420306', 2592, 3355, '34562052300117184',97850017), + ('673420257', 2591, 9395, '34562052300117176',50713786), + ('673420231', 2590, 1378, '34562052300117168',50151763), + ('673420223', 2589, 9580, '34562052300117150',99534550), + ('673420216', 2588, 4955, '34562052300117143',317554), + ('673420203', 2587, 6742, '34562052300117135',69321531), + ('673420201', 2586, 1659, '34562052300117127',54720480), + ('673420199', 2585, 7823, '34562052300117119',22923796), + ('673420198', 2584, 1787, '34562052300117101',54414630), + ('673420168', 2583, 6334, '34562052300117093',50694894), + ('673420147', 2582, 8951, '34562052300117085',1402535), + ('673420125', 2581, 3068, '34562052300117077',86216200), + ('673420124', 2580, 9517, '34562052300117069',42504099), + ('600294609', 2715, 7474, '34569832304894588',55923317), + ('600084713', 2703, 8342, '34569832304894570',8392636), + ('600084732', 2704, 1625, '34569832304894513',75477452), + ('600084850', 2705, 9896, '34569832304894653',28589813), + ('600084951', 2706, 5520, '34569832304894661',75353012), + ('600084978', 2707, 2698, '34569832304894679',9005523), + ('600085403', 2708, 0837, '34569832304894646',77051152), + ('600085513', 2709, 3106, '34569832304894687',41571002), + ('600293916', 2712, 8990, '34569832304894620',95188676), + ('600294160', 2714, 6376, '34569832304894703',79879896), + ('671919529', 2975, 9184, '34569832304806236',7535392), + ('671919942', 2981, 0328, '34569832304806269',31052894), + ('671919530', 2976, 0344, '34569832304806251',89860304), + ('671919533', 2977, 0668, '34569832304806244',42921771), + ('671919535', 2978, 0105, '34569832304806277',31009417), + ('671919537', 2979, 0881, '34569832304806285',33479769), + ('671919540', 2980, 9874, '34569832304806293',14103929), + ('671919525', 2972, 2089, '34569832304806301',45903729), + ('671919527', 2973, 8206, '34569832304806368',1586035), + ('671919528', 2974, 2532, '34569832304806327',62310124), + ('673668717', 2836, 7973, '34562032301044223',15635496), + ('673668734', 2837, 4457, '34562032301044231',18313118), + ('673668738', 2824, 2911, '34562032301044249',30875583), + ('673668745', 2838, 7253, '34562032301044256',62754222), + ('673668796', 2839, 0068, '34562032301044264',15556829), + ('673668803', 2840, 2386, '34562032301044272',17572287), + ('673669591', 2850, 3833, '34562032301044280',34828896), + ('673668808', 2841, 3584, '34562032301044298',16234497), + ('673670102', 2851, 3554, '34562032301044306',23652625), + ('673670131', 2852, 4412, '34562032301044314',88611709), + ('673670135', 2827, 6058, '34562032301044322',53918579), + ('673670201', 2828, 8066, '34562032301044330',92369343), + ('673670225', 2829, 4592, '34562032301044348',24126635), + ('673670236', 2830, 2974, '34562032301044355',88608465), + ('673671485', 2849, 0349, '34562032301044363',44944874), + ('673461977', 2871, 1728, '34562032400157090',46975780), + ('673461975', 2870, 4734, '34562032400157082',69628432), + ('673461972', 2867, 6276, '34562032400157058',53338365), + ('673461979', 2872, 6043, '34562032400157108',36525197), + ('673461958', 2859, 3164, '34562032400156977',58947831), + ('673461957', 2857, 8685, '34562032400156969',15826386), + ('673461944', 2853, 1073, '34562032400156910',20452195), + ('673461974', 2869, 7121, '34562032400157074',32044645), + ('673461973', 2868, 8022, '34562032400157066',29282044), + ('673461971', 2866, 3089, '34562032400157041',66149978), + ('673461969', 2865, 7555, '34562032400157033',78391293), + ('673461960', 2860, 5203, '34562032400156985',37138232), + ('673461952', 2855, 6915, '34562032400156936',62724661), + ('673461949', 2854, 8706, '34562032400156928',5594345), + ('673461966', 2863, 2496, '34562032400157017',93450666), + ('673461968', 2864, 3703, '34562032400157025',23208841), + ('673461963', 2862, 9364, '34562032400157009',29712130), + ('673462719', 2873, 9387, '34562032400156951',50434348), + ('673461962', 2861, 8441, '34562032400156993',39686909), + ('673461956', 2826, 5392, '34562032400156944',5496107), + ('673465284', 2694, 1523, '34562032400171349',14554994), + ('673465282', 2692, 4645, '34562032400171323',24871187), + ('673465283', 2693, 5253, '34562032400171331',28303238), + ('673465841', 2696, 0849, '34562032400171257',21673222), + ('673465258', 2679, 4140, '34562032400171174',39793881), + ('673465263', 2680, 6922, '34562032400171182',12253261), + ('673465265', 2681, 9112, '34562032400171190',93894366), + ('673465267', 2682, 3259, '34562032400171208',2342189), + ('673465268', 2683, 8540, '34562032400171216',63886925), + ('673465285', 2695, 4167, '34562032400171356',79227618), + ('673465270', 2684, 4292, '34562032400171224',19216349), + ('673465272', 2685, 4007, '34562032400171232',14396903), + ('673465273', 2686, 6894, '34562032400171240',13569394), + ('673465274', 2687, 5268, '34562032400171265',59453667), + ('673465275', 2688, 0232, '34562032400171273',62324713), + ('673465276', 2689, 2720, '34562032400171281',65977200), + ('673465843', 2698, 4773, '34562032400171364',78387158), + ('673465842', 2697, 3729, '34562032400171315',94201789), + ('673465280', 2691, 0503, '34562032400171307',12298533), + ('673465279', 2690, 8239, '34562032400171299',76183877); UPDATE vn.deviceProductionUser SET simFk = NULL WHERE id IN ( SELECT dpu.id FROM vn.deviceProductionUser dpu - LEFT JOIN vn.sim s ON s.id = dpu.simFk - WHERE s.id IS NULL + LEFT JOIN vn.sim s ON s.code = dpu.simFk + WHERE s.code IS NULL AND dpu.simFk IS NOT NULL ); ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_sim_FK - FOREIGN KEY (simFk) REFERENCES vn.sim(id) ON DELETE RESTRICT ON UPDATE CASCADE; + FOREIGN KEY (simFk) REFERENCES vn.sim(code) ON DELETE RESTRICT ON UPDATE CASCADE; + +GRANT SELECT, INSERT, DELETE, UPDATE ON TABLE vn.sim TO hr; From d9a6e8a1c98744b9e69d00da5caa612962c079b1 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Dec 2024 09:34:45 +0100 Subject: [PATCH 144/219] refactor: refs #7882 Added ACL's --- db/dump/fixtures.before.sql | 2 +- db/versions/11379-yellowCordyline/01-secScript.sql | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 db/versions/11379-yellowCordyline/01-secScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index c108bc0f6..57a9f9ca8 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4038,7 +4038,7 @@ INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) INSERT INTO vn.workerIrpf (workerFk,spouseNif, geographicMobilityDate) VALUES (1106,'26493101E','2019-09-20'); -INSERT INTO vn.osrmConfig (id,url,tolerance) +INSERT IGNORE INTO vn.osrmConfig (id,url,tolerance) VALUES (1,'https://router.project-osrm.org', 0.002); INSERT IGNORE INTO vn.inventoryConfig diff --git a/db/versions/11379-yellowCordyline/01-secScript.sql b/db/versions/11379-yellowCordyline/01-secScript.sql new file mode 100644 index 000000000..bfeb04477 --- /dev/null +++ b/db/versions/11379-yellowCordyline/01-secScript.sql @@ -0,0 +1,5 @@ +INSERT IGNORE INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('OsrmConfig','optimize','READ','ALLOW','ROLE','employee'), + ('Route',' optimizePriority','*','ALLOW','ROLE','employee'); +INSERT IGNORE INTO vn.osrmConfig (id,url,tolerance) + VALUES (1,'https://router.project-osrm.org', 0.002); From d9eab361600ab1eddcd1f02576bebef0932146b3 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 16 Dec 2024 09:35:41 +0100 Subject: [PATCH 145/219] fix: refs #7936 conflicts --- db/routines/sage/procedures/invoiceIn_add.sql | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/db/routines/sage/procedures/invoiceIn_add.sql b/db/routines/sage/procedures/invoiceIn_add.sql index eeeb28143..8fdbb9ce3 100644 --- a/db/routines/sage/procedures/invoiceIn_add.sql +++ b/db/routines/sage/procedures/invoiceIn_add.sql @@ -25,7 +25,7 @@ BEGIN DECLARE vIsInformativeExportation BOOL DEFAULT FALSE; DECLARE vCursor CURSOR FOR - SELECT it.taxableBase, + SELECT SUM(it.taxableBase), CAST(SUM((( it.taxableBase / 100) * t.PorcentajeIva)) AS DECIMAL (10,2)), t.PorcentajeIva, it.transactionTypeSageFk, @@ -204,25 +204,25 @@ BEGIN FROM vn.invoiceInCorrection WHERE correctingFk = vInvoiceInFk; - IF vInvoiceInOriginalFk THEN + IF vInvoiceInOriginalFk THEN UPDATE movContaIVA mci JOIN vn.invoiceInCorrection iic ON iic.correctingFk = vInvoiceInFk JOIN vn.siiTypeInvoiceIn st ON st.id = iic.siiTypeInvoiceInFk JOIN (SELECT issued, - SUM(sub.taxableBase) taxableBase, + SUM(sub.taxableBase) taxableBase, SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat FROM(SELECT issued, - SUM(iit.taxableBase) taxableBase, + SUM(iit.taxableBase) taxableBase, ti.PorcentajeIva - FROM vn.invoiceIn i + FROM vn.invoiceIn i JOIN vn.invoiceInTax iit ON iit.invoiceInFk = i.id JOIN TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk WHERE i.id = vInvoiceInOriginalFk GROUP BY ti.CodigoIva)sub )invoiceInOriginal JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa' - SET mci.TipoRectificativa = iic.cplusRectificationTypeFk, - mci.ClaseAbonoRectificativas = REGEXP_REPLACE(st.`code`, '[^0-9]', ''), + SET mci.TipoRectificativa = iir.refundCategoryFk, + mci.ClaseAbonoRectificativas = iir.refundType, mci.FechaFacturaOriginal = invoiceInOriginal.issued, mci.FechaOperacion = invoiceInOriginal.issued, mci.BaseImponibleOriginal = invoiceInOriginal.taxableBase, @@ -231,5 +231,4 @@ BEGIN WHERE mci.id = vXDiarioFk; END IF; END$$ -$$ -DELIMITER ; \ No newline at end of file +DELIMITER ; From 71fb3996cdc5fe4675c17a6ea3c092fcf8819861 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Dec 2024 09:40:55 +0100 Subject: [PATCH 146/219] refactor: refs #7882 Added ACL's --- db/versions/11379-yellowCordyline/01-secScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11379-yellowCordyline/01-secScript.sql b/db/versions/11379-yellowCordyline/01-secScript.sql index bfeb04477..30479229e 100644 --- a/db/versions/11379-yellowCordyline/01-secScript.sql +++ b/db/versions/11379-yellowCordyline/01-secScript.sql @@ -1,5 +1,5 @@ INSERT IGNORE INTO salix.ACL (model,property,accessType,permission,principalType,principalId) VALUES ('OsrmConfig','optimize','READ','ALLOW','ROLE','employee'), - ('Route',' optimizePriority','*','ALLOW','ROLE','employee'); + ('Route', 'optimizePriority','*','ALLOW','ROLE','employee'); INSERT IGNORE INTO vn.osrmConfig (id,url,tolerance) VALUES (1,'https://router.project-osrm.org', 0.002); From 32d9a3ace1a2b5a96ec5c74ecdce576a583bd8e3 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 16 Dec 2024 09:57:48 +0100 Subject: [PATCH 147/219] fix: refs #7028 remove ifs --- loopback/locale/es.json | 5 +---- modules/ticket/back/methods/ticket-request/deny.js | 4 ---- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 73efce216..a47195d07 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -398,8 +398,5 @@ "An item type with the same code already exists": "Un tipo con el mismo código ya existe", "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", "All tickets have a route order": "Todos los tickets tienen orden de ruta", - "Price cannot be blank": "Price cannot be blank", - "Worker not found": "Trabajador no encontrado", - "Invalid request or related ticket/client data": "Solicitud no válida o datos de ticket/cliente relacionados" - + "Price cannot be blank": "Price cannot be blank" } diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index c6a1d35af..b96d8a244 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -44,7 +44,6 @@ module.exports = Self => { try { const userId = ctx.req.accessToken.userId; const worker = await models.Worker.findById(userId, myOptions); - if (!worker) throw new UserError('Worker not found'); const params = { isOk: false, @@ -66,9 +65,6 @@ module.exports = Self => { } }, myOptions); - if (!request || !request.ticket() || !request.ticket().client()) - throw new UserError('Invalid request or related ticket/client data'); - const url = await models.Url.getUrl(); const requesterId = request.ticket().client().salesPersonFk; const message = $t('Deny buy request', { From 1e471ac20f146e76405309017f609717c8cca44a Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 16 Dec 2024 10:25:33 +0100 Subject: [PATCH 148/219] fix: refs #7028 requesterId fix --- .../back/methods/ticket-request/confirm.js | 23 ++++++++++--------- .../back/methods/ticket-request/deny.js | 18 ++++++++------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/modules/ticket/back/methods/ticket-request/confirm.js b/modules/ticket/back/methods/ticket-request/confirm.js index 56ee14a73..ab4d39d51 100644 --- a/modules/ticket/back/methods/ticket-request/confirm.js +++ b/modules/ticket/back/methods/ticket-request/confirm.js @@ -97,18 +97,19 @@ module.exports = Self => { const query = `CALL vn.sale_calculateComponent(?, NULL)`; await Self.rawSql(query, [sale.id], myOptions); - const url = await Self.app.models.Url.getUrl(); const requesterId = request.ticket().client().salesPersonFk; - const message = $t('Bought units from buy request', { - quantity: sale.quantity, - concept: sale.concept, - itemId: sale.itemFk, - ticketId: sale.ticketFk, - url: `${url}ticket/${sale.ticketFk}/summary`, - urlItem: `${url}item/${sale.itemFk}/summary` - }); - await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); - + if (requesterId) { + const url = await Self.app.models.Url.getUrl(); + const message = $t('Bought units from buy request', { + quantity: sale.quantity, + concept: sale.concept, + itemId: sale.itemFk, + ticketId: sale.ticketFk, + url: `${url}ticket/${sale.ticketFk}/summary`, + urlItem: `${url}item/${sale.itemFk}/summary` + }); + await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); + } if (tx) await tx.commit(); return sale; diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index b96d8a244..5c9f87dde 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -65,16 +65,18 @@ module.exports = Self => { } }, myOptions); - const url = await models.Url.getUrl(); const requesterId = request.ticket().client().salesPersonFk; - const message = $t('Deny buy request', { - ticketId: request.ticketFk, - url: `${url}ticket/${request.ticketFk}/request/index`, - observation: params.response - }); + if (requesterId) { + const url = await models.Url.getUrl(); + const message = $t('Deny buy request', { + ticketId: request.ticketFk, + url: `${url}ticket/${request.ticketFk}/request/index`, + observation: params.response + }); - await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); - await request.updateAttributes(params, myOptions); + await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); + await request.updateAttributes(params, myOptions); + } if (tx) await tx.commit(); From 36705a028edda6324e318fec95ccee74eec00553 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Dec 2024 11:33:18 +0100 Subject: [PATCH 149/219] fix: refs #8174 Version --- modules/worker/back/models/device-production-user.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/worker/back/models/device-production-user.json b/modules/worker/back/models/device-production-user.json index a024cc94c..31aaf92d4 100644 --- a/modules/worker/back/models/device-production-user.json +++ b/modules/worker/back/models/device-production-user.json @@ -25,7 +25,7 @@ "userFk": { "type": "number" }, - "simSerialNumber": { + "simFk": { "type": "string" }, "created": { From 5346dd845e39e239b78efe38e76c5cea1258489a Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Dec 2024 11:40:57 +0100 Subject: [PATCH 150/219] feat: refs #8218 Added time and code in mistakeType --- db/versions/11384-grayAnthurium/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/versions/11384-grayAnthurium/00-firstScript.sql diff --git a/db/versions/11384-grayAnthurium/00-firstScript.sql b/db/versions/11384-grayAnthurium/00-firstScript.sql new file mode 100644 index 000000000..b3a7f3da2 --- /dev/null +++ b/db/versions/11384-grayAnthurium/00-firstScript.sql @@ -0,0 +1,3 @@ +ALTER TABLE vn.mistakeType + ADD `time` int(10) NULL COMMENT 'Segundos que se suelen tardar en arreglar el fallo', + ADD code varchar(50) DEFAULT NULL NULL AFTER id; From 576641d09d05ef4a9848db4c3137690930b44150 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 16 Dec 2024 11:55:01 +0100 Subject: [PATCH 151/219] fix: refs #7028 requesterId fix --- modules/ticket/back/methods/ticket-request/deny.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index 5c9f87dde..686b9d1de 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -43,7 +43,7 @@ module.exports = Self => { try { const userId = ctx.req.accessToken.userId; - const worker = await models.Worker.findById(userId, myOptions); + const worker = await models.Worker.findById(userId, {fields: ['id']}, myOptions); const params = { isOk: false, From 5f43c0440c0e0710497624993915b0ce63dec196 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 16 Dec 2024 11:58:21 +0100 Subject: [PATCH 152/219] fix: refs #7028 requesterId fix salesPerson --- modules/ticket/back/methods/ticket-request/confirm.js | 6 +++--- modules/ticket/back/methods/ticket-request/deny.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/ticket/back/methods/ticket-request/confirm.js b/modules/ticket/back/methods/ticket-request/confirm.js index ab4d39d51..45ee287de 100644 --- a/modules/ticket/back/methods/ticket-request/confirm.js +++ b/modules/ticket/back/methods/ticket-request/confirm.js @@ -97,8 +97,8 @@ module.exports = Self => { const query = `CALL vn.sale_calculateComponent(?, NULL)`; await Self.rawSql(query, [sale.id], myOptions); - const requesterId = request.ticket().client().salesPersonFk; - if (requesterId) { + const salesPerson = request.ticket().client().salesPersonFk; + if (salesPerson) { const url = await Self.app.models.Url.getUrl(); const message = $t('Bought units from buy request', { quantity: sale.quantity, @@ -108,7 +108,7 @@ module.exports = Self => { url: `${url}ticket/${sale.ticketFk}/summary`, urlItem: `${url}item/${sale.itemFk}/summary` }); - await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); + await models.Chat.sendCheckingPresence(ctx, salesPerson, message, myOptions); } if (tx) await tx.commit(); diff --git a/modules/ticket/back/methods/ticket-request/deny.js b/modules/ticket/back/methods/ticket-request/deny.js index 686b9d1de..26e6f63ff 100644 --- a/modules/ticket/back/methods/ticket-request/deny.js +++ b/modules/ticket/back/methods/ticket-request/deny.js @@ -65,8 +65,8 @@ module.exports = Self => { } }, myOptions); - const requesterId = request.ticket().client().salesPersonFk; - if (requesterId) { + const salesPerson = request.ticket().client().salesPersonFk; + if (salesPerson) { const url = await models.Url.getUrl(); const message = $t('Deny buy request', { ticketId: request.ticketFk, @@ -74,7 +74,7 @@ module.exports = Self => { observation: params.response }); - await models.Chat.sendCheckingPresence(ctx, requesterId, message, myOptions); + await models.Chat.sendCheckingPresence(ctx, salesPerson, message, myOptions); await request.updateAttributes(params, myOptions); } From fda2c5725a6f4fc6e9dcda5760272d0bfc17ceb4 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Dec 2024 12:23:02 +0100 Subject: [PATCH 153/219] refactor: refs #8262 Deprecated inventoryFailure --- .../vn/procedures/inventoryFailureAdd.sql | 48 ------------------- .../vn/procedures/item_cleanFloramondo.sql | 4 -- .../11385-yellowOrchid/00-firstScript.sql | 5 ++ 3 files changed, 5 insertions(+), 52 deletions(-) delete mode 100644 db/routines/vn/procedures/inventoryFailureAdd.sql create mode 100644 db/versions/11385-yellowOrchid/00-firstScript.sql diff --git a/db/routines/vn/procedures/inventoryFailureAdd.sql b/db/routines/vn/procedures/inventoryFailureAdd.sql deleted file mode 100644 index e2b5fa4a0..000000000 --- a/db/routines/vn/procedures/inventoryFailureAdd.sql +++ /dev/null @@ -1,48 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`inventoryFailureAdd`() -BEGIN - -DECLARE done BOOL DEFAULT FALSE; -DECLARE vTicketFk INT; - -DECLARE rs CURSOR FOR - SELECT id FROM vn.ticket - WHERE shipped = util.yesterday() - AND clientFk = 400 - AND warehouseFk IN (1,44); - -DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - -OPEN rs; - -FETCH rs INTO vTicketFk; - -WHILE NOT done DO - - INSERT INTO vn.inventoryFailure(dated, itemFk, quantity, value, warehouseFk, throwerFk) - SELECT t.shipped, - s.itemFk, - s.quantity, - b.buyingValue + b.freightValue + b.packageValue + b.comissionValue, - t.warehouseFk, - w.id - FROM vn.ticket t - JOIN vn.sale s ON s.ticketFk = t.id - LEFT JOIN cache.last_buy lb ON lb.warehouse_id = t.warehouseFk AND item_id = s.itemFk - LEFT JOIN vn.buy b ON b.id = lb.buy_id - LEFT JOIN vn.worker w ON w.code = LEFT(s.concept, 3) - WHERE t.id = vTicketFk - AND s.quantity > 0; - - FETCH rs INTO vTicketFk; - -END WHILE; - - -CLOSE rs; - - - - -END$$ -DELIMITER ; diff --git a/db/routines/vn/procedures/item_cleanFloramondo.sql b/db/routines/vn/procedures/item_cleanFloramondo.sql index 849cfe93d..21d8ebe3c 100644 --- a/db/routines/vn/procedures/item_cleanFloramondo.sql +++ b/db/routines/vn/procedures/item_cleanFloramondo.sql @@ -164,10 +164,6 @@ BEGIN SET itemFk = vItemNew WHERE itemFk = vItemOld; - UPDATE inventoryFailure - SET itemFk = vItemNew - WHERE itemFk = vItemOld; - UPDATE genericAllocation SET itemFk = vItemNew WHERE itemFk = vItemOld; diff --git a/db/versions/11385-yellowOrchid/00-firstScript.sql b/db/versions/11385-yellowOrchid/00-firstScript.sql new file mode 100644 index 000000000..287e9fcab --- /dev/null +++ b/db/versions/11385-yellowOrchid/00-firstScript.sql @@ -0,0 +1,5 @@ +RENAME TABLE vn.inventoryFailure TO vn.inventoryFailure__; +ALTER TABLE vn.inventoryFailure__ COMMENT='@deprecated 2024-12-16'; + +RENAME TABLE vn.inventoryFailureCause TO vn.inventoryFailureCause__; +ALTER TABLE vn.inventoryFailureCause__ COMMENT='@deprecated 2024-12-16'; From d03a2ced04e151daba34e59338098a7c63b9a7d2 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 16 Dec 2024 12:30:35 +0100 Subject: [PATCH 154/219] fix: refs8174 pasar a char el PIN --- db/versions/11386-turquoiseTulip/00-firstScript.sql | 1 + 1 file changed, 1 insertion(+) create mode 100644 db/versions/11386-turquoiseTulip/00-firstScript.sql diff --git a/db/versions/11386-turquoiseTulip/00-firstScript.sql b/db/versions/11386-turquoiseTulip/00-firstScript.sql new file mode 100644 index 000000000..0dc1c8e82 --- /dev/null +++ b/db/versions/11386-turquoiseTulip/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.sim MODIFY COLUMN pin char(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'); From 7232bfb7a6ce26edd33fbaee8f3f67f44967ecca Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 16 Dec 2024 12:42:08 +0100 Subject: [PATCH 155/219] fix: 8174 pasar PIN a CHAR --- db/versions/11327-maroonOak/00-firstScript.sql | 2 +- db/versions/11386-turquoiseTulip/00-firstScript.sql | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 db/versions/11386-turquoiseTulip/00-firstScript.sql diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index 570f393cf..a68cf7e6a 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`sim` ( `code` VARCHAR(25) COMMENT 'No se ha puesto BIGINT por incompatibilidad con Access', `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), `ext` INT(4) NOT NULL, - `pin` INT(4) NOT NULL, + `pin` INT(4) NOT NULL (`pin` REGEXP '^[0-9]+$') `puk` INT(15) NOT NULL, PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; diff --git a/db/versions/11386-turquoiseTulip/00-firstScript.sql b/db/versions/11386-turquoiseTulip/00-firstScript.sql deleted file mode 100644 index 0dc1c8e82..000000000 --- a/db/versions/11386-turquoiseTulip/00-firstScript.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE vn.sim MODIFY COLUMN pin char(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'); From deb1b68c49319257fbb4ff928a35d11421240c3c Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 16 Dec 2024 12:47:47 +0100 Subject: [PATCH 156/219] fix: refs#8174 fix --- db/versions/11327-maroonOak/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index a68cf7e6a..b17d12dfc 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`sim` ( `code` VARCHAR(25) COMMENT 'No se ha puesto BIGINT por incompatibilidad con Access', `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), `ext` INT(4) NOT NULL, - `pin` INT(4) NOT NULL (`pin` REGEXP '^[0-9]+$') + `pin` INT(4) NOT NULL (`pin` REGEXP '^[0-9]+$'), `puk` INT(15) NOT NULL, PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; From 11db90c67c3d099de6f6c0e90ae0578e3e19a7fe Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 16 Dec 2024 12:48:43 +0100 Subject: [PATCH 157/219] fix: refs#8174 fix --- db/versions/11327-maroonOak/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index b17d12dfc..68ab19e05 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`sim` ( `code` VARCHAR(25) COMMENT 'No se ha puesto BIGINT por incompatibilidad con Access', `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), `ext` INT(4) NOT NULL, - `pin` INT(4) NOT NULL (`pin` REGEXP '^[0-9]+$'), + `pin` INT(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), `puk` INT(15) NOT NULL, PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; From de69a8db1d52b55abb12e1d8fd6240a92602e0f7 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 16 Dec 2024 13:01:00 +0100 Subject: [PATCH 158/219] fix: refs#8174 fix --- .../11327-maroonOak/00-firstScript.sql | 316 +++++++++--------- 1 file changed, 158 insertions(+), 158 deletions(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index 68ab19e05..81a36ee26 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`sim` ( `code` VARCHAR(25) COMMENT 'No se ha puesto BIGINT por incompatibilidad con Access', `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), `ext` INT(4) NOT NULL, - `pin` INT(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), + `pin` CHAR(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), `puk` INT(15) NOT NULL, PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -11,163 +11,163 @@ ALTER TABLE vn.deviceProductionUser CHANGE simSerialNumber simFk VARCHAR(25) DEF ALTER TABLE vn.deviceProductionUser MODIFY COLUMN simFk VARCHAR(25) DEFAULT NULL NULL; INSERT IGNORE INTO `vn`.`sim` (`line`, `ext`, `pin`, `code`, `puk`) VALUES - ('621188151', 2209, 1486, '3456985220092508',14213470), - ('621188152', 2210, 8765, '3456985220092509',99473093), - ('621188153', 2211, 3064, '3456985220092510',52967210), - ('621188759', 2081, 3700, '3456985220123637',56600999), - ('621188760', 2082, 3259, '345698522023638',87492404), - ('621188761', 2083, 2790, '3456985220123639',94009456), - ('621188762', 2084, 2480, '3456985220123644',1484999), - ('621188763', 2085, 6876, '3456985220123641',36577064), - ('621188766', 2086, 7775, '3456985220123642',80761698), - ('621188769', 2088, 4027, '3456985220123643',37921712), - ('621188771', 2089, 8797, '3456985220123640',63092540), - ('621188772', 2090, 8404, '3456985220123645',21014997), - ('621188773', 2091, 5481, '3456985220123646',16317277), - ('621188774', 2092, 9632, '3456985220123647',22235994), - ('621188775', 2093, 4654, '3456985220123648',28506486), - ('621188838', 2094, 1392, '3456985220123649',29498627), - ('621188839', 2095, 7774, '3456985220123650',46263490), - ('621188840', 2096, 7304, '3456985220123658',8212044), - ('621188841', 2097, 5569, '3456985220123652',81597658), - ('621188842', 2098, 4944, '3456985220123653',24961501), - ('621188843', 2099, 5142, '3456985220123654',17035634), - ('621188844', 2111, 7245, '3456985220123655',90231951), - ('621188846', 2110, 6590, '3456985220123656',72201537), - ('667680207', 2564, 4042, '34569832200759166',48401979), - ('667680315', 2565, 7143, '34569832200759372',32143252), - ('667680318', 2566, 6342, '34569832200759364',39597112), - ('667680413', 2567, 5580, '34569832200759356',32786992), - ('667680463', 2568, 0171, '34569832200759349',34240853), - ('667688217', 2569, 2500, '34569832200759331',5687589), - ('633603945', 2212, 7129, '34569832200759323',51554019), - ('622130186', 2213, 4826, '34569832200759307',19623551), - ('633973424', 2214, 8535, '34569832200759299',94619307), - ('633703828', 2215, 8628, '34569832200759281',22468012), - ('622025110', 2216, 2399, '34569832200759273',34602918), - ('622924867', 2217, 5665, '34569832200759265',26920216), - ('722409630', 2218, 5211, '34569832200759240',93750137), - ('623590529', 2219, 0493, '34569832200759208',47077088), - ('633243462', 2220, 6902, '34569832200759174',6421962), - ('633047286', 2221, 5592, '34569832200759182',32069439), - ('744716801', 2112, 9184, '34569832200759190',57049814), - ('655995021', 2131, 8896, '34569852202049093',19497356), - ('685522718', 2132, 1955, '34569852202049101',28519879), - ('674587213', 2994, 2006, '34569332200223743',62360135), - ('674587227', 2993, 9271, '34569332200223750',81628192), - ('674587229', 2993, 0900, '34569332200223768',91119071), - ('674587231', 2992, 5007, '34569332200223776',45826232), - ('674587234', 2991, 1378, '34569332200223784',91245744), - ('674587240', 2990, 0905, '34569332200223792',13083224), - ('674587245', 2989, 9059, '34569332200223800',15291807), - ('674587250', 2988, 8188, '34569332200223818',83017918), - ('674587254', 2987, 2962, '34569332200223826',92809271), - ('674587256', 2986, 0358, '34569332200223834',81067040), - ('674592713', 2570, 2537, '34569332200230672',82325850), - ('697832478', 2579, 0936, '34568732200494825',49658372), - ('697832176', 2571, 5944, '34568732200494742',19039461), - ('697832477', 2572, 5138, '34568732200494759',25712504), - ('697832178', 2573, 4597, '34568732200494767',66241760), - ('697832182', 2574, 9241, '34568732200494775',07342562), - ('697832196', 2575, 2995, '34568732200494783',53929026), - ('697832214', 2576, 7434, '34568732200494791',49698432), - ('697832230', 2577, 7004, '34568732200494809',21578612), - ('697832235', 2578, 9674, '34568732200494817',93090700), - ('673420375', 2599, 5430, '34562052300117259',35911412), - ('673420367', 2598, 8402, '34562052300117242',924654), - ('673420361', 2597, 5125, '34562052300117234',12027970), - ('673420355', 2596, 5069, '34562052300117226',34978149), - ('673420348', 2595, 8911, '34562052300117218',4228121), - ('673420346', 2594, 2461, '34562052300117200',67670772), - ('673420345', 2593, 2226, '34562052300117192',90586404), - ('673420306', 2592, 3355, '34562052300117184',97850017), - ('673420257', 2591, 9395, '34562052300117176',50713786), - ('673420231', 2590, 1378, '34562052300117168',50151763), - ('673420223', 2589, 9580, '34562052300117150',99534550), - ('673420216', 2588, 4955, '34562052300117143',317554), - ('673420203', 2587, 6742, '34562052300117135',69321531), - ('673420201', 2586, 1659, '34562052300117127',54720480), - ('673420199', 2585, 7823, '34562052300117119',22923796), - ('673420198', 2584, 1787, '34562052300117101',54414630), - ('673420168', 2583, 6334, '34562052300117093',50694894), - ('673420147', 2582, 8951, '34562052300117085',1402535), - ('673420125', 2581, 3068, '34562052300117077',86216200), - ('673420124', 2580, 9517, '34562052300117069',42504099), - ('600294609', 2715, 7474, '34569832304894588',55923317), - ('600084713', 2703, 8342, '34569832304894570',8392636), - ('600084732', 2704, 1625, '34569832304894513',75477452), - ('600084850', 2705, 9896, '34569832304894653',28589813), - ('600084951', 2706, 5520, '34569832304894661',75353012), - ('600084978', 2707, 2698, '34569832304894679',9005523), - ('600085403', 2708, 0837, '34569832304894646',77051152), - ('600085513', 2709, 3106, '34569832304894687',41571002), - ('600293916', 2712, 8990, '34569832304894620',95188676), - ('600294160', 2714, 6376, '34569832304894703',79879896), - ('671919529', 2975, 9184, '34569832304806236',7535392), - ('671919942', 2981, 0328, '34569832304806269',31052894), - ('671919530', 2976, 0344, '34569832304806251',89860304), - ('671919533', 2977, 0668, '34569832304806244',42921771), - ('671919535', 2978, 0105, '34569832304806277',31009417), - ('671919537', 2979, 0881, '34569832304806285',33479769), - ('671919540', 2980, 9874, '34569832304806293',14103929), - ('671919525', 2972, 2089, '34569832304806301',45903729), - ('671919527', 2973, 8206, '34569832304806368',1586035), - ('671919528', 2974, 2532, '34569832304806327',62310124), - ('673668717', 2836, 7973, '34562032301044223',15635496), - ('673668734', 2837, 4457, '34562032301044231',18313118), - ('673668738', 2824, 2911, '34562032301044249',30875583), - ('673668745', 2838, 7253, '34562032301044256',62754222), - ('673668796', 2839, 0068, '34562032301044264',15556829), - ('673668803', 2840, 2386, '34562032301044272',17572287), - ('673669591', 2850, 3833, '34562032301044280',34828896), - ('673668808', 2841, 3584, '34562032301044298',16234497), - ('673670102', 2851, 3554, '34562032301044306',23652625), - ('673670131', 2852, 4412, '34562032301044314',88611709), - ('673670135', 2827, 6058, '34562032301044322',53918579), - ('673670201', 2828, 8066, '34562032301044330',92369343), - ('673670225', 2829, 4592, '34562032301044348',24126635), - ('673670236', 2830, 2974, '34562032301044355',88608465), - ('673671485', 2849, 0349, '34562032301044363',44944874), - ('673461977', 2871, 1728, '34562032400157090',46975780), - ('673461975', 2870, 4734, '34562032400157082',69628432), - ('673461972', 2867, 6276, '34562032400157058',53338365), - ('673461979', 2872, 6043, '34562032400157108',36525197), - ('673461958', 2859, 3164, '34562032400156977',58947831), - ('673461957', 2857, 8685, '34562032400156969',15826386), - ('673461944', 2853, 1073, '34562032400156910',20452195), - ('673461974', 2869, 7121, '34562032400157074',32044645), - ('673461973', 2868, 8022, '34562032400157066',29282044), - ('673461971', 2866, 3089, '34562032400157041',66149978), - ('673461969', 2865, 7555, '34562032400157033',78391293), - ('673461960', 2860, 5203, '34562032400156985',37138232), - ('673461952', 2855, 6915, '34562032400156936',62724661), - ('673461949', 2854, 8706, '34562032400156928',5594345), - ('673461966', 2863, 2496, '34562032400157017',93450666), - ('673461968', 2864, 3703, '34562032400157025',23208841), - ('673461963', 2862, 9364, '34562032400157009',29712130), - ('673462719', 2873, 9387, '34562032400156951',50434348), - ('673461962', 2861, 8441, '34562032400156993',39686909), - ('673461956', 2826, 5392, '34562032400156944',5496107), - ('673465284', 2694, 1523, '34562032400171349',14554994), - ('673465282', 2692, 4645, '34562032400171323',24871187), - ('673465283', 2693, 5253, '34562032400171331',28303238), - ('673465841', 2696, 0849, '34562032400171257',21673222), - ('673465258', 2679, 4140, '34562032400171174',39793881), - ('673465263', 2680, 6922, '34562032400171182',12253261), - ('673465265', 2681, 9112, '34562032400171190',93894366), - ('673465267', 2682, 3259, '34562032400171208',2342189), - ('673465268', 2683, 8540, '34562032400171216',63886925), - ('673465285', 2695, 4167, '34562032400171356',79227618), - ('673465270', 2684, 4292, '34562032400171224',19216349), - ('673465272', 2685, 4007, '34562032400171232',14396903), - ('673465273', 2686, 6894, '34562032400171240',13569394), - ('673465274', 2687, 5268, '34562032400171265',59453667), - ('673465275', 2688, 0232, '34562032400171273',62324713), - ('673465276', 2689, 2720, '34562032400171281',65977200), - ('673465843', 2698, 4773, '34562032400171364',78387158), - ('673465842', 2697, 3729, '34562032400171315',94201789), - ('673465280', 2691, 0503, '34562032400171307',12298533), - ('673465279', 2690, 8239, '34562032400171299',76183877); + ('621188151', 2209, '1486', '3456985220092508',14213470), + ('621188152', 2210, '8765', '3456985220092509',99473093), + ('621188153', 2211, '3064', '3456985220092510',52967210), + ('621188759', 2081, '3700', '3456985220123637',56600999), + ('621188760', 2082, '3259', '345698522023638',87492404), + ('621188761', 2083, '2790', '3456985220123639',94009456), + ('621188762', 2084, '2480', '3456985220123644',1484999), + ('621188763', 2085, '6876', '3456985220123641',36577064), + ('621188766', 2086, '7775', '3456985220123642',80761698), + ('621188769', 2088, '4027', '3456985220123643',37921712), + ('621188771', 2089, '8797', '3456985220123640',63092540), + ('621188772', 2090, '8404', '3456985220123645',21014997), + ('621188773', 2091, '5481', '3456985220123646',16317277), + ('621188774', 2092, '9632', '3456985220123647',22235994), + ('621188775', 2093, '4654', '3456985220123648',28506486), + ('621188838', 2094, '1392', '3456985220123649',29498627), + ('621188839', 2095, '7774', '3456985220123650',46263490), + ('621188840', 2096, '7304', '3456985220123658',8212044), + ('621188841', 2097, '5569', '3456985220123652',81597658), + ('621188842', 2098, '4944', '3456985220123653',24961501), + ('621188843', 2099, '5142', '3456985220123654',17035634), + ('621188844', 2111, '7245', '3456985220123655',90231951), + ('621188846', 2110, '6590', '3456985220123656',72201537), + ('667680207', 2564, '4042', '34569832200759166',48401979), + ('667680315', 2565, '7143', '34569832200759372',32143252), + ('667680318', 2566, '6342', '34569832200759364',39597112), + ('667680413', 2567, '5580', '34569832200759356',32786992), + ('667680463', 2568, '0171', '34569832200759349',34240853), + ('667688217', 2569, '2500', '34569832200759331',5687589), + ('633603945', 2212, '7129', '34569832200759323',51554019), + ('622130186', 2213, '4826', '34569832200759307',19623551), + ('633973424', 2214, '8535', '34569832200759299',94619307), + ('633703828', 2215, '8628', '34569832200759281',22468012), + ('622025110', 2216, '2399', '34569832200759273',34602918), + ('622924867', 2217, '5665', '34569832200759265',26920216), + ('722409630', 2218, '5211', '34569832200759240',93750137), + ('623590529', 2219, '0493', '34569832200759208',47077088), + ('633243462', 2220, '6902', '34569832200759174',6421962), + ('633047286', 2221, '5592', '34569832200759182',32069439), + ('744716801', 2112, '9184', '34569832200759190',57049814), + ('655995021', 2131, '8896', '34569852202049093',19497356), + ('685522718', 2132, '1955', '34569852202049101',28519879), + ('674587213', 2994, '2006', '34569332200223743',62360135), + ('674587227', 2993, '9271', '34569332200223750',81628192), + ('674587229', 2993, '0900', '34569332200223768',91119071), + ('674587231', 2992, '5007', '34569332200223776',45826232), + ('674587234', 2991, '1378', '34569332200223784',91245744), + ('674587240', 2990, '0905', '34569332200223792',13083224), + ('674587245', 2989, '9059', '34569332200223800',15291807), + ('674587250', 2988, '8188', '34569332200223818',83017918), + ('674587254', 2987, '2962', '34569332200223826',92809271), + ('674587256', 2986, '0358', '34569332200223834',81067040), + ('674592713', 2570, '2537', '34569332200230672',82325850), + ('697832478', 2579, '0936', '34568732200494825',49658372), + ('697832176', 2571, '5944', '34568732200494742',19039461), + ('697832477', 2572, '5138', '34568732200494759',25712504), + ('697832178', 2573, '4597', '34568732200494767',66241760), + ('697832182', 2574, '9241', '34568732200494775',07342562), + ('697832196', 2575, '2995', '34568732200494783',53929026), + ('697832214', 2576, '7434', '34568732200494791',49698432), + ('697832230', 2577, '7004', '34568732200494809',21578612), + ('697832235', 2578, '9674', '34568732200494817',93090700), + ('673420375', 2599, '5430', '34562052300117259',35911412), + ('673420367', 2598, '8402', '34562052300117242',924654), + ('673420361', 2597, '5125', '34562052300117234',12027970), + ('673420355', 2596, '5069', '34562052300117226',34978149), + ('673420348', 2595, '8911', '34562052300117218',4228121), + ('673420346', 2594, '2461', '34562052300117200',67670772), + ('673420345', 2593, '2226', '34562052300117192',90586404), + ('673420306', 2592, '3355', '34562052300117184',97850017), + ('673420257', 2591, '9395', '34562052300117176',50713786), + ('673420231', 2590, '1378', '34562052300117168',50151763), + ('673420223', 2589, '9580', '34562052300117150',99534550), + ('673420216', 2588, '4955', '34562052300117143',317554), + ('673420203', 2587, '6742', '34562052300117135',69321531), + ('673420201', 2586, '1659', '34562052300117127',54720480), + ('673420199', 2585, '7823', '34562052300117119',22923796), + ('673420198', 2584, '1787', '34562052300117101',54414630), + ('673420168', 2583, '6334', '34562052300117093',50694894), + ('673420147', 2582, '8951', '34562052300117085',1402535), + ('673420125', 2581, '3068', '34562052300117077',86216200), + ('673420124', 2580, '9517', '34562052300117069',42504099), + ('600294609', 2715, '7474', '34569832304894588',55923317), + ('600084713', 2703, '8342', '34569832304894570',8392636), + ('600084732', 2704, '1625', '34569832304894513',75477452), + ('600084850', 2705, '9896', '34569832304894653',28589813), + ('600084951', 2706, '5520', '34569832304894661',75353012), + ('600084978', 2707, '2698', '34569832304894679',9005523), + ('600085403', 2708, '0837', '34569832304894646',77051152), + ('600085513', 2709, '3106', '34569832304894687',41571002), + ('600293916', 2712, '8990', '34569832304894620',95188676), + ('600294160', 2714, '6376', '34569832304894703',79879896), + ('671919529', 2975, '9184', '34569832304806236',7535392), + ('671919942', 2981, '0328', '34569832304806269',31052894), + ('671919530', 2976, '0344', '34569832304806251',89860304), + ('671919533', 2977, '0668', '34569832304806244',42921771), + ('671919535', 2978, '0105', '34569832304806277',31009417), + ('671919537', 2979, '0881', '34569832304806285',33479769), + ('671919540', 2980, '9874', '34569832304806293',14103929), + ('671919525', 2972, '2089', '34569832304806301',45903729), + ('671919527', 2973, '8206', '34569832304806368',1586035), + ('671919528', 2974, '2532', '34569832304806327',62310124), + ('673668717', 2836, '7973', '34562032301044223',15635496), + ('673668734', 2837, '4457', '34562032301044231',18313118), + ('673668738', 2824, '2911', '34562032301044249',30875583), + ('673668745', 2838, '7253', '34562032301044256',62754222), + ('673668796', 2839, '0068', '34562032301044264',15556829), + ('673668803', 2840, '2386', '34562032301044272',17572287), + ('673669591', 2850, '3833', '34562032301044280',34828896), + ('673668808', 2841, '3584', '34562032301044298',16234497), + ('673670102', 2851, '3554', '34562032301044306',23652625), + ('673670131', 2852, '4412', '34562032301044314',88611709), + ('673670135', 2827, '6058', '34562032301044322',53918579), + ('673670201', 2828, '8066', '34562032301044330',92369343), + ('673670225', 2829, '4592', '34562032301044348',24126635), + ('673670236', 2830, '2974', '34562032301044355',88608465), + ('673671485', 2849, '0349', '34562032301044363',44944874), + ('673461977', 2871, '1728', '34562032400157090',46975780), + ('673461975', 2870, '4734', '34562032400157082',69628432), + ('673461972', 2867, '6276', '34562032400157058',53338365), + ('673461979', 2872, '6043', '34562032400157108',36525197), + ('673461958', 2859, '3164', '34562032400156977',58947831), + ('673461957', 2857, '8685', '34562032400156969',15826386), + ('673461944', 2853, '1073', '34562032400156910',20452195), + ('673461974', 2869, '7121', '34562032400157074',32044645), + ('673461973', 2868, '8022', '34562032400157066',29282044), + ('673461971', 2866, '3089', '34562032400157041',66149978), + ('673461969', 2865, '7555', '34562032400157033',78391293), + ('673461960', 2860, '5203', '34562032400156985',37138232), + ('673461952', 2855, '6915', '34562032400156936',62724661), + ('673461949', 2854, '8706', '34562032400156928',5594345), + ('673461966', 2863, '2496', '34562032400157017',93450666), + ('673461968', 2864, '3703', '34562032400157025',23208841), + ('673461963', 2862, '9364', '34562032400157009',29712130), + ('673462719', 2873, '9387', '34562032400156951',50434348), + ('673461962', 2861, '8441', '34562032400156993',39686909), + ('673461956', 2826, '5392', '34562032400156944',5496107), + ('673465284', 2694, '1523', '34562032400171349',14554994), + ('673465282', 2692, '4645', '34562032400171323',24871187), + ('673465283', 2693, '5253', '34562032400171331',28303238), + ('673465841', 2696, '0849', '34562032400171257',21673222), + ('673465258', 2679, '4140', '34562032400171174',39793881), + ('673465263', 2680, '6922', '34562032400171182',12253261), + ('673465265', 2681, '9112', '34562032400171190',93894366), + ('673465267', 2682, '3259', '34562032400171208',2342189), + ('673465268', 2683, '8540', '34562032400171216',63886925), + ('673465285', 2695, '4167', '34562032400171356',79227618), + ('673465270', 2684, '4292', '34562032400171224',19216349), + ('673465272', 2685, '4007', '34562032400171232',14396903), + ('673465273', 2686, '6894', '34562032400171240',13569394), + ('673465274', 2687, '5268', '34562032400171265',59453667), + ('673465275', 2688, '0232', '34562032400171273',62324713), + ('673465276', 2689, '2720', '34562032400171281',65977200), + ('673465843', 2698, '4773', '34562032400171364',78387158), + ('673465842', 2697, '3729', '34562032400171315',94201789), + ('673465280', 2691, '0503', '34562032400171307',12298533), + ('673465279', 2690, '8239', '34562032400171299',76183877); UPDATE vn.deviceProductionUser SET simFk = NULL From 48064d639377f3dd54cafc80068604ddaf7b188a Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 16 Dec 2024 13:35:50 +0100 Subject: [PATCH 159/219] fix: refs #8174 fix --- db/versions/11327-maroonOak/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index 81a36ee26..f59cdfe7e 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`sim` ( `code` VARCHAR(25) COMMENT 'No se ha puesto BIGINT por incompatibilidad con Access', `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), `ext` INT(4) NOT NULL, - `pin` CHAR(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), + `pin` VARCHAR(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), `puk` INT(15) NOT NULL, PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; From 5a7ac8dcb36a249f67fef45285485df1f3866b5c Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 16 Dec 2024 13:44:58 +0100 Subject: [PATCH 160/219] fix: refs #8174 fix --- .../11327-maroonOak/00-firstScript.sql | 318 +++++++++--------- 1 file changed, 159 insertions(+), 159 deletions(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index f59cdfe7e..b1c87bf32 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -1,9 +1,9 @@ CREATE TABLE IF NOT EXISTS `vn`.`sim` ( `code` VARCHAR(25) COMMENT 'No se ha puesto BIGINT por incompatibilidad con Access', `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), - `ext` INT(4) NOT NULL, + `ext` VARCHAR(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), `pin` VARCHAR(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), - `puk` INT(15) NOT NULL, + `puk` VARCHAR(15) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), PRIMARY KEY (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; @@ -11,163 +11,163 @@ ALTER TABLE vn.deviceProductionUser CHANGE simSerialNumber simFk VARCHAR(25) DEF ALTER TABLE vn.deviceProductionUser MODIFY COLUMN simFk VARCHAR(25) DEFAULT NULL NULL; INSERT IGNORE INTO `vn`.`sim` (`line`, `ext`, `pin`, `code`, `puk`) VALUES - ('621188151', 2209, '1486', '3456985220092508',14213470), - ('621188152', 2210, '8765', '3456985220092509',99473093), - ('621188153', 2211, '3064', '3456985220092510',52967210), - ('621188759', 2081, '3700', '3456985220123637',56600999), - ('621188760', 2082, '3259', '345698522023638',87492404), - ('621188761', 2083, '2790', '3456985220123639',94009456), - ('621188762', 2084, '2480', '3456985220123644',1484999), - ('621188763', 2085, '6876', '3456985220123641',36577064), - ('621188766', 2086, '7775', '3456985220123642',80761698), - ('621188769', 2088, '4027', '3456985220123643',37921712), - ('621188771', 2089, '8797', '3456985220123640',63092540), - ('621188772', 2090, '8404', '3456985220123645',21014997), - ('621188773', 2091, '5481', '3456985220123646',16317277), - ('621188774', 2092, '9632', '3456985220123647',22235994), - ('621188775', 2093, '4654', '3456985220123648',28506486), - ('621188838', 2094, '1392', '3456985220123649',29498627), - ('621188839', 2095, '7774', '3456985220123650',46263490), - ('621188840', 2096, '7304', '3456985220123658',8212044), - ('621188841', 2097, '5569', '3456985220123652',81597658), - ('621188842', 2098, '4944', '3456985220123653',24961501), - ('621188843', 2099, '5142', '3456985220123654',17035634), - ('621188844', 2111, '7245', '3456985220123655',90231951), - ('621188846', 2110, '6590', '3456985220123656',72201537), - ('667680207', 2564, '4042', '34569832200759166',48401979), - ('667680315', 2565, '7143', '34569832200759372',32143252), - ('667680318', 2566, '6342', '34569832200759364',39597112), - ('667680413', 2567, '5580', '34569832200759356',32786992), - ('667680463', 2568, '0171', '34569832200759349',34240853), - ('667688217', 2569, '2500', '34569832200759331',5687589), - ('633603945', 2212, '7129', '34569832200759323',51554019), - ('622130186', 2213, '4826', '34569832200759307',19623551), - ('633973424', 2214, '8535', '34569832200759299',94619307), - ('633703828', 2215, '8628', '34569832200759281',22468012), - ('622025110', 2216, '2399', '34569832200759273',34602918), - ('622924867', 2217, '5665', '34569832200759265',26920216), - ('722409630', 2218, '5211', '34569832200759240',93750137), - ('623590529', 2219, '0493', '34569832200759208',47077088), - ('633243462', 2220, '6902', '34569832200759174',6421962), - ('633047286', 2221, '5592', '34569832200759182',32069439), - ('744716801', 2112, '9184', '34569832200759190',57049814), - ('655995021', 2131, '8896', '34569852202049093',19497356), - ('685522718', 2132, '1955', '34569852202049101',28519879), - ('674587213', 2994, '2006', '34569332200223743',62360135), - ('674587227', 2993, '9271', '34569332200223750',81628192), - ('674587229', 2993, '0900', '34569332200223768',91119071), - ('674587231', 2992, '5007', '34569332200223776',45826232), - ('674587234', 2991, '1378', '34569332200223784',91245744), - ('674587240', 2990, '0905', '34569332200223792',13083224), - ('674587245', 2989, '9059', '34569332200223800',15291807), - ('674587250', 2988, '8188', '34569332200223818',83017918), - ('674587254', 2987, '2962', '34569332200223826',92809271), - ('674587256', 2986, '0358', '34569332200223834',81067040), - ('674592713', 2570, '2537', '34569332200230672',82325850), - ('697832478', 2579, '0936', '34568732200494825',49658372), - ('697832176', 2571, '5944', '34568732200494742',19039461), - ('697832477', 2572, '5138', '34568732200494759',25712504), - ('697832178', 2573, '4597', '34568732200494767',66241760), - ('697832182', 2574, '9241', '34568732200494775',07342562), - ('697832196', 2575, '2995', '34568732200494783',53929026), - ('697832214', 2576, '7434', '34568732200494791',49698432), - ('697832230', 2577, '7004', '34568732200494809',21578612), - ('697832235', 2578, '9674', '34568732200494817',93090700), - ('673420375', 2599, '5430', '34562052300117259',35911412), - ('673420367', 2598, '8402', '34562052300117242',924654), - ('673420361', 2597, '5125', '34562052300117234',12027970), - ('673420355', 2596, '5069', '34562052300117226',34978149), - ('673420348', 2595, '8911', '34562052300117218',4228121), - ('673420346', 2594, '2461', '34562052300117200',67670772), - ('673420345', 2593, '2226', '34562052300117192',90586404), - ('673420306', 2592, '3355', '34562052300117184',97850017), - ('673420257', 2591, '9395', '34562052300117176',50713786), - ('673420231', 2590, '1378', '34562052300117168',50151763), - ('673420223', 2589, '9580', '34562052300117150',99534550), - ('673420216', 2588, '4955', '34562052300117143',317554), - ('673420203', 2587, '6742', '34562052300117135',69321531), - ('673420201', 2586, '1659', '34562052300117127',54720480), - ('673420199', 2585, '7823', '34562052300117119',22923796), - ('673420198', 2584, '1787', '34562052300117101',54414630), - ('673420168', 2583, '6334', '34562052300117093',50694894), - ('673420147', 2582, '8951', '34562052300117085',1402535), - ('673420125', 2581, '3068', '34562052300117077',86216200), - ('673420124', 2580, '9517', '34562052300117069',42504099), - ('600294609', 2715, '7474', '34569832304894588',55923317), - ('600084713', 2703, '8342', '34569832304894570',8392636), - ('600084732', 2704, '1625', '34569832304894513',75477452), - ('600084850', 2705, '9896', '34569832304894653',28589813), - ('600084951', 2706, '5520', '34569832304894661',75353012), - ('600084978', 2707, '2698', '34569832304894679',9005523), - ('600085403', 2708, '0837', '34569832304894646',77051152), - ('600085513', 2709, '3106', '34569832304894687',41571002), - ('600293916', 2712, '8990', '34569832304894620',95188676), - ('600294160', 2714, '6376', '34569832304894703',79879896), - ('671919529', 2975, '9184', '34569832304806236',7535392), - ('671919942', 2981, '0328', '34569832304806269',31052894), - ('671919530', 2976, '0344', '34569832304806251',89860304), - ('671919533', 2977, '0668', '34569832304806244',42921771), - ('671919535', 2978, '0105', '34569832304806277',31009417), - ('671919537', 2979, '0881', '34569832304806285',33479769), - ('671919540', 2980, '9874', '34569832304806293',14103929), - ('671919525', 2972, '2089', '34569832304806301',45903729), - ('671919527', 2973, '8206', '34569832304806368',1586035), - ('671919528', 2974, '2532', '34569832304806327',62310124), - ('673668717', 2836, '7973', '34562032301044223',15635496), - ('673668734', 2837, '4457', '34562032301044231',18313118), - ('673668738', 2824, '2911', '34562032301044249',30875583), - ('673668745', 2838, '7253', '34562032301044256',62754222), - ('673668796', 2839, '0068', '34562032301044264',15556829), - ('673668803', 2840, '2386', '34562032301044272',17572287), - ('673669591', 2850, '3833', '34562032301044280',34828896), - ('673668808', 2841, '3584', '34562032301044298',16234497), - ('673670102', 2851, '3554', '34562032301044306',23652625), - ('673670131', 2852, '4412', '34562032301044314',88611709), - ('673670135', 2827, '6058', '34562032301044322',53918579), - ('673670201', 2828, '8066', '34562032301044330',92369343), - ('673670225', 2829, '4592', '34562032301044348',24126635), - ('673670236', 2830, '2974', '34562032301044355',88608465), - ('673671485', 2849, '0349', '34562032301044363',44944874), - ('673461977', 2871, '1728', '34562032400157090',46975780), - ('673461975', 2870, '4734', '34562032400157082',69628432), - ('673461972', 2867, '6276', '34562032400157058',53338365), - ('673461979', 2872, '6043', '34562032400157108',36525197), - ('673461958', 2859, '3164', '34562032400156977',58947831), - ('673461957', 2857, '8685', '34562032400156969',15826386), - ('673461944', 2853, '1073', '34562032400156910',20452195), - ('673461974', 2869, '7121', '34562032400157074',32044645), - ('673461973', 2868, '8022', '34562032400157066',29282044), - ('673461971', 2866, '3089', '34562032400157041',66149978), - ('673461969', 2865, '7555', '34562032400157033',78391293), - ('673461960', 2860, '5203', '34562032400156985',37138232), - ('673461952', 2855, '6915', '34562032400156936',62724661), - ('673461949', 2854, '8706', '34562032400156928',5594345), - ('673461966', 2863, '2496', '34562032400157017',93450666), - ('673461968', 2864, '3703', '34562032400157025',23208841), - ('673461963', 2862, '9364', '34562032400157009',29712130), - ('673462719', 2873, '9387', '34562032400156951',50434348), - ('673461962', 2861, '8441', '34562032400156993',39686909), - ('673461956', 2826, '5392', '34562032400156944',5496107), - ('673465284', 2694, '1523', '34562032400171349',14554994), - ('673465282', 2692, '4645', '34562032400171323',24871187), - ('673465283', 2693, '5253', '34562032400171331',28303238), - ('673465841', 2696, '0849', '34562032400171257',21673222), - ('673465258', 2679, '4140', '34562032400171174',39793881), - ('673465263', 2680, '6922', '34562032400171182',12253261), - ('673465265', 2681, '9112', '34562032400171190',93894366), - ('673465267', 2682, '3259', '34562032400171208',2342189), - ('673465268', 2683, '8540', '34562032400171216',63886925), - ('673465285', 2695, '4167', '34562032400171356',79227618), - ('673465270', 2684, '4292', '34562032400171224',19216349), - ('673465272', 2685, '4007', '34562032400171232',14396903), - ('673465273', 2686, '6894', '34562032400171240',13569394), - ('673465274', 2687, '5268', '34562032400171265',59453667), - ('673465275', 2688, '0232', '34562032400171273',62324713), - ('673465276', 2689, '2720', '34562032400171281',65977200), - ('673465843', 2698, '4773', '34562032400171364',78387158), - ('673465842', 2697, '3729', '34562032400171315',94201789), - ('673465280', 2691, '0503', '34562032400171307',12298533), - ('673465279', 2690, '8239', '34562032400171299',76183877); + ('621188151', '2209', '1486', '3456985220092508','14213470'), + ('621188152', '2210', '8765', '3456985220092509','99473093'), + ('621188153', '2211', '3064', '3456985220092510','52967210'), + ('621188759', '2081', '3700', '3456985220123637','56600999'), + ('621188760', '2082', '3259', '345698522023638','87492404'), + ('621188761', '2083', '2790', '3456985220123639','94009456'), + ('621188762', '2084', '2480', '3456985220123644','1484999'), + ('621188763', '2085', '6876', '3456985220123641','36577064'), + ('621188766', '2086', '7775', '3456985220123642','80761698'), + ('621188769', '2088', '4027', '3456985220123643','37921712'), + ('621188771', '2089', '8797', '3456985220123640','63092540'), + ('621188772', '2090', '8404', '3456985220123645','21014997'), + ('621188773', '2091', '5481', '3456985220123646','16317277'), + ('621188774', '2092', '9632', '3456985220123647','22235994'), + ('621188775', '2093', '4654', '3456985220123648','28506486'), + ('621188838', '2094', '1392', '3456985220123649','29498627'), + ('621188839', '2095', '7774', '3456985220123650','46263490'), + ('621188840', '2096', '7304', '3456985220123658','8212044'), + ('621188841', '2097', '5569', '3456985220123652','81597658'), + ('621188842', '2098', '4944', '3456985220123653','24961501'), + ('621188843', '2099', '5142', '3456985220123654','17035634'), + ('621188844', '2111', '7245', '3456985220123655','90231951'), + ('621188846', '2110', '6590', '3456985220123656','72201537'), + ('667680207', '2564', '4042', '34569832200759166','48401979'), + ('667680315', '2565', '7143', '34569832200759372','32143252'), + ('667680318', '2566', '6342', '34569832200759364','39597112'), + ('667680413', '2567', '5580', '34569832200759356','32786992'), + ('667680463', '2568', '0171', '34569832200759349','34240853'), + ('667688217', '2569', '2500', '34569832200759331','5687589'), + ('633603945', '2212', '7129', '34569832200759323','51554019'), + ('622130186', '2213', '4826', '34569832200759307','19623551'), + ('633973424', '2214', '8535', '34569832200759299','94619307'), + ('633703828', '2215', '8628', '34569832200759281','22468012'), + ('622025110', '2216', '2399', '34569832200759273','34602918'), + ('622924867', '2217', '5665', '34569832200759265','26920216'), + ('722409630', '2218', '5211', '34569832200759240','93750137'), + ('623590529', '2219', '0493', '34569832200759208','47077088'), + ('633243462', '2220', '6902', '34569832200759174','6421962'), + ('633047286', '2221', '5592', '34569832200759182','32069439'), + ('744716801', '2112', '9184', '34569832200759190','57049814'), + ('655995021', '2131', '8896', '34569852202049093','19497356'), + ('685522718', '2132', '1955', '34569852202049101','28519879'), + ('674587213', '2994', '2006', '34569332200223743','62360135'), + ('674587227', '2993', '9271', '34569332200223750','81628192'), + ('674587229', '2993', '0900', '34569332200223768','91119071'), + ('674587231', '2992', '5007', '34569332200223776','45826232'), + ('674587234', '2991', '1378', '34569332200223784','91245744'), + ('674587240', '2990', '0905', '34569332200223792','13083224'), + ('674587245', '2989', '9059', '34569332200223800','15291807'), + ('674587250', '2988', '8188', '34569332200223818','83017918'), + ('674587254', '2987', '2962', '34569332200223826','92809271'), + ('674587256', '2986', '0358', '34569332200223834','81067040'), + ('674592713', '2570', '2537', '34569332200230672','82325850'), + ('697832478', '2579', '0936', '34568732200494825','49658372'), + ('697832176', '2571', '5944', '34568732200494742','19039461'), + ('697832477', '2572', '5138', '34568732200494759','25712504'), + ('697832178', '2573', '4597', '34568732200494767','66241760'), + ('697832182', '2574', '9241', '34568732200494775','07342562'), + ('697832196', '2575', '2995', '34568732200494783','53929026'), + ('697832214', '2576', '7434', '34568732200494791','49698432'), + ('697832230', '2577', '7004', '34568732200494809','21578612'), + ('697832235', '2578', '9674', '34568732200494817','93090700'), + ('673420375', '2599', '5430', '34562052300117259','35911412'), + ('673420367', '2598', '8402', '34562052300117242','924654'), + ('673420361', '2597', '5125', '34562052300117234','12027970'), + ('673420355', '2596', '5069', '34562052300117226','34978149'), + ('673420348', '2595', '8911', '34562052300117218','4228121'), + ('673420346', '2594', '2461', '34562052300117200','67670772'), + ('673420345', '2593', '2226', '34562052300117192','90586404'), + ('673420306', '2592', '3355', '34562052300117184','97850017'), + ('673420257', '2591', '9395', '34562052300117176','50713786'), + ('673420231', '2590', '1378', '34562052300117168','50151763'), + ('673420223', '2589', '9580', '34562052300117150','99534550'), + ('673420216', '2588', '4955', '34562052300117143','317554'), + ('673420203', '2587', '6742', '34562052300117135','69321531'), + ('673420201', '2586', '1659', '34562052300117127','54720480'), + ('673420199', '2585', '7823', '34562052300117119','22923796'), + ('673420198', '2584', '1787', '34562052300117101','54414630'), + ('673420168', '2583', '6334', '34562052300117093','50694894'), + ('673420147', '2582', '8951', '34562052300117085','1402535'), + ('673420125', '2581', '3068', '34562052300117077','86216200'), + ('673420124', '2580', '9517', '34562052300117069','42504099'), + ('600294609', '2715', '7474', '34569832304894588','55923317'), + ('600084713', '2703', '8342', '34569832304894570','8392636'), + ('600084732', '2704', '1625', '34569832304894513','75477452'), + ('600084850', '2705', '9896', '34569832304894653','28589813'), + ('600084951', '2706', '5520', '34569832304894661','75353012'), + ('600084978', '2707', '2698', '34569832304894679','9005523'), + ('600085403', '2708', '0837', '34569832304894646','77051152'), + ('600085513', '2709', '3106', '34569832304894687','41571002'), + ('600293916', '2712', '8990', '34569832304894620','95188676'), + ('600294160', '2714', '6376', '34569832304894703','79879896'), + ('671919529', '2975', '9184', '34569832304806236','7535392'), + ('671919942', '2981', '0328', '34569832304806269','31052894'), + ('671919530', '2976', '0344', '34569832304806251','89860304'), + ('671919533', '2977', '0668', '34569832304806244','42921771'), + ('671919535', '2978', '0105', '34569832304806277','31009417'), + ('671919537', '2979', '0881', '34569832304806285','33479769'), + ('671919540', '2980', '9874', '34569832304806293','14103929'), + ('671919525', '2972', '2089', '34569832304806301','45903729'), + ('671919527', '2973', '8206', '34569832304806368','1586035'), + ('671919528', '2974', '2532', '34569832304806327','62310124'), + ('673668717', '2836', '7973', '34562032301044223','15635496'), + ('673668734', '2837', '4457', '34562032301044231','18313118'), + ('673668738', '2824', '2911', '34562032301044249','30875583'), + ('673668745', '2838', '7253', '34562032301044256','62754222'), + ('673668796', '2839', '0068', '34562032301044264','15556829'), + ('673668803', '2840', '2386', '34562032301044272','17572287'), + ('673669591', '2850', '3833', '34562032301044280','34828896'), + ('673668808', '2841', '3584', '34562032301044298','16234497'), + ('673670102', '2851', '3554', '34562032301044306','23652625'), + ('673670131', '2852', '4412', '34562032301044314','88611709'), + ('673670135', '2827', '6058', '34562032301044322','53918579'), + ('673670201', '2828', '8066', '34562032301044330','92369343'), + ('673670225', '2829', '4592', '34562032301044348','24126635'), + ('673670236', '2830', '2974', '34562032301044355','88608465'), + ('673671485', '2849', '0349', '34562032301044363','44944874'), + ('673461977', '2871', '1728', '34562032400157090','46975780'), + ('673461975', '2870', '4734', '34562032400157082','69628432'), + ('673461972', '2867', '6276', '34562032400157058','53338365'), + ('673461979', '2872', '6043', '34562032400157108','36525197'), + ('673461958', '2859', '3164', '34562032400156977','58947831'), + ('673461957', '2857', '8685', '34562032400156969','15826386'), + ('673461944', '2853', '1073', '34562032400156910','20452195'), + ('673461974', '2869', '7121', '34562032400157074','32044645'), + ('673461973', '2868', '8022', '34562032400157066','29282044'), + ('673461971', '2866', '3089', '34562032400157041','66149978'), + ('673461969', '2865', '7555', '34562032400157033','78391293'), + ('673461960', '2860', '5203', '34562032400156985','37138232'), + ('673461952', '2855', '6915', '34562032400156936','62724661'), + ('673461949', '2854', '8706', '34562032400156928','5594345'), + ('673461966', '2863', '2496', '34562032400157017','93450666'), + ('673461968', '2864', '3703', '34562032400157025','23208841'), + ('673461963', '2862', '9364', '34562032400157009','29712130'), + ('673462719', '2873', '9387', '34562032400156951','50434348'), + ('673461962', '2861', '8441', '34562032400156993','39686909'), + ('673461956', '2826', '5392', '34562032400156944','5496107'), + ('673465284', '2694', '1523', '34562032400171349','14554994'), + ('673465282', '2692', '4645', '34562032400171323','24871187'), + ('673465283', '2693', '5253', '34562032400171331','28303238'), + ('673465841', '2696', '0849', '34562032400171257','21673222'), + ('673465258', '2679', '4140', '34562032400171174','39793881'), + ('673465263', '2680', '6922', '34562032400171182','12253261'), + ('673465265', '2681', '9112', '34562032400171190','93894366'), + ('673465267', '2682', '3259', '34562032400171208','2342189'), + ('673465268', '2683', '8540', '34562032400171216','63886925'), + ('673465285', '2695', '4167', '34562032400171356','79227618'), + ('673465270', '2684', '4292', '34562032400171224','19216349'), + ('673465272', '2685', '4007', '34562032400171232','14396903'), + ('673465273', '2686', '6894', '34562032400171240','13569394'), + ('673465274', '2687', '5268', '34562032400171265','59453667'), + ('673465275', '2688', '0232', '34562032400171273','62324713'), + ('673465276', '2689', '2720', '34562032400171281','65977200'), + ('673465843', '2698', '4773', '34562032400171364','78387158'), + ('673465842', '2697', '3729', '34562032400171315','94201789'), + ('673465280', '2691', '0503', '34562032400171307','12298533'), + ('673465279', '2690', '8239', '34562032400171299','76183877'); UPDATE vn.deviceProductionUser SET simFk = NULL From 6a3cbed3ddc2ef57592608ac2401858e09305992 Mon Sep 17 00:00:00 2001 From: Jbreso Date: Mon, 16 Dec 2024 13:47:36 +0100 Subject: [PATCH 161/219] fix: refs #8174 fix --- .../11327-maroonOak/00-firstScript.sql | 316 +++++++++--------- 1 file changed, 158 insertions(+), 158 deletions(-) diff --git a/db/versions/11327-maroonOak/00-firstScript.sql b/db/versions/11327-maroonOak/00-firstScript.sql index b1c87bf32..a51ee3fff 100644 --- a/db/versions/11327-maroonOak/00-firstScript.sql +++ b/db/versions/11327-maroonOak/00-firstScript.sql @@ -1,7 +1,7 @@ CREATE TABLE IF NOT EXISTS `vn`.`sim` ( `code` VARCHAR(25) COMMENT 'No se ha puesto BIGINT por incompatibilidad con Access', `line` VARCHAR(15) NOT NULL CHECK (`line` REGEXP '^[0-9]+$'), - `ext` VARCHAR(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), + `ext` INT(4) NOT NULL, `pin` VARCHAR(4) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), `puk` VARCHAR(15) NOT NULL CHECK (`pin` REGEXP '^[0-9]+$'), PRIMARY KEY (`code`) @@ -11,163 +11,163 @@ ALTER TABLE vn.deviceProductionUser CHANGE simSerialNumber simFk VARCHAR(25) DEF ALTER TABLE vn.deviceProductionUser MODIFY COLUMN simFk VARCHAR(25) DEFAULT NULL NULL; INSERT IGNORE INTO `vn`.`sim` (`line`, `ext`, `pin`, `code`, `puk`) VALUES - ('621188151', '2209', '1486', '3456985220092508','14213470'), - ('621188152', '2210', '8765', '3456985220092509','99473093'), - ('621188153', '2211', '3064', '3456985220092510','52967210'), - ('621188759', '2081', '3700', '3456985220123637','56600999'), - ('621188760', '2082', '3259', '345698522023638','87492404'), - ('621188761', '2083', '2790', '3456985220123639','94009456'), - ('621188762', '2084', '2480', '3456985220123644','1484999'), - ('621188763', '2085', '6876', '3456985220123641','36577064'), - ('621188766', '2086', '7775', '3456985220123642','80761698'), - ('621188769', '2088', '4027', '3456985220123643','37921712'), - ('621188771', '2089', '8797', '3456985220123640','63092540'), - ('621188772', '2090', '8404', '3456985220123645','21014997'), - ('621188773', '2091', '5481', '3456985220123646','16317277'), - ('621188774', '2092', '9632', '3456985220123647','22235994'), - ('621188775', '2093', '4654', '3456985220123648','28506486'), - ('621188838', '2094', '1392', '3456985220123649','29498627'), - ('621188839', '2095', '7774', '3456985220123650','46263490'), - ('621188840', '2096', '7304', '3456985220123658','8212044'), - ('621188841', '2097', '5569', '3456985220123652','81597658'), - ('621188842', '2098', '4944', '3456985220123653','24961501'), - ('621188843', '2099', '5142', '3456985220123654','17035634'), - ('621188844', '2111', '7245', '3456985220123655','90231951'), - ('621188846', '2110', '6590', '3456985220123656','72201537'), - ('667680207', '2564', '4042', '34569832200759166','48401979'), - ('667680315', '2565', '7143', '34569832200759372','32143252'), - ('667680318', '2566', '6342', '34569832200759364','39597112'), - ('667680413', '2567', '5580', '34569832200759356','32786992'), - ('667680463', '2568', '0171', '34569832200759349','34240853'), - ('667688217', '2569', '2500', '34569832200759331','5687589'), - ('633603945', '2212', '7129', '34569832200759323','51554019'), - ('622130186', '2213', '4826', '34569832200759307','19623551'), - ('633973424', '2214', '8535', '34569832200759299','94619307'), - ('633703828', '2215', '8628', '34569832200759281','22468012'), - ('622025110', '2216', '2399', '34569832200759273','34602918'), - ('622924867', '2217', '5665', '34569832200759265','26920216'), - ('722409630', '2218', '5211', '34569832200759240','93750137'), - ('623590529', '2219', '0493', '34569832200759208','47077088'), - ('633243462', '2220', '6902', '34569832200759174','6421962'), - ('633047286', '2221', '5592', '34569832200759182','32069439'), - ('744716801', '2112', '9184', '34569832200759190','57049814'), - ('655995021', '2131', '8896', '34569852202049093','19497356'), - ('685522718', '2132', '1955', '34569852202049101','28519879'), - ('674587213', '2994', '2006', '34569332200223743','62360135'), - ('674587227', '2993', '9271', '34569332200223750','81628192'), - ('674587229', '2993', '0900', '34569332200223768','91119071'), - ('674587231', '2992', '5007', '34569332200223776','45826232'), - ('674587234', '2991', '1378', '34569332200223784','91245744'), - ('674587240', '2990', '0905', '34569332200223792','13083224'), - ('674587245', '2989', '9059', '34569332200223800','15291807'), - ('674587250', '2988', '8188', '34569332200223818','83017918'), - ('674587254', '2987', '2962', '34569332200223826','92809271'), - ('674587256', '2986', '0358', '34569332200223834','81067040'), - ('674592713', '2570', '2537', '34569332200230672','82325850'), - ('697832478', '2579', '0936', '34568732200494825','49658372'), - ('697832176', '2571', '5944', '34568732200494742','19039461'), - ('697832477', '2572', '5138', '34568732200494759','25712504'), - ('697832178', '2573', '4597', '34568732200494767','66241760'), - ('697832182', '2574', '9241', '34568732200494775','07342562'), - ('697832196', '2575', '2995', '34568732200494783','53929026'), - ('697832214', '2576', '7434', '34568732200494791','49698432'), - ('697832230', '2577', '7004', '34568732200494809','21578612'), - ('697832235', '2578', '9674', '34568732200494817','93090700'), - ('673420375', '2599', '5430', '34562052300117259','35911412'), - ('673420367', '2598', '8402', '34562052300117242','924654'), - ('673420361', '2597', '5125', '34562052300117234','12027970'), - ('673420355', '2596', '5069', '34562052300117226','34978149'), - ('673420348', '2595', '8911', '34562052300117218','4228121'), - ('673420346', '2594', '2461', '34562052300117200','67670772'), - ('673420345', '2593', '2226', '34562052300117192','90586404'), - ('673420306', '2592', '3355', '34562052300117184','97850017'), - ('673420257', '2591', '9395', '34562052300117176','50713786'), - ('673420231', '2590', '1378', '34562052300117168','50151763'), - ('673420223', '2589', '9580', '34562052300117150','99534550'), - ('673420216', '2588', '4955', '34562052300117143','317554'), - ('673420203', '2587', '6742', '34562052300117135','69321531'), - ('673420201', '2586', '1659', '34562052300117127','54720480'), - ('673420199', '2585', '7823', '34562052300117119','22923796'), - ('673420198', '2584', '1787', '34562052300117101','54414630'), - ('673420168', '2583', '6334', '34562052300117093','50694894'), - ('673420147', '2582', '8951', '34562052300117085','1402535'), - ('673420125', '2581', '3068', '34562052300117077','86216200'), - ('673420124', '2580', '9517', '34562052300117069','42504099'), - ('600294609', '2715', '7474', '34569832304894588','55923317'), - ('600084713', '2703', '8342', '34569832304894570','8392636'), - ('600084732', '2704', '1625', '34569832304894513','75477452'), - ('600084850', '2705', '9896', '34569832304894653','28589813'), - ('600084951', '2706', '5520', '34569832304894661','75353012'), - ('600084978', '2707', '2698', '34569832304894679','9005523'), - ('600085403', '2708', '0837', '34569832304894646','77051152'), - ('600085513', '2709', '3106', '34569832304894687','41571002'), - ('600293916', '2712', '8990', '34569832304894620','95188676'), - ('600294160', '2714', '6376', '34569832304894703','79879896'), - ('671919529', '2975', '9184', '34569832304806236','7535392'), - ('671919942', '2981', '0328', '34569832304806269','31052894'), - ('671919530', '2976', '0344', '34569832304806251','89860304'), - ('671919533', '2977', '0668', '34569832304806244','42921771'), - ('671919535', '2978', '0105', '34569832304806277','31009417'), - ('671919537', '2979', '0881', '34569832304806285','33479769'), - ('671919540', '2980', '9874', '34569832304806293','14103929'), - ('671919525', '2972', '2089', '34569832304806301','45903729'), - ('671919527', '2973', '8206', '34569832304806368','1586035'), - ('671919528', '2974', '2532', '34569832304806327','62310124'), - ('673668717', '2836', '7973', '34562032301044223','15635496'), - ('673668734', '2837', '4457', '34562032301044231','18313118'), - ('673668738', '2824', '2911', '34562032301044249','30875583'), - ('673668745', '2838', '7253', '34562032301044256','62754222'), - ('673668796', '2839', '0068', '34562032301044264','15556829'), - ('673668803', '2840', '2386', '34562032301044272','17572287'), - ('673669591', '2850', '3833', '34562032301044280','34828896'), - ('673668808', '2841', '3584', '34562032301044298','16234497'), - ('673670102', '2851', '3554', '34562032301044306','23652625'), - ('673670131', '2852', '4412', '34562032301044314','88611709'), - ('673670135', '2827', '6058', '34562032301044322','53918579'), - ('673670201', '2828', '8066', '34562032301044330','92369343'), - ('673670225', '2829', '4592', '34562032301044348','24126635'), - ('673670236', '2830', '2974', '34562032301044355','88608465'), - ('673671485', '2849', '0349', '34562032301044363','44944874'), - ('673461977', '2871', '1728', '34562032400157090','46975780'), - ('673461975', '2870', '4734', '34562032400157082','69628432'), - ('673461972', '2867', '6276', '34562032400157058','53338365'), - ('673461979', '2872', '6043', '34562032400157108','36525197'), - ('673461958', '2859', '3164', '34562032400156977','58947831'), - ('673461957', '2857', '8685', '34562032400156969','15826386'), - ('673461944', '2853', '1073', '34562032400156910','20452195'), - ('673461974', '2869', '7121', '34562032400157074','32044645'), - ('673461973', '2868', '8022', '34562032400157066','29282044'), - ('673461971', '2866', '3089', '34562032400157041','66149978'), - ('673461969', '2865', '7555', '34562032400157033','78391293'), - ('673461960', '2860', '5203', '34562032400156985','37138232'), - ('673461952', '2855', '6915', '34562032400156936','62724661'), - ('673461949', '2854', '8706', '34562032400156928','5594345'), - ('673461966', '2863', '2496', '34562032400157017','93450666'), - ('673461968', '2864', '3703', '34562032400157025','23208841'), - ('673461963', '2862', '9364', '34562032400157009','29712130'), - ('673462719', '2873', '9387', '34562032400156951','50434348'), - ('673461962', '2861', '8441', '34562032400156993','39686909'), - ('673461956', '2826', '5392', '34562032400156944','5496107'), - ('673465284', '2694', '1523', '34562032400171349','14554994'), - ('673465282', '2692', '4645', '34562032400171323','24871187'), - ('673465283', '2693', '5253', '34562032400171331','28303238'), - ('673465841', '2696', '0849', '34562032400171257','21673222'), - ('673465258', '2679', '4140', '34562032400171174','39793881'), - ('673465263', '2680', '6922', '34562032400171182','12253261'), - ('673465265', '2681', '9112', '34562032400171190','93894366'), - ('673465267', '2682', '3259', '34562032400171208','2342189'), - ('673465268', '2683', '8540', '34562032400171216','63886925'), - ('673465285', '2695', '4167', '34562032400171356','79227618'), - ('673465270', '2684', '4292', '34562032400171224','19216349'), - ('673465272', '2685', '4007', '34562032400171232','14396903'), - ('673465273', '2686', '6894', '34562032400171240','13569394'), - ('673465274', '2687', '5268', '34562032400171265','59453667'), - ('673465275', '2688', '0232', '34562032400171273','62324713'), - ('673465276', '2689', '2720', '34562032400171281','65977200'), - ('673465843', '2698', '4773', '34562032400171364','78387158'), - ('673465842', '2697', '3729', '34562032400171315','94201789'), - ('673465280', '2691', '0503', '34562032400171307','12298533'), - ('673465279', '2690', '8239', '34562032400171299','76183877'); + ('621188151', 2209, '1486', '3456985220092508','14213470'), + ('621188152', 2210, '8765', '3456985220092509','99473093'), + ('621188153', 2211, '3064', '3456985220092510','52967210'), + ('621188759', 2081, '3700', '3456985220123637','56600999'), + ('621188760', 2082, '3259', '345698522023638','87492404'), + ('621188761', 2083, '2790', '3456985220123639','94009456'), + ('621188762', 2084, '2480', '3456985220123644','1484999'), + ('621188763', 2085, '6876', '3456985220123641','36577064'), + ('621188766', 2086, '7775', '3456985220123642','80761698'), + ('621188769', 2088, '4027', '3456985220123643','37921712'), + ('621188771', 2089, '8797', '3456985220123640','63092540'), + ('621188772', 2090, '8404', '3456985220123645','21014997'), + ('621188773', 2091, '5481', '3456985220123646','16317277'), + ('621188774', 2092, '9632', '3456985220123647','22235994'), + ('621188775', 2093, '4654', '3456985220123648','28506486'), + ('621188838', 2094, '1392', '3456985220123649','29498627'), + ('621188839', 2095, '7774', '3456985220123650','46263490'), + ('621188840', 2096, '7304', '3456985220123658','8212044'), + ('621188841', 2097, '5569', '3456985220123652','81597658'), + ('621188842', 2098, '4944', '3456985220123653','24961501'), + ('621188843', 2099, '5142', '3456985220123654','17035634'), + ('621188844', 2111, '7245', '3456985220123655','90231951'), + ('621188846', 2110, '6590', '3456985220123656','72201537'), + ('667680207', 2564, '4042', '34569832200759166','48401979'), + ('667680315', 2565, '7143', '34569832200759372','32143252'), + ('667680318', 2566, '6342', '34569832200759364','39597112'), + ('667680413', 2567, '5580', '34569832200759356','32786992'), + ('667680463', 2568, '0171', '34569832200759349','34240853'), + ('667688217', 2569, '2500', '34569832200759331','5687589'), + ('633603945', 2212, '7129', '34569832200759323','51554019'), + ('622130186', 2213, '4826', '34569832200759307','19623551'), + ('633973424', 2214, '8535', '34569832200759299','94619307'), + ('633703828', 2215, '8628', '34569832200759281','22468012'), + ('622025110', 2216, '2399', '34569832200759273','34602918'), + ('622924867', 2217, '5665', '34569832200759265','26920216'), + ('722409630', 2218, '5211', '34569832200759240','93750137'), + ('623590529', 2219, '0493', '34569832200759208','47077088'), + ('633243462', 2220, '6902', '34569832200759174','6421962'), + ('633047286', 2221, '5592', '34569832200759182','32069439'), + ('744716801', 2112, '9184', '34569832200759190','57049814'), + ('655995021', 2131, '8896', '34569852202049093','19497356'), + ('685522718', 2132, '1955', '34569852202049101','28519879'), + ('674587213', 2994, '2006', '34569332200223743','62360135'), + ('674587227', 2993, '9271', '34569332200223750','81628192'), + ('674587229', 2993, '0900', '34569332200223768','91119071'), + ('674587231', 2992, '5007', '34569332200223776','45826232'), + ('674587234', 2991, '1378', '34569332200223784','91245744'), + ('674587240', 2990, '0905', '34569332200223792','13083224'), + ('674587245', 2989, '9059', '34569332200223800','15291807'), + ('674587250', 2988, '8188', '34569332200223818','83017918'), + ('674587254', 2987, '2962', '34569332200223826','92809271'), + ('674587256', 2986, '0358', '34569332200223834','81067040'), + ('674592713', 2570, '2537', '34569332200230672','82325850'), + ('697832478', 2579, '0936', '34568732200494825','49658372'), + ('697832176', 2571, '5944', '34568732200494742','19039461'), + ('697832477', 2572, '5138', '34568732200494759','25712504'), + ('697832178', 2573, '4597', '34568732200494767','66241760'), + ('697832182', 2574, '9241', '34568732200494775','07342562'), + ('697832196', 2575, '2995', '34568732200494783','53929026'), + ('697832214', 2576, '7434', '34568732200494791','49698432'), + ('697832230', 2577, '7004', '34568732200494809','21578612'), + ('697832235', 2578, '9674', '34568732200494817','93090700'), + ('673420375', 2599, '5430', '34562052300117259','35911412'), + ('673420367', 2598, '8402', '34562052300117242','924654'), + ('673420361', 2597, '5125', '34562052300117234','12027970'), + ('673420355', 2596, '5069', '34562052300117226','34978149'), + ('673420348', 2595, '8911', '34562052300117218','4228121'), + ('673420346', 2594, '2461', '34562052300117200','67670772'), + ('673420345', 2593, '2226', '34562052300117192','90586404'), + ('673420306', 2592, '3355', '34562052300117184','97850017'), + ('673420257', 2591, '9395', '34562052300117176','50713786'), + ('673420231', 2590, '1378', '34562052300117168','50151763'), + ('673420223', 2589, '9580', '34562052300117150','99534550'), + ('673420216', 2588, '4955', '34562052300117143','317554'), + ('673420203', 2587, '6742', '34562052300117135','69321531'), + ('673420201', 2586, '1659', '34562052300117127','54720480'), + ('673420199', 2585, '7823', '34562052300117119','22923796'), + ('673420198', 2584, '1787', '34562052300117101','54414630'), + ('673420168', 2583, '6334', '34562052300117093','50694894'), + ('673420147', 2582, '8951', '34562052300117085','1402535'), + ('673420125', 2581, '3068', '34562052300117077','86216200'), + ('673420124', 2580, '9517', '34562052300117069','42504099'), + ('600294609', 2715, '7474', '34569832304894588','55923317'), + ('600084713', 2703, '8342', '34569832304894570','8392636'), + ('600084732', 2704, '1625', '34569832304894513','75477452'), + ('600084850', 2705, '9896', '34569832304894653','28589813'), + ('600084951', 2706, '5520', '34569832304894661','75353012'), + ('600084978', 2707, '2698', '34569832304894679','9005523'), + ('600085403', 2708, '0837', '34569832304894646','77051152'), + ('600085513', 2709, '3106', '34569832304894687','41571002'), + ('600293916', 2712, '8990', '34569832304894620','95188676'), + ('600294160', 2714, '6376', '34569832304894703','79879896'), + ('671919529', 2975, '9184', '34569832304806236','7535392'), + ('671919942', 2981, '0328', '34569832304806269','31052894'), + ('671919530', 2976, '0344', '34569832304806251','89860304'), + ('671919533', 2977, '0668', '34569832304806244','42921771'), + ('671919535', 2978, '0105', '34569832304806277','31009417'), + ('671919537', 2979, '0881', '34569832304806285','33479769'), + ('671919540', 2980, '9874', '34569832304806293','14103929'), + ('671919525', 2972, '2089', '34569832304806301','45903729'), + ('671919527', 2973, '8206', '34569832304806368','1586035'), + ('671919528', 2974, '2532', '34569832304806327','62310124'), + ('673668717', 2836, '7973', '34562032301044223','15635496'), + ('673668734', 2837, '4457', '34562032301044231','18313118'), + ('673668738', 2824, '2911', '34562032301044249','30875583'), + ('673668745', 2838, '7253', '34562032301044256','62754222'), + ('673668796', 2839, '0068', '34562032301044264','15556829'), + ('673668803', 2840, '2386', '34562032301044272','17572287'), + ('673669591', 2850, '3833', '34562032301044280','34828896'), + ('673668808', 2841, '3584', '34562032301044298','16234497'), + ('673670102', 2851, '3554', '34562032301044306','23652625'), + ('673670131', 2852, '4412', '34562032301044314','88611709'), + ('673670135', 2827, '6058', '34562032301044322','53918579'), + ('673670201', 2828, '8066', '34562032301044330','92369343'), + ('673670225', 2829, '4592', '34562032301044348','24126635'), + ('673670236', 2830, '2974', '34562032301044355','88608465'), + ('673671485', 2849, '0349', '34562032301044363','44944874'), + ('673461977', 2871, '1728', '34562032400157090','46975780'), + ('673461975', 2870, '4734', '34562032400157082','69628432'), + ('673461972', 2867, '6276', '34562032400157058','53338365'), + ('673461979', 2872, '6043', '34562032400157108','36525197'), + ('673461958', 2859, '3164', '34562032400156977','58947831'), + ('673461957', 2857, '8685', '34562032400156969','15826386'), + ('673461944', 2853, '1073', '34562032400156910','20452195'), + ('673461974', 2869, '7121', '34562032400157074','32044645'), + ('673461973', 2868, '8022', '34562032400157066','29282044'), + ('673461971', 2866, '3089', '34562032400157041','66149978'), + ('673461969', 2865, '7555', '34562032400157033','78391293'), + ('673461960', 2860, '5203', '34562032400156985','37138232'), + ('673461952', 2855, '6915', '34562032400156936','62724661'), + ('673461949', 2854, '8706', '34562032400156928','5594345'), + ('673461966', 2863, '2496', '34562032400157017','93450666'), + ('673461968', 2864, '3703', '34562032400157025','23208841'), + ('673461963', 2862, '9364', '34562032400157009','29712130'), + ('673462719', 2873, '9387', '34562032400156951','50434348'), + ('673461962', 2861, '8441', '34562032400156993','39686909'), + ('673461956', 2826, '5392', '34562032400156944','5496107'), + ('673465284', 2694, '1523', '34562032400171349','14554994'), + ('673465282', 2692, '4645', '34562032400171323','24871187'), + ('673465283', 2693, '5253', '34562032400171331','28303238'), + ('673465841', 2696, '0849', '34562032400171257','21673222'), + ('673465258', 2679, '4140', '34562032400171174','39793881'), + ('673465263', 2680, '6922', '34562032400171182','12253261'), + ('673465265', 2681, '9112', '34562032400171190','93894366'), + ('673465267', 2682, '3259', '34562032400171208','2342189'), + ('673465268', 2683, '8540', '34562032400171216','63886925'), + ('673465285', 2695, '4167', '34562032400171356','79227618'), + ('673465270', 2684, '4292', '34562032400171224','19216349'), + ('673465272', 2685, '4007', '34562032400171232','14396903'), + ('673465273', 2686, '6894', '34562032400171240','13569394'), + ('673465274', 2687, '5268', '34562032400171265','59453667'), + ('673465275', 2688, '0232', '34562032400171273','62324713'), + ('673465276', 2689, '2720', '34562032400171281','65977200'), + ('673465843', 2698, '4773', '34562032400171364','78387158'), + ('673465842', 2697, '3729', '34562032400171315','94201789'), + ('673465280', 2691, '0503', '34562032400171307','12298533'), + ('673465279', 2690, '8239', '34562032400171299','76183877'); UPDATE vn.deviceProductionUser SET simFk = NULL From 863f20424740c0d2dcbb99f9572466adfc23bd42 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 16 Dec 2024 14:12:43 +0100 Subject: [PATCH 162/219] fix(deleteZone): contrary condition --- loopback/locale/en.json | 3 ++- loopback/locale/es.json | 3 ++- modules/zone/back/methods/zone/deleteZone.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 7372ac9a6..54d004400 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -247,5 +247,6 @@ "The raid information is not correct": "The raid information is not correct", "Payment method is required": "Payment method is required", "Sales already moved": "Sales already moved", - "Holidays to past days not available": "Holidays to past days not available" + "Holidays to past days not available": "Holidays to past days not available", + "There are tickets to be invoiced": "There are tickets to be invoiced" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 8bb38fee0..e891b8720 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -390,6 +390,7 @@ "The web user's email already exists": "El correo del usuario web ya existe", "Sales already moved": "Ya han sido transferidas", "The raid information is not correct": "La información de la redada no es correcta", - "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles" + "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", + "There are tickets to be invoiced": "Hay ticket por facturar" } diff --git a/modules/zone/back/methods/zone/deleteZone.js b/modules/zone/back/methods/zone/deleteZone.js index e2e01a949..a147ee588 100644 --- a/modules/zone/back/methods/zone/deleteZone.js +++ b/modules/zone/back/methods/zone/deleteZone.js @@ -51,7 +51,7 @@ module.exports = Self => { }; const ticketList = await models.Ticket.find(filter, myOptions); - const hasRefFk = ticketList.some(ticket => ticket.refFk); + const hasRefFk = ticketList.some(ticket => !ticket.refFk); if (hasRefFk) throw new UserError('There are tickets to be invoiced'); From 26b0ea647d3525ce7f03174db30a67d33e8aa54a Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 17 Dec 2024 07:01:44 +0100 Subject: [PATCH 163/219] refactor: change translation --- loopback/locale/es.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopback/locale/es.json b/loopback/locale/es.json index e891b8720..e536e7e7d 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -391,6 +391,6 @@ "Sales already moved": "Ya han sido transferidas", "The raid information is not correct": "La información de la redada no es correcta", "Holidays to past days not available": "Las vacaciones a días pasados no están disponibles", - "There are tickets to be invoiced": "Hay ticket por facturar" + "There are tickets to be invoiced": "La zona tiene tickets por facturar" } From acccb4abc3bd548af0f3e9ce524b818f75f8191f Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 17 Dec 2024 12:19:46 +0100 Subject: [PATCH 164/219] fix: hotfix mix --- modules/travel/back/methods/travel/filter.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/travel/back/methods/travel/filter.js b/modules/travel/back/methods/travel/filter.js index b96873925..30c1a45fa 100644 --- a/modules/travel/back/methods/travel/filter.js +++ b/modules/travel/back/methods/travel/filter.js @@ -83,6 +83,14 @@ module.exports = Self => { arg: 'daysOnward', type: 'number', description: 'The days onward' + }, { + arg: 'shipped', + type: 'date', + description: 'The shipped date' + }, { + arg: 'landed', + type: 'date', + description: 'The landed date' } ], returns: { @@ -108,6 +116,10 @@ module.exports = Self => { : {'t.ref': {like: `%${value}%`}}; case 'ref': return {'t.ref': {like: `%${value}%`}}; + case 'shipped': + return {'t.shipped': value}; + case 'landed': + return {'t.landed': value}; case 'shippedFrom': return {'t.shipped': {gte: value}}; case 'shippedTo': From acfafa1c7299f6eb203460f679f42d57a6b39fda Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 17 Dec 2024 12:44:55 +0100 Subject: [PATCH 165/219] fix: monitorPayMethodFilter --- .../monitor/back/methods/sales-monitor/salesFilter.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/monitor/back/methods/sales-monitor/salesFilter.js b/modules/monitor/back/methods/sales-monitor/salesFilter.js index 95713f9fb..ac8a722bd 100644 --- a/modules/monitor/back/methods/sales-monitor/salesFilter.js +++ b/modules/monitor/back/methods/sales-monitor/salesFilter.js @@ -98,6 +98,11 @@ module.exports = Self => { arg: 'countryFk', type: 'number', description: 'The country id filter' + }, + { + arg: 'payMethod', + type: 'string', + description: 'The payment method filter' } ], returns: { @@ -165,6 +170,8 @@ module.exports = Self => { case 'clientFk': param = `t.${param}`; return {[param]: value}; + case 'payMethod': + return {'c.payMethodFk': value}; } }); @@ -205,6 +212,8 @@ module.exports = Self => { u.name userName, c.salesPersonFk, c.credit, + c.payMethodFk payMethodFk, + pm.id payMethodId, pm.name payMethod, z.hour zoneLanding, z.name zoneName, From f965f7aa52d2bd394ecd89d2bd7b1538c84f81e0 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 17 Dec 2024 12:46:48 +0100 Subject: [PATCH 166/219] fix: refs #6583 update onlyWithDestination logic to handle null values correctly --- modules/ticket/back/methods/ticket/getTicketsAdvance.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/ticket/back/methods/ticket/getTicketsAdvance.js b/modules/ticket/back/methods/ticket/getTicketsAdvance.js index 6abac455f..58d46173c 100644 --- a/modules/ticket/back/methods/ticket/getTicketsAdvance.js +++ b/modules/ticket/back/methods/ticket/getTicketsAdvance.js @@ -109,8 +109,7 @@ module.exports = Self => { case 'departmentFk': return {'f.departmentFk': value}; case 'onlyWithDestination': - if (!value) return; - return {'f.id': {neq: null}}; + return {'f.id': value ? {neq: null} : null}; } }); From b935878dd6ec75820bf1d4159c20d029f4b6b0a1 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 17 Dec 2024 12:58:25 +0100 Subject: [PATCH 167/219] feat: refs #6583 add tests --- .../ticket/specs/getTicketsAdvance.spec.js | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js index a941013cd..bb7f230ee 100644 --- a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js @@ -167,4 +167,56 @@ describe('TicketFuture getTicketsAdvance()', () => { throw e; } }); + + it('should return the tickets with only destination', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const args = { + dateFuture: today, + dateToAdvance: today.setHours(23, 59, 59, 999), + warehouseFk: 1, + }; + ctx.args = args; + + const allTickets = await models.Ticket.getTicketsAdvance(ctx, options); + ctx.args.onlyWithDestination = true; + const withDestinationTickets = await models.Ticket.getTicketsAdvance(ctx, options); + + expect(allTickets.filter(ticket => ticket.id).length).toBe(withDestinationTickets.length); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + fit('should return the tickets without only destination', async() => { + const tx = await models.Ticket.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const args = { + dateFuture: today, + dateToAdvance: today.setHours(23, 59, 59, 999), + warehouseFk: 1, + }; + ctx.args = args; + + const allTickets = await models.Ticket.getTicketsAdvance(ctx, options); + ctx.args.onlyWithDestination = false; + const withoutDestinationTickets = await models.Ticket.getTicketsAdvance(ctx, options); + + expect(allTickets.filter(ticket => !ticket.id).length).toBe(withoutDestinationTickets.length); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); From 9ac8e60f0cb31de688f8d385d16afab5f603f525 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 17 Dec 2024 12:58:57 +0100 Subject: [PATCH 168/219] fix: refs #6583 drop focus --- .../ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js index bb7f230ee..e71942341 100644 --- a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js @@ -194,7 +194,7 @@ describe('TicketFuture getTicketsAdvance()', () => { } }); - fit('should return the tickets without only destination', async() => { + it('should return the tickets without only destination', async() => { const tx = await models.Ticket.beginTransaction({}); try { From 31952725aa23b50171f42f27b914d1656dc130d6 Mon Sep 17 00:00:00 2001 From: jorgep Date: Tue, 17 Dec 2024 13:33:29 +0100 Subject: [PATCH 169/219] refactor: refs #6583 use warehouseId var --- .../ticket/specs/getTicketsAdvance.spec.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js index e71942341..157cdb1ff 100644 --- a/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js +++ b/modules/ticket/back/methods/ticket/specs/getTicketsAdvance.spec.js @@ -8,6 +8,7 @@ describe('TicketFuture getTicketsAdvance()', () => { tomorrow.setDate(today.getDate() + 1); const salesDeptId = 43; const spain1DeptId = 95; + const warehouseId = 1; beforeAll.mockLoopBackContext(); it('should return the tickets passing the required data', async() => { @@ -19,7 +20,7 @@ describe('TicketFuture getTicketsAdvance()', () => { const args = { dateFuture: tomorrow, dateToAdvance: today, - warehouseFk: 1, + warehouseFk: warehouseId, }; ctx.args = args; @@ -42,7 +43,7 @@ describe('TicketFuture getTicketsAdvance()', () => { const args = { dateFuture: tomorrow, dateToAdvance: today, - warehouseFk: 1, + warehouseFk: warehouseId, isFullMovable: true }; @@ -67,7 +68,7 @@ describe('TicketFuture getTicketsAdvance()', () => { const args = { dateFuture: tomorrow, dateToAdvance: today, - warehouseFk: 1, + warehouseFk: warehouseId, isFullMovable: false }; @@ -92,7 +93,7 @@ describe('TicketFuture getTicketsAdvance()', () => { const args = { dateFuture: tomorrow, dateToAdvance: today, - warehouseFk: 1, + warehouseFk: warehouseId, ipt: 'V' }; @@ -117,7 +118,7 @@ describe('TicketFuture getTicketsAdvance()', () => { const args = { dateFuture: tomorrow, dateToAdvance: today, - warehouseFk: 1, + warehouseFk: warehouseId, tfIpt: 'V' }; @@ -141,7 +142,7 @@ describe('TicketFuture getTicketsAdvance()', () => { ctx.args = { dateFuture: tomorrow, dateToAdvance: today, - warehouseFk: 1, + warehouseFk: warehouseId, }; await models.Ticket.updateAll({id: {inq: [12, 31]}}, {clientFk: 1}, options); @@ -177,7 +178,7 @@ describe('TicketFuture getTicketsAdvance()', () => { const args = { dateFuture: today, dateToAdvance: today.setHours(23, 59, 59, 999), - warehouseFk: 1, + warehouseFk: warehouseId, }; ctx.args = args; @@ -203,7 +204,7 @@ describe('TicketFuture getTicketsAdvance()', () => { const args = { dateFuture: today, dateToAdvance: today.setHours(23, 59, 59, 999), - warehouseFk: 1, + warehouseFk: warehouseId, }; ctx.args = args; From 1a8b05c46bb782a2fd46e1b05329be25744fac2b Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 18 Dec 2024 07:08:23 +0100 Subject: [PATCH 170/219] fix: refs #8315 fixture claimDevelopment --- db/dump/fixtures.before.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 57a9f9ca8..c2afbb7b4 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1922,7 +1922,7 @@ INSERT INTO `vn`.`claimDestination`(`id`, `description`, `addressFk`) INSERT INTO `vn`.`claimDevelopment`(`id`, `claimFk`, `claimResponsibleFk`, `workerFk`, `claimReasonFk`, `claimResultFk`, `claimRedeliveryFk`, `claimDestinationFk`) VALUES - (1, 1, 1, 21, 1, 1, 2, 5), + (1, 1, 1, 21, 7, 1, 2, 5), (2, 1, 2, 21, 7, 2, 2, 5), (3, 2, 7, 21, 9, 3, 2, 5), (4, 3, 7, 21, 15, 8, 2, 5), From 42c3cdae5d76d8da0420c8aff7fee07ba1f2f35c Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 18 Dec 2024 11:33:48 +0100 Subject: [PATCH 171/219] build: init version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4e823eaad..a843ac9c5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "24.52.0", + "version": "25.02.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From c0893f8684e4d6cdbe1f2af731d5c2c81c09076a Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 18 Dec 2024 13:06:01 +0100 Subject: [PATCH 172/219] feat: refs #7936 add locale --- modules/invoiceIn/back/locale/invoiceIn/en.yml | 7 ++++++- modules/invoiceIn/back/locale/invoiceIn/es.yml | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/invoiceIn/back/locale/invoiceIn/en.yml b/modules/invoiceIn/back/locale/invoiceIn/en.yml index 9e94eba0d..6940b6f77 100644 --- a/modules/invoiceIn/back/locale/invoiceIn/en.yml +++ b/modules/invoiceIn/back/locale/invoiceIn/en.yml @@ -17,4 +17,9 @@ columns: isVatDeductible: is VAT deductible withholdingSageFk: withholding expenseFkDeductible: expense deductible - editorFk: editor \ No newline at end of file + editorFk: editor + cplusRectificationTypeFk: cplus rectification type + cplusSubjectOpFk: cplus subject op + cplusTaxBreakFk: cplus tax break + siiTrasCendencyInvoiceInFk: sii tras cendency invoice in + siiTypeInvoiceInFk: sii type invoice in \ No newline at end of file diff --git a/modules/invoiceIn/back/locale/invoiceIn/es.yml b/modules/invoiceIn/back/locale/invoiceIn/es.yml index bd64c4327..9599c0535 100644 --- a/modules/invoiceIn/back/locale/invoiceIn/es.yml +++ b/modules/invoiceIn/back/locale/invoiceIn/es.yml @@ -5,7 +5,7 @@ columns: serial: serie supplierFk: proveedor issued: fecha emisión - supplierRef: referéncia proveedor + supplierRef: referencia proveedor isBooked: facturado currencyFk: moneda created: creado @@ -17,4 +17,9 @@ columns: isVatDeductible: impuesto deducible withholdingSageFk: código de retención expenseFkDeductible: gasto deducible - editorFk: editor \ No newline at end of file + editorFk: editor + cplusRectificationTypeFk: tipo de rectificación cplus + cplusSubjectOpFk: sujeto op cplus + cplusTaxBreakFk: exención fiscal cplus + siiTrasCendencyInvoiceInFk: trascendencia sii factura recibida + siiTypeInvoiceInFk: tipo sii factura recibida \ No newline at end of file From 94136d35ff284cd5a07bbbc909616450419f8fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 18 Dec 2024 12:22:59 +0000 Subject: [PATCH 173/219] Actualizar db/routines/vn/triggers/route_afterUpdate.sql --- db/routines/vn/triggers/route_afterUpdate.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/db/routines/vn/triggers/route_afterUpdate.sql b/db/routines/vn/triggers/route_afterUpdate.sql index 447608acc..a15c1a4b7 100644 --- a/db/routines/vn/triggers/route_afterUpdate.sql +++ b/db/routines/vn/triggers/route_afterUpdate.sql @@ -22,6 +22,7 @@ BEGIN OR !(NEW.workerFk <=> OLD.workerFk) OR !(NEW.m3 <=> OLD.m3) OR !(NEW.agencyModeFk <=> OLD.agencyModeFk) + OR !(NEW.dated <=> OLD.dated) OR !(NEW.vehicleFk <=> OLD.vehicleFk)THEN CALL route_calcCommission(NEW.id); END IF; From 1ba23ad45057893a6612a62e1844025c0b353657 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 18 Dec 2024 13:27:43 +0100 Subject: [PATCH 174/219] feat: refs #8073 #refs 8073 create vn.productionCountryVolume --- db/versions/11387-whiteDendro/00-firstScript.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 db/versions/11387-whiteDendro/00-firstScript.sql diff --git a/db/versions/11387-whiteDendro/00-firstScript.sql b/db/versions/11387-whiteDendro/00-firstScript.sql new file mode 100644 index 000000000..4461b945d --- /dev/null +++ b/db/versions/11387-whiteDendro/00-firstScript.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS vn.productionCountryVolume( + id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, + countryFk MEDIUMINT(8) UNSIGNED NOT NULL, + estimate DECIMAL(6, 2), + PRIMARY KEY (id), + CONSTRAINT productionCountryVolume_countryFK + FOREIGN KEY (countryFk) REFERENCES vn.country (id) + ON DELETE RESTRICT ON UPDATE CASCADE +) COMMENT = 'Estimación del crecimiento por país' \ No newline at end of file From 148ab57b1a1cf0bc4d42f999a039951ace7c41a8 Mon Sep 17 00:00:00 2001 From: ivanm Date: Wed, 18 Dec 2024 15:06:49 +0100 Subject: [PATCH 175/219] feat: refs #8073 change names and primary key --- db/versions/11387-whiteDendro/00-firstScript.sql | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/db/versions/11387-whiteDendro/00-firstScript.sql b/db/versions/11387-whiteDendro/00-firstScript.sql index 4461b945d..3226dfc42 100644 --- a/db/versions/11387-whiteDendro/00-firstScript.sql +++ b/db/versions/11387-whiteDendro/00-firstScript.sql @@ -1,8 +1,7 @@ -CREATE TABLE IF NOT EXISTS vn.productionCountryVolume( - id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, +CREATE TABLE IF NOT EXISTS vn.productionCountry( countryFk MEDIUMINT(8) UNSIGNED NOT NULL, - estimate DECIMAL(6, 2), - PRIMARY KEY (id), + volumeGrowthEstimatePercent DECIMAL(6, 2), + PRIMARY KEY (countryFk), CONSTRAINT productionCountryVolume_countryFK FOREIGN KEY (countryFk) REFERENCES vn.country (id) ON DELETE RESTRICT ON UPDATE CASCADE From 83d46d0a281d9b9fbbda13a798c52aee79e67174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 18 Dec 2024 17:58:30 +0100 Subject: [PATCH 176/219] feat: refs #8324 country unique --- db/versions/11390-goldenPalmetto/00-firstScript.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 db/versions/11390-goldenPalmetto/00-firstScript.sql diff --git a/db/versions/11390-goldenPalmetto/00-firstScript.sql b/db/versions/11390-goldenPalmetto/00-firstScript.sql new file mode 100644 index 000000000..adcc76e4f --- /dev/null +++ b/db/versions/11390-goldenPalmetto/00-firstScript.sql @@ -0,0 +1,3 @@ + +ALTER TABLE vn.country + ADD CONSTRAINT country_unique_name UNIQUE KEY (name); From 9ae27e104e006a964f7feb2cf8aa51a16f12a3a7 Mon Sep 17 00:00:00 2001 From: jgallego Date: Thu, 19 Dec 2024 07:07:56 +0100 Subject: [PATCH 177/219] feat: refs #8167 update canBeInvoiced method to include active status check and improve test cases --- .../back/methods/client/canBeInvoiced.js | 9 +-- .../client/specs/canBeInvoiced.spec.js | 67 ++++++++----------- 2 files changed, 30 insertions(+), 46 deletions(-) diff --git a/modules/client/back/methods/client/canBeInvoiced.js b/modules/client/back/methods/client/canBeInvoiced.js index cdb865500..536606b0b 100644 --- a/modules/client/back/methods/client/canBeInvoiced.js +++ b/modules/client/back/methods/client/canBeInvoiced.js @@ -2,7 +2,7 @@ const UserError = require('vn-loopback/util/user-error'); module.exports = function(Self) { Self.remoteMethod('canBeInvoiced', { - description: 'Change property isEqualizated in all client addresses', + description: 'Check if a client can be invoiced', accessType: 'READ', accepts: [ { @@ -38,7 +38,7 @@ module.exports = function(Self) { Object.assign(myOptions, options); const client = await models.Client.findById(id, { - fields: ['id', 'isTaxDataChecked', 'hasToInvoice', 'payMethodFk'], + fields: ['id', 'isTaxDataChecked', 'hasToInvoice', 'payMethodFk', 'isActive'], include: { relation: 'payMethod', @@ -53,9 +53,6 @@ module.exports = function(Self) { if (client.payMethod().code === 'wireTransfer' && !company.supplierAccountFk) throw new UserError('The company has not informed the supplier account for bank transfers'); - if (client.isTaxDataChecked && client.hasToInvoice) - return true; - - return false; + return client.isTaxDataChecked && client.hasToInvoice && client.isActive; }; }; diff --git a/modules/client/back/methods/client/specs/canBeInvoiced.spec.js b/modules/client/back/methods/client/specs/canBeInvoiced.spec.js index 397be3c92..4012b7409 100644 --- a/modules/client/back/methods/client/specs/canBeInvoiced.spec.js +++ b/modules/client/back/methods/client/specs/canBeInvoiced.spec.js @@ -8,6 +8,8 @@ describe('client canBeInvoiced()', () => { const activeCtx = { accessToken: {userId: userId} }; + let tx; + let options; beforeAll(async() => { spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({ @@ -15,60 +17,45 @@ describe('client canBeInvoiced()', () => { }); }); + beforeEach(async() => { + tx = await models.Client.beginTransaction({}); + options = {transaction: tx}; + }); + + afterEach(async() => { + await tx.rollback(); + }); + it('should return falsy for a client without the data checked', async() => { - const tx = await models.Client.beginTransaction({}); + const client = await models.Client.findById(clientId, null, options); + await client.updateAttribute('isTaxDataChecked', false, options); - try { - const options = {transaction: tx}; + const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options); - const client = await models.Client.findById(clientId, null, options); - await client.updateAttribute('isTaxDataChecked', false, options); + expect(canBeInvoiced).toEqual(false); + }); - const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options); + it('should return falsy for a client not active', async() => { + const client = await models.Client.findById(clientId, null, options); + await client.updateAttribute('isActive', false, options); - expect(canBeInvoiced).toEqual(false); + const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options); - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(canBeInvoiced).toEqual(false); }); it('should return falsy for a client with invoicing disabled', async() => { - const tx = await models.Client.beginTransaction({}); + const client = await models.Client.findById(clientId, null, options); + await client.updateAttribute('hasToInvoice', false, options); - try { - const options = {transaction: tx}; + const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options); - const client = await models.Client.findById(clientId, null, options); - await client.updateAttribute('hasToInvoice', false, options); - - const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options); - - expect(canBeInvoiced).toEqual(false); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(canBeInvoiced).toEqual(false); }); it('should return truthy for an invoiceable client', async() => { - const tx = await models.Client.beginTransaction({}); + const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options); - try { - const options = {transaction: tx}; - - const canBeInvoiced = await models.Client.canBeInvoiced(clientId, companyId, options); - - expect(canBeInvoiced).toEqual(true); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(canBeInvoiced).toEqual(true); }); }); From 49c30890e5c6487ecf8ad41e27fff13693fbfb66 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 19 Dec 2024 08:31:51 +0100 Subject: [PATCH 178/219] fix: refs #7301 update SQL fixtures and improve lastEntriesFilter logic --- db/dump/fixtures.before.sql | 11 ++++--- .../back/methods/item/lastEntriesFilter.js | 30 ++++++++++++------- .../item/specs/lastEntriesFilter.spec.js | 16 +++++----- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 57a9f9ca8..41ed69d53 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1516,7 +1516,8 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10, FALSE, NULL), (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, TRUE, 2), (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL), - (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL); + (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL), + (13, util.VN_CURDATE() - INTERVAL 1 MONTH - INTERVAL 1 DAY, util.VN_CURDATE() - INTERVAL 1 MONTH, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL); INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`, `typeFk`) VALUES @@ -1529,8 +1530,9 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 'observation seven', 'product'), (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, '', 'product'), (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, '', 'product'), - (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10',1, '', 'product'), - (11, 4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 11',0, '', 'product'), + (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2010', 'Movement 10',1, '', 'product'), + (11, 4, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 1, 442, 'IN2011', 'Movement 11',0, '', 'product'), + (12, 4, util.VN_CURDATE() - INTERVAL 1 MONTH, 13, 1, 442, 'IN2012', 'Movement 12',0, '', 'product'), (99, 69, util.VN_CURDATE() - INTERVAL 1 MONTH, 11, 0, 442, 'IN2009', 'Movement 99',0, '', 'product'); INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`) @@ -1572,7 +1574,8 @@ INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `sal (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()), (16, 99,1,50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, '2024-07-30 08:13:51.000'), - (17, 11, 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); + (17, 11, 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), + (18, 12, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH); 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 diff --git a/modules/item/back/methods/item/lastEntriesFilter.js b/modules/item/back/methods/item/lastEntriesFilter.js index 06c60162f..dd2e638e4 100644 --- a/modules/item/back/methods/item/lastEntriesFilter.js +++ b/modules/item/back/methods/item/lastEntriesFilter.js @@ -29,10 +29,11 @@ module.exports = Self => { Object.assign(myOptions, options); const stmt = new ParameterizedSQL( - `SELECT w.id AS warehouseFk, - w.name AS warehouse, - tr.landed, - b.id AS buyFk, + `SELECT i.id itemFk, + w.id warehouseFk, + w.name warehouse, + CAST(tr.landed AS CHAR) landed, + b.id buyFk, b.entryFk, b.isIgnored, b.price2, @@ -47,15 +48,18 @@ module.exports = Self => { b.buyingValue + b.freightValue + b.comissionValue + - b.packageValue AS cost, + b.packageValue cost, b.buyingValue, b.freightValue, b.comissionValue, b.packageValue, b.packagingFk , - s.id AS supplierFk, - s.name AS supplier, - b.printedStickers + s.id supplierFk, + s.name supplier, + b.printedStickers, + c.inventoried, + ic.supplierFk inventorySupplierFk, + s.id = ic.supplierFk isInventorySupplier FROM itemType it RIGHT JOIN (entry e LEFT JOIN supplier s ON s.id = e.supplierFk @@ -66,10 +70,16 @@ module.exports = Self => { LEFT JOIN warehouse w ON w.id = tr.warehouseInFk LEFT JOIN origin o ON o.id = i.originFk ) ON it.id = i.typeFk - LEFT JOIN edi.ekt ek ON b.ektFk = ek.id` + LEFT JOIN edi.ekt ek ON b.ektFk = ek.id + JOIN config c + JOIN inventoryConfig ic` ); - stmt.merge(conn.makeSuffix(filter)); + stmt.merge(conn.makeWhere(filter.where)); + stmt.merge('AND IF(s.id = ic.supplierFk, tr.landed = DATE(c.inventoried), TRUE)'); + stmt.merge(conn.makePagination(filter)); + + console.log('stmt: ', stmt); return conn.executeStmt(stmt, myOptions); }; }; diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js index d4429e158..3182f3a35 100644 --- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js +++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js @@ -1,16 +1,17 @@ const {models} = require('vn-loopback/server/server'); +const itemFk = 1; describe('item lastEntriesFilter()', () => { - it('should return two entry for the given item', async() => { + fit('should return two entry for the given item', async() => { const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); const maxDate = Date.vnNew(); - maxDate.setHours(23, 59, 59, 59); + maxDate.setHours(23, 59, 59, 999); const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; try { - const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}}; + const filter = {where: {itemFk, landed: {between: [minDate, maxDate]}}}; const result = await models.Item.lastEntriesFilter(filter, options); expect(result.length).toEqual(2); @@ -22,7 +23,7 @@ describe('item lastEntriesFilter()', () => { } }); - it('should return six entries for the given item', async() => { + fit('should return six entries for the given item', async() => { const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); minDate.setMonth(minDate.getMonth() - 2, 1); @@ -34,11 +35,10 @@ describe('item lastEntriesFilter()', () => { const options = {transaction: tx}; try { - const itemFk = 1; const filter = {where: {itemFk, landed: {between: [minDate, maxDate]}}}; const result = await models.Item.lastEntriesFilter(filter, options); - const minDateUtc = new Date(minDate).getTime(); - const maxDateUtc = new Date(maxDate).getTime(); + const minDateUtc = minDate.getTime(); + const maxDateUtc = maxDate.getTime(); const resultMatch = ( await Promise.all( @@ -50,7 +50,7 @@ describe('item lastEntriesFilter()', () => { }); const isItemFkValid = itemRecord?.id === itemFk; - const landedDate = new Date(item.landed).getTime(); + const landedDate = Date.vnNew(item.landed).getTime(); const isLandedValid = landedDate >= minDateUtc && landedDate <= maxDateUtc; return isItemFkValid && isLandedValid; From b838e988e0e6262cf81d2b186b51e7ce160fff1d Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 19 Dec 2024 08:39:47 +0100 Subject: [PATCH 179/219] fix: refs #7301 remove debug console log and update test cases in lastEntriesFilter --- modules/item/back/methods/item/lastEntriesFilter.js | 1 - .../item/back/methods/item/specs/lastEntriesFilter.spec.js | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/item/back/methods/item/lastEntriesFilter.js b/modules/item/back/methods/item/lastEntriesFilter.js index dd2e638e4..7a98eabd9 100644 --- a/modules/item/back/methods/item/lastEntriesFilter.js +++ b/modules/item/back/methods/item/lastEntriesFilter.js @@ -79,7 +79,6 @@ module.exports = Self => { stmt.merge('AND IF(s.id = ic.supplierFk, tr.landed = DATE(c.inventoried), TRUE)'); stmt.merge(conn.makePagination(filter)); - console.log('stmt: ', stmt); return conn.executeStmt(stmt, myOptions); }; }; diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js index 3182f3a35..a32225af7 100644 --- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js +++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js @@ -1,7 +1,7 @@ const {models} = require('vn-loopback/server/server'); const itemFk = 1; describe('item lastEntriesFilter()', () => { - fit('should return two entry for the given item', async() => { + it('should return two entry for the given item', async() => { const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); const maxDate = Date.vnNew(); @@ -23,7 +23,7 @@ describe('item lastEntriesFilter()', () => { } }); - fit('should return six entries for the given item', async() => { + it('should return six entries for the given item', async() => { const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); minDate.setMonth(minDate.getMonth() - 2, 1); From a99d7adfe88c36e4356a3dd685dbf2d1e9ffd5d7 Mon Sep 17 00:00:00 2001 From: jgallego Date: Thu, 19 Dec 2024 10:11:33 +0100 Subject: [PATCH 180/219] feat: refs #7924 add isCustomInspectionRequired field to item and update related logic --- db/dump/fixtures.before.sql | 46 ++++++++++--------- .../11391-redPalmetto/00-itemAlter.sql | 2 + modules/item/back/models/item.json | 5 +- .../methods/travel/extraCommunityFilter.js | 19 ++++---- .../travel/specs/extraCommunityFilter.spec.js | 13 ++++++ 5 files changed, 54 insertions(+), 31 deletions(-) create mode 100644 db/versions/11391-redPalmetto/00-itemAlter.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 97ed0ae47..181b34e5a 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -974,26 +974,30 @@ INSERT INTO `vn`.`itemFamily`(`code`, `description`) ('SER', 'Services'), ('VT', 'Sales'); -INSERT INTO `vn`.`item`(`id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`, - `comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`, `itemPackingTypeFk`, `hasMinPrice`, `weightByPiece`) - VALUES - (1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, 3), - (2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, 2), - (3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, 5), - (4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL), - (10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL), - (13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL), - (14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL), - (15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL), - (16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL), - (71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL); +INSERT INTO `vn`.`item`( + `id`, `typeFk`, `stems`, `originFk`, `description`, `producerFk`, `intrastatFk`, `expenseFk`, + `comment`, `relevancy`, `image`, `subName`, `minPrice`, `family`, `isFloramondo`, `genericFk`, + `itemPackingTypeFk`, `hasMinPrice`, `weightByPiece`, `isCustomInspectionRequired` +) +VALUES + (1, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '1', NULL, 0, 'EMB', 0, NULL, 'V', 0, 3, 1), + (2, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '2', NULL, 0, 'VT', 0, NULL, 'H', 0, 2, 1), + (3, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '3', NULL, 0, 'VT', 0, NULL, NULL, 0, 5, 0), + (4, 1, 1, 1, 'Increases block', 1, 05080000, 4751000000, NULL, 0, '4', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (5, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '5', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (6, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '6', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (7, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '7', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (8, 2, 1, 1, NULL, 1, 06021010, 2000000000, NULL, 0, '8', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (9, 2, 1, 2, NULL, 1, 06021010, 2000000000, NULL, 0, '9', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL, 0), + (10, 1, 1, 3, NULL, 1, 05080000, 4751000000, NULL, 0, '10', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (11, 1, 1, 1, NULL, 1, 05080000, 4751000000, NULL, 0, '11', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (12, 3, 1, 2, NULL, 2, 06021010, 4751000000, NULL, 0, '12', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0), + (13, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '13', NULL, 1, 'VT', 1, NULL, NULL, 1, NULL, 0), + (14, 5, 1, 2, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 1, NULL, NULL, 0, NULL, 0), + (15, 4, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 0), + (16, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'EMB', 0, NULL, NULL, 0, NULL, 0), + (71, 6, NULL, 1, NULL, NULL, 06021010, 4751000000, NULL, 0, '', NULL, 0, 'VT', 0, NULL, NULL, 0, NULL, 0); + -- Update the taxClass after insert of the items UPDATE `vn`.`itemTaxCountry` SET `taxClassFk` = 2 @@ -4038,7 +4042,7 @@ INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) INSERT INTO vn.workerIrpf (workerFk,spouseNif, geographicMobilityDate) VALUES (1106,'26493101E','2019-09-20'); -INSERT INTO vn.referenceRate (currencyFk, dated, value) +INSERT INTO vn.referenceRate (currencyFk, dated, value) VALUES (2, '2000-12-01', 1.0495), (2, '2001-01-01', 1.0531), (2, '2001-02-01', 7.6347); diff --git a/db/versions/11391-redPalmetto/00-itemAlter.sql b/db/versions/11391-redPalmetto/00-itemAlter.sql new file mode 100644 index 000000000..1eaef1a1b --- /dev/null +++ b/db/versions/11391-redPalmetto/00-itemAlter.sql @@ -0,0 +1,2 @@ +ALTER TABLE `item` +ADD COLUMN `isCustomInspectionRequired` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'Indicates if the item requires physical inspection at customs'; diff --git a/modules/item/back/models/item.json b/modules/item/back/models/item.json index eda56e938..159883455 100644 --- a/modules/item/back/models/item.json +++ b/modules/item/back/models/item.json @@ -154,6 +154,9 @@ }, "photoMotivation": { "type": "string" + }, + "isCustomInspectionRequired": { + "type": "boolean" } }, "relations": { @@ -222,4 +225,4 @@ } } } -} \ No newline at end of file +} diff --git a/modules/travel/back/methods/travel/extraCommunityFilter.js b/modules/travel/back/methods/travel/extraCommunityFilter.js index f1586f804..2f3f998d6 100644 --- a/modules/travel/back/methods/travel/extraCommunityFilter.js +++ b/modules/travel/back/methods/travel/extraCommunityFilter.js @@ -132,18 +132,18 @@ module.exports = Self => { CAST(SUM(b.weight * b.stickers) AS DECIMAL(10,0)) loadedKg, CAST( SUM( - vc.aerealVolumetricDensity * - b.stickers * + vc.aerealVolumetricDensity * + b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) AS DECIMAL(10,0) ) volumeKg, CAST( GREATEST( SUM(b.weight * b.stickers) , - SUM(vc.aerealVolumetricDensity * - b.stickers * - IF(pkg.volume, - pkg.volume, + SUM(vc.aerealVolumetricDensity * + b.stickers * + IF(pkg.volume, + pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000) ) / t.kg * 100 AS INT ) percentageKg @@ -185,11 +185,12 @@ module.exports = Self => { CAST(SUM(b.weight * b.stickers) AS DECIMAL(10,0)) as loadedkg, CAST( SUM( - vc.aerealVolumetricDensity * - b.stickers * + vc.aerealVolumetricDensity * + b.stickers * IF(pkg.volume, pkg.volume, pkg.width * pkg.depth * pkg.height) / 1000000 ) AS DECIMAL(10,0) - ) as volumeKg + ) as volumeKg, + MAX(i.isCustomInspectionRequired) isCustomInspectionRequired FROM tmp.travel tr JOIN entry e ON e.travelFk = tr.id JOIN buy b ON b.entryFk = e.id diff --git a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js index 7e90c7681..8fa013fe4 100644 --- a/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js +++ b/modules/travel/back/methods/travel/specs/extraCommunityFilter.spec.js @@ -112,4 +112,17 @@ describe('Travel extraCommunityFilter()', () => { expect(result.length).toEqual(2); }); + + it('should return field isCustomInspectionRequired true', async() => { + const ctx = { + args: { + id: 2 + } + }; + + const result = await app.models.Travel.extraCommunityFilter(ctx, filter); + + expect(result[0].entries[0].isCustomInspectionRequired).toBeTruthy(); + expect(result[0].entries[1].isCustomInspectionRequired).toBeFalsy(); + }); }); From ea4b11801516e7abca32781501dcd31731177402 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 19 Dec 2024 10:26:53 +0100 Subject: [PATCH 181/219] feat: refs #7301 update lastEntriesFilter to include landedDate and enhance test cases --- .../back/methods/item/lastEntriesFilter.js | 1 + .../item/specs/lastEntriesFilter.spec.js | 53 ++++++++++++++----- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/modules/item/back/methods/item/lastEntriesFilter.js b/modules/item/back/methods/item/lastEntriesFilter.js index 7a98eabd9..b038bb155 100644 --- a/modules/item/back/methods/item/lastEntriesFilter.js +++ b/modules/item/back/methods/item/lastEntriesFilter.js @@ -33,6 +33,7 @@ module.exports = Self => { w.id warehouseFk, w.name warehouse, CAST(tr.landed AS CHAR) landed, + tr.landed landedDate, b.id buyFk, b.entryFk, b.isIgnored, diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js index a32225af7..b2bfdf59c 100644 --- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js +++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js @@ -1,17 +1,22 @@ const {models} = require('vn-loopback/server/server'); const itemFk = 1; + +const today = Date.vnNew(); +today.setHours(23, 59, 59, 999); + +const twoMonthsAgo = Date.vnNew(); +twoMonthsAgo.setHours(0, 0, 0, 0); +twoMonthsAgo.setMonth(twoMonthsAgo.getMonth() - 2, 1); describe('item lastEntriesFilter()', () => { it('should return two entry for the given item', async() => { const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); - const maxDate = Date.vnNew(); - maxDate.setHours(23, 59, 59, 999); const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; try { - const filter = {where: {itemFk, landed: {between: [minDate, maxDate]}}}; + const filter = {where: {itemFk, landed: {between: [minDate, today]}}}; const result = await models.Item.lastEntriesFilter(filter, options); expect(result.length).toEqual(2); @@ -24,21 +29,14 @@ describe('item lastEntriesFilter()', () => { }); it('should return six entries for the given item', async() => { - const minDate = Date.vnNew(); - minDate.setHours(0, 0, 0, 0); - minDate.setMonth(minDate.getMonth() - 2, 1); - - const maxDate = Date.vnNew(); - maxDate.setHours(23, 59, 59, 59); - const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; try { - const filter = {where: {itemFk, landed: {between: [minDate, maxDate]}}}; + const filter = {where: {itemFk, landed: {between: [twoMonthsAgo, today]}}}; const result = await models.Item.lastEntriesFilter(filter, options); - const minDateUtc = minDate.getTime(); - const maxDateUtc = maxDate.getTime(); + const twoMonthsAgoUtc = twoMonthsAgo.getTime(); + const todayUtc = today.getTime(); const resultMatch = ( await Promise.all( @@ -51,7 +49,7 @@ describe('item lastEntriesFilter()', () => { const isItemFkValid = itemRecord?.id === itemFk; const landedDate = Date.vnNew(item.landed).getTime(); - const isLandedValid = landedDate >= minDateUtc && landedDate <= maxDateUtc; + const isLandedValid = landedDate >= twoMonthsAgoUtc && landedDate <= todayUtc; return isItemFkValid && isLandedValid; }) @@ -66,4 +64,31 @@ describe('item lastEntriesFilter()', () => { throw e; } }); + + it('should return just the inventoried inventory', async() => { + const tx = await models.Item.beginTransaction({}); + const options = {transaction: tx}; + + try { + const filter = {where: {itemFk, landed: {between: [twoMonthsAgo, today]}}}; + const result = await models.Item.lastEntriesFilter(filter, options); + + const {supplierFk} = await models.InventoryConfig.findOne(options); + const {inventoried} = await models.Config.findOne(options); + + let hasInventoriedDate = false; + result.forEach(entry => { + if (entry.supplierFk === supplierFk && + entry.landedDate.getTime() === inventoried.getTime() + )hasInventoriedDate = true; + }); + + expect(hasInventoriedDate).toEqual(true); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); From 1f7dae2514a238ec9d49ef8c9e076b109735a649 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 19 Dec 2024 10:34:46 +0100 Subject: [PATCH 182/219] fix: refs #7936 locale --- modules/invoiceIn/back/locale/invoiceIn/en.yml | 7 ++----- modules/invoiceIn/back/locale/invoiceIn/es.yml | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/modules/invoiceIn/back/locale/invoiceIn/en.yml b/modules/invoiceIn/back/locale/invoiceIn/en.yml index 6940b6f77..f590f9656 100644 --- a/modules/invoiceIn/back/locale/invoiceIn/en.yml +++ b/modules/invoiceIn/back/locale/invoiceIn/en.yml @@ -18,8 +18,5 @@ columns: withholdingSageFk: withholding expenseFkDeductible: expense deductible editorFk: editor - cplusRectificationTypeFk: cplus rectification type - cplusSubjectOpFk: cplus subject op - cplusTaxBreakFk: cplus tax break - siiTrasCendencyInvoiceInFk: sii tras cendency invoice in - siiTypeInvoiceInFk: sii type invoice in \ No newline at end of file + siiTrasCendencyInvoiceInFk: SII tax regime + siiTypeInvoiceInFk: SII Type \ No newline at end of file diff --git a/modules/invoiceIn/back/locale/invoiceIn/es.yml b/modules/invoiceIn/back/locale/invoiceIn/es.yml index 9599c0535..494764d07 100644 --- a/modules/invoiceIn/back/locale/invoiceIn/es.yml +++ b/modules/invoiceIn/back/locale/invoiceIn/es.yml @@ -18,8 +18,5 @@ columns: withholdingSageFk: código de retención expenseFkDeductible: gasto deducible editorFk: editor - cplusRectificationTypeFk: tipo de rectificación cplus - cplusSubjectOpFk: sujeto op cplus - cplusTaxBreakFk: exención fiscal cplus - siiTrasCendencyInvoiceInFk: trascendencia sii factura recibida - siiTypeInvoiceInFk: tipo sii factura recibida \ No newline at end of file + siiTrasCendencyInvoiceInFk: Régimen fiscal SII + siiTypeInvoiceInFk: Tipo SII \ No newline at end of file From 6abbf3ec1d5ddcf7b55191a82db99f00c0af82cd Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 19 Dec 2024 13:01:34 +0100 Subject: [PATCH 183/219] fix: refs #7936 update Spanish locale for SII terms --- modules/invoiceIn/back/locale/invoiceIn/es.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/invoiceIn/back/locale/invoiceIn/es.yml b/modules/invoiceIn/back/locale/invoiceIn/es.yml index 494764d07..64ded6aca 100644 --- a/modules/invoiceIn/back/locale/invoiceIn/es.yml +++ b/modules/invoiceIn/back/locale/invoiceIn/es.yml @@ -18,5 +18,5 @@ columns: withholdingSageFk: código de retención expenseFkDeductible: gasto deducible editorFk: editor - siiTrasCendencyInvoiceInFk: Régimen fiscal SII - siiTypeInvoiceInFk: Tipo SII \ No newline at end of file + siiTrasCendencyInvoiceInFk: régimen fiscal SII + siiTypeInvoiceInFk: tipo SII \ No newline at end of file From c59cae9f74fbe65d14badde2fc40e82660573a1c Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 19 Dec 2024 14:38:28 +0100 Subject: [PATCH 184/219] feat: refs #8073 new comment message --- db/versions/11387-whiteDendro/00-firstScript.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/versions/11387-whiteDendro/00-firstScript.sql b/db/versions/11387-whiteDendro/00-firstScript.sql index 3226dfc42..4e9f1d217 100644 --- a/db/versions/11387-whiteDendro/00-firstScript.sql +++ b/db/versions/11387-whiteDendro/00-firstScript.sql @@ -1,8 +1,8 @@ CREATE TABLE IF NOT EXISTS vn.productionCountry( countryFk MEDIUMINT(8) UNSIGNED NOT NULL, - volumeGrowthEstimatePercent DECIMAL(6, 2), + volumeGrowthEstimatePercent DECIMAL(6, 2) COMMENT 'Porcentaje estimado de crecimiento del volumen', PRIMARY KEY (countryFk), CONSTRAINT productionCountryVolume_countryFK FOREIGN KEY (countryFk) REFERENCES vn.country (id) ON DELETE RESTRICT ON UPDATE CASCADE -) COMMENT = 'Estimación del crecimiento por país' \ No newline at end of file +) COMMENT = 'Datos de producción por país' \ No newline at end of file From a2218b41f8b5192b060ca2ad1944dd25ec221dfb Mon Sep 17 00:00:00 2001 From: jtubau Date: Mon, 23 Dec 2024 14:49:44 +0100 Subject: [PATCH 185/219] feat: refs #8266 added itemFk and needed fixtures --- db/dump/fixtures.before.sql | 2 +- modules/ticket/back/methods/expedition/filter.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 663705ff5..8dbaac2c2 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3963,7 +3963,7 @@ VALUES(1, ''); INSERT INTO dipole.expedition_PrintOut (expeditionFk, ticketFk, addressFk, street, postalCode, city, shopName, isPrinted, created, printerFk, routeFk, parkingCode, truckName, clientFk, phone, province, agency, m3, workerCode, itemFk, quantity, longName, shelvingFk, comments) -VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, NULL, 'NCC', NULL); +VALUES(1, 1, 0, ' ', ' ', ' ', ' ', 0, '2001-01-01 00:00:00', 1, 0, ' ', ' ', 0, NULL, '', NULL, 0.000, NULL, 10, NULL, 'Ranged Reinforced weapon sniper rifle 700mm' , 'NCC', NULL); INSERT INTO vn.accountDetail (id, value, accountDetailTypeFk, supplierAccountFk) diff --git a/modules/ticket/back/methods/expedition/filter.js b/modules/ticket/back/methods/expedition/filter.js index bd2012668..801d00a9b 100644 --- a/modules/ticket/back/methods/expedition/filter.js +++ b/modules/ticket/back/methods/expedition/filter.js @@ -50,7 +50,8 @@ module.exports = Self => { su.name scannerUserName, es.scanned, est.description state, - de.longName + de.longName, + de.itemFk FROM vn.expedition e LEFT JOIN vn.expeditionStateType est ON est.id = e.stateTypeFk INNER JOIN vn.item i1 ON i1.id = e.freightItemFk From 48d2d1d3271eb6d92ef8cda0979e38daed999e30 Mon Sep 17 00:00:00 2001 From: jtubau Date: Thu, 26 Dec 2024 10:41:20 +0100 Subject: [PATCH 186/219] feat: refs #8117 add worker first and last name to item type query --- modules/ticket/back/methods/ticket-request/getItemTypeWorker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/ticket-request/getItemTypeWorker.js b/modules/ticket/back/methods/ticket-request/getItemTypeWorker.js index f160cfaac..2f2a85abb 100644 --- a/modules/ticket/back/methods/ticket-request/getItemTypeWorker.js +++ b/modules/ticket/back/methods/ticket-request/getItemTypeWorker.js @@ -30,7 +30,7 @@ module.exports = Self => { Object.assign(myOptions, options); const query = - `SELECT DISTINCT u.id, u.nickname + `SELECT DISTINCT u.id, u.nickname, w.firstName, w.lastName FROM itemType it JOIN worker w ON w.id = it.workerFk JOIN account.user u ON u.id = w.id`; From 98e2483565754146a05fe7dd3f2a2773b13ceba3 Mon Sep 17 00:00:00 2001 From: jgallego Date: Sun, 29 Dec 2024 09:38:51 +0100 Subject: [PATCH 187/219] feat: refs #8167 update locale and improve invoicing logic with error handling --- loopback/locale/en.json | 9 +++++---- .../back/methods/invoiceOut/clientsToInvoice.js | 12 ++++++++---- .../invoiceOut/specs/clientsToInvoice.spec.js | 4 ++-- .../back/methods/ticket/specs/makeInvoice.spec.js | 4 +++- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index e6ec52d63..80da13ae5 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -246,8 +246,9 @@ "ticketLostExpedition": "The ticket [{{ticketId}}]({{{ticketUrl}}}) has the following lost expedition:{{ expeditionId }}", "The raid information is not correct": "The raid information is not correct", "Payment method is required": "Payment method is required", - "Sales already moved": "Sales already moved", - "Holidays to past days not available": "Holidays to past days not available", + "Sales already moved": "Sales already moved", + "Holidays to past days not available": "Holidays to past days not available", "Price cannot be blank": "Price cannot be blank", - "There are tickets to be invoiced": "There are tickets to be invoiced" -} + "There are tickets to be invoiced": "There are tickets to be invoiced", + "The address of the customer must have information about Incoterms and Customs Agent": "The address of the customer must have information about Incoterms and Customs Agent" +} \ No newline at end of file diff --git a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js index 5526d214a..7befdcbeb 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js @@ -1,3 +1,5 @@ +const UserError = require('vn-loopback/util/user-error'); + module.exports = Self => { Self.remoteMethodCtx('clientsToInvoice', { description: 'Get the clients to make global invoicing', @@ -47,7 +49,12 @@ module.exports = Self => { } try { - // Packaging liquidation + const clientCanBeInvoiced = + await Self.app.models.Client.canBeInvoiced(clientId, companyFk, myOptions); + + if (!clientCanBeInvoiced) + throw new UserError(`This client can't be invoiced`); + const vIsAllInvoiceable = false; await Self.rawSql('CALL ticketPackaging_add(?, ?, ?, ?)', [ clientId, @@ -71,9 +78,6 @@ module.exports = Self => { AND t.shipped BETWEEN ? AND util.dayEnd(?) AND (t.clientFk = ? OR ? IS NULL ) AND t.companyFk = ? - AND c.hasToInvoice - AND c.isTaxDataChecked - AND c.isActive AND NOT t.isDeleted GROUP BY IF(c.hasToInvoiceByAddress, a.id, c.id) HAVING SUM(t.totalWithVat) > 0;`; diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js index 470690c5a..df0566c54 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js @@ -4,11 +4,11 @@ describe('InvoiceOut clientsToInvoice()', () => { const userId = 1; const clientId = 1101; const companyFk = 442; - const maxShipped = new Date(); + const maxShipped = Date.vnNew(); maxShipped.setMonth(11); maxShipped.setDate(31); maxShipped.setHours(23, 59, 59, 999); - const invoiceDate = new Date(); + const invoiceDate = Date.vnNew(); const activeCtx = { getLocale: () => { return 'en'; diff --git a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js index 88812dc92..f9e4bcac0 100644 --- a/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js +++ b/modules/ticket/back/methods/ticket/specs/makeInvoice.spec.js @@ -77,6 +77,8 @@ describe('ticket makeInvoice()', () => { await tx.rollback(); } - expect(error.message).toEqual(`The address of the customer must have information about Incoterms and Customs Agent`); + expect(error.message).toEqual( + `The address of the customer must have information about Incoterms and Customs Agent` + ); }); }); From 8ca5808554dc01b28f5a88eb7f8e412b58644397 Mon Sep 17 00:00:00 2001 From: jgallego Date: Sun, 29 Dec 2024 10:16:38 +0100 Subject: [PATCH 188/219] fix: add isCustomInspectionRequired column to item table for customs inspection indication --- db/versions/11391-redPalmetto/00-itemAlter.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11391-redPalmetto/00-itemAlter.sql b/db/versions/11391-redPalmetto/00-itemAlter.sql index 1eaef1a1b..fc47d5fc0 100644 --- a/db/versions/11391-redPalmetto/00-itemAlter.sql +++ b/db/versions/11391-redPalmetto/00-itemAlter.sql @@ -1,2 +1,2 @@ -ALTER TABLE `item` +ALTER TABLE `vn`.`item` ADD COLUMN `isCustomInspectionRequired` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'Indicates if the item requires physical inspection at customs'; From 879ffcad64a8e3867b8e1b76afe3df47c0ee4545 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 30 Dec 2024 15:51:11 +0100 Subject: [PATCH 189/219] fix: refs #6598 update ACL property assignment --- back/methods/vn-user/acls.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/vn-user/acls.js b/back/methods/vn-user/acls.js index 7da75ed2c..347cfa426 100644 --- a/back/methods/vn-user/acls.js +++ b/back/methods/vn-user/acls.js @@ -19,7 +19,7 @@ module.exports = Self => { if (acl.principalType == 'ROLE' && acl.permission == 'ALLOW') { const staticAcl = { model: model.name, - property: '*', + property: acl.property, accessType: acl.accessType, permission: acl.permission, principalType: acl.principalType, From 1f23ebf6d5a3d5528acb535dac45c87a783c352b Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 31 Dec 2024 11:46:32 +0100 Subject: [PATCH 190/219] feat: refs #7832 implement refund ticket restrictions and add unit tests for ticket service updates --- .../back/models/specs/ticket-service.spec.js | 65 +++++++++++++++++++ modules/ticket/back/models/ticket-service.js | 11 +++- 2 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 modules/ticket/back/models/specs/ticket-service.spec.js diff --git a/modules/ticket/back/models/specs/ticket-service.spec.js b/modules/ticket/back/models/specs/ticket-service.spec.js new file mode 100644 index 000000000..0edd296c6 --- /dev/null +++ b/modules/ticket/back/models/specs/ticket-service.spec.js @@ -0,0 +1,65 @@ +/* eslint max-len: ["error", { "code": 150 }]*/ +const {models} = require('vn-loopback/server/server'); + +fdescribe('ticketService model ', () => { + const originalTicketFk = 1; + const refundTicketFk = 11; + + let tx; + let opts; + let ticketService; + + beforeEach(async() => { + tx = await models.Sale.beginTransaction({}); + opts = {transaction: tx}; + + ticketService = await models.TicketService.create({ + ticketFk: refundTicketFk, + description: 'test', + quantity: 1, + price: 100, + taxClassFk: 1, + ticketServiceTypeFk: 1 + }, opts); + }); + + afterEach(async() => { + await tx.rollback(); + }); + + describe('TicketService', () => { + it('should allow updating description and quantity for non-refund tickets', async() => { + await ticketService.updateAttributes({ + ticketServiceTypeFk: 2, + quantity: 5 + }, opts); + + const updated = await models.TicketService.findById(ticketService.id, null, opts); + + expect(updated.description).not.toBe('test'); + expect(updated.quantity).toBe(5); + }); + + it('should only allow updating description for refund tickets', async() => { + await models.TicketRefund.create({ + refundTicketFk, + originalTicketFk + }, opts); + + await ticketService.updateAttributes({ + ticketServiceTypeFk: 2 + }, opts); + + try { + await ticketService.updateAttributes({ + ticketServiceTypeFk: 3, + quantity: 5 + }, opts); + + fail('Should have thrown error'); + } catch (e) { + expect(e.message).toBe('Only description can be modified in refund tickets'); + } + }); + }); +}); diff --git a/modules/ticket/back/models/ticket-service.js b/modules/ticket/back/models/ticket-service.js index 209727ee4..77479498a 100644 --- a/modules/ticket/back/models/ticket-service.js +++ b/modules/ticket/back/models/ticket-service.js @@ -10,9 +10,18 @@ module.exports = Self => { const isLocked = await models.Ticket.isLocked(ticketId); if (isLocked) throw new UserError(`The current ticket can't be modified`); + + const isRefund = await models.TicketRefund.findOne({ + where: {refundTicketFk: ticketId} + }, { + transaction: ctx.options.transaction + }); + + if (isRefund && ctx.data && Object.keys(ctx.data).some(field => field !== 'ticketServiceTypeFk')) + throw new UserError('Only description can be modified in refund tickets'); } - if (changes && changes.ticketServiceTypeFk) { + if (changes?.ticketServiceTypeFk) { const ticketServiceType = await models.TicketServiceType.findById(changes.ticketServiceTypeFk); changes.description = ticketServiceType.name; } From 0ad26b336d7a08a4a885b1d0b04947c968684a56 Mon Sep 17 00:00:00 2001 From: jgallego Date: Tue, 31 Dec 2024 11:48:05 +0100 Subject: [PATCH 191/219] fix: refs #7832 update ticketService model test suite to correct describe block --- modules/ticket/back/models/specs/ticket-service.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/ticket/back/models/specs/ticket-service.spec.js b/modules/ticket/back/models/specs/ticket-service.spec.js index 0edd296c6..2691123eb 100644 --- a/modules/ticket/back/models/specs/ticket-service.spec.js +++ b/modules/ticket/back/models/specs/ticket-service.spec.js @@ -1,7 +1,6 @@ -/* eslint max-len: ["error", { "code": 150 }]*/ const {models} = require('vn-loopback/server/server'); -fdescribe('ticketService model ', () => { +describe('ticketService model ', () => { const originalTicketFk = 1; const refundTicketFk = 11; From 8822fde7fb194c93f284db3b9e5b7b38374a4c4a Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 2 Jan 2025 18:04:53 +0100 Subject: [PATCH 192/219] feat: refs #7343 delete sending to user --- .../back/methods/route/driverRouteEmail.js | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/modules/route/back/methods/route/driverRouteEmail.js b/modules/route/back/methods/route/driverRouteEmail.js index bbac2b0e8..78069683d 100644 --- a/modules/route/back/methods/route/driverRouteEmail.js +++ b/modules/route/back/methods/route/driverRouteEmail.js @@ -8,7 +8,7 @@ module.exports = Self => { arg: 'id', type: 'number', required: true, - description: 'The client id', + description: 'The route id', http: {source: 'path'} }, { arg: 'replyTo', @@ -31,26 +31,13 @@ module.exports = Self => { }); Self.driverRouteEmail = async(ctx, id) => { - const models = Self.app.models; - const {workerFk, agencyMode} = await Self.findById(id, { - fields: ['workerFk', 'agencyModeFk'], + const {agencyMode} = await Self.findById(id, { + fields: ['agencyModeFk'], include: {relation: 'agencyMode'} }); const {reportMail} = agencyMode(); - let user; - let account; - - if (workerFk) { - user = await models.VnUser.findById(workerFk, { - fields: ['active', 'id'], - include: {relation: 'emailUser'} - }); - account = await models.Account.findById(workerFk); - } - - if (user?.active && account) ctx.args.recipient = user.emailUser().email; - else ctx.args.recipient = reportMail; + ctx.args.recipient = reportMail; if (!ctx.args.recipient) throw new UserError('An email is necessary'); return Self.sendTemplate(ctx, 'driver-route'); }; From 67c484cd876ab4472e3c1b6e7754d6292a4d51f7 Mon Sep 17 00:00:00 2001 From: pablone Date: Fri, 3 Jan 2025 09:39:49 +0100 Subject: [PATCH 193/219] feat: refs #7301 update SQL fixtures and enhance lastEntriesFilter logic --- db/dump/fixtures.before.sql | 11 ++-- .../back/methods/item/lastEntriesFilter.js | 30 ++++++---- .../item/specs/lastEntriesFilter.spec.js | 57 +++++++++++++------ 3 files changed, 68 insertions(+), 30 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 97ed0ae47..ff24fa2a6 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -1516,7 +1516,8 @@ INSERT INTO `vn`.`travel`(`id`,`shipped`, `landed`, `warehouseInFk`, `warehouseO (8, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 5, 1, 1, 50.00, 500, 'eight travel', 1, 2, 10, FALSE, NULL), (10, DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), DATE_ADD(util.VN_CURDATE(), INTERVAL +5 DAY), 5, 1, 1, 50.00, 500, 'nineth travel', 1, 2, 10, TRUE, 2), (11, util.VN_CURDATE() - INTERVAL 1 DAY , util.VN_CURDATE(), 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL), - (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL); + (12, util.VN_CURDATE() , util.VN_CURDATE() + INTERVAL 1 DAY, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL), + (13, util.VN_CURDATE() - INTERVAL 1 MONTH - INTERVAL 1 DAY, util.VN_CURDATE() - INTERVAL 1 MONTH, 6, 3, 0, 50.00, 500, 'eleventh travel', 1, 2, 4, FALSE, NULL); INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed`, `companyFk`, `invoiceNumber`, `reference`, `isExcludedFromAvailable`, `evaNotes`, `typeFk`) VALUES @@ -1529,8 +1530,9 @@ INSERT INTO `vn`.`entry`(`id`, `supplierFk`, `created`, `travelFk`, `isConfirmed (7, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2007', 'Movement 7', 0, 'observation seven', 'product'), (8, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 7, 0, 442, 'IN2008', 'Movement 8', 1, '', 'product'), (9, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 9', 1, '', 'product'), - (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2009', 'Movement 10',1, '', 'product'), - (11, 4, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH), 1, 1, 442, 'IN2001', 'Movement 11',0, '', 'product'), + (10, 2, DATE_ADD(util.VN_CURDATE(), INTERVAL +2 DAY), 10, 0, 442, 'IN2010', 'Movement 10',1, '', 'product'), + (11, 4, DATE_ADD(util.VN_CURDATE(), INTERVAL -2 MONTH), 1, 1, 442, 'IN2011', 'Movement 11',0, '', 'product'), + (12, 4, util.VN_CURDATE() - INTERVAL 1 MONTH, 13, 1, 442, 'IN2012', 'Movement 12',0, '', 'product'), (99, 69, util.VN_CURDATE() - INTERVAL 1 MONTH, 11, 0, 442, 'IN2009', 'Movement 99',0, '', 'product'); INSERT INTO `vn`.`entryConfig` (`defaultEntry`, `inventorySupplierFk`, `defaultSupplierFk`) @@ -1572,7 +1574,8 @@ INSERT INTO `bs`.`waste`(`buyerFk`, `year`, `week`, `itemFk`, `itemTypeFk`, `sal (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()), (16, 99,1,50.0000, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'packing', NULL, 0.00, 99.60, 99.40, 0, 1, 0, 1.00, '2024-07-30 08:13:51.000'), - (17, 11, 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); + (17, 11, 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), + (18, 12, 1, 50, 5000, 4, 1, 1.500, 1.500, 0.000, 1, 1, 'grouping', NULL, 0.00, 99.6, 99.4, 0, 1, 0, 1, util.VN_CURDATE() - INTERVAL 2 MONTH); 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 diff --git a/modules/item/back/methods/item/lastEntriesFilter.js b/modules/item/back/methods/item/lastEntriesFilter.js index 06c60162f..b038bb155 100644 --- a/modules/item/back/methods/item/lastEntriesFilter.js +++ b/modules/item/back/methods/item/lastEntriesFilter.js @@ -29,10 +29,12 @@ module.exports = Self => { Object.assign(myOptions, options); const stmt = new ParameterizedSQL( - `SELECT w.id AS warehouseFk, - w.name AS warehouse, - tr.landed, - b.id AS buyFk, + `SELECT i.id itemFk, + w.id warehouseFk, + w.name warehouse, + CAST(tr.landed AS CHAR) landed, + tr.landed landedDate, + b.id buyFk, b.entryFk, b.isIgnored, b.price2, @@ -47,15 +49,18 @@ module.exports = Self => { b.buyingValue + b.freightValue + b.comissionValue + - b.packageValue AS cost, + b.packageValue cost, b.buyingValue, b.freightValue, b.comissionValue, b.packageValue, b.packagingFk , - s.id AS supplierFk, - s.name AS supplier, - b.printedStickers + s.id supplierFk, + s.name supplier, + b.printedStickers, + c.inventoried, + ic.supplierFk inventorySupplierFk, + s.id = ic.supplierFk isInventorySupplier FROM itemType it RIGHT JOIN (entry e LEFT JOIN supplier s ON s.id = e.supplierFk @@ -66,9 +71,14 @@ module.exports = Self => { LEFT JOIN warehouse w ON w.id = tr.warehouseInFk LEFT JOIN origin o ON o.id = i.originFk ) ON it.id = i.typeFk - LEFT JOIN edi.ekt ek ON b.ektFk = ek.id` + LEFT JOIN edi.ekt ek ON b.ektFk = ek.id + JOIN config c + JOIN inventoryConfig ic` ); - stmt.merge(conn.makeSuffix(filter)); + + stmt.merge(conn.makeWhere(filter.where)); + stmt.merge('AND IF(s.id = ic.supplierFk, tr.landed = DATE(c.inventoried), TRUE)'); + stmt.merge(conn.makePagination(filter)); return conn.executeStmt(stmt, myOptions); }; diff --git a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js index d4429e158..b2bfdf59c 100644 --- a/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js +++ b/modules/item/back/methods/item/specs/lastEntriesFilter.spec.js @@ -1,16 +1,22 @@ const {models} = require('vn-loopback/server/server'); +const itemFk = 1; + +const today = Date.vnNew(); +today.setHours(23, 59, 59, 999); + +const twoMonthsAgo = Date.vnNew(); +twoMonthsAgo.setHours(0, 0, 0, 0); +twoMonthsAgo.setMonth(twoMonthsAgo.getMonth() - 2, 1); describe('item lastEntriesFilter()', () => { it('should return two entry for the given item', async() => { const minDate = Date.vnNew(); minDate.setHours(0, 0, 0, 0); - const maxDate = Date.vnNew(); - maxDate.setHours(23, 59, 59, 59); const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; try { - const filter = {where: {itemFk: 1, landed: {between: [minDate, maxDate]}}}; + const filter = {where: {itemFk, landed: {between: [minDate, today]}}}; const result = await models.Item.lastEntriesFilter(filter, options); expect(result.length).toEqual(2); @@ -23,22 +29,14 @@ describe('item lastEntriesFilter()', () => { }); it('should return six entries for the given item', async() => { - const minDate = Date.vnNew(); - minDate.setHours(0, 0, 0, 0); - minDate.setMonth(minDate.getMonth() - 2, 1); - - const maxDate = Date.vnNew(); - maxDate.setHours(23, 59, 59, 59); - const tx = await models.Item.beginTransaction({}); const options = {transaction: tx}; try { - const itemFk = 1; - const filter = {where: {itemFk, landed: {between: [minDate, maxDate]}}}; + const filter = {where: {itemFk, landed: {between: [twoMonthsAgo, today]}}}; const result = await models.Item.lastEntriesFilter(filter, options); - const minDateUtc = new Date(minDate).getTime(); - const maxDateUtc = new Date(maxDate).getTime(); + const twoMonthsAgoUtc = twoMonthsAgo.getTime(); + const todayUtc = today.getTime(); const resultMatch = ( await Promise.all( @@ -50,8 +48,8 @@ describe('item lastEntriesFilter()', () => { }); const isItemFkValid = itemRecord?.id === itemFk; - const landedDate = new Date(item.landed).getTime(); - const isLandedValid = landedDate >= minDateUtc && landedDate <= maxDateUtc; + const landedDate = Date.vnNew(item.landed).getTime(); + const isLandedValid = landedDate >= twoMonthsAgoUtc && landedDate <= todayUtc; return isItemFkValid && isLandedValid; }) @@ -66,4 +64,31 @@ describe('item lastEntriesFilter()', () => { throw e; } }); + + it('should return just the inventoried inventory', async() => { + const tx = await models.Item.beginTransaction({}); + const options = {transaction: tx}; + + try { + const filter = {where: {itemFk, landed: {between: [twoMonthsAgo, today]}}}; + const result = await models.Item.lastEntriesFilter(filter, options); + + const {supplierFk} = await models.InventoryConfig.findOne(options); + const {inventoried} = await models.Config.findOne(options); + + let hasInventoriedDate = false; + result.forEach(entry => { + if (entry.supplierFk === supplierFk && + entry.landedDate.getTime() === inventoried.getTime() + )hasInventoriedDate = true; + }); + + expect(hasInventoriedDate).toEqual(true); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); From dc52c08c150b5cbb638193af2b018f045c15cec7 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 6 Jan 2025 19:30:06 +0100 Subject: [PATCH 194/219] build: refs #8355 add changelog --- CHANGELOG.md | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73ebecabc..c4eb7d29a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,106 @@ +# Version 24.52 - 2024-01-07 + +### Added 🆕 + +- chore: pullinfo by:alexm +- chore: refs #8002 drop comments by:jorgep +- chore: refs #8002 drop useless code by:jorgep +- feat: added translations and show error in item-type by:Jon +- feat: modified data to be equal as the updated back by:Jon +- feat: refs #4460 invoiceIn refund by:Carlos Andrés +- feat: refs #4466 invoiceIn refund by:Carlos Andrés +- feat: refs #6583 add new opt in where builder by:jorgep +- feat: refs #6583 add tests by:jorgep +- feat: refs #6583 retrieve cloned sale by:jorgep +- feat: refs #6583 rollback by:jorgep +- feat: refs #7301 add inventory-config and acl by:pablone +- feat: refs #7301 update SQL fixtures and enhance lastEntriesFilter logic by:pablone +- feat: refs #7882 Added locationiq service by:guillermo +- feat: refs #7882 Added osrm service by:guillermo +- feat: refs #7882 Added tests by:guillermo +- feat: refs #7882 Fixed problems osrm service by:guillermo +- feat: refs #7882 Osrm service by:guillermo +- feat: refs #7882 Reequested changes by:guillermo +- feat: refs #7882 Requested changes by:guillermo +- feat: refs #7936 add back test for updateInvoiceIn by:jorgep +- feat: refs #7936 add company filter by:jorgep +- feat: refs #7936 add currency check to updateInvoiceIn by:jorgep +- feat: refs #7936 add currency handling in invoiceIn trigger by:jorgep +- feat: refs #7936 add locale by:jorgep +- feat: refs #7936 add minimum due date by:jorgep +- feat: refs #7936 add reference rates for currency in fixtures by:jorgep +- feat: refs #7936 add save validation by:jorgep +- feat: refs #7936 add SiiTypeInvoiceIn model and update invoice correction logic by:jorgep +- feat: refs #7936 add tests for invoiceIn by:jorgep +- feat: refs #7936 add tests for invoiceIn filter by:jorgep +- feat: refs #7936 add validation to InvoiceIn & InvoiceInTax by:jorgep +- feat: refs #7936 return country code & is vies fields by:jorgep +- feat: refs #8002 adjust to lilium by:jorgep +- feat: refs #8002 drop support btn by:jorgep +- feat: refs #8174 Changed datatype incompatibility access by:guillermo +- feat: refs #8174 Created table sim by:guillermo +- feat: refs #8174 create table simsupplier by:Jbreso +- feat: refs #8174 fix by:Jbreso +- feat: refs#8174 simSupplier by:Jbreso +- feat: refs #8190 entry_getCommission by:robert +- feat: refs #8190 entry_getCommission change request by:robert +- feat: refs #8218 Added time and code in mistakeType by:guillermo +- feat: refs #8293 include zone data by:Jtubau +- refactor: refs #6583 entry report table style by:jorgep + +### Changed 📦 + +- refactor: refs #6583 entry report table style by:jorgep +- refactor: refs #6583 use warehouseId var by:jorgep +- refactor: refs #7301 update entry and item filter tests to validate results against specific criteria by:pablone +- refactor: refs #7882 Added ACL's by:guillermo +- refactor: refs #7882 Deleted quadminds files by:guillermo +- refactor: refs #7936 add transaction & tests by:jorgep +- refactor: refs #7936 remove old trigger and add isRaid column to travel table by:jorgep +- refactor: refs #7936 remove schema by:jorgep +- refactor: refs #8002 use loop wip by:jorgep +- refactor: refs #8004 simplify SQL query by removing redundant aliases by:pablone +- refactor: refs #8262 Deprecated inventoryFailure by:guillermo +- refactor: refs #8266 changed expedition item name by:Jtubau +- refactor: refs #8272 delete bi.rotacion by:ivanm + +### Fixed 🛠️ + +- feat: refs #7301 update SQL fixtures and enhance lastEntriesFilter logic by:pablone +- feat: refs #7936 add reference rates for currency in fixtures by:jorgep +- feat: refs #8174 fix by:Jbreso +- fix: 8174 pasar PIN a CHAR by:Jbreso +- fix: monitorPayMethodFilter by:carlossa +- fix: refs #6389 back by:carlossa +- fix: refs #6389 filter by:carlossa +- fix: refs #6389 packing by:carlossa +- fix: refs #6389 saleMonitor filter by:carlossa +- fix: refs #6389 salesFilter by:carlossa +- fix: refs #6583 drop focus by:jorgep +- fix: refs #6583 update onlyWithDestination logic to handle null values correctly by:jorgep +- fix: refs #7028 fix confirm deny by:carlossa +- fix: refs #7028 fix pr by:carlossa +- fix: refs #7028 fix tback findById by:carlossa +- fix: refs #7028 fix userError by:carlossa +- fix: refs #7028 remove ifs by:carlossa +- fix: refs #7028 requesterId fix by:carlossa +- fix: refs #7028 requesterId fix salesPerson by:carlossa +- fix: refs #7031 fix vnPrice by:carlossa +- fix: refs #7031 remove check by:carlossa +- fix: refs #7301 update ACL insertion to use INSERT IGNORE and refine property value by:pablone +- fix: refs #7936 add IF NOT EXISTS to isRaid column in travel table by:jorgep +- fix: refs #7936 change type by:jorgep +- fix: refs #7936 check if insert in hook & change test description by:jorgep +- fix: refs #7936 conflicts by:jorgep +- fix: refs #7936 locale by:jorgep +- fix: refs #7936 update Spanish locale for SII terms by:jorgep +- fix: refs #8174 fix by:Jbreso +- fix: refs#8174 fix by:Jbreso +- fix: refs8174 pasar a char el PIN by:Jbreso +- fix: refs #8174 Version by:guillermo +- fix: refs #8251 add eng template by:carlossa +- fix: refs #8315 fixture claimDevelopment by:alexm + # Version 24.48 - 2024-11-25 ### Added 🆕 From ad0c1eb4c5e8b493066cf8302863df0515ecb633 Mon Sep 17 00:00:00 2001 From: Jon Date: Tue, 7 Jan 2025 07:12:33 +0100 Subject: [PATCH 195/219] feat: refs #8246 added relation for the front's new field --- modules/client/back/models/address.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/client/back/models/address.json b/modules/client/back/models/address.json index e8bf8d8a0..2d11b7745 100644 --- a/modules/client/back/models/address.json +++ b/modules/client/back/models/address.json @@ -84,6 +84,11 @@ "type": "belongsTo", "model": "CustomsAgent", "foreignKey": "customsAgentFk" + }, + "postcode": { + "type": "belongsTo", + "model": "Postcode", + "foreignKey": "postalCode" } } } From 48d4bab7062eb9d8c3b04976801ad93b1acdf26d Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 7 Jan 2025 08:01:44 +0100 Subject: [PATCH 196/219] build: refs #8355 dump db --- db/dump/.dump/data.sql | 25 ++- db/dump/.dump/privileges.sql | 11 +- db/dump/.dump/structure.sql | 351 ++++++++++++++--------------------- db/dump/.dump/triggers.sql | 29 ++- 4 files changed, 191 insertions(+), 225 deletions(-) diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index cd978e4a8..a2df34218 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -4,7 +4,7 @@ USE `util`; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -INSERT INTO `version` VALUES ('vn-database','11377','d3fe5098277c3935c434838b53facb271f84ebec','2024-12-10 07:22:33','11379'); +INSERT INTO `version` VALUES ('vn-database','11385','72bf27f08d3ddf646ec0bb6594fc79cecd4b72f2','2025-01-07 07:46:33','11395'); INSERT INTO `versionLog` VALUES ('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL); @@ -1083,6 +1083,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','11322','00-entryAcl.sql','jenkin INSERT INTO `versionLog` VALUES ('vn-database','11324','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-13 10:49:47',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11325','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11326','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11327','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-07 07:46:24',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11330','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11331','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11332','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL); @@ -1110,6 +1111,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','11348','00-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','11349','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:14',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11350','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:14',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11351','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11352','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-07 07:46:24',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11353','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:14',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11354','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11355','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:28:14',NULL,NULL); @@ -1120,6 +1122,8 @@ INSERT INTO `versionLog` VALUES ('vn-database','11362','00-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','11363','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11366','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11367','00-deprecate.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11368','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-07 07:46:32',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11368','01-acls.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-07 07:46:32',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11369','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:05',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11371','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:05',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11371','01-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:47',NULL,NULL); @@ -1128,7 +1132,13 @@ INSERT INTO `versionLog` VALUES ('vn-database','11371','03-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','11372','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-09 13:30:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11373','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-02 16:09:01',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11375','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-03 08:58:20',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11376','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-07 07:46:32',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11377','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:22:31',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11378','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-07 07:46:32',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11379','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-07 07:46:32',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11379','01-secScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-07 07:46:32',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11384','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-07 07:46:32',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11385','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-07 07:46:33',NULL,NULL); /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; @@ -2128,7 +2138,7 @@ INSERT INTO `ACL` VALUES (746,'Claim','getSummary','READ','ALLOW','ROLE','claimV INSERT INTO `ACL` VALUES (747,'CplusRectificationType','*','READ','ALLOW','ROLE','administrative',NULL); INSERT INTO `ACL` VALUES (748,'SiiTypeInvoiceOut','*','READ','ALLOW','ROLE','salesPerson',NULL); INSERT INTO `ACL` VALUES (749,'InvoiceCorrectionType','*','READ','ALLOW','ROLE','salesPerson',NULL); -INSERT INTO `ACL` VALUES (750,'InvoiceOut','transfer','WRITE','ALLOW','ROLE','administrative',NULL); +INSERT INTO `ACL` VALUES (750,'InvoiceOut','transfer','WRITE','ALLOW','ROLE','administrative',13657); INSERT INTO `ACL` VALUES (751,'Application','executeProc','*','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (752,'Application','executeFunc','*','ALLOW','ROLE','employee',NULL); INSERT INTO `ACL` VALUES (753,'NotificationSubscription','getList','READ','ALLOW','ROLE','employee',NULL); @@ -2369,6 +2379,10 @@ INSERT INTO `ACL` VALUES (1006,'Entry','latestBuysFilter','READ','ALLOW','ROLE', INSERT INTO `ACL` VALUES (1007,'ItemShelving','getItemsByReviewOrder','READ','ALLOW','ROLE','production',19294); INSERT INTO `ACL` VALUES (1008,'Entry','buyLabelSupplier','READ','ALLOW','ROLE','employee',19295); INSERT INTO `ACL` VALUES (1009,'Entry','buyLabel','READ','ALLOW','ROLE','supplier',19295); +INSERT INTO `ACL` VALUES (1010,'InventoryConfig','find','READ','ALLOW','ROLE','buyer',10578); +INSERT INTO `ACL` VALUES (1011,'SiiTypeInvoiceIn','find','READ','ALLOW','ROLE','salesPerson',10578); +INSERT INTO `ACL` VALUES (1012,'OsrmConfig','optimize','READ','ALLOW','ROLE','employee',10578); +INSERT INTO `ACL` VALUES (1013,'Route','optimizePriority','*','ALLOW','ROLE','employee',10578); INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee'); INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee'); @@ -2525,9 +2539,8 @@ INSERT INTO `companyI18n` VALUES (442,'en','In compliance with the provisions of INSERT INTO `companyI18n` VALUES (442,'fr','Conformément aux dispositions de la loi organique 15/1999 sur la protection des données personnelles, nous vous informons que les données personnelles que vous fournissez seront incluses dans des dossiers. VERDNATURA LEVANTE S.L., vous pouvez à tout moment, exercer les droits d``accès, de rectification, d``annulation et d``opposition, en communiquant par écrit au siège social de la société. Le dossier a pour objet la gestion administrative, la comptabilité et la facturation.'); INSERT INTO `companyI18n` VALUES (442,'pt','Em cumprimento do disposto na lei Orgânica 15/1999, de Protecção de Dados de Carácter Pessoal, comunicamos que os dados pessoais que facilite se incluirão nos ficheiros automatizados de VERDNATURA LEVANTE S.L., podendo em todo momento exercer os direitos de acesso, rectificação, cancelação e oposição, comunicando por escrito ao domicílio social da entidade. A finalidade do ficheiro é a gestão administrativa, contabilidade e facturação.'); -INSERT INTO `cplusRectificationType` VALUES (1,'Campo vacio'); +INSERT INTO `cplusRectificationType` VALUES (1,'S – Por sustitución'); INSERT INTO `cplusRectificationType` VALUES (2,'I – Por diferencias'); -INSERT INTO `cplusRectificationType` VALUES (3,'S – Por sustitución'); INSERT INTO `cplusSubjectOp` VALUES (1,'Campo vacio'); INSERT INTO `cplusSubjectOp` VALUES (2,'S1 – Sujeta – No exenta'); @@ -2619,6 +2632,8 @@ INSERT INTO `claimResult` VALUES (26,'Decepcion/Esperaba mas'); INSERT INTO `claimResult` VALUES (27,'Otros'); INSERT INTO `claimResult` VALUES (28,'Baboso/Cocido'); INSERT INTO `claimResult` VALUES (29,'Videocámaras'); +INSERT INTO `claimResult` VALUES (30,'Manipulado'); +INSERT INTO `claimResult` VALUES (31,'ReclamReclamado PR/AG'); INSERT INTO `component` VALUES (10,'Precios Especiales',4,NULL,NULL,1,'specialPrices',0); INSERT INTO `component` VALUES (14,'porte extra por dia semana',6,NULL,NULL,1,'extraCostPerWeekDay',0); @@ -2725,7 +2740,7 @@ INSERT INTO `department` VALUES (146,NULL,'VERDNACOLOMBIA',3,4,NULL,72,0,0,2,0,2 INSERT INTO `department` VALUES (147,'spainTeamAsia','EQUIPO ESPAÑA ASIA',71,72,40214,0,0,0,2,0,43,'/1/43/','esA_equipo',1,'esA@verdnatura.es',0,0,0,0,NULL,NULL,'5500',NULL); INSERT INTO `department` VALUES (148,'franceTeamCatchment','EQUIPO CAPTACIÓN FRANCIA',73,74,25178,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,'6000',NULL); INSERT INTO `department` VALUES (149,'spainTeamCatchment','EQUIPO ESPAÑA CAPTACIÓN',75,76,1203,0,0,0,2,0,43,'/1/43/','es_captacion_equipo',1,'es_captacion@verdnatura.es',0,0,0,0,NULL,NULL,'5700',NULL); -INSERT INTO `department` VALUES (150,'spainTeamLevanteIslands','EQUIPO ESPAÑA LEVANTE/ISLAS',77,78,1118,0,0,0,2,0,43,'/1/43/','es_levanteislas_equipo',1,'levanteislas.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5000',NULL); +INSERT INTO `department` VALUES (150,'spainTeamLevanteIslands','EQUIPO ESPAÑA LEVANTE',77,78,1118,0,0,0,2,0,43,'/1/43/','es_levante_equipo',1,'levanteislas.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5000',NULL); INSERT INTO `department` VALUES (151,'spainTeamNorthwest','EQUIPO ESPAÑA NOROESTE',79,80,7102,0,0,0,2,0,43,'/1/43/','es_noroeste_equipo',1,'noroeste.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5300',NULL); INSERT INTO `department` VALUES (152,'spainTeamNortheast','EQUIPO ESPAÑA NORESTE',81,82,1118,0,0,0,2,0,43,'/1/43/','es_noreste_equipo',1,'noreste.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5200',NULL); INSERT INTO `department` VALUES (153,'spainTeamSouth','EQUIPO ESPAÑA SUR',83,84,36578,0,0,0,2,0,43,'/1/43/','es_sur_equipo',1,'sur.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5400',NULL); diff --git a/db/dump/.dump/privileges.sql b/db/dump/.dump/privileges.sql index f608d0e8a..460256b56 100644 --- a/db/dump/.dump/privileges.sql +++ b/db/dump/.dump/privileges.sql @@ -979,7 +979,7 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','bi','officeBoss','Greuge_Evolution' INSERT IGNORE INTO `tables_priv` VALUES ('','bi','claimManager','rotacion','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','bs','grafana','sale','juan@db-proxy2.static.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','zonePromo__','alexm@%','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','accountingConfig','alexm@%','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','accountingConfig','carlosap@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','administrative','accountingType','alexm@%','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logistic','agencyMode','alexm@%','0000-00-00 00:00:00','Insert,Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','cache','employee','visible','juan@10.5.1.2','0000-00-00 00:00:00','Select',''); @@ -1417,9 +1417,11 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','adminOfficer','accountDetail', INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBoss','project','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','maintenanceBoss','machineDetail','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workerActivityType','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); -INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerSalesAssistant','route','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','delivery','zoneConfig','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyerSalesAssistant','route','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','workCenter','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerSalesAssistant','Rutas','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','marketingBoss','specialPrice','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','genericAllocation','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','businessReasonEnd','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyer','buy_edi','alexm@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); @@ -1488,6 +1490,10 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemBaseTag', INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemBreederTag','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemShelvingLog','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','logisticAssist','itemTextureTag','jenkins@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','travelThermograph','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','thermograph','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerSalesAssistant','Tickets','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','sim','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); /*!40000 ALTER TABLE `tables_priv` ENABLE KEYS */; /*!40000 ALTER TABLE `columns_priv` DISABLE KEYS */; @@ -1873,6 +1879,7 @@ INSERT IGNORE INTO `procs_priv` VALUES ('','vn','salesAssistant','subordinateget INSERT IGNORE INTO `procs_priv` VALUES ('','vn','buyer','buy_afterUpsert','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','util','grafana','dayend','FUNCTION','juan@db-proxy2.static.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','srt','production','buffer_settypebyname','PROCEDURE','alexm@db-proxy1.static.verdnatura.es','Execute','0000-00-00 00:00:00'); +INSERT IGNORE INTO `procs_priv` VALUES ('','vn','grafana','clientGetMana','FUNCTION','guillermo@db-proxy2.servers.dc.verdnatura.es','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','barcodeToItem','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','ticket_splititempackingtype','PROCEDURE','alexm@%','Execute','0000-00-00 00:00:00'); INSERT IGNORE INTO `procs_priv` VALUES ('','vn','employee','entry_getCommission','FUNCTION','alexm@%','Execute','0000-00-00 00:00:00'); diff --git a/db/dump/.dump/structure.sql b/db/dump/.dump/structure.sql index a4ae460b1..e52ed2a51 100644 --- a/db/dump/.dump/structure.sql +++ b/db/dump/.dump/structure.sql @@ -2569,28 +2569,6 @@ SET character_set_client = utf8; 1 AS `Consumo` */; SET character_set_client = @saved_cs_client; --- --- Temporary table structure for view `rotacion` --- - -DROP TABLE IF EXISTS `rotacion`; -/*!50001 DROP VIEW IF EXISTS `rotacion`*/; -SET @saved_cs_client = @@character_set_client; -SET character_set_client = utf8; -/*!50001 CREATE VIEW `rotacion` AS SELECT - 1 AS `Id_Article`, - 1 AS `warehouse_id`, - 1 AS `total`, - 1 AS `rotacion`, - 1 AS `cm3`, - 1 AS `almacenaje`, - 1 AS `manipulacion`, - 1 AS `auxiliar`, - 1 AS `mermas`, - 1 AS `cm3reparto`, - 1 AS `grams` */; -SET character_set_client = @saved_cs_client; - -- -- Table structure for table `rutasBoard` -- @@ -17481,10 +17459,10 @@ BEGIN /** * Traslada la info de contabilidad relacionada con las facturas recibidas * - * @vInvoiceInFk Factura recibida - * @vXDiarioFk Id tabla XDiario + * @param vInvoiceInFk Factura recibida + * @param vXDiarioFk Id tabla XDiario */ - DECLARE vInvoiceInOriginalFk INT; + DECLARE vInvoiceInOriginalFk INT; DECLARE vDone BOOL DEFAULT FALSE; DECLARE vBase DOUBLE; DECLARE vVat DOUBLE; @@ -17502,7 +17480,7 @@ BEGIN DECLARE vIsInformativeExportation BOOL DEFAULT FALSE; DECLARE vCursor CURSOR FOR - SELECT it.taxableBase, + SELECT SUM(it.taxableBase), CAST(SUM((( it.taxableBase / 100) * t.PorcentajeIva)) AS DECIMAL (10,2)), t.PorcentajeIva, it.transactionTypeSageFk, @@ -17681,32 +17659,31 @@ BEGIN FROM vn.invoiceInCorrection WHERE correctingFk = vInvoiceInFk; - IF vInvoiceInOriginalFk THEN - + IF vInvoiceInOriginalFk THEN UPDATE movContaIVA mci - JOIN vn.invoiceInRefund iir ON iir.invoiceInRefundFk = vInvoiceInFk + JOIN vn.invoiceInCorrection iic ON iic.correctingFk = vInvoiceInFk + JOIN vn.siiTypeInvoiceIn st ON st.id = iic.siiTypeInvoiceInFk JOIN (SELECT issued, - SUM(sub.taxableBase) taxableBase, + SUM(sub.taxableBase) taxableBase, SUM(ROUND((sub.taxableBase * sub.PorcentajeIva) / 100 , 2)) vat FROM(SELECT issued, - SUM(iit.taxableBase) taxableBase, + SUM(iit.taxableBase) taxableBase, ti.PorcentajeIva - FROM vn.invoiceIn i + FROM vn.invoiceIn i JOIN vn.invoiceInTax iit ON iit.invoiceInFk = i.id - JOIN sage.TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk + JOIN TiposIva ti ON ti.CodigoIva = iit.taxTypeSageFk WHERE i.id = vInvoiceInOriginalFk GROUP BY ti.CodigoIva)sub )invoiceInOriginal JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa' SET mci.TipoRectificativa = iir.refundCategoryFk, - mci.ClaseAbonoRectificativas = iir.refundType, + mci.ClaseAbonoRectificativas = iir.refundType, mci.FechaFacturaOriginal = invoiceInOriginal.issued, mci.FechaOperacion = invoiceInOriginal.issued, mci.BaseImponibleOriginal = invoiceInOriginal.taxableBase, mci.CuotaIvaOriginal = invoiceInOriginal.vat, mci.ClaveOperacionFactura = co.ClaveOperacionFactura_ WHERE mci.id = vXDiarioFk; - END IF; END ;; DELIMITER ; @@ -18178,6 +18155,7 @@ BEGIN UPDATE movContaIVA mci JOIN vn.invoiceOut i ON i.id = vInvoiceOutCorrectedFk JOIN vn.invoiceCorrection ic ON ic.correctedFk = vInvoiceOutCorrectedFk + JOIN vn.siiTypeInvoiceOut st ON st.id = ic.siiTypeInvoiceOutFk JOIN (SELECT SUM(IF(IFNULL(e.vatFk, TRUE), iot.taxableBase, 0)) taxableBase, SUM(IF(IFNULL(e.vatFk, TRUE), iot.vat, 0)) vat, SUM(IF(IFNULL(e.vatFk, TRUE), 0, iot.vat)) equ @@ -18186,8 +18164,8 @@ BEGIN WHERE iot.invoiceOutFk = vInvoiceOutCorrectedFk ) tax JOIN ClavesOperacion co ON co.Descripcion = 'Factura rectificativa' - SET mci.TipoRectificativa = 2, - mci.ClaseAbonoRectificativas = 1, + SET mci.TipoRectificativa = ic.cplusRectificationTypeFk, + mci.ClaseAbonoRectificativas = REGEXP_REPLACE(st.`code`, '[^0-9]', ''), mci.FechaFacturaOriginal = i.issued, mci.FechaOperacion = i.issued, mci.BaseImponibleOriginal = tax.taxableBase, @@ -29528,14 +29506,16 @@ CREATE TABLE `deviceProductionUser` ( `userFk` int(10) unsigned NOT NULL, `created` timestamp NULL DEFAULT current_timestamp(), `editorFk` int(10) unsigned DEFAULT NULL, - `simSerialNumber` text DEFAULT NULL, + `simFk` varchar(25) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `deviceProductionUser_unique` (`deviceProductionFk`), KEY `userFgn_idx` (`userFk`), KEY `deviceProductionUser_fk_editor` (`editorFk`), + KEY `deviceProductionUser_sim_FK` (`simFk`), CONSTRAINT `deviceProductionUser_PK` FOREIGN KEY (`userFk`) REFERENCES `account`.`user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `deviceProductionUser_deviceProduction_FK` FOREIGN KEY (`deviceProductionFk`) REFERENCES `deviceProduction` (`id`), - CONSTRAINT `deviceProductionUser_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) + CONSTRAINT `deviceProductionUser_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`), + CONSTRAINT `deviceProductionUser_sim_FK` FOREIGN KEY (`simFk`) REFERENCES `sim` (`code`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -31354,13 +31334,27 @@ CREATE TABLE `inventoryConfig` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `inventoryFailure` +-- Table structure for table `inventoryFailureCause__` -- -DROP TABLE IF EXISTS `inventoryFailure`; +DROP TABLE IF EXISTS `inventoryFailureCause__`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `inventoryFailure` ( +CREATE TABLE `inventoryFailureCause__` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `description` varchar(100) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2024-12-16'; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `inventoryFailure__` +-- + +DROP TABLE IF EXISTS `inventoryFailure__`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `inventoryFailure__` ( `id` int(11) NOT NULL AUTO_INCREMENT, `dated` date NOT NULL, `itemFk` int(11) NOT NULL, @@ -31381,22 +31375,8 @@ CREATE TABLE `inventoryFailure` ( CONSTRAINT `inventoryFailure_fk2` FOREIGN KEY (`throwerFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inventoryFailure_fk3` FOREIGN KEY (`guiltyFk`) REFERENCES `worker` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `inventoryFailure_fk4` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `inventoryFailure_fk5` FOREIGN KEY (`causeFk`) REFERENCES `inventoryFailureCause` (`id`) ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - --- --- Table structure for table `inventoryFailureCause` --- - -DROP TABLE IF EXISTS `inventoryFailureCause`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `inventoryFailureCause` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `description` varchar(100) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + CONSTRAINT `inventoryFailure_fk5` FOREIGN KEY (`causeFk`) REFERENCES `inventoryFailureCause__` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='@deprecated 2024-12-16'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -31554,18 +31534,18 @@ CREATE TABLE `invoiceInCorrection` ( `correctingFk` mediumint(8) unsigned NOT NULL COMMENT 'Factura rectificativa', `correctedFk` mediumint(8) unsigned NOT NULL COMMENT 'Factura rectificada', `cplusRectificationTypeFk` int(10) unsigned NOT NULL, - `siiTypeInvoiceOutFk` int(10) unsigned NOT NULL, + `siiTypeInvoiceInFk` int(10) unsigned NOT NULL, `invoiceCorrectionTypeFk` int(11) NOT NULL DEFAULT 3, PRIMARY KEY (`correctingFk`), KEY `invoiceInCorrection_correctedFk` (`correctedFk`), KEY `invoiceInCorrection_cplusRectificationTypeFk` (`cplusRectificationTypeFk`), - KEY `invoiceInCorrection_siiTypeInvoiceOut` (`siiTypeInvoiceOutFk`), + KEY `invoiceInCorrection_siiTypeInvoiceIn` (`siiTypeInvoiceInFk`), KEY `invoiceInCorrection_invoiceCorrectionTypeFk` (`invoiceCorrectionTypeFk`), CONSTRAINT `invoiceInCorrection_correctedFk` FOREIGN KEY (`correctedFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceInCorrection_correctingFk` FOREIGN KEY (`correctingFk`) REFERENCES `invoiceIn` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `invoiceInCorrection_cplusRectificationTypeFk` FOREIGN KEY (`cplusRectificationTypeFk`) REFERENCES `cplusRectificationType` (`id`) ON UPDATE CASCADE, CONSTRAINT `invoiceInCorrection_invoiceCorrectionTypeFk` FOREIGN KEY (`invoiceCorrectionTypeFk`) REFERENCES `invoiceCorrectionType` (`id`) ON UPDATE CASCADE, - CONSTRAINT `invoiceInCorrection_siiTypeInvoiceOut` FOREIGN KEY (`siiTypeInvoiceOutFk`) REFERENCES `siiTypeInvoiceOut` (`id`) ON UPDATE CASCADE + CONSTRAINT `invoiceInCorrection_siiTypeInvoiceIn` FOREIGN KEY (`siiTypeInvoiceInFk`) REFERENCES `siiTypeInvoiceIn` (`id`) ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -33837,7 +33817,9 @@ DROP TABLE IF EXISTS `mistakeType`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `mistakeType` ( `id` int(11) NOT NULL AUTO_INCREMENT, + `code` varchar(50) DEFAULT NULL, `description` varchar(45) NOT NULL, + `time` int(10) DEFAULT NULL COMMENT 'Segundos que se suelen tardar en arreglar el fallo', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -34204,6 +34186,22 @@ CREATE TABLE `osTicketConfig` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `osrmConfig` +-- + +DROP TABLE IF EXISTS `osrmConfig`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `osrmConfig` ( + `id` int(10) unsigned NOT NULL, + `url` varchar(100) NOT NULL COMMENT 'Dirección base de la API', + `tolerance` decimal(6,6) NOT NULL DEFAULT 0.000000 COMMENT 'Tolerancia entre las coordenadas enviadas y las retornadas', + PRIMARY KEY (`id`), + CONSTRAINT `osrmConfig_check` CHECK (`id` = 1) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `outgoingInvoiceVat` -- @@ -35763,26 +35761,6 @@ CREATE TABLE `punchState` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Table for storing punches that have cars with errors'; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `quadmindsApiConfig` --- - -DROP TABLE IF EXISTS `quadmindsApiConfig`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `quadmindsApiConfig` ( - `id` int(10) unsigned NOT NULL, - `url` varchar(255) DEFAULT NULL, - `key` varchar(255) DEFAULT NULL, - `maxObjects` int(11) DEFAULT NULL COMMENT 'Número máximo de objetos en el array por petición', - `limit` int(11) DEFAULT NULL COMMENT 'Limite de objetos solicitados por petición', - `orderTimeFrom` varchar(5) DEFAULT NULL COMMENT 'Inicio de ventana horaria de pedido', - `orderTimeTo` varchar(5) DEFAULT NULL COMMENT 'Fin de ventana horaria de pedido', - PRIMARY KEY (`id`), - CONSTRAINT `quadMindsConfig_check` CHECK (`id` = 1) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; -/*!40101 SET character_set_client = @saved_cs_client */; - -- -- Table structure for table `quality` -- @@ -37542,6 +37520,23 @@ CREATE TABLE `siiTypeInvoiceOut` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Tipo de Factura Emitidas en el suministro de inmediato'; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `sim` +-- + +DROP TABLE IF EXISTS `sim`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `sim` ( + `code` varchar(25) NOT NULL COMMENT 'No se ha puesto BIGINT por incompatibilidad con Access', + `line` varchar(15) NOT NULL CHECK (`line` regexp '^[0-9]+$'), + `ext` int(4) NOT NULL, + `pin` varchar(4) NOT NULL CHECK (`pin` regexp '^[0-9]+$'), + `puk` varchar(15) NOT NULL CHECK (`pin` regexp '^[0-9]+$'), + PRIMARY KEY (`code`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `sinister` -- @@ -41255,7 +41250,7 @@ CREATE TABLE `zone` ( `hour` datetime NOT NULL, `agencyModeFk` int(11) NOT NULL, `travelingDays` int(11) NOT NULL DEFAULT 1, - `price` double NOT NULL DEFAULT 0 CHECK (`price` > 0), + `price` decimal(10,2) DEFAULT NULL, `bonus` double NOT NULL DEFAULT 0, `isVolumetric` tinyint(1) NOT NULL DEFAULT 0, `inflation` decimal(5,2) NOT NULL DEFAULT 1.00, @@ -41264,11 +41259,14 @@ CREATE TABLE `zone` ( `code` varchar(45) DEFAULT NULL, `editorFk` int(10) unsigned DEFAULT NULL, `itemMaxLength` int(11) DEFAULT NULL COMMENT 'Longitud maxima para articulos acostados que esa agencia puede transportar', + `addressFk` int(11) DEFAULT NULL COMMENT 'Punto de distribución de donde salen para repartir', PRIMARY KEY (`id`), KEY `fk_zone_2_idx` (`agencyModeFk`), KEY `zone_name_idx` (`name`), KEY `zone_fk_editor` (`editorFk`), + KEY `zone_address_FK` (`addressFk`), CONSTRAINT `fk_zone_2` FOREIGN KEY (`agencyModeFk`) REFERENCES `agencyMode` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT `zone_address_FK` FOREIGN KEY (`addressFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE, CONSTRAINT `zone_fk_editor` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -41318,7 +41316,10 @@ CREATE TABLE `zoneConfig` ( `id` int(10) unsigned NOT NULL, `scope` int(10) unsigned NOT NULL, `forwardDays` int(10) NOT NULL DEFAULT 7 COMMENT 'days forward to show zone_upcomingDeliveries', + `defaultAddressFk` int(11) DEFAULT NULL COMMENT 'Punto de distribución por defecto', PRIMARY KEY (`id`), + KEY `zoneConfig_address_FK` (`defaultAddressFk`), + CONSTRAINT `zoneConfig_address_FK` FOREIGN KEY (`defaultAddressFk`) REFERENCES `address` (`id`) ON UPDATE CASCADE, CONSTRAINT `zoneConfig_check` CHECK (`id` = 1) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; @@ -43244,6 +43245,7 @@ BEGIN DECLARE vCurrentCommission INT; DECLARE vIsNotEUR INT; DECLARE vLastEntryFk INT; + DECLARE vLanded INT; SELECT count(*) INTO vIsNotEUR FROM currency c @@ -43259,23 +43261,25 @@ BEGIN RETURN IFNULL(vCommission, 0); ELSE + SELECT landed INTO vLanded + FROM travel + WHERE id = vTravelFk; + SELECT e.id INTO vLastEntryFk FROM `entry` e JOIN travel tr ON tr.id = e.travelFk - WHERE e.supplierFk = vSupplierFk - ORDER BY tr.landed DESC - LIMIT 1; + WHERE e.supplierFk = vSupplierFk + ORDER BY (vLanded <= tr.landed), tr.landed DESC + LIMIT 1; IF vLastEntryFk THEN SELECT commission INTO vCurrentCommission FROM `entry` WHERE id = vLastEntryFk; - ELSE SELECT commission INTO vCurrentCommission FROM supplier s WHERE s.id = vSupplierFk; - END IF; RETURN vCurrentCommission; @@ -49455,7 +49459,7 @@ BEGIN JOIN claimDestination cd ON cd.id = ce.claimDestinationFk JOIN claim c ON c.id = ce.claimFk JOIN claimState cs ON cs.id = c.claimStateFk - WHERE cd.description NOT IN ('Bueno', 'Corregido') + WHERE cd.code NOT IN ('good', 'corrected', 'supplierClaim') AND NOT ce.isGreuge AND cs.code = 'resolved'; @@ -49480,7 +49484,7 @@ BEGIN JOIN claimDestination cd ON cd.id = ce.claimDestinationFk JOIN claim c ON c.id = ce.claimFk JOIN claimState cs ON cs.id = c.claimStateFk - WHERE cd.description NOT IN ('Bueno', 'Corregido') + WHERE cd.code NOT IN ('good', 'corrected', 'supplierClaim') AND NOT ce.isGreuge AND cs.code = 'resolved' AND c.isChargedToMana; @@ -49491,7 +49495,7 @@ BEGIN JOIN claim c ON c.id = ce.claimFk JOIN claimState cs ON cs.id = c.claimStateFk SET ce.isGreuge = TRUE - WHERE cd.description NOT IN ('Bueno', 'Corregido') + WHERE cd.code NOT IN ('good', 'corrected', 'supplierClaim') AND NOT ce.isGreuge AND cs.code = 'resolved'; @@ -49570,7 +49574,7 @@ BEGIN JOIN claimDestination cd ON cd.id = ce.claimDestinationFk JOIN claim c ON c.id = ce.claimFk JOIN claimState cs ON cs.id = c.claimStateFk - WHERE cd.description NOT IN ('Bueno', 'Corregido') + WHERE cd.code NOT IN ('good', 'corrected', 'supplierClaim') AND cs.code = 'resolved' AND c.ticketCreated >= util.VN_CURDATE() - INTERVAL 1 YEAR GROUP BY c.clientFk @@ -56857,67 +56861,6 @@ BEGIN UPDATE greugeConfig SET lastNotifyCheck = vTimeEnd; -END ;; -DELIMITER ; -/*!50003 SET sql_mode = @saved_sql_mode */ ; -/*!50003 SET character_set_client = @saved_cs_client */ ; -/*!50003 SET character_set_results = @saved_cs_results */ ; -/*!50003 SET collation_connection = @saved_col_connection */ ; -/*!50003 SET @saved_sql_mode = @@sql_mode */ ; -/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ; -/*!50003 DROP PROCEDURE IF EXISTS `inventoryFailureAdd` */; -/*!50003 SET @saved_cs_client = @@character_set_client */ ; -/*!50003 SET @saved_cs_results = @@character_set_results */ ; -/*!50003 SET @saved_col_connection = @@collation_connection */ ; -/*!50003 SET character_set_client = utf8mb4 */ ; -/*!50003 SET character_set_results = utf8mb4 */ ; -/*!50003 SET collation_connection = utf8mb4_unicode_ci */ ; -DELIMITER ;; -CREATE DEFINER=`vn`@`localhost` PROCEDURE `inventoryFailureAdd`() -BEGIN - -DECLARE done BOOL DEFAULT FALSE; -DECLARE vTicketFk INT; - -DECLARE rs CURSOR FOR - SELECT id FROM vn.ticket - WHERE shipped = util.yesterday() - AND clientFk = 400 - AND warehouseFk IN (1,44); - -DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; - -OPEN rs; - -FETCH rs INTO vTicketFk; - -WHILE NOT done DO - - INSERT INTO vn.inventoryFailure(dated, itemFk, quantity, value, warehouseFk, throwerFk) - SELECT t.shipped, - s.itemFk, - s.quantity, - b.buyingValue + b.freightValue + b.packageValue + b.comissionValue, - t.warehouseFk, - w.id - FROM vn.ticket t - JOIN vn.sale s ON s.ticketFk = t.id - LEFT JOIN cache.last_buy lb ON lb.warehouse_id = t.warehouseFk AND item_id = s.itemFk - LEFT JOIN vn.buy b ON b.id = lb.buy_id - LEFT JOIN vn.worker w ON w.code = LEFT(s.concept, 3) - WHERE t.id = vTicketFk - AND s.quantity > 0; - - FETCH rs INTO vTicketFk; - -END WHILE; - - -CLOSE rs; - - - - END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -57927,7 +57870,7 @@ BEGIN ii.cplusTaxBreakFk, ii.cplusSubjectOpFk, ii.siiTypeInvoiceInFk, - ii.cplusRectificationTypeFk, + ic.cplusRectificationTypeFk, ii.booked, IFNULL(a.isUeeMember, c.isUeeMember) isUeeMember, (c.id = cc.id) isSameCountry, @@ -57950,6 +57893,7 @@ BEGIN e.name expenseName FROM invoiceIn ii JOIN supplier s ON s.id = ii.supplierFk + LEFT JOIN invoiceInCorrection ic ON ic.correctingFk = ii.id LEFT JOIN province p ON p.id = s.provinceFk LEFT JOIN autonomy a ON a.id = p.autonomyFk JOIN country c ON c.id = s.countryFk @@ -62647,10 +62591,6 @@ BEGIN SET itemFk = vItemNew WHERE itemFk = vItemOld; - UPDATE inventoryFailure - SET itemFk = vItemNew - WHERE itemFk = vItemOld; - UPDATE genericAllocation SET itemFk = vItemNew WHERE itemFk = vItemOld; @@ -73325,7 +73265,8 @@ BEGIN IFNULL(dest.nickname, origin.nickname) nickname, dest.landed, dest.preparation, - origin.departmentFk + origin.departmentFk, + origin.saleClonedFk FROM ( SELECT s.ticketFk, c.salesPersonFk workerFk, @@ -73346,11 +73287,13 @@ BEGIN t.warehouseFk, t.companyFk, t.agencyModeFk, - wd.departmentFk + wd.departmentFk, + sc.saleClonedFk FROM ticket t JOIN client c ON c.id = t.clientFk JOIN workerDepartment wd ON wd.workerFk = c.salesPersonFk JOIN sale s ON s.ticketFk = t.id + LEFT JOIN saleCloned sc ON sc.saleClonedFk = s.id JOIN saleVolume sv ON sv.saleFk = s.id JOIN item i ON i.id = s.itemFk JOIN ticketState ts ON ts.ticketFk = t.id @@ -77747,8 +77690,8 @@ BEGIN * @param vIsRaid idRaid value * @param vDaysInForward daysInForward value */ - IF (NOT vIsRaid AND vDaysInForward IS NOT NULL) OR (vIsRaid AND vDaysInForward IS NULL) THEN - CALL util.throw('The raid information is not correct'); + IF NOT vIsRaid AND vDaysInForward THEN + CALL util.throw('If daysInForward has a value, the raid cannot be unchecked'); END IF; END ;; DELIMITER ; @@ -78115,22 +78058,15 @@ BEGIN DECLARE vDone BOOL DEFAULT FALSE; DECLARE vBuyerEmail VARCHAR(40); DECLARE vTravelLink TEXT; - DECLARE vMailBody TEXT DEFAULT ''; + DECLARE vMailBody TEXT; + DECLARE vDaysBetweenDates INT; + DECLARE vSubject VARCHAR(30); - DECLARE vCur CURSOR FOR - SELECT GROUP_CONCAT(DISTINCT - CONCAT('https://salix.verdnatura.es/#!/travel/', - ttm.travelFk, - '/summary ') - ORDER BY ttm.travelFk SEPARATOR '\n\r') travelLink, - CONCAT(u.name, '@verdnatura.es') buyerEmail - FROM tTravelToMove ttm - JOIN entry e ON e.travelFk = ttm.travelFk - JOIN buy b ON b.entryFk = e.id - JOIN item i ON i.id = b.itemFk - JOIN itemType it ON it.id = i.typeFk - JOIN account.user u ON u.id = it.workerFk - GROUP BY u.name; + DECLARE vTravels CURSOR FOR + SELECT GROUP_CONCAT(DISTINCT travelLink ORDER BY id SEPARATOR '\n\r'), + buyerEmail + FROM tTravelToMove + GROUP BY buyerEmail; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; @@ -78141,35 +78077,50 @@ BEGIN END; CREATE OR REPLACE TEMPORARY TABLE tTravelToMove - SELECT id travelFk, - util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded - FROM travel + WITH travels AS ( + SELECT id, + CONCAT('https://salix.verdnatura.es/#!/travel/', id,'/summary') travelLink, + util.VN_CURDATE() + INTERVAL daysInForward DAY newLanded, + util.VN_CURDATE() - INTERVAL DATEDIFF(landed, shipped) + daysInForward DAY newShipped + FROM vn.travel WHERE isRaid - AND daysInForward; + AND daysInForward + )SELECT t.id, + t.travelLink, + t.newLanded, + t.newShipped, + CONCAT(u.name, '@verdnatura.es') buyerEmail + FROM travels t + STRAIGHT_JOIN vn.entry e ON e.travelFk = t.id + JOIN vn.buy b ON b.entryFk = e.id + JOIN vn.item i ON i.id = b.itemFk + JOIN vn.itemType it ON it.id = i.typeFk + JOIN account.user u ON u.id = it.workerFk + GROUP BY t.id; START TRANSACTION; UPDATE travel tr - JOIN tTravelToMove ttm ON ttm.travelFk = tr.id - SET tr.landed = ttm.newLanded; + JOIN tTravelToMove ttm ON ttm.id = tr.id + SET tr.landed = ttm.newLanded, + tr.shipped = ttm.newShipped; - OPEN vCur; + OPEN vTravels; l: LOOP SET vDone = FALSE; - FETCH vCur INTO vTravelLink, vBuyerEmail; + FETCH vTravels INTO vTravelLink, vBuyerEmail; IF vDone THEN LEAVE l; END IF; - CALL `vn`.`mail_insert`( - vBuyerEmail, - 'noreply@verdnatura.es', - 'Cambio de fecha en Redadas', - CONCAT('Se ha movido los siguientes travels: \n\r ', vTravelLink)); + SET vSubject = 'Cambio de fecha en Redadas', + vMailBody = CONCAT('Se ha movido los siguientes travels: \n\r ', vTravelLink); + + CALL mail_insert(vBuyerEmail, 'noreply@verdnatura.es', vSubject, vMailBody); END LOOP; - CLOSE vCur; + CLOSE vTravels; COMMIT; DROP TEMPORARY TABLE tTravelToMove; END ;; @@ -85618,24 +85569,6 @@ USE `bi`; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; --- --- Final view structure for view `rotacion` --- - -/*!50001 DROP VIEW IF EXISTS `rotacion`*/; -/*!50001 SET @saved_cs_client = @@character_set_client */; -/*!50001 SET @saved_cs_results = @@character_set_results */; -/*!50001 SET @saved_col_connection = @@collation_connection */; -/*!50001 SET character_set_client = utf8mb4 */; -/*!50001 SET character_set_results = utf8mb4 */; -/*!50001 SET collation_connection = utf8mb4_unicode_ci */; -/*!50001 CREATE ALGORITHM=UNDEFINED */ -/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `rotacion` AS select `ic`.`itemFk` AS `Id_Article`,`ic`.`warehouseFk` AS `warehouse_id`,`ic`.`quantity` AS `total`,`ic`.`rotation` AS `rotacion`,`ic`.`cm3` AS `cm3`,`ic`.`storage` AS `almacenaje`,`ic`.`handling` AS `manipulacion`,`ic`.`extraCharge` AS `auxiliar`,`ic`.`wasted` AS `mermas`,`ic`.`cm3delivery` AS `cm3reparto`,`ic`.`grams` AS `grams` from `vn`.`itemCost` `ic` */; -/*!50001 SET character_set_client = @saved_cs_client */; -/*!50001 SET character_set_results = @saved_cs_results */; -/*!50001 SET collation_connection = @saved_col_connection */; - -- -- Final view structure for view `tarifa_componentes` -- @@ -90949,4 +90882,4 @@ USE `vn2008`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-12-10 8:17:51 +-- Dump completed on 2025-01-07 6:51:38 diff --git a/db/dump/.dump/triggers.sql b/db/dump/.dump/triggers.sql index 3299aea37..039dbb2a8 100644 --- a/db/dump/.dump/triggers.sql +++ b/db/dump/.dump/triggers.sql @@ -5701,7 +5701,7 @@ BEGIN SET NEW.editorFk = account.myUser_getId(); - IF (SELECT COUNT(*) FROM vn.invoiceIn + IF (SELECT COUNT(*) FROM invoiceIn WHERE supplierRef = NEW.supplierRef AND supplierFk = NEW.supplierFk AND YEAR(issued) = YEAR(NEW.issued) @@ -5713,7 +5713,7 @@ BEGIN IF NEW.supplierFk != OLD.supplierFk THEN CALL supplier_checkIsActive(NEW.supplierFk); SELECT withholdingSageFk INTO vWithholdingSageFk - FROM vn.supplier + FROM supplier WHERE id = NEW.supplierFk; SET NEW.withholdingSageFk = vWithholdingSageFk; END IF; @@ -5737,25 +5737,31 @@ DELIMITER ;; AFTER UPDATE ON `invoiceIn` FOR EACH ROW BEGIN - IF NEW.issued != OLD.issued - OR NEW.currencyFk != OLD.currencyFk THEN + DECLARE vIsEuro BOOL; + + SELECT `code` = 'EUR' INTO vIsEuro + FROM currency + WHERE id = NEW.currencyFk; + + IF (NOT NEW.issued <=> OLD.issued + OR NEW.currencyFk <> OLD.currencyFk) THEN UPDATE invoiceInTax iit JOIN invoiceIn ii ON ii.id = iit.invoiceInFk LEFT JOIN referenceRate rr ON rr.dated = ii.issued AND rr.currencyFk = ii.currencyFk - SET iit.taxableBase = IF(iit.foreignValue IS NULL, iit.taxableBase, iit.foreignValue / rr.value) + SET iit.taxableBase = IF(vIsEuro, iit.taxableBase, iit.foreignValue / rr.value), + iit.foreignValue = IF(vIsEuro, NULL, iit.foreignValue) WHERE ii.id = NEW.id; UPDATE invoiceInDueDay iidd JOIN invoiceIn ii ON ii.id = iidd.invoiceInFk LEFT JOIN referenceRate rr ON rr.dated = ii.issued AND rr.currencyFk = ii.currencyFk - SET iidd.amount = IF(iidd.foreignValue IS NULL, iidd.amount, iidd.foreignValue / rr.value) + SET iidd.amount = IF(vIsEuro, iidd.amount, iidd.foreignValue / rr.value), + iidd.foreignValue = IF(vIsEuro, NULL, iidd.foreignValue) WHERE ii.id = NEW.id; - END IF; - END */;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -8161,6 +8167,7 @@ BEGIN OR !(NEW.workerFk <=> OLD.workerFk) OR !(NEW.m3 <=> OLD.m3) OR !(NEW.agencyModeFk <=> OLD.agencyModeFk) + OR !(NEW.dated <=> OLD.dated) OR !(NEW.vehicleFk <=> OLD.vehicleFk)THEN CALL route_calcCommission(NEW.id); END IF; @@ -10582,6 +10589,10 @@ BEGIN CALL travel_checkWarehouseIsFeedStock(NEW.warehouseInFk); END IF; + IF NOT (NEW.isRaid <=> OLD.isRaid) OR NOT (NEW.daysInForward <=> OLD.daysInForward) THEN + CALL travel_checkRaid(NEW.isRaid, NEW.daysInForward); + END IF; + IF NOT (NEW.awbFk <=> OLD.awbFk)THEN SELECT COUNT(*) INTO vHasAnyInvoiceBooked FROM travel t @@ -11488,4 +11499,4 @@ USE `vn2008`; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-12-10 8:18:11 +-- Dump completed on 2025-01-07 6:51:57 From 1d8dcdf63f70534afc1c3529ef85244d9e08a608 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 7 Jan 2025 09:44:50 +0100 Subject: [PATCH 197/219] build: add new version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a843ac9c5..e4cbf1406 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "salix-back", - "version": "25.02.0", + "version": "25.04.0", "author": "Verdnatura Levante SL", "description": "Salix backend", "license": "GPL-3.0", From 065f13557b9265d1e0903560c05be40d91b18039 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 7 Jan 2025 11:58:36 +0100 Subject: [PATCH 198/219] feat: refs #8357 Agregados triggers para manejar exclusiones de trabajadores en la tabla workerMana --- .../vn/triggers/workerManaExcluded_beforeInsert.sql | 9 +++++++++ .../vn/triggers/workerManaExcluded_beforeUpdate.sql | 9 +++++++++ db/routines/vn/triggers/workerMana_beforeInsert.sql | 10 ++++++++++ db/routines/vn/triggers/workerMana_beforeUpdate.sql | 10 ++++++++++ db/versions/11396-blueErica/00-firstScript.sql | 5 +++++ 5 files changed, 43 insertions(+) create mode 100644 db/routines/vn/triggers/workerManaExcluded_beforeInsert.sql create mode 100644 db/routines/vn/triggers/workerManaExcluded_beforeUpdate.sql create mode 100644 db/routines/vn/triggers/workerMana_beforeInsert.sql create mode 100644 db/routines/vn/triggers/workerMana_beforeUpdate.sql create mode 100644 db/versions/11396-blueErica/00-firstScript.sql diff --git a/db/routines/vn/triggers/workerManaExcluded_beforeInsert.sql b/db/routines/vn/triggers/workerManaExcluded_beforeInsert.sql new file mode 100644 index 000000000..824f0982b --- /dev/null +++ b/db/routines/vn/triggers/workerManaExcluded_beforeInsert.sql @@ -0,0 +1,9 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerManaExcluded_beforeInsert` + BEFORE INSERT ON `workerManaExcluded` + FOR EACH ROW +BEGIN + DELETE FROM workerMana + WHERE workerFk = NEW.workerFk; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/workerManaExcluded_beforeUpdate.sql b/db/routines/vn/triggers/workerManaExcluded_beforeUpdate.sql new file mode 100644 index 000000000..83d73e131 --- /dev/null +++ b/db/routines/vn/triggers/workerManaExcluded_beforeUpdate.sql @@ -0,0 +1,9 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerManaExcluded_beforeUpdate` + BEFORE UPDATE ON `workerManaExcluded` + FOR EACH ROW +BEGIN + DELETE FROM workerMana + WHERE workerFk = NEW.workerFk; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/workerMana_beforeInsert.sql b/db/routines/vn/triggers/workerMana_beforeInsert.sql new file mode 100644 index 000000000..2d27004e3 --- /dev/null +++ b/db/routines/vn/triggers/workerMana_beforeInsert.sql @@ -0,0 +1,10 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerMana_beforeInsert` + BEFORE INSERT ON `workerMana` + FOR EACH ROW +BEGIN + IF (SELECT EXISTS(SELECT TRUE FROM workerManaExcluded WHERE workerFk = NEW.workerFk)) THEN + CALL util.throw('Worker is excluded from mana'); + END IF; +END$$ +DELIMITER ; diff --git a/db/routines/vn/triggers/workerMana_beforeUpdate.sql b/db/routines/vn/triggers/workerMana_beforeUpdate.sql new file mode 100644 index 000000000..6916733cb --- /dev/null +++ b/db/routines/vn/triggers/workerMana_beforeUpdate.sql @@ -0,0 +1,10 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerMana_beforeUpdate` + BEFORE UPDATE ON `workerMana` + FOR EACH ROW +BEGIN + IF (SELECT EXISTS(SELECT TRUE FROM workerManaExcluded WHERE workerFk = NEW.workerFk)) THEN + CALL util.throw('Worker is excluded from mana'); + END IF; +END$$ +DELIMITER ; diff --git a/db/versions/11396-blueErica/00-firstScript.sql b/db/versions/11396-blueErica/00-firstScript.sql new file mode 100644 index 000000000..b21965fe8 --- /dev/null +++ b/db/versions/11396-blueErica/00-firstScript.sql @@ -0,0 +1,5 @@ +DELETE FROM vn.workerMana + WHERE workerFk IN ( + SELECT workerFk + FROM vn.workerManaExcluded + ); From 5ab06ef6e46d5b5771a75f6ed080c502d5e71395 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 8 Jan 2025 09:39:55 +0100 Subject: [PATCH 199/219] fix: hotFix getStartDateOfWeekNumber --- .../methods/worker-time-control/sendMail.js | 16 ++------------ .../weeklyHourRecordEmail.js | 21 +------------------ .../worker/back/models/worker-time-control.js | 11 ++++++++++ 3 files changed, 14 insertions(+), 34 deletions(-) diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index 2e1e00d83..229e4d323 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -45,7 +45,7 @@ module.exports = Self => { const from = Date.vnNew(); const to = Date.vnNew(); - const time = await models.Time.findOne({ + const [time] = await models.Time.find({ where: { dated: {between: [from.setDate(from.getDate() - 10), to.setDate(to.getDate() - 4)]} }, @@ -55,8 +55,7 @@ module.exports = Self => { args.week = time.week; args.year = time.year; } - - const started = getStartDateOfWeekNumber(args.week, args.year); + const started = Self.getStartDateOfWeekNumber(args.week, args.year); started.setHours(0, 0, 0, 0); const ended = new Date(started); @@ -388,17 +387,6 @@ module.exports = Self => { return true; }; - function getStartDateOfWeekNumber(week, year) { - const simple = new Date(year, 0, 1 + (week - 1) * 7); - const dow = simple.getDay(); - const weekStart = simple; - if (dow <= 4) - weekStart.setDate(simple.getDate() - simple.getDay() + 1); - else - weekStart.setDate(simple.getDate() + 8 - simple.getDay()); - return weekStart; - } - function getTime(timeString) { const [hours, minutes, seconds] = timeString.split(':'); return [parseInt(hours), parseInt(minutes), parseInt(seconds)]; diff --git a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js index e352eb3cb..51573c1d6 100644 --- a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js +++ b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js @@ -55,7 +55,7 @@ module.exports = Self => { } }, myOptions); - const dated = getMondayDateFromYearWeek(args.year, args.week); + const dated = Self.getStartDateOfWeekNumber(args.week, args.year); const timestamp = dated.getTime() / 1000; const url = `${salix.url}worker/${args.workerId}/time-control?timestamp=${timestamp}`; @@ -64,23 +64,4 @@ module.exports = Self => { await models.WorkerTimeControl.updateMailState(ctx, ctx.args.workerId, myOptions); return Self.sendTemplate(ctx, 'weekly-hour-record'); }; - - function getMondayDateFromYearWeek(yearNumber, weekNumber) { - const yearStart = new Date(yearNumber, 0, 1); - const firstMonday = new Date(yearStart.getTime() + ((7 - yearStart.getDay() + 1) % 7) * 86400000); - const firstMondayWeekNumber = getWeekNumber(firstMonday); - - if (firstMondayWeekNumber > 1) - firstMonday.setDate(firstMonday.getDate() + 7); - - firstMonday.setDate(firstMonday.getDate() + (weekNumber - 1) * 7); - - return firstMonday; - } - - function getWeekNumber(date) { - const firstDayOfYear = new Date(date.getFullYear(), 0, 1); - const daysPassed = (date - firstDayOfYear) / 86400000; - return Math.ceil((daysPassed + firstDayOfYear.getDay() + 1) / 7); - } }; diff --git a/modules/worker/back/models/worker-time-control.js b/modules/worker/back/models/worker-time-control.js index 92f1bacf0..eab061b0e 100644 --- a/modules/worker/back/models/worker-time-control.js +++ b/modules/worker/back/models/worker-time-control.js @@ -19,4 +19,15 @@ module.exports = Self => { return new UserError(`The introduced hour already exists`); return err; }); + + Self.getStartDateOfWeekNumber = (week, year) => { + const simple = new Date(year, 0, 1 + (week - 1) * 7); + const dow = simple.getDay(); + const weekStart = simple; + if (dow <= 4) + weekStart.setDate(simple.getDate() - simple.getDay() + 1); + else + weekStart.setDate(simple.getDate() + 8 - simple.getDay()); + return weekStart; + }; }; From 70ad6e26249d9a47603b8e5a318c45d4563e97bf Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 8 Jan 2025 10:25:08 +0100 Subject: [PATCH 200/219] =?UTF-8?q?fix:=20refs=20#6861=20refs=C2=B76861=20?= =?UTF-8?q?ticketOrderReserve?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/methods/collection/getTickets.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/back/methods/collection/getTickets.js b/back/methods/collection/getTickets.js index 677c9e444..85d1111df 100644 --- a/back/methods/collection/getTickets.js +++ b/back/methods/collection/getTickets.js @@ -40,6 +40,7 @@ module.exports = Self => { const sales = await Self.rawSql(` SELECT s.ticketFk, + NULL ticketOrder, sgd.saleGroupFk, s.id saleFk, s.itemFk, @@ -83,6 +84,7 @@ module.exports = Self => { GROUP BY s.id, ish.id, p.code, p2.code UNION ALL SELECT s.ticketFk, + DENSE_RANK() OVER (ORDER BY ss.id), sgd.saleGroupFk, s.id saleFk, s.itemFk, From 9842f70becf95430fa0f5e7de3a90454a5fb831c Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 8 Jan 2025 11:25:07 +0100 Subject: [PATCH 201/219] fix: hotFix getMondayWeekYear --- .../methods/worker-time-control/sendMail.js | 17 +++-------------- .../weeklyHourRecordEmail.js | 4 ++-- .../worker/back/models/worker-time-control.js | 19 ++++++++++--------- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index 229e4d323..5fd5f65ff 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -41,21 +41,10 @@ module.exports = Self => { const stmts = []; let stmt; - if (!args.week || !args.year) { - const from = Date.vnNew(); - const to = Date.vnNew(); + const {date: started, week, year} = Self.getMondayWeekYear(args.week, args.year); + args.week = week; + args.year = year; - const [time] = await models.Time.find({ - where: { - dated: {between: [from.setDate(from.getDate() - 10), to.setDate(to.getDate() - 4)]} - }, - order: 'week ASC' - }, myOptions); - - args.week = time.week; - args.year = time.year; - } - const started = Self.getStartDateOfWeekNumber(args.week, args.year); started.setHours(0, 0, 0, 0); const ended = new Date(started); diff --git a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js index 51573c1d6..eadbecb00 100644 --- a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js +++ b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js @@ -55,8 +55,8 @@ module.exports = Self => { } }, myOptions); - const dated = Self.getStartDateOfWeekNumber(args.week, args.year); - const timestamp = dated.getTime() / 1000; + const {date} = Self.getMondayWeekYear(args.week, args.year); + const timestamp = date.getTime() / 1000; const url = `${salix.url}worker/${args.workerId}/time-control?timestamp=${timestamp}`; ctx.args.url = url; diff --git a/modules/worker/back/models/worker-time-control.js b/modules/worker/back/models/worker-time-control.js index eab061b0e..cdf51b712 100644 --- a/modules/worker/back/models/worker-time-control.js +++ b/modules/worker/back/models/worker-time-control.js @@ -1,4 +1,5 @@ const UserError = require('vn-loopback/util/user-error'); +const moment = require('moment'); module.exports = Self => { require('../methods/worker-time-control/filter')(Self); @@ -20,14 +21,14 @@ module.exports = Self => { return err; }); - Self.getStartDateOfWeekNumber = (week, year) => { - const simple = new Date(year, 0, 1 + (week - 1) * 7); - const dow = simple.getDay(); - const weekStart = simple; - if (dow <= 4) - weekStart.setDate(simple.getDate() - simple.getDay() + 1); - else - weekStart.setDate(simple.getDate() + 8 - simple.getDay()); - return weekStart; + Self.getMondayWeekYear = (week, year) => { + if (!week || !year) { + const today = Date.vnNew(); + today.setDate(today.getDate() - 7); + week = moment(today).isoWeek(); + year = moment(today).isoWeekYear(); + } + const date = moment(year, 'YYYY').week(week).startOf('isoweek').toDate(); + return {date, year, week}; }; }; From 60933216f788fcd4037b45895cac1f2dd6fcc072 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 8 Jan 2025 11:25:07 +0100 Subject: [PATCH 202/219] fix: hotFix getMondayWeekYear --- .../methods/worker-time-control/sendMail.js | 17 +++-------------- .../weeklyHourRecordEmail.js | 4 ++-- .../worker/back/models/worker-time-control.js | 19 ++++++++++--------- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index 229e4d323..5fd5f65ff 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -41,21 +41,10 @@ module.exports = Self => { const stmts = []; let stmt; - if (!args.week || !args.year) { - const from = Date.vnNew(); - const to = Date.vnNew(); + const {date: started, week, year} = Self.getMondayWeekYear(args.week, args.year); + args.week = week; + args.year = year; - const [time] = await models.Time.find({ - where: { - dated: {between: [from.setDate(from.getDate() - 10), to.setDate(to.getDate() - 4)]} - }, - order: 'week ASC' - }, myOptions); - - args.week = time.week; - args.year = time.year; - } - const started = Self.getStartDateOfWeekNumber(args.week, args.year); started.setHours(0, 0, 0, 0); const ended = new Date(started); diff --git a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js index 51573c1d6..eadbecb00 100644 --- a/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js +++ b/modules/worker/back/methods/worker-time-control/weeklyHourRecordEmail.js @@ -55,8 +55,8 @@ module.exports = Self => { } }, myOptions); - const dated = Self.getStartDateOfWeekNumber(args.week, args.year); - const timestamp = dated.getTime() / 1000; + const {date} = Self.getMondayWeekYear(args.week, args.year); + const timestamp = date.getTime() / 1000; const url = `${salix.url}worker/${args.workerId}/time-control?timestamp=${timestamp}`; ctx.args.url = url; diff --git a/modules/worker/back/models/worker-time-control.js b/modules/worker/back/models/worker-time-control.js index eab061b0e..cdf51b712 100644 --- a/modules/worker/back/models/worker-time-control.js +++ b/modules/worker/back/models/worker-time-control.js @@ -1,4 +1,5 @@ const UserError = require('vn-loopback/util/user-error'); +const moment = require('moment'); module.exports = Self => { require('../methods/worker-time-control/filter')(Self); @@ -20,14 +21,14 @@ module.exports = Self => { return err; }); - Self.getStartDateOfWeekNumber = (week, year) => { - const simple = new Date(year, 0, 1 + (week - 1) * 7); - const dow = simple.getDay(); - const weekStart = simple; - if (dow <= 4) - weekStart.setDate(simple.getDate() - simple.getDay() + 1); - else - weekStart.setDate(simple.getDate() + 8 - simple.getDay()); - return weekStart; + Self.getMondayWeekYear = (week, year) => { + if (!week || !year) { + const today = Date.vnNew(); + today.setDate(today.getDate() - 7); + week = moment(today).isoWeek(); + year = moment(today).isoWeekYear(); + } + const date = moment(year, 'YYYY').week(week).startOf('isoweek').toDate(); + return {date, year, week}; }; }; From c07e30a89c691e11e2bace073b0c587e54d15d9d Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 8 Jan 2025 12:48:28 +0100 Subject: [PATCH 203/219] fix: prevent deleting absences for past dates --- db/versions/11400-turquoiseChrysanthemum/00-firstScript.sql | 2 ++ modules/worker/back/methods/worker/deleteAbsence.js | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 db/versions/11400-turquoiseChrysanthemum/00-firstScript.sql diff --git a/db/versions/11400-turquoiseChrysanthemum/00-firstScript.sql b/db/versions/11400-turquoiseChrysanthemum/00-firstScript.sql new file mode 100644 index 000000000..8ab24cb0d --- /dev/null +++ b/db/versions/11400-turquoiseChrysanthemum/00-firstScript.sql @@ -0,0 +1,2 @@ +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('Worker','canDeleteAbsenceInPast','WRITE','ALLOW','ROLE','hr'); \ No newline at end of file diff --git a/modules/worker/back/methods/worker/deleteAbsence.js b/modules/worker/back/methods/worker/deleteAbsence.js index b71d077a4..a7c6efc21 100644 --- a/modules/worker/back/methods/worker/deleteAbsence.js +++ b/modules/worker/back/methods/worker/deleteAbsence.js @@ -53,6 +53,12 @@ module.exports = Self => { } } }, myOptions); + const canDeleteAbsenceInPast = + await models.ACL.checkAccessAcl(ctx, 'Worker', 'canDeleteAbsenceInPast', 'WRITE'); + + if (!canDeleteAbsenceInPast && Date.vnNow() > absence.dated.getTime()) + throw new UserError(`Holidays to past days not available`); + const result = await absence.destroy(myOptions); const labour = absence.labour(); const department = labour && labour.department(); From f557b41feb782d1f1eb9788ec3d8fd413f2d3284 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 8 Jan 2025 13:52:50 +0100 Subject: [PATCH 204/219] fix: tests --- .../worker/specs/deleteAbsence.spec.js | 65 ++++++++++++++++++- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js b/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js index 0f3f913dc..c0d05e4a2 100644 --- a/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js +++ b/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js @@ -4,6 +4,8 @@ const LoopBackContext = require('loopback-context'); describe('Worker deleteAbsence()', () => { const businessId = 18; const workerId = 18; + const hrId = 37; + const salesBossId = 19; const activeCtx = { accessToken: {userId: 1106}, headers: {origin: 'http://localhost'} @@ -50,16 +52,16 @@ describe('Worker deleteAbsence()', () => { }); it('should successfully delete an absence', async() => { - activeCtx.accessToken.userId = 19; + activeCtx.accessToken.userId = salesBossId; const tx = await app.models.Calendar.beginTransaction({}); - + const pastDate = new Date(Date.vnNow() + 24 * 60 * 60 * 1000); try { const options = {transaction: tx}; const createdAbsence = await app.models.Calendar.create({ businessFk: businessId, dayOffTypeFk: 1, - dated: Date.vnNew() + dated: pastDate }, options); ctx.args = {absenceId: createdAbsence.id}; @@ -76,4 +78,61 @@ describe('Worker deleteAbsence()', () => { throw e; } }); + + it('should successfully delete an absence if the user is HR even if the date is in the past', async() => { + activeCtx.accessToken.userId = hrId; + const tx = await app.models.Calendar.beginTransaction({}); + + try { + const options = {transaction: tx}; + const pastDate = new Date(Date.vnNow() - 24 * 60 * 60 * 1000); // Restar un día + const createdAbsence = await app.models.Calendar.create({ + businessFk: businessId, + dayOffTypeFk: 1, + dated: pastDate + }, options); + + ctx.args = {absenceId: createdAbsence.id}; + await app.models.Worker.deleteAbsence(ctx, workerId, options); + + const deletedAbsence = await app.models.Calendar.findById(createdAbsence.id, null, options); + + expect(deletedAbsence).toBeNull(); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); + + it('should throw an error if the date is in the past', async() => { + activeCtx.accessToken.userId = salesBossId; + const tx = await app.models.Calendar.beginTransaction({}); + + let error; + try { + const options = {transaction: tx}; + const pastDate = new Date(Date.vnNow() - 24 * 60 * 60 * 1000); + const createdAbsence = await app.models.Calendar.create({ + businessFk: businessId, + dayOffTypeFk: 1, + dated: pastDate + }, options); + + ctx.args = {absenceId: createdAbsence.id}; + await app.models.Worker.deleteAbsence(ctx, workerId, options); + + const deletedAbsence = await app.models.Calendar.findById(createdAbsence.id, null, options); + + expect(deletedAbsence).toBeNull(); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + error = e; + } + + expect(error.message).toBe('Holidays to past days not available'); + }); }); From 838617e3f667fdb9ad14d454cdaa1854eca7d6d5 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 8 Jan 2025 15:47:53 +0100 Subject: [PATCH 205/219] fix: update access control for modifying absences in the past --- db/versions/11400-turquoiseChrysanthemum/00-firstScript.sql | 4 +++- modules/worker/back/methods/worker/createAbsence.js | 6 +++--- modules/worker/back/methods/worker/deleteAbsence.js | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/db/versions/11400-turquoiseChrysanthemum/00-firstScript.sql b/db/versions/11400-turquoiseChrysanthemum/00-firstScript.sql index 8ab24cb0d..f3e0355a8 100644 --- a/db/versions/11400-turquoiseChrysanthemum/00-firstScript.sql +++ b/db/versions/11400-turquoiseChrysanthemum/00-firstScript.sql @@ -1,2 +1,4 @@ +DELETE FROM salix.ACL WHERE property = 'canCreateAbsenceInPast'; + INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('Worker','canDeleteAbsenceInPast','WRITE','ALLOW','ROLE','hr'); \ No newline at end of file + VALUES ('Worker','canModifyAbsenceInPast','WRITE','ALLOW','ROLE','hr'); diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 93ca7fd89..36781bc3f 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -58,12 +58,12 @@ module.exports = Self => { if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); - const canCreateAbsenceInPast = - await models.ACL.checkAccessAcl(ctx, 'Worker', 'canCreateAbsenceInPast', 'WRITE'); + const canModifyAbsenceInPast = + await models.ACL.checkAccessAcl(ctx, 'Worker', 'canModifyAbsenceInPast', 'WRITE'); const now = Date.vnNew(); const newDate = new Date(args.dated).getTime(); - if ((now.getTime() > newDate) && !canCreateAbsenceInPast) + if ((now.getTime() > newDate) && !canModifyAbsenceInPast) throw new UserError(`Holidays to past days not available`); const labour = await models.WorkerLabour.findById(args.businessFk, diff --git a/modules/worker/back/methods/worker/deleteAbsence.js b/modules/worker/back/methods/worker/deleteAbsence.js index a7c6efc21..11a8cb0c1 100644 --- a/modules/worker/back/methods/worker/deleteAbsence.js +++ b/modules/worker/back/methods/worker/deleteAbsence.js @@ -53,10 +53,10 @@ module.exports = Self => { } } }, myOptions); - const canDeleteAbsenceInPast = - await models.ACL.checkAccessAcl(ctx, 'Worker', 'canDeleteAbsenceInPast', 'WRITE'); + const canModifyAbsenceInPast = + await models.ACL.checkAccessAcl(ctx, 'Worker', 'canModifyAbsenceInPast', 'WRITE'); - if (!canDeleteAbsenceInPast && Date.vnNow() > absence.dated.getTime()) + if (!canModifyAbsenceInPast && Date.vnNow() > absence.dated.getTime()) throw new UserError(`Holidays to past days not available`); const result = await absence.destroy(myOptions); From 412638d59000f04fbe10aa45c4429230e57f1a41 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 8 Jan 2025 18:27:23 +0100 Subject: [PATCH 206/219] fix: refactor access control for modifying past absences --- modules/worker/back/methods/worker/createAbsence.js | 4 +--- modules/worker/back/methods/worker/deleteAbsence.js | 4 +--- .../worker/back/methods/worker/specs/createAbsence.spec.js | 2 +- .../worker/back/methods/worker/specs/deleteAbsence.spec.js | 2 +- modules/worker/back/models/worker.js | 7 +++++++ 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/worker/back/methods/worker/createAbsence.js b/modules/worker/back/methods/worker/createAbsence.js index 36781bc3f..dc716c95d 100644 --- a/modules/worker/back/methods/worker/createAbsence.js +++ b/modules/worker/back/methods/worker/createAbsence.js @@ -58,12 +58,10 @@ module.exports = Self => { if (!isSubordinate || (isSubordinate && userId == id && !isTeamBoss)) throw new UserError(`You don't have enough privileges`); - const canModifyAbsenceInPast = - await models.ACL.checkAccessAcl(ctx, 'Worker', 'canModifyAbsenceInPast', 'WRITE'); const now = Date.vnNew(); const newDate = new Date(args.dated).getTime(); - if ((now.getTime() > newDate) && !canModifyAbsenceInPast) + if (!await Self.canModifyAbsenceInPast(ctx, newDate)) throw new UserError(`Holidays to past days not available`); const labour = await models.WorkerLabour.findById(args.businessFk, diff --git a/modules/worker/back/methods/worker/deleteAbsence.js b/modules/worker/back/methods/worker/deleteAbsence.js index 11a8cb0c1..596f8f28d 100644 --- a/modules/worker/back/methods/worker/deleteAbsence.js +++ b/modules/worker/back/methods/worker/deleteAbsence.js @@ -53,10 +53,8 @@ module.exports = Self => { } } }, myOptions); - const canModifyAbsenceInPast = - await models.ACL.checkAccessAcl(ctx, 'Worker', 'canModifyAbsenceInPast', 'WRITE'); - if (!canModifyAbsenceInPast && Date.vnNow() > absence.dated.getTime()) + if (!await Self.canModifyAbsenceInPast(ctx, absence.dated.getTime())) throw new UserError(`Holidays to past days not available`); const result = await absence.destroy(myOptions); diff --git a/modules/worker/back/methods/worker/specs/createAbsence.spec.js b/modules/worker/back/methods/worker/specs/createAbsence.spec.js index 1c7efcd28..b6600048f 100644 --- a/modules/worker/back/methods/worker/specs/createAbsence.spec.js +++ b/modules/worker/back/methods/worker/specs/createAbsence.spec.js @@ -1,7 +1,7 @@ const app = require('vn-loopback/server/server'); const LoopBackContext = require('loopback-context'); -describe('Worker createAbsence()', () => { +fdescribe('Worker createAbsence()', () => { const workerId = 18; it('should return an error for a user without enough privileges', async() => { diff --git a/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js b/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js index c0d05e4a2..dfbcd9835 100644 --- a/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js +++ b/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js @@ -1,7 +1,7 @@ const app = require('vn-loopback/server/server'); const LoopBackContext = require('loopback-context'); -describe('Worker deleteAbsence()', () => { +fdescribe('Worker deleteAbsence()', () => { const businessId = 18; const workerId = 18; const hrId = 37; diff --git a/modules/worker/back/models/worker.js b/modules/worker/back/models/worker.js index 3351c348c..e1adca77e 100644 --- a/modules/worker/back/models/worker.js +++ b/modules/worker/back/models/worker.js @@ -26,6 +26,13 @@ module.exports = Self => { message: 'Invalid TIN' }); + Self.canModifyAbsenceInPast = async(ctx, time) => { + const hasPrivs = await Self.app.models.ACL.checkAccessAcl(ctx, 'Worker', 'canModifyAbsenceInPast', 'WRITE'); + const now = Date.vnNew(); + now.setHours(0, 0, 0, 0); + return hasPrivs || now.getTime() < time; + }; + async function tinIsValid(err, done) { const country = await Self.app.models.Country.findOne({ fields: ['code'], From b12c3bb72f8d182983bfd89d64c55237bf20f834 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 8 Jan 2025 18:28:00 +0100 Subject: [PATCH 207/219] fix: enable tests for createAbsence and deleteAbsence methods --- modules/worker/back/methods/worker/specs/createAbsence.spec.js | 2 +- modules/worker/back/methods/worker/specs/deleteAbsence.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/worker/back/methods/worker/specs/createAbsence.spec.js b/modules/worker/back/methods/worker/specs/createAbsence.spec.js index b6600048f..1c7efcd28 100644 --- a/modules/worker/back/methods/worker/specs/createAbsence.spec.js +++ b/modules/worker/back/methods/worker/specs/createAbsence.spec.js @@ -1,7 +1,7 @@ const app = require('vn-loopback/server/server'); const LoopBackContext = require('loopback-context'); -fdescribe('Worker createAbsence()', () => { +describe('Worker createAbsence()', () => { const workerId = 18; it('should return an error for a user without enough privileges', async() => { diff --git a/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js b/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js index dfbcd9835..c0d05e4a2 100644 --- a/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js +++ b/modules/worker/back/methods/worker/specs/deleteAbsence.spec.js @@ -1,7 +1,7 @@ const app = require('vn-loopback/server/server'); const LoopBackContext = require('loopback-context'); -fdescribe('Worker deleteAbsence()', () => { +describe('Worker deleteAbsence()', () => { const businessId = 18; const workerId = 18; const hrId = 37; From 50a95ed3c4bdb1396d1d1c1ad12b81ed301e1561 Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 8 Jan 2025 18:30:33 +0100 Subject: [PATCH 208/219] fix: correct variable name in canModifyAbsenceInPast method --- modules/worker/back/models/worker.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/worker/back/models/worker.js b/modules/worker/back/models/worker.js index e1adca77e..2e45b78da 100644 --- a/modules/worker/back/models/worker.js +++ b/modules/worker/back/models/worker.js @@ -28,9 +28,9 @@ module.exports = Self => { Self.canModifyAbsenceInPast = async(ctx, time) => { const hasPrivs = await Self.app.models.ACL.checkAccessAcl(ctx, 'Worker', 'canModifyAbsenceInPast', 'WRITE'); - const now = Date.vnNew(); - now.setHours(0, 0, 0, 0); - return hasPrivs || now.getTime() < time; + const today = Date.vnNew(); + today.setHours(0, 0, 0, 0); + return hasPrivs || today.getTime() < time; }; async function tinIsValid(err, done) { From d0d1950e7554d970159cbb4233242e5c6d9c0107 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 9 Jan 2025 07:28:14 +0100 Subject: [PATCH 209/219] fix: refs #7912 Changed week num param to to be similar vn.time --- db/routines/bs/procedures/waste_addSales.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/bs/procedures/waste_addSales.sql b/db/routines/bs/procedures/waste_addSales.sql index ea4adbc27..9ce67b19d 100644 --- a/db/routines/bs/procedures/waste_addSales.sql +++ b/db/routines/bs/procedures/waste_addSales.sql @@ -22,7 +22,7 @@ BEGIN REPLACE bs.waste SELECT YEAR(t.shipped), - WEEK(t.shipped, 4), + WEEK(t.shipped, 6), it.workerFk, it.id, s.itemFk, @@ -70,6 +70,6 @@ BEGIN JOIN vn.buy b ON b.id = lb.buy_id WHERE t.shipped BETWEEN vDateFrom AND vDateTo AND w.isManaged - GROUP BY YEAR(t.shipped), WEEK(t.shipped, 4), i.id; + GROUP BY YEAR(t.shipped), WEEK(t.shipped, 6), i.id; END$$ DELIMITER ; From d258de1194deb54a730a39d59484e0aa83dac77b Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 9 Jan 2025 07:58:59 +0100 Subject: [PATCH 210/219] fix: lang any --- back/methods/vn-user/update-user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/vn-user/update-user.js b/back/methods/vn-user/update-user.js index 2bb390cf9..32bad0f17 100644 --- a/back/methods/vn-user/update-user.js +++ b/back/methods/vn-user/update-user.js @@ -22,7 +22,7 @@ module.exports = Self => { description: 'The user email' }, { arg: 'lang', - type: 'string', + type: 'any', description: 'The user lang' }, { arg: 'twoFactor', From 2141d7d95dc6273e2cc44b12629686b69cd959b8 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 9 Jan 2025 11:29:07 +0100 Subject: [PATCH 211/219] fix: refs #7912 Major corrections waste_addSales --- db/routines/bs/procedures/waste_addSales.sql | 24 +++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/db/routines/bs/procedures/waste_addSales.sql b/db/routines/bs/procedures/waste_addSales.sql index 9ce67b19d..4a34d74b3 100644 --- a/db/routines/bs/procedures/waste_addSales.sql +++ b/db/routines/bs/procedures/waste_addSales.sql @@ -10,18 +10,26 @@ BEGIN * @param vDateFrom Fecha desde * @param vDateTo Fecha hasta */ - IF vDateFrom IS NULL THEN - SET vDateFrom = util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY; + DECLARE vDaysInYear INT; + SET vDaysInYear = DATEDIFF(util.lastDayOfYear(CURDATE()), util.firstDayOfYear(CURDATE())); + + SET vDateFrom = COALESCE(vDateFrom, util.VN_CURDATE()); + SET vDateTo = COALESCE(vDateTo, util.VN_CURDATE()); + + IF DATEDIFF(vDateTo, vDateFrom) > vDaysInYear THEN + CALL util.throw('The period cannot be longer than one year'); END IF; - IF vDateTo IS NULL THEN - SET vDateTo = vDateFrom + INTERVAL 6 DAY; - END IF; + -- Obtiene el primer día de la semana de esa fecha + SET vDateFrom = DATE_SUB(vDateFrom, INTERVAL ((WEEKDAY(vDateFrom) + 1) % 7) DAY); + + -- Obtiene el último día de la semana de esa fecha + SET vDateTo = DATE_ADD(vDateTo, INTERVAL (6 - ((WEEKDAY(vDateTo) + 1) % 7)) DAY); CALL cache.last_buy_refresh(FALSE); REPLACE bs.waste - SELECT YEAR(t.shipped), + SELECT YEARWEEK(t.shipped, 6) DIV 100, WEEK(t.shipped, 6), it.workerFk, it.id, @@ -68,8 +76,8 @@ BEGIN JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = w.id JOIN vn.buy b ON b.id = lb.buy_id - WHERE t.shipped BETWEEN vDateFrom AND vDateTo + WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDateTo) AND w.isManaged - GROUP BY YEAR(t.shipped), WEEK(t.shipped, 6), i.id; + GROUP BY YEARWEEK(t.shipped, 6) DIV 100, WEEK(t.shipped, 6), i.id; END$$ DELIMITER ; From 446ffac7f848c3dc47f7667e001778c939baabde Mon Sep 17 00:00:00 2001 From: robert Date: Thu, 9 Jan 2025 13:44:59 +0100 Subject: [PATCH 212/219] feat: sendCheckingPresence debug --- back/methods/chat/sendCheckingPresence.js | 69 +++++++++++++---------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 7ab5d63fe..83e8da304 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -27,38 +27,47 @@ module.exports = Self => { }); Self.sendCheckingPresence = async(ctx, recipientId, message) => { - if (!recipientId) return false; - const models = Self.app.models; - const userId = ctx.req.accessToken.userId; - const sender = await models.VnUser.findById(userId, {fields: ['id']}); - const recipient = await models.VnUser.findById(recipientId, null); - - // Prevent sending messages to yourself - if (recipientId == userId) return false; - if (!recipient) - throw new Error(`Could not send message "${message}" to worker id ${recipientId} from user ${userId}`); - - if (!isProduction()) - message = `[Test:Environment to user ${userId}] ` + message; - - const chat = await models.Chat.create({ - senderFk: sender.id, - recipient: `@${recipient.name}`, - dated: Date.vnNew(), - checkUserStatus: 1, - message: message, - status: 'sending', - attempts: 0 - }); - try { - await Self.sendCheckingUserStatus(chat); - await Self.updateChat(chat, 'sent'); - } catch (error) { - await Self.updateChat(chat, 'error', error); - } + const models = Self.app.models; + const sender = await models.VnUser.findById(userId, {fields: ['id']}); + const error = `Could not send message from user ${userId}`; - return true; + if (!recipientId) throw new Error(error); + const recipient = await models.VnUser.findById(recipientId, null); + if (!recipient) + throw new Error(error); + + // Prevent sending messages to yourself + if (recipientId == userId) return false; + + if (!isProduction()) + message = `[Test:Environment to user ${userId}] ` + message; + + const chat = await models.Chat.create({ + senderFk: sender.id, + recipient: `@${recipient.name}`, + dated: Date.vnNew(), + checkUserStatus: 1, + message: message, + status: 'sending', + attempts: 0 + }); + + try { + await Self.sendCheckingUserStatus(chat); + await Self.updateChat(chat, 'sent'); + } catch (error) { + await Self.updateChat(chat, 'error', error); + } + + return true; + } catch (e) { + await Self.rawSql(` + INSERT INTO util.debug (variable, value) + VALUES ('sendCheckingPresence_error', ?) + `, [`User: ${userId}, recipient: ${recipientId}, message: ${message}, error: ${e}`]); + throw e; + } }; }; From 6a85272085ec0c90f9cc5c79ce473ae6490801b1 Mon Sep 17 00:00:00 2001 From: guillermo Date: Thu, 9 Jan 2025 14:45:20 +0100 Subject: [PATCH 213/219] fix: refs #7644 Corrected size of buy-label-supplier --- .../reports/buy-label-supplier/assets/css/style.css | 10 +++++----- .../reports/buy-label-supplier/buy-label-supplier.js | 5 +++-- .../templates/reports/buy-label-supplier/options.json | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/print/templates/reports/buy-label-supplier/assets/css/style.css b/print/templates/reports/buy-label-supplier/assets/css/style.css index 3b1f2f91e..f64e01688 100644 --- a/print/templates/reports/buy-label-supplier/assets/css/style.css +++ b/print/templates/reports/buy-label-supplier/assets/css/style.css @@ -1,7 +1,7 @@ html { font-family: "Roboto", "Helvetica", "Arial", sans-serif; margin-top: -7px; - font-size: 28px; + font-size: 20px; } table { border: 1px solid; @@ -10,22 +10,22 @@ table { } td { border: 1px solid; - padding: 5px; + padding: 2px; width: 100%; } span { - font-size: 48px; + font-size: 34px; font-weight: bold; } .lbl { color: gray; font-weight: lighter; - font-size: 18px; + font-size: 12px; display: block; } .cell { width: 157px; - height: 50px; + height: 35px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; diff --git a/print/templates/reports/buy-label-supplier/buy-label-supplier.js b/print/templates/reports/buy-label-supplier/buy-label-supplier.js index 5e59472eb..c8af17a5d 100755 --- a/print/templates/reports/buy-label-supplier/buy-label-supplier.js +++ b/print/templates/reports/buy-label-supplier/buy-label-supplier.js @@ -10,7 +10,7 @@ module.exports = { async serverPrefetch() { const buy = await models.Buy.findById(this.id, null); this.buys = await this.rawSqlFromDef('buy', [buy.entryFk, buy.entryFk, buy.entryFk, this.id, this.id]); - const date = new Date(); + const date = Date.vnNew(); this.weekNum = moment(date).isoWeek(); this.dayNum = moment(date).day(); }, @@ -24,7 +24,8 @@ module.exports = { format: 'code128', displayValue: false, width: 3.8, - height: 115, + height: 60, + margin: 3, }); return new XMLSerializer().serializeToString(svgNode); }, diff --git a/print/templates/reports/buy-label-supplier/options.json b/print/templates/reports/buy-label-supplier/options.json index 4ed0461b3..a2a781cbf 100644 --- a/print/templates/reports/buy-label-supplier/options.json +++ b/print/templates/reports/buy-label-supplier/options.json @@ -1,6 +1,6 @@ { "width": "10cm", - "height": "10cm", + "height": "6.5cm", "margin": { "top": "0.17cm", "right": "0.2cm", From 1ac75d87ade3d238585c075813fc136601417f3c Mon Sep 17 00:00:00 2001 From: sergiodt Date: Fri, 10 Jan 2025 08:55:45 +0100 Subject: [PATCH 214/219] fix: refs #6861 refs#6861 addPrevOK --- db/routines/vn/procedures/saleTracking_addPrevOK.sql | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/db/routines/vn/procedures/saleTracking_addPrevOK.sql b/db/routines/vn/procedures/saleTracking_addPrevOK.sql index 34d1cfac8..9f823e9a0 100644 --- a/db/routines/vn/procedures/saleTracking_addPrevOK.sql +++ b/db/routines/vn/procedures/saleTracking_addPrevOK.sql @@ -16,10 +16,11 @@ BEGIN TRUE, sc.userFk, s.id - FROM vn.sectorCollection sc - JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id - JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk - JOIN vn.state s ON s.code = 'OK PREVIOUS' + FROM sectorCollection sc + JOIN sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id + JOIN saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk + JOIN state s ON s.code = 'OK PREVIOUS' + JOIN itemShelvingSale iss ON iss.saleFk = sgd.saleFk WHERE sc.id = vSectorCollectionFk; END$$ DELIMITER ; From bdaaffbbd76247d2eaf64635c58fbd8e707bff2b Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 10 Jan 2025 10:33:19 +0100 Subject: [PATCH 215/219] feat: refs #7584 changes request --- db/routines/vn/triggers/workerTimeControl_afterDelete.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/triggers/workerTimeControl_afterDelete.sql b/db/routines/vn/triggers/workerTimeControl_afterDelete.sql index 762754591..96db381b5 100644 --- a/db/routines/vn/triggers/workerTimeControl_afterDelete.sql +++ b/db/routines/vn/triggers/workerTimeControl_afterDelete.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`workerTimeControl_after AFTER DELETE ON `workerTimeControl` FOR EACH ROW BEGIN - IF account.myUser_getId() THEN + IF account.myUser_getId() IS NOT NULL THEN INSERT INTO workerLog SET `action` = 'delete', `changedModel` = 'WorkerTimeControl', From 9d05b16404da3a7d3d7d5e14300f7b4a9d8baa9f Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 13 Jan 2025 09:18:46 +0100 Subject: [PATCH 216/219] fix: canBeInvoiced only in makeInvoice --- loopback/locale/en.json | 3 +- loopback/locale/es.json | 2 +- loopback/locale/fr.json | 2 +- loopback/locale/pt.json | 2 +- .../methods/invoiceOut/clientsToInvoice.js | 6 --- .../invoiceOut/specs/clientsToInvoice.spec.js | 54 +++++++++++-------- 6 files changed, 38 insertions(+), 31 deletions(-) diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 80da13ae5..8d5eab4bc 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -211,6 +211,7 @@ "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", + "No tickets to invoice": "There are no tickets to invoice that meet the invoicing requirements", "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.", @@ -251,4 +252,4 @@ "Price cannot be blank": "Price cannot be blank", "There are tickets to be invoiced": "There are tickets to be invoiced", "The address of the customer must have information about Incoterms and Customs Agent": "The address of the customer must have information about Incoterms and Customs Agent" -} \ No newline at end of file +} diff --git a/loopback/locale/es.json b/loopback/locale/es.json index fcee0e111..cde81e0cb 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -339,7 +339,7 @@ "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", + "No tickets to invoice": "No hay tickets para facturar que cumplan los requisitos de facturación", "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", diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 9941358be..f49196a8f 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -339,7 +339,7 @@ "Incorrect pin": "Pin incorrect.", "You already have the mailAlias": "Vous avez déjà cet alias de courrier", "The alias cant be modified": "Cet alias de courrier ne peut pas être modifié", - "No tickets to invoice": "Pas de tickets à facturer", + "No tickets to invoice": "Il n'y a pas de tickets à facturer qui répondent aux exigences de facturation", "this warehouse has not dms": "L'entrepôt n'accepte pas les documents", "This ticket already has a cmr saved": "Ce ticket a déjà un cmr enregistré", "Name should be uppercase": "Le nom doit être en majuscules", diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index e84b30f3d..e2374d35f 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -339,7 +339,7 @@ "Incorrect pin": "PIN incorreto.", "You already have the mailAlias": "Você já tem o alias de e-mail", "The alias cant be modified": "O alias não pode ser modificado", - "No tickets to invoice": "Não há tickets para faturar", + "No tickets to invoice": "Não há bilhetes para faturar que atendam aos requisitos de faturamento", "this warehouse has not dms": "Este armazém não tem DMS", "This ticket already has a cmr saved": "Este ticket já tem um CMR salvo", "Name should be uppercase": "O nome deve estar em maiúsculas", diff --git a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js index 7befdcbeb..f66221409 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js +++ b/modules/invoiceOut/back/methods/invoiceOut/clientsToInvoice.js @@ -49,12 +49,6 @@ module.exports = Self => { } try { - const clientCanBeInvoiced = - await Self.app.models.Client.canBeInvoiced(clientId, companyFk, myOptions); - - if (!clientCanBeInvoiced) - throw new UserError(`This client can't be invoiced`); - const vIsAllInvoiceable = false; await Self.rawSql('CALL ticketPackaging_add(?, ?, ?, ?)', [ clientId, diff --git a/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js b/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js index df0566c54..6e536f433 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js +++ b/modules/invoiceOut/back/methods/invoiceOut/specs/clientsToInvoice.spec.js @@ -1,4 +1,5 @@ const models = require('vn-loopback/server/server').models; +const LoopBackContext = require('loopback-context'); describe('InvoiceOut clientsToInvoice()', () => { const userId = 1; @@ -20,6 +21,21 @@ describe('InvoiceOut clientsToInvoice()', () => { headers: {origin: 'http://localhost'} }; const ctx = {req: activeCtx}; + let tx; + let options; + + beforeEach(async() => { + LoopBackContext.getCurrentContext = () => ({ + active: activeCtx, + }); + + tx = await models.InvoiceOut.beginTransaction({}); + options = {transaction: tx}; + }); + + afterEach(async() => { + await tx.rollback(); + }); it('should return a list of clients to invoice', async() => { spyOn(models.InvoiceOut, 'rawSql').and.callFake(query => { @@ -37,24 +53,14 @@ describe('InvoiceOut clientsToInvoice()', () => { } }); - const tx = await models.InvoiceOut.beginTransaction({}); - const options = {transaction: tx}; + const addresses = await models.InvoiceOut.clientsToInvoice( + ctx, clientId, invoiceDate, maxShipped, companyFk, options); - try { - const addresses = await models.InvoiceOut.clientsToInvoice( - ctx, clientId, invoiceDate, maxShipped, companyFk, options); - - expect(addresses.length).toBeGreaterThan(0); - expect(addresses[0].clientId).toBe(clientId); - expect(addresses[0].clientName).toBe('Test Client'); - expect(addresses[0].id).toBe(1); - expect(addresses[0].nickname).toBe('Address 1'); - - await tx.rollback(); - } catch (e) { - await tx.rollback(); - throw e; - } + expect(addresses.length).toBeGreaterThan(0); + expect(addresses[0].clientId).toBe(clientId); + expect(addresses[0].clientName).toBe('Test Client'); + expect(addresses[0].id).toBe(1); + expect(addresses[0].nickname).toBe('Address 1'); }); it('should handle errors and rollback transaction', async() => { @@ -62,14 +68,20 @@ describe('InvoiceOut clientsToInvoice()', () => { return Promise.reject(new Error('Test Error')); }); - const tx = await models.InvoiceOut.beginTransaction({}); - const options = {transaction: tx}; - try { await models.InvoiceOut.clientsToInvoice(ctx, clientId, invoiceDate, maxShipped, companyFk, options); } catch (e) { expect(e.message).toBe('Test Error'); - await tx.rollback(); } }); + + it('should return all list', async() => { + const minShipped = Date.vnNew(); + minShipped.setFullYear(maxShipped.getFullYear() - 1); + + const toInvoice = await models.InvoiceOut.clientsToInvoice( + ctx, null, invoiceDate, maxShipped, companyFk, options); + + expect(toInvoice).toBeDefined(); + }); }); From 6e56bdeeb1159473d8a6797eb82a2656e89f5e0f Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 13 Jan 2025 15:24:01 +0100 Subject: [PATCH 217/219] fix: refs #8389 prevent error propagation --- back/methods/chat/sendCheckingPresence.js | 1 - 1 file changed, 1 deletion(-) diff --git a/back/methods/chat/sendCheckingPresence.js b/back/methods/chat/sendCheckingPresence.js index 83e8da304..955ed0240 100644 --- a/back/methods/chat/sendCheckingPresence.js +++ b/back/methods/chat/sendCheckingPresence.js @@ -67,7 +67,6 @@ module.exports = Self => { INSERT INTO util.debug (variable, value) VALUES ('sendCheckingPresence_error', ?) `, [`User: ${userId}, recipient: ${recipientId}, message: ${message}, error: ${e}`]); - throw e; } }; }; From 00577056ddd933b153bd63c8ee9cc8734d1e6f8e Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 13 Jan 2025 15:24:12 +0100 Subject: [PATCH 218/219] build: refs #8389 changelog --- CHANGELOG.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4eb7d29a..67ffe9f12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,31 @@ +# Version 25.00 - 2025-01-14 + +### Added 🆕 + +- feat: refs #7235 add serialType parameter to getInvoiceDate and implement corresponding tests by:jgallego +- feat: refs #7301 update lastEntriesFilter to include landedDate and enhance test cases (origin/7301-removeRedundantInventories) by:pablone +- feat: refs #7880 error code and translations by:ivanm +- feat: refs #7924 add isCustomInspectionRequired field to item and update related logic by:jgallego +- feat: refs #8167 update canBeInvoiced method to include active status check and improve test cases by:jgallego +- feat: refs #8167 update locale and improve invoicing logic with error handling by:jgallego +- feat: refs #8246 added relation for the front's new field by:Jon +- feat: refs #8266 added itemFk and needed fixtures by:jtubau +- feat: refs #8324 country unique by:Carlos Andrés + +### Changed 📦 + + +### Fixed 🛠️ + +- feat: refs #8266 added itemFk and needed fixtures by:jtubau +- fix: add isCustomInspectionRequired column to item table for customs inspection indication by:jgallego +- fix: canBeInvoiced only in makeInvoice by:alexm +- fix: hotFix getMondayWeekYear by:alexm +- fix: refs #6598 update ACL property assignment by:jorgep +- fix: refs #6861 refs#6861 addPrevOK by:sergiodt +- fix: refs #7301 remove debug console log and update test cases in lastEntriesFilter by:pablone +- fix: refs #7301 update SQL fixtures and improve lastEntriesFilter logic by:pablone + # Version 24.52 - 2024-01-07 ### Added 🆕 From 6aa898ee596b29347fba4e88f3bd712cd4be3e19 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 14 Jan 2025 07:39:52 +0100 Subject: [PATCH 219/219] build: refs #8389 dump db --- db/dump/.dump/data.sql | 31 ++++++++++++++++----------- db/dump/.dump/privileges.sql | 4 ++++ db/dump/.dump/structure.sql | 41 +++++++++++++++++++++++------------- db/dump/.dump/triggers.sql | 2 +- 4 files changed, 50 insertions(+), 28 deletions(-) diff --git a/db/dump/.dump/data.sql b/db/dump/.dump/data.sql index a2df34218..b95890b0d 100644 --- a/db/dump/.dump/data.sql +++ b/db/dump/.dump/data.sql @@ -4,7 +4,7 @@ USE `util`; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -INSERT INTO `version` VALUES ('vn-database','11385','72bf27f08d3ddf646ec0bb6594fc79cecd4b72f2','2025-01-07 07:46:33','11395'); +INSERT INTO `version` VALUES ('vn-database','11391','43edb1f82e88dcc44eedc8501b93c1fac66d71e9','2025-01-14 07:32:09','11407'); INSERT INTO `versionLog` VALUES ('vn-database','10107','00-firstScript.sql','jenkins@10.0.2.69','2022-04-23 10:53:53',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','10112','00-firstScript.sql','jenkins@10.0.2.69','2022-05-09 09:14:53',NULL,NULL); @@ -1078,6 +1078,7 @@ INSERT INTO `versionLog` VALUES ('vn-database','11315','00-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','11316','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11317','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11319','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11320','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-14 07:32:07',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11321','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-26 07:05:30',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11322','00-entryAcl.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-12-10 07:20:04',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11324','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2024-11-13 10:49:47',NULL,NULL); @@ -1139,6 +1140,9 @@ INSERT INTO `versionLog` VALUES ('vn-database','11379','00-firstScript.sql','jen INSERT INTO `versionLog` VALUES ('vn-database','11379','01-secScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-07 07:46:32',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11384','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-07 07:46:32',NULL,NULL); INSERT INTO `versionLog` VALUES ('vn-database','11385','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-07 07:46:33',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11390','00-firstScript.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-14 07:32:08',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11391','00-itemAlter.sql','jenkins@db-proxy2.servers.dc.verdnatura.es','2025-01-14 07:32:08',NULL,NULL); +INSERT INTO `versionLog` VALUES ('vn-database','11400','00-firstScript.sql','jenkins@db-proxy1.servers.dc.verdnatura.es','2025-01-09 09:55:24',NULL,NULL); /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; @@ -1515,6 +1519,7 @@ INSERT INTO `roleInherit` VALUES (378,101,15,19294); INSERT INTO `roleInherit` VALUES (379,103,121,19294); INSERT INTO `roleInherit` VALUES (381,119,123,19295); INSERT INTO `roleInherit` VALUES (382,48,72,783); +INSERT INTO `roleInherit` VALUES (383,114,111,19295); INSERT INTO `userPassword` VALUES (1,7,1,0,2,1); @@ -2311,9 +2316,9 @@ INSERT INTO `ACL` VALUES (938,'Worker','__get__mail','READ','ALLOW','ROLE','hr', INSERT INTO `ACL` VALUES (939,'Machine','*','*','ALLOW','ROLE','productionBoss',10578); INSERT INTO `ACL` VALUES (940,'ItemTypeLog','find','READ','ALLOW','ROLE','employee',10578); INSERT INTO `ACL` VALUES (941,'Entry','buyLabel','READ','ALLOW','ROLE','employee',10578); -INSERT INTO `ACL` VALUES (942,'Cmr','filter','READ','ALLOW','ROLE','production',10578); -INSERT INTO `ACL` VALUES (943,'Cmr','downloadZip','READ','ALLOW','ROLE','production',10578); -INSERT INTO `ACL` VALUES (944,'Cmr','print','READ','ALLOW','ROLE','production',10578); +INSERT INTO `ACL` VALUES (942,'Cmr','filter','READ','ALLOW','ROLE','employee',19295); +INSERT INTO `ACL` VALUES (943,'Cmr','downloadZip','READ','ALLOW','ROLE','employee',19295); +INSERT INTO `ACL` VALUES (944,'Cmr','print','READ','ALLOW','ROLE','employee',19295); INSERT INTO `ACL` VALUES (945,'Collection','create','WRITE','ALLOW','ROLE','productionBoss',10578); INSERT INTO `ACL` VALUES (946,'Collection','upsert','WRITE','ALLOW','ROLE','productionBoss',10578); INSERT INTO `ACL` VALUES (947,'Collection','replaceById','WRITE','ALLOW','ROLE','productionBoss',10578); @@ -2327,7 +2332,6 @@ INSERT INTO `ACL` VALUES (954,'RouteComplement','find','READ','ALLOW','ROLE','de INSERT INTO `ACL` VALUES (955,'RouteComplement','create','WRITE','ALLOW','ROLE','delivery',10578); INSERT INTO `ACL` VALUES (956,'RouteComplement','deleteById','WRITE','ALLOW','ROLE','delivery',10578); INSERT INTO `ACL` VALUES (957,'SaleGroup','find','READ','ALLOW','ROLE','production',10578); -INSERT INTO `ACL` VALUES (958,'Worker','canCreateAbsenceInPast','WRITE','ALLOW','ROLE','hr',10578); INSERT INTO `ACL` VALUES (959,'WorkerRelative','updateAttributes','*','ALLOW','ROLE','hr',10578); INSERT INTO `ACL` VALUES (960,'WorkerRelative','crud','WRITE','ALLOW','ROLE','hr',10578); INSERT INTO `ACL` VALUES (961,'WorkerRelative','findById','*','ALLOW','ROLE','hr',10578); @@ -2383,6 +2387,8 @@ INSERT INTO `ACL` VALUES (1010,'InventoryConfig','find','READ','ALLOW','ROLE','b INSERT INTO `ACL` VALUES (1011,'SiiTypeInvoiceIn','find','READ','ALLOW','ROLE','salesPerson',10578); INSERT INTO `ACL` VALUES (1012,'OsrmConfig','optimize','READ','ALLOW','ROLE','employee',10578); INSERT INTO `ACL` VALUES (1013,'Route','optimizePriority','*','ALLOW','ROLE','employee',10578); +INSERT INTO `ACL` VALUES (1014,'Worker','canModifyAbsenceInPast','WRITE','ALLOW','ROLE','hr',10578); +INSERT INTO `ACL` VALUES (1015,'Worker','__get__sip','READ','ALLOW','ROLE','employee',19294); INSERT INTO `fieldAcl` VALUES (1,'Client','name','update','employee'); INSERT INTO `fieldAcl` VALUES (2,'Client','contact','update','employee'); @@ -2725,7 +2731,7 @@ INSERT INTO `department` VALUES (124,NULL,'CONTROL INTERNO',122,123,NULL,72,0,0, INSERT INTO `department` VALUES (125,'spainTeam3','EQUIPO ESPAÑA 3',59,60,1118,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (126,NULL,'PRESERVADO',29,30,NULL,0,0,0,2,0,37,'/1/37/',NULL,0,NULL,0,1,1,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (128,NULL,'PALETIZADO',31,32,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,0,NULL,NULL,NULL,'PALLETIZING'); -INSERT INTO `department` VALUES (130,NULL,'REVISION',33,34,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'ON_CHECKING'); +INSERT INTO `department` VALUES (130,'reviewers','REVISION',33,34,NULL,0,1,0,2,0,37,'/1/37/',NULL,0,NULL,0,0,0,1,NULL,NULL,NULL,'ON_CHECKING'); INSERT INTO `department` VALUES (131,'greenhouse','INVERNADERO',105,106,NULL,0,0,0,2,0,58,'/1/58/',NULL,0,NULL,0,1,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (132,NULL,'EQUIPO DC',61,62,1731,0,0,0,2,0,43,'/1/43/','dc_equipo',1,'gestioncomercial@verdnatura.es',0,0,0,0,NULL,NULL,NULL,NULL); INSERT INTO `department` VALUES (133,'franceTeamManagement','EQUIPO GESTIÓN FRANCIA',63,64,9751,72,0,0,2,0,43,'/1/43/','fr_equipo',1,'gestionfrancia@verdnatura.es',0,0,0,0,NULL,NULL,'3300',NULL); @@ -2740,12 +2746,12 @@ INSERT INTO `department` VALUES (146,NULL,'VERDNACOLOMBIA',3,4,NULL,72,0,0,2,0,2 INSERT INTO `department` VALUES (147,'spainTeamAsia','EQUIPO ESPAÑA ASIA',71,72,40214,0,0,0,2,0,43,'/1/43/','esA_equipo',1,'esA@verdnatura.es',0,0,0,0,NULL,NULL,'5500',NULL); INSERT INTO `department` VALUES (148,'franceTeamCatchment','EQUIPO CAPTACIÓN FRANCIA',73,74,25178,0,0,0,2,0,43,'/1/43/',NULL,1,NULL,0,0,0,0,NULL,NULL,'6000',NULL); INSERT INTO `department` VALUES (149,'spainTeamCatchment','EQUIPO ESPAÑA CAPTACIÓN',75,76,1203,0,0,0,2,0,43,'/1/43/','es_captacion_equipo',1,'es_captacion@verdnatura.es',0,0,0,0,NULL,NULL,'5700',NULL); -INSERT INTO `department` VALUES (150,'spainTeamLevanteIslands','EQUIPO ESPAÑA LEVANTE',77,78,1118,0,0,0,2,0,43,'/1/43/','es_levante_equipo',1,'levanteislas.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5000',NULL); -INSERT INTO `department` VALUES (151,'spainTeamNorthwest','EQUIPO ESPAÑA NOROESTE',79,80,7102,0,0,0,2,0,43,'/1/43/','es_noroeste_equipo',1,'noroeste.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5300',NULL); -INSERT INTO `department` VALUES (152,'spainTeamNortheast','EQUIPO ESPAÑA NORESTE',81,82,1118,0,0,0,2,0,43,'/1/43/','es_noreste_equipo',1,'noreste.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5200',NULL); -INSERT INTO `department` VALUES (153,'spainTeamSouth','EQUIPO ESPAÑA SUR',83,84,36578,0,0,0,2,0,43,'/1/43/','es_sur_equipo',1,'sur.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5400',NULL); -INSERT INTO `department` VALUES (154,'spainTeamCenter','EQUIPO ESPAÑA CENTRO',85,86,4661,0,0,0,2,0,43,'/1/43/','es_centro_equipo',1,'centro.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5100',NULL); -INSERT INTO `department` VALUES (155,'spainTeamVip','EQUIPO ESPAÑA VIP',87,88,5432,0,0,0,2,0,43,'/1/43/','es_vip_equipo',1,'vip.verdnatura@gmail.com',0,0,0,0,NULL,NULL,'5600',NULL); +INSERT INTO `department` VALUES (150,'spainTeamLevanteIslands','EQUIPO ESPAÑA LEVANTE',77,78,1118,0,0,0,2,0,43,'/1/43/','es_levante_equipo',1,'es_levante@verdnatura.es',0,0,0,0,NULL,NULL,'5000',NULL); +INSERT INTO `department` VALUES (151,'spainTeamNorthwest','EQUIPO ESPAÑA NOROESTE',79,80,7102,0,0,0,2,0,43,'/1/43/','es_noroeste_equipo',1,'es_noroeste@verdnatura.es',0,0,0,0,NULL,NULL,'5300',NULL); +INSERT INTO `department` VALUES (152,'spainTeamNortheast','EQUIPO ESPAÑA NORESTE',81,82,1118,0,0,0,2,0,43,'/1/43/','es_noreste_equipo',1,'es_noreste@verdnatura.es',0,0,0,0,NULL,NULL,'5200',NULL); +INSERT INTO `department` VALUES (153,'spainTeamSouth','EQUIPO ESPAÑA SUR',83,84,36578,0,0,0,2,0,43,'/1/43/','es_sur_equipo',1,'es_sur@verdnatura.es',0,0,0,0,NULL,NULL,'5400',NULL); +INSERT INTO `department` VALUES (154,'spainTeamCenter','EQUIPO ESPAÑA CENTRO',85,86,4661,0,0,0,2,0,43,'/1/43/','es_centro_equipo',1,'es_centro@verdnatura.es',0,0,0,0,NULL,NULL,'5100',NULL); +INSERT INTO `department` VALUES (155,'spainTeamVip','EQUIPO ESPAÑA VIP',87,88,5432,0,0,0,2,0,43,'/1/43/','es_vip_equipo',1,'es_vip@verdnatura.es',0,0,0,0,NULL,NULL,'5600',NULL); INSERT INTO `docuware` VALUES (1,'deliveryNote','Albaranes cliente','find','find','N__ALBAR_N',NULL); INSERT INTO `docuware` VALUES (2,'deliveryNote','Albaranes cliente','store','Archivar','N__ALBAR_N',NULL); @@ -3046,6 +3052,7 @@ INSERT INTO `message` VALUES (20,'clientNotVerified','Incomplete tax data, pleas INSERT INTO `message` VALUES (21,'quantityLessThanMin','The quantity cannot be less than the minimum'); INSERT INTO `message` VALUES (22,'ORDER_ROW_UNAVAILABLE','The ordered quantity exceeds the available'); INSERT INTO `message` VALUES (23,'AMOUNT_NOT_MATCH_GROUPING','The quantity ordered does not match the grouping'); +INSERT INTO `message` VALUES (24,'orderLinesWithZero','There are empty lines. Please delete them'); INSERT INTO `metatag` VALUES (2,'title','Verdnatura Levante SL, mayorista de flores, plantas y complementos para floristería y decoración'); INSERT INTO `metatag` VALUES (3,'description','Verdnatura Levante SL, mayorista de flores, plantas y complementos para floristería y decoración. Envío a toda España, pedidos por internet o por teléfono.'); diff --git a/db/dump/.dump/privileges.sql b/db/dump/.dump/privileges.sql index 460256b56..598bfdf75 100644 --- a/db/dump/.dump/privileges.sql +++ b/db/dump/.dump/privileges.sql @@ -1494,6 +1494,10 @@ INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','travelThermograph',' INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','thermograph','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn2008','buyerSalesAssistant','Tickets','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Update',''); INSERT IGNORE INTO `tables_priv` VALUES ('','vn','hr','sim','jenkins@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select,Insert,Update,Delete',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','employee','zoneGeo','guillermo@db-proxy2.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','itemCampaign','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','grafana','itemCampaign','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); +INSERT IGNORE INTO `tables_priv` VALUES ('','vn','buyer','campaign','guillermo@db-proxy1.servers.dc.verdnatura.es','0000-00-00 00:00:00','Select',''); /*!40000 ALTER TABLE `tables_priv` ENABLE KEYS */; /*!40000 ALTER TABLE `columns_priv` DISABLE KEYS */; diff --git a/db/dump/.dump/structure.sql b/db/dump/.dump/structure.sql index e52ed2a51..58f1e7591 100644 --- a/db/dump/.dump/structure.sql +++ b/db/dump/.dump/structure.sql @@ -6249,19 +6249,27 @@ BEGIN * @param vDateFrom Fecha desde * @param vDateTo Fecha hasta */ - IF vDateFrom IS NULL THEN - SET vDateFrom = util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY; + DECLARE vDaysInYear INT; + SET vDaysInYear = DATEDIFF(util.lastDayOfYear(CURDATE()), util.firstDayOfYear(CURDATE())); + + SET vDateFrom = COALESCE(vDateFrom, util.VN_CURDATE()); + SET vDateTo = COALESCE(vDateTo, util.VN_CURDATE()); + + IF DATEDIFF(vDateTo, vDateFrom) > vDaysInYear THEN + CALL util.throw('The period cannot be longer than one year'); END IF; - IF vDateTo IS NULL THEN - SET vDateTo = vDateFrom + INTERVAL 6 DAY; - END IF; + -- Obtiene el primer día de la semana de esa fecha + SET vDateFrom = DATE_SUB(vDateFrom, INTERVAL ((WEEKDAY(vDateFrom) + 1) % 7) DAY); + + -- Obtiene el último día de la semana de esa fecha + SET vDateTo = DATE_ADD(vDateTo, INTERVAL (6 - ((WEEKDAY(vDateTo) + 1) % 7)) DAY); CALL cache.last_buy_refresh(FALSE); REPLACE bs.waste - SELECT YEAR(t.shipped), - WEEK(t.shipped, 4), + SELECT YEARWEEK(t.shipped, 6) DIV 100, + WEEK(t.shipped, 6), it.workerFk, it.id, s.itemFk, @@ -6307,9 +6315,9 @@ BEGIN JOIN cache.last_buy lb ON lb.item_id = i.id AND lb.warehouse_id = w.id JOIN vn.buy b ON b.id = lb.buy_id - WHERE t.shipped BETWEEN vDateFrom AND vDateTo + WHERE t.shipped BETWEEN vDateFrom AND util.dayEnd(vDateTo) AND w.isManaged - GROUP BY YEAR(t.shipped), WEEK(t.shipped, 4), i.id; + GROUP BY YEARWEEK(t.shipped, 6) DIV 100, WEEK(t.shipped, 6), i.id; END ;; DELIMITER ; /*!50003 SET sql_mode = @saved_sql_mode */ ; @@ -13807,7 +13815,7 @@ BEGIN ) INTO vHas0Amount; IF vHas0Amount THEN - CALL util.throw('Hay líneas vacías. Por favor, elimínelas'); + CALL util.throw('orderLinesWithZero'); END IF; START TRANSACTION; @@ -28922,6 +28930,7 @@ CREATE TABLE `country` ( `isSocialNameUnique` tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `country_unique` (`code`), + UNIQUE KEY `country_unique_name` (`name`), KEY `currency_id_fk_idx` (`currencyFk`), KEY `country_Ix4` (`name`), KEY `continent_id_fk_idx` (`continentFk`), @@ -31971,6 +31980,7 @@ CREATE TABLE `item` ( `value12` varchar(50) DEFAULT NULL, `tag13` varchar(20) DEFAULT NULL, `value13` varchar(50) DEFAULT NULL, + `isCustomInspectionRequired` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Indicates if the item requires physical inspection at customs', PRIMARY KEY (`id`), UNIQUE KEY `item_supplyResponseFk_idx` (`supplyResponseFk`), KEY `Color` (`inkFk`), @@ -68661,10 +68671,11 @@ BEGIN TRUE, sc.userFk, s.id - FROM vn.sectorCollection sc - JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id - JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk - JOIN vn.state s ON s.code = 'OK PREVIOUS' + FROM sectorCollection sc + JOIN sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id + JOIN saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk + JOIN state s ON s.code = 'OK PREVIOUS' + JOIN itemShelvingSale iss ON iss.saleFk = sgd.saleFk WHERE sc.id = vSectorCollectionFk; END ;; DELIMITER ; @@ -90882,4 +90893,4 @@ USE `vn2008`; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2025-01-07 6:51:38 +-- Dump completed on 2025-01-14 6:39:04 diff --git a/db/dump/.dump/triggers.sql b/db/dump/.dump/triggers.sql index 039dbb2a8..fb72e9899 100644 --- a/db/dump/.dump/triggers.sql +++ b/db/dump/.dump/triggers.sql @@ -11499,4 +11499,4 @@ USE `vn2008`; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2025-01-07 6:51:57 +-- Dump completed on 2025-01-14 6:39:25
{{$t('reference')}} {{$t('boxes')}} {{$t('packing')}}{{$t('concept')}}{{$t('tags')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}{{$t('concept')}}{{$t('reference')}}{{$t('tags')}}{{$t('quantity')}}{{$t('price')}}{{$t('amount')}}
{{buy.comment}} {{buy.stickers}}x{{buy.packing}}{{buy.name}} - {{buy.tag5}} → {{buy.value5}} - {{buy.tag6}} → {{buy.value6}} - {{buy.tag7}} → {{buy.value7}} + x{{buy.packing}}{{buy.name}}{{buy.comment}} + {{buy.tag5}} → {{buy.value5}} + {{buy.tag6}} → {{buy.value6}} + {{buy.tag7}} → {{buy.value7}} {{buy.quantity | number($i18n.locale)}}x{{buy.buyingValue | currency('EUR', $i18n.locale)}}= + {{buy.quantity | number($i18n.locale)}}x{{buy.buyingValue | currency('EUR', $i18n.locale)}}= {{buy.buyingValue * buy.quantity | currency('EUR', $i18n.locale)}}
+
{{formatNumber(buy.itemFk)}}
+
{{`${(packing || buy.packing)} x ${buy.stems || ''}`}}
From 00e5f8602064fe6c9ecf49d829ab9ecf97aeea37 Mon Sep 17 00:00:00 2001 From: pablone Date: Thu, 28 Nov 2024 11:18:09 +0100 Subject: [PATCH 041/219] fix: refs #7404 add debug logging for cancelShipment and deleteExpeditions methods --- back/methods/mrw-config/cancelShipment.js | 4 ++-- modules/ticket/back/methods/expedition/deleteExpeditions.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js index 98aa8be39..608797d8f 100644 --- a/back/methods/mrw-config/cancelShipment.js +++ b/back/methods/mrw-config/cancelShipment.js @@ -30,6 +30,8 @@ module.exports = Self => { const clientType = await models.MrwConfig.getClientType(expeditionFk); const template = fs.readFileSync(__dirname + '/cancelShipment.ejs', 'utf-8'); const renderedXml = ejs.render(template, {mrw, externalId, clientType}); + + await Self.rawSql('CALL util.debugAdd(?,?);', ['cancelShipment', renderedXml]); const response = await axios.post(mrw.url, renderedXml, { headers: { 'Content-Type': 'application/soap+xml; charset=utf-8' @@ -40,8 +42,6 @@ module.exports = Self => { const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); - await Self.rawSql('CALL util.debugAdd(?,?);', ['cancelShipment', xmlDoc]); - const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; return result.toLowerCase().includes('se ha cancelado correctamente'); }; diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index 75993a485..ff4a2bbad 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -52,7 +52,8 @@ module.exports = Self => { const deletedExpedition = await models.Expedition.destroyById(expeditionId); deletedExpeditions.push(deletedExpedition); - } catch (e) { + } catch (error) { + await Self.rawSql('CALL util.debugAdd(?,?);', ['deleteExpeditions', error]); notDeletedExpeditions.push(expeditionId); } } From 5923916cda07176dc3e05f97eb2e5cf58f3e8e14 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 28 Nov 2024 11:31:38 +0100 Subject: [PATCH 042/219] fix: change debugAdd to console.error --- modules/ticket/back/methods/expedition/deleteExpeditions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ticket/back/methods/expedition/deleteExpeditions.js b/modules/ticket/back/methods/expedition/deleteExpeditions.js index ff4a2bbad..267811d25 100644 --- a/modules/ticket/back/methods/expedition/deleteExpeditions.js +++ b/modules/ticket/back/methods/expedition/deleteExpeditions.js @@ -53,7 +53,7 @@ module.exports = Self => { const deletedExpedition = await models.Expedition.destroyById(expeditionId); deletedExpeditions.push(deletedExpedition); } catch (error) { - await Self.rawSql('CALL util.debugAdd(?,?);', ['deleteExpeditions', error]); + console.error('error: ', error); notDeletedExpeditions.push(expeditionId); } } From e730b5d4a14a00b47e0993e558eb539230e321e7 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 28 Nov 2024 11:53:42 +0100 Subject: [PATCH 043/219] fix: add debugAdd response axios --- back/methods/mrw-config/cancelShipment.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js index 608797d8f..cd80fe4bb 100644 --- a/back/methods/mrw-config/cancelShipment.js +++ b/back/methods/mrw-config/cancelShipment.js @@ -42,6 +42,8 @@ module.exports = Self => { const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); + await Self.rawSql('CALL util.debugAdd(?,?);', ['cancelShipmentResponse', xmlDoc]); + const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; return result.toLowerCase().includes('se ha cancelado correctamente'); }; From 6785779fe5338ca259d051792e4135909fa86ab0 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 28 Nov 2024 12:26:03 +0100 Subject: [PATCH 044/219] fix: add console log --- back/methods/mrw-config/cancelShipment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js index cd80fe4bb..0e12909ba 100644 --- a/back/methods/mrw-config/cancelShipment.js +++ b/back/methods/mrw-config/cancelShipment.js @@ -42,7 +42,7 @@ module.exports = Self => { const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); - await Self.rawSql('CALL util.debugAdd(?,?);', ['cancelShipmentResponse', xmlDoc]); + console.log('xmlDoc', xmlDoc); const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; return result.toLowerCase().includes('se ha cancelado correctamente'); From 838296e74463c9361c3280d9f1b8f50e00a7ff66 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 28 Nov 2024 13:02:58 +0100 Subject: [PATCH 045/219] fix: add expected message result --- back/methods/mrw-config/cancelShipment.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js index 0e12909ba..bd483fc58 100644 --- a/back/methods/mrw-config/cancelShipment.js +++ b/back/methods/mrw-config/cancelShipment.js @@ -24,7 +24,6 @@ module.exports = Self => { Self.cancelShipment = async expeditionFk => { const models = Self.app.models; - const mrw = await models.MrwConfig.findOne(); const {externalId} = await models.Expedition.findById(expeditionFk); const clientType = await models.MrwConfig.getClientType(expeditionFk); @@ -39,12 +38,11 @@ module.exports = Self => { }); const xmlString = response.data; + await Self.rawSql('CALL util.debugAdd(?,?);', ['cancelShipmentResponse', xmlString]); const parser = new DOMParser(); const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); - console.log('xmlDoc', xmlDoc); - const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; - return result.toLowerCase().includes('se ha cancelado correctamente'); + return ['no se ha encontrado', 'se ha cancelado correctamente'].some(r => r.includes(result.toLowerCase())); }; }; From d6a849727e0b5dc4a60266ec5b00fb48eb20c8e4 Mon Sep 17 00:00:00 2001 From: alexm Date: Thu, 28 Nov 2024 13:11:43 +0100 Subject: [PATCH 046/219] fix: fix result test --- back/methods/mrw-config/cancelShipment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/mrw-config/cancelShipment.js b/back/methods/mrw-config/cancelShipment.js index bd483fc58..e96d6d694 100644 --- a/back/methods/mrw-config/cancelShipment.js +++ b/back/methods/mrw-config/cancelShipment.js @@ -43,6 +43,6 @@ module.exports = Self => { const xmlDoc = parser.parseFromString(xmlString, 'text/xml'); const result = xmlDoc.getElementsByTagName('Mensaje')[0].textContent; - return ['no se ha encontrado', 'se ha cancelado correctamente'].some(r => r.includes(result.toLowerCase())); + return ['no se ha encontrado', 'se ha cancelado correctamente'].some(res => result.toLowerCase().includes(res)); }; }; From 7d5ae9dfbd4a0ba3a6ec4b34a46473ab475f4e1b Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 28 Nov 2024 14:52:41 +0100 Subject: [PATCH 047/219] feat: refs #7936 add reference rates for currency in fixtures --- db/dump/fixtures.before.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index e5d5f53dc..542d3dfe9 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4033,3 +4033,8 @@ INSERT IGNORE INTO vn.saySimpleConfig (url, defaultChannel) INSERT INTO vn.workerIrpf (workerFk,spouseNif, geographicMobilityDate) VALUES (1106,'26493101E','2019-09-20'); + +INSERT INTO vn.referenceRate (currencyFk, dated, value) + VALUES (2, '2000-12-01', 1.0495), + (2, '2001-01-01', 1.0531), + (2, '2001-02-01', 7.6347); \ No newline at end of file From 6d315bf84d1ac3e4d1f6378089ebe280461018d4 Mon Sep 17 00:00:00 2001 From: ivanm Date: Thu, 28 Nov 2024 17:29:39 +0100 Subject: [PATCH 048/219] refactor: refs #7146 route.created to route.dated --- db/dump/fixtures.before.sql | 16 ++++++++-------- db/routines/bi/procedures/rutasAnalyze.sql | 16 ++++++++-------- db/routines/vn/functions/routeProposal.sql | 2 +- db/routines/vn/functions/routeProposal_beta.sql | 2 +- .../vn/procedures/expedition_getFromRoute.sql | 2 +- .../vn/procedures/routeMonitor_calculate.sql | 2 +- .../vn/procedures/route_calcCommission.sql | 2 +- .../vn/triggers/itemCost_beforeUpdate.sql | 2 +- db/routines/vn/triggers/route_beforeInsert.sql | 2 +- db/routines/vn/triggers/sale_afterInsert.sql | 2 +- db/routines/vn/triggers/sale_afterUpdate.sql | 2 +- db/routines/vn/triggers/sale_beforeDelete.sql | 2 +- db/routines/vn/triggers/ticket_beforeDelete.sql | 2 +- db/routines/vn/triggers/ticket_beforeUpdate.sql | 4 ++-- db/routines/vn/views/expeditionPallet_Print.sql | 4 ++-- db/routines/vn/views/expeditionRoute_Monitor.sql | 4 ++-- db/routines/vn2008/views/Rutas.sql | 2 +- .../11371-salmonRuscus/00-firstScript.sql | 1 + .../11371-salmonRuscus/01-firstScript.sql | 1 + .../11371-salmonRuscus/02-firstScript.sql | 2 ++ .../11371-salmonRuscus/03-firstScript.sql | 2 ++ e2e/helpers/selectors.js | 2 +- modules/route/back/methods/agency-term/filter.js | 8 ++++---- modules/route/back/methods/route/clone.js | 8 ++++---- modules/route/back/methods/route/filter.js | 6 +++--- modules/route/back/methods/route/getByWorker.js | 6 +++--- .../back/methods/route/getSuggestedTickets.js | 4 ++-- modules/route/back/methods/route/insertTicket.js | 4 ++-- modules/route/back/models/route.json | 2 +- modules/route/front/descriptor/index.html | 2 +- modules/route/front/descriptor/index.js | 2 +- modules/route/front/summary/index.html | 2 +- .../reports/driver-route/driver-route.html | 2 +- .../reports/driver-route/sql/routes.sql | 2 +- .../expedition-pallet-label/sql/labelData.sql | 2 +- 35 files changed, 66 insertions(+), 60 deletions(-) create mode 100644 db/versions/11371-salmonRuscus/00-firstScript.sql create mode 100644 db/versions/11371-salmonRuscus/01-firstScript.sql create mode 100644 db/versions/11371-salmonRuscus/02-firstScript.sql create mode 100644 db/versions/11371-salmonRuscus/03-firstScript.sql diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index e5d5f53dc..037be771b 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -745,15 +745,15 @@ INSERT INTO `vn`.`zoneClosure` (`zoneFk`, `dated`, `hour`) INSERT INTO `vn`.`zoneConfig` (`id`, `scope`) VALUES (1, '1'); -INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`, `zoneFk`) +INSERT INTO `vn`.`route`(`id`, `time`, `workerFk`, `created`, `vehicleFk`, `agencyModeFk`, `description`, `m3`, `cost`, `started`, `finished`, `zoneFk`, `dated`) VALUES - (1, '1899-12-30 12:15:00', 56, util.VN_CURDATE(), 1, 1, 'first route', 1.8, 10, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1), - (2, '1899-12-30 13:20:00', 56, util.VN_CURDATE(), 1, 2, 'second route', 0.2, 20, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 9), - (3, '1899-12-30 14:30:00', 56, util.VN_CURDATE(), 2, 3, 'third route', 0.5, 30, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 10), - (4, '1899-12-30 15:45:00', 56, util.VN_CURDATE(), 3, 4, 'fourth route', 0, 40, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 12), - (5, '1899-12-30 16:00:00', 56, util.VN_CURDATE(), 4, 5, 'fifth route', 0.1, 50, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 13), - (6, NULL, 57, util.VN_CURDATE(), 5, 7, 'sixth route', 1.7, 60, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 3), - (7, NULL, 57, util.VN_CURDATE(), 6, 8, 'seventh route', 0, 70, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 5); + (1, '1899-12-30 12:15:00', 56, util.VN_CURDATE(), 1, 1, 'first route', 1.8, 10, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 1, util.VN_CURDATE()), + (2, '1899-12-30 13:20:00', 56, util.VN_CURDATE(), 1, 2, 'second route', 0.2, 20, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 9, util.VN_CURDATE()), + (3, '1899-12-30 14:30:00', 56, util.VN_CURDATE(), 2, 3, 'third route', 0.5, 30, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 10, util.VN_CURDATE()), + (4, '1899-12-30 15:45:00', 56, util.VN_CURDATE(), 3, 4, 'fourth route', 0, 40, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 12, util.VN_CURDATE()), + (5, '1899-12-30 16:00:00', 56, util.VN_CURDATE(), 4, 5, 'fifth route', 0.1, 50, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 13, util.VN_CURDATE()), + (6, NULL, 57, util.VN_CURDATE(), 5, 7, 'sixth route', 1.7, 60, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 3, util.VN_CURDATE()), + (7, NULL, 57, util.VN_CURDATE(), 6, 8, 'seventh route', 0, 70, util.VN_CURDATE(), DATE_ADD(util.VN_CURDATE(), INTERVAL + 1 DAY), 5, util.VN_CURDATE()); INSERT INTO `vn`.`ticket`(`id`, `priority`, `agencyModeFk`,`warehouseFk`,`routeFk`, `shipped`, `landed`, `clientFk`,`nickname`, `addressFk`, `refFk`, `isDeleted`, `zoneFk`, `zonePrice`, `zoneBonus`, `created`, `weight`, `cmrFk`, `problem`, `risk`) VALUES diff --git a/db/routines/bi/procedures/rutasAnalyze.sql b/db/routines/bi/procedures/rutasAnalyze.sql index e277968bf..1f103bde0 100644 --- a/db/routines/bi/procedures/rutasAnalyze.sql +++ b/db/routines/bi/procedures/rutasAnalyze.sql @@ -19,14 +19,14 @@ BEGIN bultos) SELECT r.id, r.agencyModeFk, - r.created, + r.dated, SUM(sv.volume / ebv.m3) FROM vn.route r JOIN vn.ticket t ON t.routeFk = r.id LEFT JOIN vn.`zone` z ON z.id = t.zoneFk JOIN vn.saleVolume sv ON sv.ticketFk = t.id JOIN vn.expeditionBoxVol ebv ON ebv.code = 'transportBox' - WHERE r.created BETWEEN vDatedFrom AND vDatedTo + WHERE r.dated BETWEEN vDatedFrom AND vDatedTo AND z.isVolumetric GROUP BY r.id; @@ -38,12 +38,12 @@ BEGIN Bultos) SELECT r.id, r.agencyModeFk, - r.created, + r.dated, SUM(t.packages) FROM vn.route r JOIN vn.ticket t ON t.routeFk = r.id LEFT JOIN vn.`zone` z ON z.id = t.zoneFk - WHERE r.created BETWEEN vDatedFrom AND vDatedTo + WHERE r.dated BETWEEN vDatedFrom AND vDatedTo AND NOT z.isVolumetric GROUP BY r.id ON DUPLICATE KEY UPDATE Bultos = Bultos + VALUES(Bultos); @@ -60,7 +60,7 @@ BEGIN JOIN vn.component c ON c.id = sc.componentFk JOIN vn.componentType ct ON ct.id = c.typeFk WHERE ct.code = 'freight' - AND r.created BETWEEN vDatedFrom AND vDatedTo + AND r.dated BETWEEN vDatedFrom AND vDatedTo GROUP BY r.id ) sub ON sub.routeFk = r.Id_Ruta SET r.practico = IFNULL(sub.totalPractice / r.Bultos, 0); @@ -77,7 +77,7 @@ BEGIN JOIN vn.address ad ON ad.id = t.addressFk JOIN vn.client c ON c.id = ad.clientFk LEFT JOIN vn.`zone` z ON z.id = t.zoneFk - WHERE r.created BETWEEN vDatedFrom AND vDatedTo + WHERE r.dated BETWEEN vDatedFrom AND vDatedTo AND NOT z.isVolumetric GROUP BY t.routeFk ) sub ON r.Id_Ruta = sub.routeFk @@ -93,7 +93,7 @@ BEGIN JOIN vn.saleVolume sf ON sf.ticketFk = t.id JOIN vn.client c ON c.id = t.clientFk JOIN vn.`zone` z ON z.id = t.zoneFk - WHERE r.created BETWEEN vDatedFrom AND vDatedTo + WHERE r.dated BETWEEN vDatedFrom AND vDatedTo AND z.isVolumetric GROUP BY t.routeFk ) sub ON r.Id_Ruta = sub.routeFk @@ -108,7 +108,7 @@ BEGIN JOIN vn.route r ON r.id = t.routeFk JOIN vn.greuge g ON g.ticketFk = t.id JOIN vn.greugeType gt ON gt.id = g.greugeTypeFk - WHERE r.created BETWEEN vDatedFrom AND vDatedTo + WHERE r.dated BETWEEN vDatedFrom AND vDatedTo AND gt.code = 'freightDifference' GROUP BY t.routeFk ) sub ON r.Id_Ruta = sub.routeFk diff --git a/db/routines/vn/functions/routeProposal.sql b/db/routines/vn/functions/routeProposal.sql index 14b626a39..70a1eaae4 100644 --- a/db/routines/vn/functions/routeProposal.sql +++ b/db/routines/vn/functions/routeProposal.sql @@ -26,7 +26,7 @@ BEGIN JOIN cache.zoneAgencyFriendship zf ON zf.agencyModeFk = r.agencyModeFk WHERE friendship >= vSignificativeFriendship AND zf.zoneFk = vZoneFk - AND r.created = vLanded + AND r.dated = vLanded ORDER BY friendship; -- Se eliminan aquellas que superan el volumen máximo diff --git a/db/routines/vn/functions/routeProposal_beta.sql b/db/routines/vn/functions/routeProposal_beta.sql index d6db4d361..f5c347a5b 100644 --- a/db/routines/vn/functions/routeProposal_beta.sql +++ b/db/routines/vn/functions/routeProposal_beta.sql @@ -26,7 +26,7 @@ BEGIN JOIN cache.zoneAgencyFriendship zf ON zf.agencyModeFk = r.agencyModeFk WHERE friendship >= vSignificativeFriendship AND zf.zoneFk = vZoneFk - AND r.created = vLanded + AND r.dated = vLanded ORDER BY friendship; -- Se eliminan aquellas que superan el volumen máximo diff --git a/db/routines/vn/procedures/expedition_getFromRoute.sql b/db/routines/vn/procedures/expedition_getFromRoute.sql index 8c2ab057d..932f614b6 100644 --- a/db/routines/vn/procedures/expedition_getFromRoute.sql +++ b/db/routines/vn/procedures/expedition_getFromRoute.sql @@ -41,6 +41,6 @@ BEGIN WHERE expeditionFk = e.id) LEFT JOIN expeditionState es2 ON es2.id = es.id WHERE t.routeFk = vRouteFk AND e.freightItemFk <> FALSE - ORDER BY r.created, t.priority DESC; + ORDER BY r.dated, t.priority DESC; END$$ DELIMITER ; diff --git a/db/routines/vn/procedures/routeMonitor_calculate.sql b/db/routines/vn/procedures/routeMonitor_calculate.sql index c9a7a9ccf..31667f211 100644 --- a/db/routines/vn/procedures/routeMonitor_calculate.sql +++ b/db/routines/vn/procedures/routeMonitor_calculate.sql @@ -27,7 +27,7 @@ BEGIN rm.ticketFree = 0, rm.ticketProduction = 0, rm.ticketPacked = 0, - rm.dated = r.created; + rm.dated = r.dated; UPDATE routesMonitor rm JOIN ( diff --git a/db/routines/vn/procedures/route_calcCommission.sql b/db/routines/vn/procedures/route_calcCommission.sql index 7db0b2682..dc44adb9b 100644 --- a/db/routines/vn/procedures/route_calcCommission.sql +++ b/db/routines/vn/procedures/route_calcCommission.sql @@ -14,7 +14,7 @@ BEGIN DECLARE vIsKmTruckRate BOOL; DECLARE vCountryFk INT; - SELECT r.created >= rc.cutoffDated INTO vIsUpdatable + SELECT r.dated >= rc.cutoffDated INTO vIsUpdatable FROM route r JOIN routeConfig rc WHERE r.id = vSelf; diff --git a/db/routines/vn/triggers/itemCost_beforeUpdate.sql b/db/routines/vn/triggers/itemCost_beforeUpdate.sql index bd5fde85a..8de288a92 100644 --- a/db/routines/vn/triggers/itemCost_beforeUpdate.sql +++ b/db/routines/vn/triggers/itemCost_beforeUpdate.sql @@ -16,7 +16,7 @@ BEGIN JOIN vn.route r ON r.id = t.routeFk WHERE r.isOk = FALSE AND ic.itemFk = NEW.itemFk - AND r.created >= util.VN_CURDATE() + AND r.dated >= util.VN_CURDATE() GROUP BY r.id; IF NEW.cm3Delivery = 0 AND NEW.warehouseFk = 60 THEN CALL mail_insert( diff --git a/db/routines/vn/triggers/route_beforeInsert.sql b/db/routines/vn/triggers/route_beforeInsert.sql index 788efe662..0afc9617e 100644 --- a/db/routines/vn/triggers/route_beforeInsert.sql +++ b/db/routines/vn/triggers/route_beforeInsert.sql @@ -14,7 +14,7 @@ BEGIN SELECT IFNULL(b.workCenterFK, r.defaultWorkCenterFk) FROM vn.routeConfig r LEFT JOIN vn.business b ON b.workerFk = vUserFk - AND NEW.created BETWEEN b.started AND IFNULL(b.ended, NEW.created)); + AND NEW.dated BETWEEN b.started AND IFNULL(b.ended, NEW.dated)); IF ISNULL(NEW.agencyModeFk) THEN SELECT r.agencyModeFk INTO vDefaultAgencyModeFk diff --git a/db/routines/vn/triggers/sale_afterInsert.sql b/db/routines/vn/triggers/sale_afterInsert.sql index f15b17722..1a9ef240a 100644 --- a/db/routines/vn/triggers/sale_afterInsert.sql +++ b/db/routines/vn/triggers/sale_afterInsert.sql @@ -23,7 +23,7 @@ BEGIN JOIN vn.route r ON r.id = t.routeFk WHERE r.isOk = FALSE AND s.id = NEW.id - AND r.created >= util.VN_CURDATE() + AND r.dated >= util.VN_CURDATE() GROUP BY r.id; END IF; END$$ diff --git a/db/routines/vn/triggers/sale_afterUpdate.sql b/db/routines/vn/triggers/sale_afterUpdate.sql index 82da55486..49e5383d0 100644 --- a/db/routines/vn/triggers/sale_afterUpdate.sql +++ b/db/routines/vn/triggers/sale_afterUpdate.sql @@ -54,7 +54,7 @@ BEGIN JOIN vn.route r ON r.id = t.routeFk WHERE r.isOk = FALSE AND s.id = NEW.id - AND r.created >= util.VN_CURDATE() + AND r.dated >= util.VN_CURDATE() GROUP BY r.id; END IF; diff --git a/db/routines/vn/triggers/sale_beforeDelete.sql b/db/routines/vn/triggers/sale_beforeDelete.sql index ad97f8b55..0f72d788b 100644 --- a/db/routines/vn/triggers/sale_beforeDelete.sql +++ b/db/routines/vn/triggers/sale_beforeDelete.sql @@ -11,7 +11,7 @@ BEGIN JOIN vn.route r ON r.id = t.routeFk WHERE r.isOk = FALSE AND s.id = OLD.id - AND r.created >= util.VN_CURDATE() + AND r.dated >= util.VN_CURDATE() GROUP BY r.id; END IF; END$$ diff --git a/db/routines/vn/triggers/ticket_beforeDelete.sql b/db/routines/vn/triggers/ticket_beforeDelete.sql index 953fa509a..2115175b5 100644 --- a/db/routines/vn/triggers/ticket_beforeDelete.sql +++ b/db/routines/vn/triggers/ticket_beforeDelete.sql @@ -8,7 +8,7 @@ BEGIN FROM vn.route r WHERE r.isOk = FALSE AND r.id = OLD.routeFk - AND r.created >= util.VN_CURDATE() + AND r.dated >= util.VN_CURDATE() GROUP BY r.id; DELETE FROM sale WHERE ticketFk = OLD.id; diff --git a/db/routines/vn/triggers/ticket_beforeUpdate.sql b/db/routines/vn/triggers/ticket_beforeUpdate.sql index 3208a93d0..f86f50485 100644 --- a/db/routines/vn/triggers/ticket_beforeUpdate.sql +++ b/db/routines/vn/triggers/ticket_beforeUpdate.sql @@ -22,7 +22,7 @@ BEGIN FROM `route` WHERE NOT isOk AND id IN (OLD.routeFk, NEW.routeFk) - AND created >= util.VN_CURDATE() + AND dated >= util.VN_CURDATE() GROUP BY id; END IF; @@ -45,7 +45,7 @@ BEGIN JOIN vn.route r ON r.id = t.routeFk WHERE r.isOk = FALSE AND t.id = NEW.id - AND r.created >= util.VN_CURDATE() + AND r.dated >= util.VN_CURDATE() GROUP BY r.id; SET NEW.shipped = DATE_FORMAT(NEW.shipped, '2000-%m-%d %T'); SET NEW.landed = DATE_FORMAT(NEW.landed, '2000-%m-%d %T'); diff --git a/db/routines/vn/views/expeditionPallet_Print.sql b/db/routines/vn/views/expeditionPallet_Print.sql index 7b933a0a1..0a445a4a6 100644 --- a/db/routines/vn/views/expeditionPallet_Print.sql +++ b/db/routines/vn/views/expeditionPallet_Print.sql @@ -9,8 +9,8 @@ AS SELECT `rs2`.`description` AS `truck`, `rs`.`id` <=> `rm`.`roadmapStopFk` AS `isMatch`, `t`.`warehouseFk` AS `warehouseFk`, IF( - `r`.`created` > `util`.`VN_CURDATE`() + INTERVAL 1 DAY, - ucase(dayname(`r`.`created`)), + `r`.`dated` > `util`.`VN_CURDATE`() + INTERVAL 1 DAY, + ucase(dayname(`r`.`dated`)), NULL ) AS `nombreDia` FROM ( diff --git a/db/routines/vn/views/expeditionRoute_Monitor.sql b/db/routines/vn/views/expeditionRoute_Monitor.sql index 9b46c8237..716702753 100644 --- a/db/routines/vn/views/expeditionRoute_Monitor.sql +++ b/db/routines/vn/views/expeditionRoute_Monitor.sql @@ -6,7 +6,7 @@ AS SELECT `r`.`id` AS `routeFk`, COUNT(DISTINCT `e`.`id`) AS `expeditions`, COUNT(DISTINCT `es`.`id`) AS `scanned`, max(`e`.`created`) AS `lastPacked`, - `r`.`created` AS `created` + `r`.`dated` AS `created` FROM ( ( ( @@ -23,5 +23,5 @@ FROM ( ) LEFT JOIN `vn`.`expeditionScan` `es` ON(`es`.`expeditionFk` = `e`.`id`) ) -WHERE `r`.`created` >= `util`.`yesterday`() +WHERE `r`.`dated` >= `util`.`yesterday`() GROUP BY `r`.`id` diff --git a/db/routines/vn2008/views/Rutas.sql b/db/routines/vn2008/views/Rutas.sql index 78b3bb471..c8ade24e9 100644 --- a/db/routines/vn2008/views/Rutas.sql +++ b/db/routines/vn2008/views/Rutas.sql @@ -3,7 +3,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` VIEW `vn2008`.`Rutas` AS SELECT `r`.`id` AS `Id_Ruta`, `r`.`workerFk` AS `Id_Trabajador`, - `r`.`created` AS `Fecha`, + `r`.`dated` AS `Fecha`, `r`.`vehicleFk` AS `Id_Vehiculo`, `r`.`agencyModeFk` AS `Id_Agencia`, `r`.`time` AS `Hora`, diff --git a/db/versions/11371-salmonRuscus/00-firstScript.sql b/db/versions/11371-salmonRuscus/00-firstScript.sql new file mode 100644 index 000000000..306ec451e --- /dev/null +++ b/db/versions/11371-salmonRuscus/00-firstScript.sql @@ -0,0 +1 @@ +ALTER TABLE vn.route ADD dated DATE; \ No newline at end of file diff --git a/db/versions/11371-salmonRuscus/01-firstScript.sql b/db/versions/11371-salmonRuscus/01-firstScript.sql new file mode 100644 index 000000000..14c8989d8 --- /dev/null +++ b/db/versions/11371-salmonRuscus/01-firstScript.sql @@ -0,0 +1 @@ +UPDATE vn.route SET dated = created; \ No newline at end of file diff --git a/db/versions/11371-salmonRuscus/02-firstScript.sql b/db/versions/11371-salmonRuscus/02-firstScript.sql new file mode 100644 index 000000000..42666b89c --- /dev/null +++ b/db/versions/11371-salmonRuscus/02-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.route +MODIFY COLUMN dated DATE NOT NULL; \ No newline at end of file diff --git a/db/versions/11371-salmonRuscus/03-firstScript.sql b/db/versions/11371-salmonRuscus/03-firstScript.sql new file mode 100644 index 000000000..b7776d31d --- /dev/null +++ b/db/versions/11371-salmonRuscus/03-firstScript.sql @@ -0,0 +1,2 @@ +ALTER TABLE vn.route +MODIFY COLUMN created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP; \ No newline at end of file diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 0a3892c86..52177b231 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -791,7 +791,7 @@ export default { }, createRouteView: { worker: 'vn-route-create vn-worker-autocomplete[ng-model="$ctrl.route.workerFk"]', - createdDatePicker: 'vn-route-create vn-date-picker[ng-model="$ctrl.route.created"]', + createdDatePicker: 'vn-route-create vn-date-picker[ng-model="$ctrl.route.dated"]', vehicleAuto: 'vn-route-create vn-autocomplete[ng-model="$ctrl.route.vehicleFk"]', agency: 'vn-route-create vn-autocomplete[ng-model="$ctrl.route.agencyModeFk"]', description: 'vn-route-create [ng-model="$ctrl.route.description"]', diff --git a/modules/route/back/methods/agency-term/filter.js b/modules/route/back/methods/agency-term/filter.js index 9d1268958..d52d93e95 100644 --- a/modules/route/back/methods/agency-term/filter.js +++ b/modules/route/back/methods/agency-term/filter.js @@ -66,9 +66,9 @@ module.exports = Self => { case 'agencyFk': return {'agencyFk': value}; case 'from': - return {'created': {gte: value}}; + return {'dated': {gte: value}}; case 'to': - return {'created': {lte: value}}; + return {'dated': {lte: value}}; } }); @@ -81,7 +81,7 @@ module.exports = Self => { `SELECT * FROM ( SELECT r.id routeFk, - r.created, + r.dated, r.agencyModeFk, am.name agencyModeName, am.agencyFk, @@ -103,7 +103,7 @@ module.exports = Self => { LEFT JOIN vn.ticket t ON t.routeFk = r.id LEFT JOIN vn.supplierAgencyTerm sat ON sat.agencyFk = a.id LEFT JOIN vn.supplier s ON s.id = sat.supplierFk - WHERE r.created > DATE_ADD(?, INTERVAL -2 MONTH) AND sat.supplierFk IS NOT NULL + WHERE r.dated > DATE_ADD(?, INTERVAL -2 MONTH) AND sat.supplierFk IS NOT NULL GROUP BY r.id ) a` , [date]); diff --git a/modules/route/back/methods/route/clone.js b/modules/route/back/methods/route/clone.js index d56118e08..c5c4d846a 100644 --- a/modules/route/back/methods/route/clone.js +++ b/modules/route/back/methods/route/clone.js @@ -10,10 +10,10 @@ module.exports = Self => { description: 'The routes ids to clone' }, { - arg: 'created', + arg: 'dated', type: 'date', required: true, - description: 'The created date for all routes' + description: 'The date for all routes' } ], returns: { @@ -26,7 +26,7 @@ module.exports = Self => { } }); - Self.clone = async(ids, created) => { + Self.clone = async(ids, dated) => { const tx = await Self.beginTransaction({}); try { const options = {transaction: tx}; @@ -39,7 +39,7 @@ module.exports = Self => { throw new Error(`The amount of routes found don't match`); const routes = originalRoutes.map(route => { - route.created = created; + route.dated = dated; return route; }); diff --git a/modules/route/back/methods/route/filter.js b/modules/route/back/methods/route/filter.js index 925927cc8..70bf7ba67 100644 --- a/modules/route/back/methods/route/filter.js +++ b/modules/route/back/methods/route/filter.js @@ -93,9 +93,9 @@ module.exports = Self => { case 'search': return {'id': value}; case 'from': - return {'created': {gte: value}}; + return {'dated': {gte: value}}; case 'to': - return {'created': {lte: value}}; + return {'dated': {lte: value}}; case 'description': return {'description': {like: `%${value}%`}}; case 'isOk': @@ -119,7 +119,7 @@ module.exports = Self => { SELECT r.id, r.workerFk, - r.created, + r.dated, r.vehicleFk, r.agencyModeFk, r.time, diff --git a/modules/route/back/methods/route/getByWorker.js b/modules/route/back/methods/route/getByWorker.js index 5d1881c20..92086bba0 100644 --- a/modules/route/back/methods/route/getByWorker.js +++ b/modules/route/back/methods/route/getByWorker.js @@ -46,14 +46,14 @@ module.exports = Self => { and: [ { or: [ - {'created': currentDate}, - {'created': nextDay} + {'dated': currentDate}, + {'dated': nextDay} ] } ] }, order: [ - 'created ASC', + 'dated ASC', 'time ASC', 'agencyName ASC' ] diff --git a/modules/route/back/methods/route/getSuggestedTickets.js b/modules/route/back/methods/route/getSuggestedTickets.js index e1b90d359..daaff2bc8 100644 --- a/modules/route/back/methods/route/getSuggestedTickets.js +++ b/modules/route/back/methods/route/getSuggestedTickets.js @@ -43,10 +43,10 @@ module.exports = Self => { for (let zoneAgencyMode of zoneAgencyModes) zoneIds.push(zoneAgencyMode.zoneFk); - const minDate = new Date(route.created); + const minDate = new Date(route.dated); minDate.setHours(0, 0, 0, 0); - const maxDate = new Date(route.created); + const maxDate = new Date(route.dated); maxDate.setHours(23, 59, 59, 59); let tickets = await Self.app.models.Ticket.find({ diff --git a/modules/route/back/methods/route/insertTicket.js b/modules/route/back/methods/route/insertTicket.js index 4ac8bad1a..41c910116 100644 --- a/modules/route/back/methods/route/insertTicket.js +++ b/modules/route/back/methods/route/insertTicket.js @@ -42,10 +42,10 @@ module.exports = Self => { try { const route = await models.Route.findById(routeId, null, myOptions); - const minDate = new Date(route.created); + const minDate = new Date(route.dated); minDate.setHours(0, 0, 0, 0); - const maxDate = new Date(route.created); + const maxDate = new Date(route.dated); maxDate.setHours(23, 59, 59, 59); const ticket = await models.Ticket.findOne({ where: { diff --git a/modules/route/back/models/route.json b/modules/route/back/models/route.json index f8be9023c..8f4eab761 100644 --- a/modules/route/back/models/route.json +++ b/modules/route/back/models/route.json @@ -15,7 +15,7 @@ "id": true, "description": "Identifier" }, - "created": { + "dated": { "type": "date" }, "time": { diff --git a/modules/route/front/descriptor/index.html b/modules/route/front/descriptor/index.html index 4e7e99f1a..0079168a6 100644 --- a/modules/route/front/descriptor/index.html +++ b/modules/route/front/descriptor/index.html @@ -32,7 +32,7 @@
+ value="{{$ctrl.route.dated | date: 'dd/MM/yyyy'}}"> + value="{{$ctrl.summary.route.dated | date: 'dd/MM/yyyy'}}"> diff --git a/print/templates/reports/driver-route/driver-route.html b/print/templates/reports/driver-route/driver-route.html index 109afd2f5..e3a206656 100644 --- a/print/templates/reports/driver-route/driver-route.html +++ b/print/templates/reports/driver-route/driver-route.html @@ -16,7 +16,7 @@
{{$t('date')}}{{formatDate(route.created, '%d-%m-%Y')}}{{formatDate(route.dated, '%d-%m-%Y')}} {{$t('vehicle')}} {{route.vehicleTradeMark}} {{route.vehicleModel}}
{{$t('boxNum')}} - {{`${buy.labelNum} / ${buy.maxLabelNum}`}} + {{getTotal(buy)}}