From 6031b1fe3f42f7193bd223313e4c0dbc96feb428 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 28 Oct 2024 12:17:56 +0100 Subject: [PATCH 01/13] feat: refs #8169 create table itemTextureTag --- .../00-firstScript.sql | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 db/versions/11324-salmonCataractarum/00-firstScript.sql diff --git a/db/versions/11324-salmonCataractarum/00-firstScript.sql b/db/versions/11324-salmonCataractarum/00-firstScript.sql new file mode 100644 index 000000000..3a528382a --- /dev/null +++ b/db/versions/11324-salmonCataractarum/00-firstScript.sql @@ -0,0 +1,71 @@ +CREATE TABLE IF NOT EXISTS `vn`.`itemTextureTag` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `name` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `name_UNIQUE` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT + CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci; + +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y encerado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y esponjoso'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y foam'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y látex'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Arenosa'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Aterciopelado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Engomado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Flocado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Foam'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Gasa'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Goma'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Látex'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Latón'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Mate'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Metálico'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Natural y engomado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plastificado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plastificado y engomado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plastificado y rugoso'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Pluma'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plástico'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Plástico engomado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Poliéster'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Poliéster texturizado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Rugoso'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Rígido'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Seminatural'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Silicona'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Suave'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela con brillo'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela con texturas'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela dura'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela engomada'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela escarchada'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela flocada'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela flocada engomada'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela foam'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela micro peach'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela plastificada'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela plástico engomado'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela poliéster'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela PVC'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela ratan'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela rigida'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela rugosa'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela rústica'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela sintética'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y cristal'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y foam'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y goma'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y látex'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y madera'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y plástico'); +INSERT IGNORE INTO `vn`.`itemTextureTag` (`name`) VALUES ('Tela y seco'); + +UPDATE vn.tag + SET isFree=0, + sourceTable='itemTextureTag' + WHERE name= 'Textura'; + +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemFarmingTag TO logisticAssist; \ No newline at end of file From 6927f4b28df4486277c11be1fc0e3760495b26a5 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 8 Nov 2024 11:51:00 +0100 Subject: [PATCH 02/13] feat: refs #6818 saysimple integration --- back/model-config.json | 3 +++ back/models/country.json | 7 ++++- back/models/say-simple-country.json | 26 +++++++++++++++++++ db/dump/fixtures.before.sql | 3 +++ .../11330-greenMoss/00-firstScript.sql | 6 +++++ modules/client/back/methods/client/summary.js | 5 +++- 6 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 back/models/say-simple-country.json create mode 100644 db/versions/11330-greenMoss/00-firstScript.sql diff --git a/back/model-config.json b/back/model-config.json index 5368769fd..efb148ee8 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -139,6 +139,9 @@ "StarredModule": { "dataSource": "vn" }, + "SaySimpleCountry": { + "dataSource": "vn" + }, "TempContainer": { "dataSource": "tempStorage" }, diff --git a/back/models/country.json b/back/models/country.json index 80d456702..ee72ae49d 100644 --- a/back/models/country.json +++ b/back/models/country.json @@ -44,6 +44,11 @@ "type": "belongsTo", "model": "Continent", "foreignKey": "continentFk" + }, + "saySimpleCountry": { + "type": "hasOne", + "model": "SaySimpleCountry", + "foreignKey": "countryFk" } }, "acls": [ @@ -54,4 +59,4 @@ "permission": "ALLOW" } ] -} +} \ No newline at end of file diff --git a/back/models/say-simple-country.json b/back/models/say-simple-country.json new file mode 100644 index 000000000..39acd5f0b --- /dev/null +++ b/back/models/say-simple-country.json @@ -0,0 +1,26 @@ +{ + "name": "SaySimpleCountry", + "base": "VnModel", + "options": { + "mysql": { + "table": "saySimpleCountry" + } + }, + "properties": { + "countryFk": { + "type": "number", + "id": true + }, + "channel": { + "type": "number" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index f25a4aab4..7bb0ace84 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4008,3 +4008,6 @@ UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA"; UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS"; +INSERT INTO vn.saySimpleCountry (countryFk, channel) + VALUES (19, 1169), + (8, 1183); \ No newline at end of file diff --git a/db/versions/11330-greenMoss/00-firstScript.sql b/db/versions/11330-greenMoss/00-firstScript.sql new file mode 100644 index 000000000..e0ef77e2d --- /dev/null +++ b/db/versions/11330-greenMoss/00-firstScript.sql @@ -0,0 +1,6 @@ +CREATE TABLE IF NOT EXISTS vn.saySimpleCountry( + countryFk MEDIUMINT(8) UNSIGNED, + channel INT(4) COMMENT 'channel de whatsapp de saySimple', + PRIMARY KEY (countryFk), + CONSTRAINT `saySimpleCountry_FK` FOREIGN KEY (`countryFk`) REFERENCES vn.country (`id`) ON UPDATE CASCADE +); \ 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 8162096f0..9242fbd44 100644 --- a/modules/client/back/methods/client/summary.js +++ b/modules/client/back/methods/client/summary.js @@ -54,7 +54,10 @@ module.exports = Self => { { relation: 'country', scope: { - fields: ['name'] + fields: ['id', 'name'], + include: { + relation: 'saySimpleCountry', + } } }, { From 9b28cf9130dff4346f627d1888a1f7de7cb4ddcd Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 8 Nov 2024 12:51:09 +0100 Subject: [PATCH 03/13] feat: refs #6818 add records --- db/dump/fixtures.before.sql | 2 +- db/versions/11330-greenMoss/00-firstScript.sql | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 7bb0ace84..ce4e9ddfc 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4008,6 +4008,6 @@ UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA"; UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS"; -INSERT INTO vn.saySimpleCountry (countryFk, channel) +INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) VALUES (19, 1169), (8, 1183); \ No newline at end of file diff --git a/db/versions/11330-greenMoss/00-firstScript.sql b/db/versions/11330-greenMoss/00-firstScript.sql index e0ef77e2d..762e456b1 100644 --- a/db/versions/11330-greenMoss/00-firstScript.sql +++ b/db/versions/11330-greenMoss/00-firstScript.sql @@ -3,4 +3,8 @@ CREATE TABLE IF NOT EXISTS vn.saySimpleCountry( channel INT(4) COMMENT 'channel de whatsapp de saySimple', PRIMARY KEY (countryFk), CONSTRAINT `saySimpleCountry_FK` FOREIGN KEY (`countryFk`) REFERENCES vn.country (`id`) ON UPDATE CASCADE -); \ No newline at end of file +); + +INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) + VALUES (19, 1169), + (8, 1183); \ No newline at end of file From 6ef1f950d17897d377cc9fb342835f4a3e745543 Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 8 Nov 2024 17:47:10 +0100 Subject: [PATCH 04/13] feat: refs #6818 add config table --- back/model-config.json | 3 +++ back/models/say-simple-config.json | 26 +++++++++++++++++++ back/models/say-simple-country.json | 2 +- db/dump/fixtures.before.sql | 6 ++++- .../11330-greenMoss/00-firstScript.sql | 8 +++++- 5 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 back/models/say-simple-config.json diff --git a/back/model-config.json b/back/model-config.json index efb148ee8..364ffabdf 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -142,6 +142,9 @@ "SaySimpleCountry": { "dataSource": "vn" }, + "SaySimpleConfig": { + "dataSource": "vn" + }, "TempContainer": { "dataSource": "tempStorage" }, diff --git a/back/models/say-simple-config.json b/back/models/say-simple-config.json new file mode 100644 index 000000000..edc4caa43 --- /dev/null +++ b/back/models/say-simple-config.json @@ -0,0 +1,26 @@ +{ + "name": "SaySimpleConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "saySimpleConfig" + } + }, + "properties": { + "id": { + "type": "number", + "id": true + }, + "url": { + "type": "string" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/back/models/say-simple-country.json b/back/models/say-simple-country.json index 39acd5f0b..adddddc02 100644 --- a/back/models/say-simple-country.json +++ b/back/models/say-simple-country.json @@ -19,7 +19,7 @@ { "accessType": "READ", "principalType": "ROLE", - "principalId": "$everyone", + "principalId": "$authenticated", "permission": "ALLOW" } ] diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index ce4e9ddfc..cd2fb8b6b 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4010,4 +4010,8 @@ UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS"; INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) VALUES (19, 1169), - (8, 1183); \ No newline at end of file + (8, 1183), + (NULL, 1320); + +INSERT IGNORE INTO vn.saySimpleConfig (url) + VALUES ('saysimle-url-mock'); \ No newline at end of file diff --git a/db/versions/11330-greenMoss/00-firstScript.sql b/db/versions/11330-greenMoss/00-firstScript.sql index 762e456b1..127c8e40e 100644 --- a/db/versions/11330-greenMoss/00-firstScript.sql +++ b/db/versions/11330-greenMoss/00-firstScript.sql @@ -5,6 +5,12 @@ CREATE TABLE IF NOT EXISTS vn.saySimpleCountry( CONSTRAINT `saySimpleCountry_FK` FOREIGN KEY (`countryFk`) REFERENCES vn.country (`id`) ON UPDATE CASCADE ); +CREATE TABLE IF NOT EXISTS vn.saySimpleConfig( + id INT AUTO_INCREMENT PRIMARY KEY, + url VARCHAR(255) NOT NULL +); + INSERT IGNORE INTO vn.saySimpleCountry (countryFk, channel) VALUES (19, 1169), - (8, 1183); \ No newline at end of file + (8, 1183), + (NULL, 1320); \ No newline at end of file From 94ed23ca07fbe1cf8d2f3c5769ed309bd8d4303f Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 11 Nov 2024 07:51:26 +0100 Subject: [PATCH 05/13] feat: refs #8169 modifica role --- db/versions/11324-salmonCataractarum/00-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11324-salmonCataractarum/00-firstScript.sql b/db/versions/11324-salmonCataractarum/00-firstScript.sql index 3a528382a..5c17ed549 100644 --- a/db/versions/11324-salmonCataractarum/00-firstScript.sql +++ b/db/versions/11324-salmonCataractarum/00-firstScript.sql @@ -68,4 +68,4 @@ UPDATE vn.tag sourceTable='itemTextureTag' WHERE name= 'Textura'; -GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemFarmingTag TO logisticAssist; \ No newline at end of file +GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE vn.itemTextureTag TO logisticAssist; From d52f537f0cb3d993eba447dbdbe42ffb21c70c12 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 12 Nov 2024 13:04:23 +0100 Subject: [PATCH 06/13] refactor: refs #8153 Optimized order_getTax --- .../hedera/procedures/order_getTax.sql | 60 ++++++++++--------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/db/routines/hedera/procedures/order_getTax.sql b/db/routines/hedera/procedures/order_getTax.sql index d24ffe7ef..8fa965343 100644 --- a/db/routines/hedera/procedures/order_getTax.sql +++ b/db/routines/hedera/procedures/order_getTax.sql @@ -15,41 +15,47 @@ BEGIN ENGINE = MEMORY SELECT DISTINCT o.address_id addressFk, o.company_id companyFk FROM tmp.`order` tmpOrder - JOIN hedera.`order` o ON o.id = tmpOrder.orderFk; + JOIN `order` o ON o.id = tmpOrder.orderFk; - CALL vn.addressTaxArea; + CALL vn.addressTaxArea(); -- Calcula el IVA y el recargo desglosado. - - DROP TEMPORARY TABLE IF EXISTS tmp.orderTax; - CREATE TEMPORARY TABLE tmp.orderTax - (INDEX (orderFk)) + CREATE OR REPLACE TEMPORARY TABLE tmp.orderTax + (PRIMARY KEY (orderFk, code, rate)) ENGINE = MEMORY - SELECT o.id orderFk, + WITH orders AS ( + SELECT tor.orderFk, + oro.amount * oro.price total, + s.countryFk, + ata.areaFk, + itc.taxClassFk + FROM orderRow oro + JOIN tmp.order tor ON tor.orderFk = oro.orderFk + JOIN `order` o ON o.id = tor.orderFk + JOIN vn.item i ON i.id = oro.itemFk + JOIN vn.`client` c ON c.id = o.customer_id + JOIN vn.supplier s ON s.id = o.company_id + JOIN tmp.addressTaxArea ata ON ata.addressFk = o.address_id + AND ata.companyFk = o.company_id + JOIN vn.itemTaxCountry itc ON itc.itemFk = i.id + AND itc.countryFk = s.countryFk + HAVING total + ) + SELECT o.orderFk, tc.code, - SUM(m.amount * m.price) taxableBase, + SUM(o.total) taxableBase, pgc.rate - FROM tmp.`order` tmpOrder - JOIN `order` o ON o.id = tmpOrder.orderFk - JOIN orderRow m ON m.orderFk = o.id - JOIN vn.item i ON i.id = m.itemFk - JOIN vn.`client` c ON c.id = o.customer_id - JOIN vn.supplier s ON s.id = o.company_id - JOIN tmp.addressTaxArea ata - ON ata.addressFk = o.address_id AND ata.companyFk = o.company_id - JOIN vn.itemTaxCountry itc - ON itc.itemFk = i.id AND itc.countryFk = s.countryFk - JOIN vn.bookingPlanner bp - ON bp.countryFk = s.countryFk - AND bp.taxAreaFk = ata.areaFk - AND bp.taxClassFk = itc.taxClassFk - JOIN vn.pgc ON pgc.`code` = bp.pgcFk + FROM orders o + JOIN vn.bookingPlanner bp ON bp.countryFk = o.countryFk + AND bp.taxAreaFk = o.areaFk + AND bp.taxClassFk = o.taxClassFk + JOIN vn.pgc ON pgc.code = bp.pgcFk JOIN vn.taxClass tc ON tc.id = bp.taxClassFk - GROUP BY tmpOrder.orderFk, pgc.`code`, pgc.rate - HAVING taxableBase != 0; + GROUP BY o.orderFk, pgc.code, pgc.rate + HAVING taxableBase + ORDER BY bp.priority; - DROP TEMPORARY TABLE IF EXISTS tmp.orderAmount; - CREATE TEMPORARY TABLE tmp.orderAmount + CREATE OR REPLACE TEMPORARY TABLE tmp.orderAmount (INDEX (orderFk)) ENGINE = MEMORY SELECT orderFk, taxableBase, `code`, From 127c6fced0cd744794f2eda0e65d3667dfcf8bab Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 12 Nov 2024 13:25:51 +0100 Subject: [PATCH 07/13] refactor: refs #8153 Optimized order_getTax --- db/routines/hedera/procedures/order_getTax.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/db/routines/hedera/procedures/order_getTax.sql b/db/routines/hedera/procedures/order_getTax.sql index 8fa965343..90c47bfc7 100644 --- a/db/routines/hedera/procedures/order_getTax.sql +++ b/db/routines/hedera/procedures/order_getTax.sql @@ -9,6 +9,7 @@ BEGIN * @param vOrder El identificador del pedido * @return tmp.orderTax Bases imponibles, IVA y recargo de equivalencia */ + -- No poner create or replace, ya que da problemas DROP TEMPORARY TABLE IF EXISTS tmp.addressCompany; CREATE TEMPORARY TABLE tmp.addressCompany (INDEX (addressFk, companyFk)) @@ -55,7 +56,9 @@ BEGIN HAVING taxableBase ORDER BY bp.priority; - CREATE OR REPLACE TEMPORARY TABLE tmp.orderAmount + -- No poner create or replace, ya que da problemas + DROP TEMPORARY TABLE IF EXISTS tmp.orderAmount; + CREATE TEMPORARY TABLE tmp.orderAmount (INDEX (orderFk)) ENGINE = MEMORY SELECT orderFk, taxableBase, `code`, From 4add10f3dde74909f531c0955d28a315a27580ab Mon Sep 17 00:00:00 2001 From: ivanm Date: Tue, 12 Nov 2024 17:52:51 +0100 Subject: [PATCH 08/13] feat: refs #7994 remove comment script --- db/versions/11251-navyChrysanthemum/01-firstScript.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/versions/11251-navyChrysanthemum/01-firstScript.sql b/db/versions/11251-navyChrysanthemum/01-firstScript.sql index c942e0400..e3e08e0aa 100644 --- a/db/versions/11251-navyChrysanthemum/01-firstScript.sql +++ b/db/versions/11251-navyChrysanthemum/01-firstScript.sql @@ -1 +1 @@ --- ALTER TABLE vn.sale MODIFY COLUMN originalQuantity decimal(10,2) DEFAULT 0.00 NOT NULL COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity'; \ No newline at end of file +ALTER TABLE vn.sale MODIFY COLUMN originalQuantity decimal(10,2) DEFAULT 0.00 NOT NULL COMMENT 'Se utiliza para notificar a través de rocket los cambios de quantity'; \ No newline at end of file From ebc04205317fd6f5c3f6d9eea2146a3db324b05b Mon Sep 17 00:00:00 2001 From: Pako Date: Wed, 13 Nov 2024 06:50:21 +0100 Subject: [PATCH 09/13] fix: problem calculation updated --- db/routines/vn/procedures/sale_getProblems.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/sale_getProblems.sql b/db/routines/vn/procedures/sale_getProblems.sql index b50b4784d..cd65bb81c 100644 --- a/db/routines/vn/procedures/sale_getProblems.sql +++ b/db/routines/vn/procedures/sale_getProblems.sql @@ -127,7 +127,7 @@ BEGIN LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk WHERE IFNULL(v.visible, 0) < s.quantity - AND IFNULL(av.available, 0) < s.quantity + AND IFNULL(av.available, 0) < 0 AND IFNULL(issw.visible, 0) < s.quantity AND NOT s.isPicked AND NOT s.reserved @@ -190,7 +190,7 @@ BEGIN LEFT JOIN tItemShelvingStock_byWarehouse issw ON issw.itemFk = i.id AND issw.warehouseFk = t.warehouseFk WHERE IFNULL(v.visible, 0) < s.quantity - AND IFNULL(av.available, 0) >= s.quantity + AND IFNULL(av.available, 0) >= 0 AND IFNULL(issw.visible, 0) < s.quantity AND s.quantity > 0 AND NOT s.isPicked From 628b67e1e58e98e594d0dd9a1ed2cd4580fd7c90 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 07:10:52 +0100 Subject: [PATCH 10/13] fix: refs #8153 Version --- db/routines/hedera/procedures/order_getTax.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/hedera/procedures/order_getTax.sql b/db/routines/hedera/procedures/order_getTax.sql index 90c47bfc7..c33b421f3 100644 --- a/db/routines/hedera/procedures/order_getTax.sql +++ b/db/routines/hedera/procedures/order_getTax.sql @@ -30,7 +30,7 @@ BEGIN s.countryFk, ata.areaFk, itc.taxClassFk - FROM orderRow oro + FROM hedera.orderRow oro JOIN tmp.order tor ON tor.orderFk = oro.orderFk JOIN `order` o ON o.id = tor.orderFk JOIN vn.item i ON i.id = oro.itemFk From ab2e35b64cd7f0cd1f6d82816dcb6e3d6b7cb440 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 07:12:49 +0100 Subject: [PATCH 11/13] fix: refs #8153 Version --- db/routines/hedera/procedures/order_getTax.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/hedera/procedures/order_getTax.sql b/db/routines/hedera/procedures/order_getTax.sql index c33b421f3..371416c29 100644 --- a/db/routines/hedera/procedures/order_getTax.sql +++ b/db/routines/hedera/procedures/order_getTax.sql @@ -32,7 +32,7 @@ BEGIN itc.taxClassFk FROM hedera.orderRow oro JOIN tmp.order tor ON tor.orderFk = oro.orderFk - JOIN `order` o ON o.id = tor.orderFk + JOIN hedera.`order` o ON o.id = tor.orderFk JOIN vn.item i ON i.id = oro.itemFk JOIN vn.`client` c ON c.id = o.customer_id JOIN vn.supplier s ON s.id = o.company_id From 1086981b536b8825f0ee4eace4448f088015f9bb Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 09:35:06 +0100 Subject: [PATCH 12/13] fix: refs #7779 ticket_splitItemPackingType --- .../vn/procedures/ticket_splitItemPackingType.sql | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index 9a4bc01eb..92ff393cd 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -14,7 +14,7 @@ proc:BEGIN */ DECLARE vDone INT DEFAULT FALSE; DECLARE vHasItemPackingType BOOL; - DECLARE vItemPackingTypeFk INT; + DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H'; DECLARE vNewTicketFk INT; DECLARE vItemPackingTypes CURSOR FOR @@ -36,14 +36,10 @@ proc:BEGIN ) ENGINE=MEMORY SELECT vSelf ticketFk, vOriginalItemPackingTypeFk itemPackingTypeFk; - IF NOT vHasItemPackingType THEN - LEAVE proc; - END IF; - CREATE OR REPLACE TEMPORARY TABLE tSalesToMove ( ticketFk INT, saleFk INT, - itemPackingTypeFk INT + itemPackingTypeFk VARCHAR(1) ) ENGINE=MEMORY; INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk) @@ -55,7 +51,6 @@ proc:BEGIN AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk; OPEN vItemPackingTypes; - l: LOOP SET vDone = FALSE; FETCH vItemPackingTypes INTO vItemPackingTypeFk; @@ -71,7 +66,6 @@ proc:BEGIN WHERE itemPackingTypeFk = vItemPackingTypeFk; END LOOP; - CLOSE vItemPackingTypes; UPDATE sale s From aa1c017f2203e8e7226dd3a4dd54054698201175 Mon Sep 17 00:00:00 2001 From: guillermo Date: Wed, 13 Nov 2024 12:17:58 +0100 Subject: [PATCH 13/13] fix: refs #7779 ticket_splitItemPackingType --- .../ticket_splitItemPackingType.sql | 145 ++++++++++++------ 1 file changed, 94 insertions(+), 51 deletions(-) diff --git a/db/routines/vn/procedures/ticket_splitItemPackingType.sql b/db/routines/vn/procedures/ticket_splitItemPackingType.sql index 92ff393cd..0ee865af5 100644 --- a/db/routines/vn/procedures/ticket_splitItemPackingType.sql +++ b/db/routines/vn/procedures/ticket_splitItemPackingType.sql @@ -3,81 +3,124 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticket_splitItemPacki vSelf INT, vOriginalItemPackingTypeFk VARCHAR(1) ) -proc:BEGIN +BEGIN /** - * Clona y reparte las líneas de ventas de un ticket en funcion del tipo de empaquetado. - * Respeta el id de ticket original para el tipo de empaquetado propuesto. + * Clona y reparte las ventas de un ticket en funcion del tipo de empaquetado. + * Respeta el id inicial para el tipo propuesto. * * @param vSelf Id ticket - * @param vOriginalItemPackingTypeFk Tipo empaquetado que se mantiene el ticket original + * @param vOriginalItemPackingTypeFk Tipo para el que se reserva el número de ticket original * @return table tmp.ticketIPT(ticketFk, itemPackingTypeFk) */ - DECLARE vDone INT DEFAULT FALSE; - DECLARE vHasItemPackingType BOOL; DECLARE vItemPackingTypeFk VARCHAR(1) DEFAULT 'H'; DECLARE vNewTicketFk INT; + DECLARE vPackingTypesToSplit INT; + DECLARE vDone INT DEFAULT FALSE; - DECLARE vItemPackingTypes CURSOR FOR - SELECT DISTINCT itemPackingTypeFk - FROM tSalesToMove; + DECLARE vSaleGroup CURSOR FOR + SELECT itemPackingTypeFk + FROM tSaleGroup + WHERE itemPackingTypeFk IS NOT NULL + ORDER BY (itemPackingTypeFk = vOriginalItemPackingTypeFk) DESC; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE; - SELECT COUNT(*) INTO vHasItemPackingType - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN item i ON i.id = s.itemFk - WHERE t.id = vSelf - AND i.itemPackingTypeFk = vOriginalItemPackingTypeFk; + START TRANSACTION; + + SELECT id + FROM sale + WHERE ticketFk = vSelf + AND NOT quantity + 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 + FROM sale s + JOIN item i ON i.id = s.itemFk + LEFT JOIN saleVolume sv ON sv.saleFk = s.id + WHERE s.ticketFk = vSelf; + + CREATE OR REPLACE TEMPORARY TABLE tSaleGroup + ENGINE = MEMORY + SELECT itemPackingTypeFk, SUM(litros) totalLitros + FROM tSale + GROUP BY itemPackingTypeFk; + + SELECT COUNT(*) INTO vPackingTypesToSplit + FROM tSaleGroup + WHERE itemPackingTypeFk IS NOT NULL; CREATE OR REPLACE TEMPORARY TABLE tmp.ticketIPT( ticketFk INT, itemPackingTypeFk VARCHAR(1) - ) ENGINE=MEMORY - SELECT vSelf ticketFk, vOriginalItemPackingTypeFk itemPackingTypeFk; + ) ENGINE = MEMORY; - CREATE OR REPLACE TEMPORARY TABLE tSalesToMove ( - ticketFk INT, - saleFk INT, - itemPackingTypeFk VARCHAR(1) - ) ENGINE=MEMORY; + 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; - INSERT INTO tSalesToMove (saleFk, itemPackingTypeFk) - SELECT s.id, i.itemPackingTypeFk - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - JOIN item i ON i.id = s.itemFk - WHERE t.id = vSelf - AND i.itemPackingTypeFk <> vOriginalItemPackingTypeFk; + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) + VALUES(vSelf, vItemPackingTypeFk); - OPEN vItemPackingTypes; - l: LOOP - SET vDone = FALSE; - FETCH vItemPackingTypes INTO vItemPackingTypeFk; + l: LOOP + SET vDone = FALSE; + FETCH vSaleGroup INTO vItemPackingTypeFk; - IF vDone THEN - LEAVE l; - END IF; + IF vDone THEN + LEAVE l; + END IF; - CALL ticket_Clone(vSelf, vNewTicketFk); + CALL ticket_Clone(vSelf, vNewTicketFk); - UPDATE tSalesToMove - SET ticketFk = vNewTicketFk - WHERE itemPackingTypeFk = vItemPackingTypeFk; + INSERT INTO tmp.ticketIPT(ticketFk, itemPackingTypeFk) + VALUES(vNewTicketFk, vItemPackingTypeFk); + END LOOP; - END LOOP; - CLOSE vItemPackingTypes; + CLOSE vSaleGroup; - UPDATE sale s - JOIN tSalesToMove stm ON stm.saleFk = s.id - SET s.ticketFk = stm.ticketFk - WHERE stm.ticketFk; + 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; - INSERT INTO tmp.ticketIPT (ticketFk, itemPackingTypeFk) - SELECT ticketFk, itemPackingTypeFk - FROM tSalesToMove - GROUP BY ticketFk; + 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; - DROP TEMPORARY TABLE tSalesToMove; + 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; + + COMMIT; + + DROP TEMPORARY TABLE + tSale, + tSaleGroup; END$$ DELIMITER ;