Merge pull request 'fix: problems in colums ticket and sale refs #7213' (!2497) from 7213-Problems-in-colums-ticket-and-sale into test
Reviewed-on: #2497 Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
commit
8b967ee927
|
@ -12,12 +12,15 @@ BEGIN
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||||
(INDEX(saleFk))
|
(INDEX(saleFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT s.id saleFk, sale_hasComponentLack(s.id) hasProblem
|
SELECT saleFk, sale_hasComponentLack(saleFk)hasProblem
|
||||||
FROM ticket t
|
FROM (
|
||||||
JOIN sale s ON s.ticketFk = t.id
|
SELECT s.id saleFk
|
||||||
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
|
FROM ticket t
|
||||||
WHERE t.shipped >= util.midnight()
|
JOIN sale s ON s.ticketFk = t.id
|
||||||
AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk);
|
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');
|
CALL sale_setProblem('hasComponentLack');
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,15 @@ BEGIN
|
||||||
|
|
||||||
CALL buyUltimate(vWarehouseFk, vShipped);
|
CALL buyUltimate(vWarehouseFk, vShipped);
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||||
SELECT vSelf saleFk, MOD(vQuantity, bu.`grouping`) hasProblem
|
SELECT vSelf saleFk, MOD(vQuantity, b.`grouping`) hasProblem
|
||||||
FROM tmp.buyUltimate bu
|
FROM tmp.buyUltimate bu
|
||||||
JOIN buy b ON b.id = bu.buyFk
|
JOIN buy b ON b.id = bu.buyFk
|
||||||
WHERE bu.itemFk = vItemFk;
|
WHERE bu.itemFk = vItemFk;
|
||||||
|
|
||||||
CALL sale_setProblem('hasRounding');
|
CALL sale_setProblem('hasRounding');
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.ticket;
|
DROP TEMPORARY TABLE tmp.sale;
|
||||||
DROP TEMPORARY TABLE tmp.buyUltimate;
|
DROP TEMPORARY TABLE tmp.buyUltimate;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -22,7 +22,7 @@ BEGIN
|
||||||
SET t.hasProblem = TRUE
|
SET t.hasProblem = TRUE
|
||||||
WHERE c.isFreezed;
|
WHERE c.isFreezed;
|
||||||
|
|
||||||
CALL ticket_setProblem('hasTicketRequest');
|
CALL ticket_setProblem('isFreezed');
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.ticket;
|
DROP TEMPORARY TABLE tmp.ticket;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -19,7 +19,7 @@ BEGIN
|
||||||
WHERE t.id = vSelf;
|
WHERE t.id = vSelf;
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||||
SELECT vSelf ticketFk, vRisk hasProblem;
|
SELECT vSelf ticketFk, vHasRisk hasProblem;
|
||||||
|
|
||||||
CALL ticket_setProblem('hasRisk');
|
CALL ticket_setProblem('hasRisk');
|
||||||
|
|
||||||
|
|
|
@ -18,17 +18,17 @@ BEGIN
|
||||||
|
|
||||||
CALL buyUltimate(vWarehouseFk, vDated);
|
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
|
SELECT s.id saleFk , MOD(s.quantity, b.`grouping`) hasProblem
|
||||||
FROM ticket t
|
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 tmp.buyUltimate bu ON bu.itemFk = s.itemFk
|
||||||
JOIN buy b ON b.id = bu.buyFk
|
JOIN buy b ON b.id = bu.buyFk
|
||||||
WHERE t.id = vSelf;
|
WHERE t.id = vSelf;
|
||||||
|
|
||||||
CALL sale_setProblem('hasRounding');
|
CALL sale_setProblem('hasRounding');
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.ticket;
|
DROP TEMPORARY TABLE tmp.sale;
|
||||||
DROP TEMPORARY TABLE tmp.buyUltimate;
|
DROP TEMPORARY TABLE tmp.buyUltimate;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -15,7 +15,7 @@ BEGIN
|
||||||
WITH tickets AS(
|
WITH tickets AS(
|
||||||
SELECT t.id ticketFk
|
SELECT t.id ticketFk
|
||||||
FROM vn.ticket t
|
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()
|
WHERE t.shipped >= util.midnight()
|
||||||
AND (s.itemFk = vItemFk OR vItemFk IS NULL)
|
AND (s.itemFk = vItemFk OR vItemFk IS NULL)
|
||||||
GROUP BY t.id
|
GROUP BY t.id
|
||||||
|
|
Loading…
Reference in New Issue