From 1f5c0d3e94445e5483dcd1357523ba44fb1deb17 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 30 Sep 2024 08:25:40 +0200 Subject: [PATCH 1/3] fix: refs #5320 withoutHaving --- .../vn/procedures/collectionPlacement_get.sql | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/db/routines/vn/procedures/collectionPlacement_get.sql b/db/routines/vn/procedures/collectionPlacement_get.sql index d81847375..7f7e23178 100644 --- a/db/routines/vn/procedures/collectionPlacement_get.sql +++ b/db/routines/vn/procedures/collectionPlacement_get.sql @@ -55,24 +55,20 @@ BEGIN SELECT ts.saleFk, ts.itemFk, CAST(0 AS DECIMAL(10,0)) saleOrder, - IF(ish.visible > 0 OR iss.id, 1, 100000) * - IFNULL(p2.pickingOrder, p.pickingOrder) `order`, - TO_SECONDS(IF(iss.id, - iss.created - INTERVAL vCurrentYear YEAR, - ish.created - INTERVAL YEAR(ish.created) YEAR)) priority, + (IF(ish.visible > 0 OR iss.id, 1, 100000) * + COALESCE(p2.pickingOrder, p.pickingOrder)) `order`, + TO_SECONDS(COALESCE(iss.created, ish.created)) - TO_SECONDS(MAKEDATE(IFNULL(YEAR(iss.created), YEAR(ish.created)), 1)) priority, CONCAT( - IF(iss.id, - CONCAT('< ', IFNULL(wk.`code`, '---'),' > '), - ''), - p.`code`) COLLATE utf8_general_ci placement, + IF(iss.id, CONCAT('< ', COALESCE(wk.`code`, '---'),' > '), ''), + p.`code` + ) COLLATE utf8_general_ci placement, sh.priority shelvingPriority, sh.code COLLATE utf8_general_ci shelving, ish.created, ish.visible, - IFNULL( - IF(st.code = 'previousByPacking', ish.packing, g.`grouping`), - 1) `grouping`, - st.code = 'previousPrepared' isPreviousPrepared, + COALESCE( + IF(st.code = 'previousByPacking', ish.packing, g.`grouping`),1) `grouping`, + (st.code = 'previousPrepared') isPreviousPrepared, iss.id itemShelvingSaleFk, ts.ticketFk, iss.id, @@ -80,11 +76,11 @@ BEGIN iss.userFk, ts.quantity FROM tSale ts - LEFT JOIN (SELECT DISTINCT saleFk - FROM saleTracking st - JOIN state s ON s.id = st.stateFk - WHERE st.isChecked - AND s.semaphore = 1) st ON st.saleFk = ts.saleFk + LEFT JOIN (SELECT st.saleFk + FROM saleTracking st + JOIN state s ON s.id = st.stateFk + WHERE st.isChecked + AND s.semaphore = 1) st ON st.saleFk = ts.saleFk JOIN itemShelving ish ON ish.itemFk = ts.itemFk JOIN shelving sh ON sh.code = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk @@ -93,14 +89,14 @@ BEGIN JOIN warehouse w ON w.id = sc.warehouseFk LEFT JOIN tGrouping g ON g.itemFk = ts.itemFk LEFT JOIN itemShelvingSale iss ON iss.saleFk = ts.saleFk - AND iss.itemShelvingFk = ish.id + AND iss.itemShelvingFk = ish.id LEFT JOIN worker wk ON wk.id = iss.userFk LEFT JOIN saleGroupDetail sgd ON sgd.saleFk = ts.saleFk LEFT JOIN saleGroup sg ON sg.id = sgd.saleGroupFk LEFT JOIN parking p2 ON p2.id = sg.parkingFk WHERE w.id = vWarehouseFk - AND NOT sc.isHideForPickers - HAVING (iss.id AND st.saleFk) OR salePreviousPrepared IS NULL; + AND NOT sc.isHideForPickers + AND ((iss.id IS NOT NULL AND st.saleFk IS NOT NULL) OR st.saleFk IS NULL); CREATE OR REPLACE TEMPORARY TABLE tSalePlacementList2 (INDEX(saleFk), INDEX(olderPriority)) -- 2.40.1 From a9b083a044a15f85342f2c69d2e1f65047671650 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 30 Sep 2024 09:39:35 +0200 Subject: [PATCH 2/3] fix: refs #5320 withoutHaving --- db/routines/vn/procedures/collectionPlacement_get.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/collectionPlacement_get.sql b/db/routines/vn/procedures/collectionPlacement_get.sql index 7f7e23178..e302f8d3c 100644 --- a/db/routines/vn/procedures/collectionPlacement_get.sql +++ b/db/routines/vn/procedures/collectionPlacement_get.sql @@ -96,7 +96,8 @@ BEGIN LEFT JOIN parking p2 ON p2.id = sg.parkingFk WHERE w.id = vWarehouseFk AND NOT sc.isHideForPickers - AND ((iss.id IS NOT NULL AND st.saleFk IS NOT NULL) OR st.saleFk IS NULL); + AND ((iss.id AND st.saleFk) OR st.saleFk IS NULL) + GROUP BY st.saleFk, created; CREATE OR REPLACE TEMPORARY TABLE tSalePlacementList2 (INDEX(saleFk), INDEX(olderPriority)) -- 2.40.1 From a0a8a22ab0e6c5550bf9b8c9758644336335c37a Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 30 Sep 2024 11:13:12 +0200 Subject: [PATCH 3/3] fix: refs #5320 withoutHaving --- db/routines/vn/procedures/collectionPlacement_get.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/routines/vn/procedures/collectionPlacement_get.sql b/db/routines/vn/procedures/collectionPlacement_get.sql index e302f8d3c..239dbd3a2 100644 --- a/db/routines/vn/procedures/collectionPlacement_get.sql +++ b/db/routines/vn/procedures/collectionPlacement_get.sql @@ -80,7 +80,8 @@ BEGIN FROM saleTracking st JOIN state s ON s.id = st.stateFk WHERE st.isChecked - AND s.semaphore = 1) st ON st.saleFk = ts.saleFk + AND s.semaphore = 1 + GROUP BY st.saleFk) st ON st.saleFk = ts.saleFk JOIN itemShelving ish ON ish.itemFk = ts.itemFk JOIN shelving sh ON sh.code = ish.shelvingFk JOIN parking p ON p.id = sh.parkingFk @@ -96,8 +97,7 @@ BEGIN LEFT JOIN parking p2 ON p2.id = sg.parkingFk WHERE w.id = vWarehouseFk AND NOT sc.isHideForPickers - AND ((iss.id AND st.saleFk) OR st.saleFk IS NULL) - GROUP BY st.saleFk, created; + AND ((iss.id AND st.saleFk) OR st.saleFk IS NULL); CREATE OR REPLACE TEMPORARY TABLE tSalePlacementList2 (INDEX(saleFk), INDEX(olderPriority)) -- 2.40.1