From 8fad522a3e78da01b1afd659c584662d54c2ed0e Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 19 Aug 2024 12:45:06 +0200 Subject: [PATCH 1/8] feat(salix): refs #7677 #7677 return more postcode fields --- modules/client/back/models/address.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/client/back/models/address.js b/modules/client/back/models/address.js index 4a93b5d5c..7011008a4 100644 --- a/modules/client/back/models/address.js +++ b/modules/client/back/models/address.js @@ -43,8 +43,14 @@ module.exports = Self => { include: [{ relation: 'province', scope: { - fields: ['id', 'name'] - } + fields: ['id', 'name', 'countryFk'], + include: [ + { + relation: 'country', + scope: {fields: ['id', 'name']}, + }, + ], + }, }, { relation: 'agencyMode', scope: { From b5940114331cf5fe3aa07ea8b0624cd4c31a29d1 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 20 Aug 2024 07:01:13 +0200 Subject: [PATCH 2/8] feat(salix): refs #7677 #7677 return more postcode fields --- back/methods/postcode/filter.js | 2 ++ db/dump/fixtures.after.sql | 4 ++-- db/dump/fixtures.before.sql | 1 + db/routines/vn/procedures/client_userDisable.sql | 6 +++--- loopback/locale/es.json | 3 ++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/back/methods/postcode/filter.js b/back/methods/postcode/filter.js index f350b1ea9..8f47b4a93 100644 --- a/back/methods/postcode/filter.js +++ b/back/methods/postcode/filter.js @@ -47,6 +47,8 @@ module.exports = Self => { let stmt; stmt = new ParameterizedSQL(` SELECT + CONCAT_WS('_', pc.code, pc.townFk, t.provinceFk, + p.countryFk) id, pc.townFk, t.provinceFk, p.countryFk, diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 59730d592..5489d2dd2 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -255,7 +255,7 @@ INSERT INTO vn.operator (workerFk, numberOfWagons, trainFk, itemPackingTypeFk, w (9, 1, 1, 'V', 1); */ -- XXX: web -/* #5483 + INSERT INTO `hedera`.`config` (`cookieLife`, `defaultForm`) VALUES (15,'cms/home'); @@ -274,7 +274,7 @@ UPDATE `vn`.`agencyMode` SET `description` = `name`; INSERT INTO `hedera`.`tpvConfig` (currency, terminal, transactionType, maxAmount, employeeFk, `url`, testMode, testUrl, testKey, merchantUrl) VALUES (978, 1, 0, 2000, 9, 'https://sis.redsys.es/sis/realizarPago', 0, 'https://sis-t.redsys.es:25443/sis/realizarPago', 'sq7HjrUOBfKmC576ILgskD5srU870gJ7', NULL); -*/ + INSERT INTO hedera.tpvMerchantEnable (merchantFk, companyFk) VALUES (1, 442); diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 6563292dd..ca2468d5e 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -364,6 +364,7 @@ INSERT INTO `vn`.`postCode`(`code`, `townFk`, `geoFk`) ('46460', 2, 6), ('46680', 3, 6), ('46600', 4, 7), + ('46600',1, 6), ('EC170150', 5, 8); INSERT INTO `vn`.`clientType`(`code`, `type`) diff --git a/db/routines/vn/procedures/client_userDisable.sql b/db/routines/vn/procedures/client_userDisable.sql index 779ffd688..c0977bc62 100644 --- a/db/routines/vn/procedures/client_userDisable.sql +++ b/db/routines/vn/procedures/client_userDisable.sql @@ -20,15 +20,15 @@ BEGIN WHERE c.typeFk = 'normal' AND a.id IS NULL AND u.active - AND c.created < util.VN_CURDATE() - INTERVAL vMonths MONTH + AND c.created < util.VN_CURDATE() - INTERVAL vMonths MONTH AND NOT u.role = (SELECT id FROM `role` WHERE name = 'supplier') AND u.id NOT IN ( SELECT DISTINCT c.id FROM client c LEFT JOIN ticket t ON t.clientFk = c.id WHERE c.salesPersonFk IS NOT NULL - OR t.created > util.VN_CURDATE() - INTERVAL vMonths MONTH - OR shipped > util.VN_CURDATE() - INTERVAL vMonths MONTH + OR t.created > util.VN_CURDATE() - INTERVAL vMonths MONTH + OR shipped > util.VN_CURDATE() - INTERVAL vMonths MONTH ); END$$ DELIMITER ; diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 377691ae6..5d9963833 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -370,5 +370,6 @@ "CONSTRAINT `supplierAccountTooShort` failed for `vn`.`supplier`": "La cuenta debe tener exactamente 10 dígitos", "The sale not exists in the item shelving": "La venta no existe en la estantería del artículo", "The entry not have stickers": "La entrada no tiene etiquetas", - "Too many records": "Demasiados registros" + "Too many records": "Demasiados registros", + "CONSTRAINT `zone.price` failed for `vn`.`zone`": "CONSTRAINT `zone.price` failed for `vn`.`zone`" } \ No newline at end of file From 7540526b9b0e1cc57247dd9e49ca4063a5f74894 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 16 Sep 2024 12:26:29 +0200 Subject: [PATCH 3/8] feat: refs #7964 entry_beforeUpdate --- db/routines/vn/triggers/entry_beforeUpdate.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/triggers/entry_beforeUpdate.sql b/db/routines/vn/triggers/entry_beforeUpdate.sql index ee2178024..e57ba08a9 100644 --- a/db/routines/vn/triggers/entry_beforeUpdate.sql +++ b/db/routines/vn/triggers/entry_beforeUpdate.sql @@ -71,7 +71,10 @@ BEGIN SET NEW.currencyFk = entry_getCurrency(NEW.currencyFk, NEW.supplierFk); END IF; - IF NOT (NEW.travelFk <=> OLD.travelFk) OR NOT (NEW.currencyFk <=> OLD.currencyFk) THEN + IF NOT (NEW.travelFk <=> OLD.travelFk) + OR NOT (NEW.currencyFk <=> OLD.currencyFk) + OR (NEW.supplierFk <=> OLD.supplierFk) THEN + SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk, NEW.supplierFk); END IF; END$$ From 51da7ae063385148090226a8e5ffbbd30ee8316c Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 16 Sep 2024 13:33:53 +0200 Subject: [PATCH 4/8] feat: refs #7893 Created waste_addSalesLauncher --- db/routines/bs/procedures/waste_addSales.sql | 16 ++++++++++++---- .../bs/procedures/waste_addSalesLauncher.sql | 6 ++++++ .../11237-goldenBamboo/00-firstScript.sql | 3 +++ 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 db/routines/bs/procedures/waste_addSalesLauncher.sql create mode 100644 db/versions/11237-goldenBamboo/00-firstScript.sql diff --git a/db/routines/bs/procedures/waste_addSales.sql b/db/routines/bs/procedures/waste_addSales.sql index f23c1b360..128c4f2db 100644 --- a/db/routines/bs/procedures/waste_addSales.sql +++ b/db/routines/bs/procedures/waste_addSales.sql @@ -1,8 +1,16 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`() +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`( + vDateFrom DATE, + vDateTo DATE +) BEGIN - DECLARE vDateFrom DATE DEFAULT util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY; - DECLARE vDateTo DATE DEFAULT vDateFrom + INTERVAL 6 DAY; + IF vDateFrom IS NULL THEN + SET vDateFrom = util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY; + END IF; + + IF vDateTo IS NULL THEN + SET vDateTo = vDateFrom + INTERVAL 6 DAY; + END IF; CALL cache.last_buy_refresh(FALSE); @@ -56,6 +64,6 @@ BEGIN JOIN vn.buy b ON b.id = lb.buy_id WHERE t.shipped BETWEEN vDateFrom AND vDateTo AND w.isManaged - GROUP BY i.id; + GROUP BY YEAR(t.shipped), WEEK(t.shipped, 4), i.id; END$$ DELIMITER ; diff --git a/db/routines/bs/procedures/waste_addSalesLauncher.sql b/db/routines/bs/procedures/waste_addSalesLauncher.sql new file mode 100644 index 000000000..5eaea9be4 --- /dev/null +++ b/db/routines/bs/procedures/waste_addSalesLauncher.sql @@ -0,0 +1,6 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSalesLauncher`() +BEGIN + CALL waste_addSales(NULL, NULL); +END$$ +DELIMITER ; diff --git a/db/versions/11237-goldenBamboo/00-firstScript.sql b/db/versions/11237-goldenBamboo/00-firstScript.sql new file mode 100644 index 000000000..3e387eba8 --- /dev/null +++ b/db/versions/11237-goldenBamboo/00-firstScript.sql @@ -0,0 +1,3 @@ +UPDATE bs.nightTask + SET `procedure` = 'waste_addSalesLauncher' + WHERE `procedure` = 'waste_addSales'; From 10fcbffd376d81e55b4622f8543fc0334f129f58 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 16 Sep 2024 13:37:35 +0200 Subject: [PATCH 5/8] feat: refs #7964 entry_beforeUpdate not --- db/routines/vn/triggers/entry_beforeUpdate.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/triggers/entry_beforeUpdate.sql b/db/routines/vn/triggers/entry_beforeUpdate.sql index e57ba08a9..8e5a326a0 100644 --- a/db/routines/vn/triggers/entry_beforeUpdate.sql +++ b/db/routines/vn/triggers/entry_beforeUpdate.sql @@ -73,7 +73,7 @@ BEGIN IF NOT (NEW.travelFk <=> OLD.travelFk) OR NOT (NEW.currencyFk <=> OLD.currencyFk) - OR (NEW.supplierFk <=> OLD.supplierFk) THEN + OR NOT (NEW.supplierFk <=> OLD.supplierFk) THEN SET NEW.commission = entry_getCommission(NEW.travelFk, NEW.currencyFk, NEW.supplierFk); END IF; From 2e32dfddc413156f88a97738f7e91dbf63862d46 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 17 Sep 2024 11:43:28 +0200 Subject: [PATCH 6/8] perf(salix): refs #7677 #7677 restore files --- db/dump/fixtures.after.sql | 4 ++-- db/routines/vn/procedures/client_userDisable.sql | 6 +++--- loopback/locale/es.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/db/dump/fixtures.after.sql b/db/dump/fixtures.after.sql index 5489d2dd2..59730d592 100644 --- a/db/dump/fixtures.after.sql +++ b/db/dump/fixtures.after.sql @@ -255,7 +255,7 @@ INSERT INTO vn.operator (workerFk, numberOfWagons, trainFk, itemPackingTypeFk, w (9, 1, 1, 'V', 1); */ -- XXX: web - +/* #5483 INSERT INTO `hedera`.`config` (`cookieLife`, `defaultForm`) VALUES (15,'cms/home'); @@ -274,7 +274,7 @@ UPDATE `vn`.`agencyMode` SET `description` = `name`; INSERT INTO `hedera`.`tpvConfig` (currency, terminal, transactionType, maxAmount, employeeFk, `url`, testMode, testUrl, testKey, merchantUrl) VALUES (978, 1, 0, 2000, 9, 'https://sis.redsys.es/sis/realizarPago', 0, 'https://sis-t.redsys.es:25443/sis/realizarPago', 'sq7HjrUOBfKmC576ILgskD5srU870gJ7', NULL); - +*/ INSERT INTO hedera.tpvMerchantEnable (merchantFk, companyFk) VALUES (1, 442); diff --git a/db/routines/vn/procedures/client_userDisable.sql b/db/routines/vn/procedures/client_userDisable.sql index e769114fb..1a7c9846b 100644 --- a/db/routines/vn/procedures/client_userDisable.sql +++ b/db/routines/vn/procedures/client_userDisable.sql @@ -20,15 +20,15 @@ BEGIN WHERE c.typeFk = 'normal' AND a.id IS NULL AND u.active - AND c.created < util.VN_CURDATE() - INTERVAL vMonths MONTH + AND c.created < util.VN_CURDATE() - INTERVAL vMonths MONTH AND NOT u.role = (SELECT id FROM `role` WHERE name = 'supplier') AND u.id NOT IN ( SELECT DISTINCT c.id FROM client c LEFT JOIN ticket t ON t.clientFk = c.id WHERE c.salesPersonFk IS NOT NULL - OR t.created > util.VN_CURDATE() - INTERVAL vMonths MONTH - OR shipped > util.VN_CURDATE() - INTERVAL vMonths MONTH + OR t.created > util.VN_CURDATE() - INTERVAL vMonths MONTH + OR shipped > util.VN_CURDATE() - INTERVAL vMonths MONTH ); END$$ DELIMITER ; diff --git a/loopback/locale/es.json b/loopback/locale/es.json index eb48b0646..1093fe326 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -378,4 +378,4 @@ "There is already a tray with the same height": "Ya existe una bandeja con la misma altura", "The height must be greater than 50cm": "La altura debe ser superior a 50cm", "The maximum height of the wagon is 200cm": "La altura máxima es 200cm" -} +} \ No newline at end of file From f962b2e38b0e365f6dba24b396d684ae68f36899 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 17 Sep 2024 11:44:34 +0200 Subject: [PATCH 7/8] perf(salix): refs #7677 #7677 restore files because unnecessary change --- back/methods/postcode/filter.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/back/methods/postcode/filter.js b/back/methods/postcode/filter.js index 8f47b4a93..f350b1ea9 100644 --- a/back/methods/postcode/filter.js +++ b/back/methods/postcode/filter.js @@ -47,8 +47,6 @@ module.exports = Self => { let stmt; stmt = new ParameterizedSQL(` SELECT - CONCAT_WS('_', pc.code, pc.townFk, t.provinceFk, - p.countryFk) id, pc.townFk, t.provinceFk, p.countryFk, From fa5ace677cec91a359bfb875370139505efdea10 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 17 Sep 2024 12:35:08 +0200 Subject: [PATCH 8/8] refactor: refs #7893 Requested changes --- db/routines/bs/procedures/waste_addSales.sql | 6 ++++++ db/versions/11240-aquaCyca/00-firstScript.sql | 1 + 2 files changed, 7 insertions(+) create mode 100644 db/versions/11240-aquaCyca/00-firstScript.sql diff --git a/db/routines/bs/procedures/waste_addSales.sql b/db/routines/bs/procedures/waste_addSales.sql index 128c4f2db..ea4adbc27 100644 --- a/db/routines/bs/procedures/waste_addSales.sql +++ b/db/routines/bs/procedures/waste_addSales.sql @@ -4,6 +4,12 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `bs`.`waste_addSales`( vDateTo DATE ) BEGIN +/** + * Recalcula las mermas de un periodo. + * + * @param vDateFrom Fecha desde + * @param vDateTo Fecha hasta + */ IF vDateFrom IS NULL THEN SET vDateFrom = util.VN_CURDATE() - INTERVAL WEEKDAY(util.VN_CURDATE()) DAY; END IF; diff --git a/db/versions/11240-aquaCyca/00-firstScript.sql b/db/versions/11240-aquaCyca/00-firstScript.sql new file mode 100644 index 000000000..97ad39ef1 --- /dev/null +++ b/db/versions/11240-aquaCyca/00-firstScript.sql @@ -0,0 +1 @@ +GRANT EXECUTE ON PROCEDURE bs.waste_addSales TO buyerBoss;