fix: problems in colums ticket and sale refs #7213 #2497
|
@ -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');
|
||||
|
||||
|
|
|
@ -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 ;
|
|
@ -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$$
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
|
@ -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 ;
|
|
@ -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
|
||||
jgallego marked this conversation as resolved
|
||||
WHERE t.shipped >= util.midnight()
|
||||
AND (s.itemFk = vItemFk OR vItemFk IS NULL)
|
||||
jgallego
commented
tin en compte que un ticket pot tindre varios itemFk repetits, ací se li pasa vItemFk, pero valora canviarlo per el saleFk. tin en compte que un ticket pot tindre varios itemFk repetits, ací se li pasa vItemFk, pero valora canviarlo per el saleFk.
De totes formes açò es un comentari la el codi es funcional.
carlosap
commented
El objectiu del procediment es recalcular tots els ticket que tinguen un items determinat, perquer han canviat algún paramétre relacionat amb el volum i es necessari revisar si ara cumplixen les condicions de tooLittle per a ficar/llevar ixe problema del ticket El objectiu del procediment es recalcular tots els ticket que tinguen un items determinat, perquer han canviat algún paramétre relacionat amb el volum i es necessari revisar si ara cumplixen les condicions de tooLittle per a ficar/llevar ixe problema del ticket
|
||||
GROUP BY t.id
|
||||
|
|
Loading…
Reference in New Issue
Perque left? Si no hi ha sales...no cal mostrar res
Sí volem que els tickets que no tinguen ventes es marque el problema a la capçalera del ticket.