From 8dea9598e885b3327f6e51c855ef029568dc3f23 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 14 Jun 2024 13:54:43 +0200 Subject: [PATCH 1/5] fix: refs #194195 item_getAtp --- db/routines/vn/procedures/item_getAtp.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/item_getAtp.sql b/db/routines/vn/procedures/item_getAtp.sql index bbf13d396..8266e58da 100644 --- a/db/routines/vn/procedures/item_getAtp.sql +++ b/db/routines/vn/procedures/item_getAtp.sql @@ -1,5 +1,5 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getAtp`(vDated DATE) +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getAtp`(vDated DATE) BEGIN /** * Calcula el valor mínimo acumulado para cada artículo ordenado por fecha y @@ -33,7 +33,7 @@ BEGIN FROM ( SELECT itemFk, - IF(itemFk <> @lastItemFk OR wareHouseFk <> @lastWareHouseFk, + IF(itemFk <> @lastItemFk OR wareHouseFk <> @lastWareHouseFk OR wareHouseFk IS NULL, @lastQuantity := quantity, @lastQuantity := @lastQuantity + quantity) quantityAccumulated, wareHouseFk, @@ -44,5 +44,5 @@ BEGIN GROUP BY itemFk, wareHouseFk; DROP TEMPORARY TABLE tItemOrdered; -END$$ -DELIMITER ; +END$$ +DELIMITER ; From df6de7e74c34e861bda3e5fb4750a837fc499773 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 14 Jun 2024 14:55:03 +0200 Subject: [PATCH 2/5] fix: refs #194195 item_getAtp --- db/routines/vn/procedures/item_getAtp.sql | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/item_getAtp.sql b/db/routines/vn/procedures/item_getAtp.sql index 8266e58da..d02d7cc90 100644 --- a/db/routines/vn/procedures/item_getAtp.sql +++ b/db/routines/vn/procedures/item_getAtp.sql @@ -20,12 +20,11 @@ BEGIN SELECT itemFk, warehouseFk, vDated, 0 FROM (SELECT DISTINCT itemFk, warehouseFk FROM tmp.itemCalc) t2 ) t1 - GROUP BY itemFk, warehouseFk, dated - ORDER BY itemFk, warehouseFk, dated; + GROUP BY itemFk, warehouseFk, dated; - SET @lastItemFk := 0; - SET @lastWareHouseFk := 0; - SET @lastQuantity := 0; + SET @lastItemFk = 0; + SET @lastWareHouseFk = 0; + SET @lastQuantity = 0; CREATE OR REPLACE TEMPORARY TABLE tmp.itemAtp (INDEX (itemFk, wareHouseFk)) @@ -40,6 +39,8 @@ BEGIN @lastItemFk := itemFk, @lastWareHouseFk := wareHouseFk FROM tItemOrdered + ORDER BY itemFk, warehouseFk, dated + LIMIT 10000000000000000000 )sub GROUP BY itemFk, wareHouseFk; From 5473f7a3080441aea25c68c738c91cbf5a27eb13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 14 Jun 2024 16:01:27 +0200 Subject: [PATCH 3/5] Hotfix Ticket #194195 Error radar negativos --- db/routines/vn/procedures/item_getAtp.sql | 14 +++++++------- db/routines/vn/procedures/item_getMinacum.sql | 5 +++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/db/routines/vn/procedures/item_getAtp.sql b/db/routines/vn/procedures/item_getAtp.sql index d02d7cc90..0cbb8ab06 100644 --- a/db/routines/vn/procedures/item_getAtp.sql +++ b/db/routines/vn/procedures/item_getAtp.sql @@ -20,11 +20,13 @@ BEGIN SELECT itemFk, warehouseFk, vDated, 0 FROM (SELECT DISTINCT itemFk, warehouseFk FROM tmp.itemCalc) t2 ) t1 - GROUP BY itemFk, warehouseFk, dated; + GROUP BY itemFk, warehouseFk, dated + HAVING warehouseFk + ORDER BY itemFk, warehouseFk, dated; - SET @lastItemFk = 0; - SET @lastWareHouseFk = 0; - SET @lastQuantity = 0; + SET @lastItemFk := 0; + SET @lastWareHouseFk := 0; + SET @lastQuantity := 0; CREATE OR REPLACE TEMPORARY TABLE tmp.itemAtp (INDEX (itemFk, wareHouseFk)) @@ -32,15 +34,13 @@ BEGIN FROM ( SELECT itemFk, - IF(itemFk <> @lastItemFk OR wareHouseFk <> @lastWareHouseFk OR wareHouseFk IS NULL, + IF(itemFk <> @lastItemFk OR wareHouseFk <> @lastWareHouseFk, @lastQuantity := quantity, @lastQuantity := @lastQuantity + quantity) quantityAccumulated, wareHouseFk, @lastItemFk := itemFk, @lastWareHouseFk := wareHouseFk FROM tItemOrdered - ORDER BY itemFk, warehouseFk, dated - LIMIT 10000000000000000000 )sub GROUP BY itemFk, wareHouseFk; diff --git a/db/routines/vn/procedures/item_getMinacum.sql b/db/routines/vn/procedures/item_getMinacum.sql index ed987637c..7573759f7 100644 --- a/db/routines/vn/procedures/item_getMinacum.sql +++ b/db/routines/vn/procedures/item_getMinacum.sql @@ -30,6 +30,7 @@ BEGIN FROM sale s JOIN ticket t ON t.id = s.ticketFk WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo + AND t.warehouseFk AND s.quantity != 0 AND (vItemFk IS NULL OR s.itemFk = vItemFk) AND (vWarehouseFk IS NULL OR t.warehouseFk = vWarehouseFk) @@ -40,7 +41,7 @@ BEGIN t.warehouseInFk FROM buy b JOIN entry e ON e.id = b.entryFk - LEFT JOIN travel t ON t.id = e.travelFk + JOIN travel t ON t.id = e.travelFk WHERE t.landed BETWEEN vDatedFrom AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) AND !e.isExcludedFromAvailable @@ -53,7 +54,7 @@ BEGIN t.warehouseOutFk FROM buy b JOIN entry e ON e.id = b.entryFk - LEFT JOIN travel t ON t.id = e.travelFk + JOIN travel t ON t.id = e.travelFk WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk) AND !e.isExcludedFromAvailable From 51078c804b439d59eeabf77d38dd19a9b7f1521e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Fri, 14 Jun 2024 16:32:13 +0200 Subject: [PATCH 4/5] Ticket #194195 Recupero vn.item_getAtp --- db/routines/vn/procedures/item_getAtp.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/db/routines/vn/procedures/item_getAtp.sql b/db/routines/vn/procedures/item_getAtp.sql index 0cbb8ab06..255e38867 100644 --- a/db/routines/vn/procedures/item_getAtp.sql +++ b/db/routines/vn/procedures/item_getAtp.sql @@ -21,7 +21,6 @@ BEGIN FROM (SELECT DISTINCT itemFk, warehouseFk FROM tmp.itemCalc) t2 ) t1 GROUP BY itemFk, warehouseFk, dated - HAVING warehouseFk ORDER BY itemFk, warehouseFk, dated; SET @lastItemFk := 0; From 4c345ffa938401daeb44b2ee20bc624e616791a5 Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 17 Jun 2024 10:57:23 +0200 Subject: [PATCH 5/5] hotfix: refs #7552 item_getSimilar --- db/routines/vn/procedures/item_getSimilar.sql | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/item_getSimilar.sql b/db/routines/vn/procedures/item_getSimilar.sql index 762c25342..65407c2df 100644 --- a/db/routines/vn/procedures/item_getSimilar.sql +++ b/db/routines/vn/procedures/item_getSimilar.sql @@ -21,9 +21,6 @@ BEGIN CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated); - -- Añadido temporalmente para que no se cuelgue la db - SET vShowType = TRUE; - WITH itemTags AS ( SELECT i.id, typeFk, @@ -38,7 +35,7 @@ BEGIN t.name, it.value FROM vn.item i - LEFT JOIN vn.itemTag it ON it.itemFk = i.id + LEFT JOIN vn.itemTag it FORCE INDEX(itemTagItemPriority) ON it.itemFk = i.id AND it.priority = vPriority LEFT JOIN vn.tag t ON t.id = it.tagFk WHERE i.id = vSelf @@ -68,7 +65,7 @@ BEGIN iss.visible located, b.price2 FROM vn.item i - JOIN cache.available a ON a.item_id = i.id + JOIN cache.available a FORCE INDEX (calc_id) ON a.item_id = i.id AND a.calc_id = vCalcFk LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id AND ip.itemFk = vSelf