From bc6af32962a17c26d9df113a4cb8a3482105c41a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Andr=C3=A9s?= Date: Wed, 22 May 2024 14:50:45 +0200 Subject: [PATCH] fix: problems in colums ticket and sale refs #7213 --- .../sale_setProblemComponentLackByComponent.sql | 15 +++++++++------ .../vn/procedures/sale_setProblemRounding.sql | 6 +++--- .../vn/procedures/ticket_setProblemFreeze.sql | 2 +- .../vn/procedures/ticket_setProblemRisk.sql | 2 +- .../vn/procedures/ticket_setProblemRounding.sql | 6 +++--- .../ticket_setProblemTooLittleItemCost.sql | 2 +- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql b/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql index 895598e84..62db0d9cf 100644 --- a/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql +++ b/db/routines/vn/procedures/sale_setProblemComponentLackByComponent.sql @@ -12,12 +12,15 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.sale (INDEX(saleFk)) ENGINE = MEMORY - SELECT s.id saleFk, sale_hasComponentLack(s.id) hasProblem - FROM ticket t - JOIN sale s ON s.ticketFk = t.id - LEFT JOIN saleComponent sc ON sc.saleFk = s.id - WHERE t.shipped >= util.midnight() - AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk); + SELECT saleFk, sale_hasComponentLack(saleFk)hasProblem + FROM ( + SELECT s.id saleFk + FROM ticket t + JOIN sale s ON s.ticketFk = t.id + LEFT JOIN saleComponent sc ON sc.saleFk = s.id + WHERE t.shipped >= util.midnight() + AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk) + GROUP BY s.id) sub; CALL sale_setProblem('hasComponentLack'); diff --git a/db/routines/vn/procedures/sale_setProblemRounding.sql b/db/routines/vn/procedures/sale_setProblemRounding.sql index 366fbf8fd..f14cd408f 100644 --- a/db/routines/vn/procedures/sale_setProblemRounding.sql +++ b/db/routines/vn/procedures/sale_setProblemRounding.sql @@ -20,15 +20,15 @@ BEGIN CALL buyUltimate(vWarehouseFk, vShipped); - CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - SELECT vSelf saleFk, MOD(vQuantity, bu.`grouping`) hasProblem + CREATE OR REPLACE TEMPORARY TABLE tmp.sale + SELECT vSelf saleFk, MOD(vQuantity, b.`grouping`) hasProblem FROM tmp.buyUltimate bu JOIN buy b ON b.id = bu.buyFk WHERE bu.itemFk = vItemFk; CALL sale_setProblem('hasRounding'); - DROP TEMPORARY TABLE tmp.ticket; + DROP TEMPORARY TABLE tmp.sale; DROP TEMPORARY TABLE tmp.buyUltimate; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setProblemFreeze.sql b/db/routines/vn/procedures/ticket_setProblemFreeze.sql index bdb32b3fe..2a5d67b0d 100644 --- a/db/routines/vn/procedures/ticket_setProblemFreeze.sql +++ b/db/routines/vn/procedures/ticket_setProblemFreeze.sql @@ -22,7 +22,7 @@ BEGIN SET t.hasProblem = TRUE WHERE c.isFreezed; - CALL ticket_setProblem('hasTicketRequest'); + CALL ticket_setProblem('isFreezed'); DROP TEMPORARY TABLE tmp.ticket; END$$ diff --git a/db/routines/vn/procedures/ticket_setProblemRisk.sql b/db/routines/vn/procedures/ticket_setProblemRisk.sql index 7c499f5ba..5f73ee838 100644 --- a/db/routines/vn/procedures/ticket_setProblemRisk.sql +++ b/db/routines/vn/procedures/ticket_setProblemRisk.sql @@ -19,7 +19,7 @@ BEGIN WHERE t.id = vSelf; CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - SELECT vSelf ticketFk, vRisk hasProblem; + SELECT vSelf ticketFk, vHasRisk hasProblem; CALL ticket_setProblem('hasRisk'); diff --git a/db/routines/vn/procedures/ticket_setProblemRounding.sql b/db/routines/vn/procedures/ticket_setProblemRounding.sql index 272a48151..81294325c 100644 --- a/db/routines/vn/procedures/ticket_setProblemRounding.sql +++ b/db/routines/vn/procedures/ticket_setProblemRounding.sql @@ -18,17 +18,17 @@ BEGIN CALL buyUltimate(vWarehouseFk, vDated); - CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + CREATE OR REPLACE TEMPORARY TABLE tmp.sale SELECT s.id saleFk , MOD(s.quantity, b.`grouping`) hasProblem FROM ticket t - JOIN sale s ON s.ticketFk = tl.ticketFk + JOIN sale s ON s.ticketFk = t.id JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk JOIN buy b ON b.id = bu.buyFk WHERE t.id = vSelf; CALL sale_setProblem('hasRounding'); - DROP TEMPORARY TABLE tmp.ticket; + DROP TEMPORARY TABLE tmp.sale; DROP TEMPORARY TABLE tmp.buyUltimate; END$$ DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql b/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql index 9a7852ac5..4403292fc 100644 --- a/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql +++ b/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql @@ -15,7 +15,7 @@ BEGIN WITH tickets AS( SELECT t.id ticketFk FROM vn.ticket t - JOIN vn.sale s ON s.ticketFk = t.id + LEFT JOIN vn.sale s ON s.ticketFk = t.id WHERE t.shipped >= util.midnight() AND (s.itemFk = vItemFk OR vItemFk IS NULL) GROUP BY t.id