fix: problems in colums ticket and sale refs #7213 #2497

Merged
carlosap merged 1 commits from 7213-Problems-in-colums-ticket-and-sale into test 2024-05-23 10:53:16 +00:00
6 changed files with 18 additions and 15 deletions

View File

@ -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
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);
AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk)
GROUP BY s.id) sub;
CALL sale_setProblem('hasComponentLack');

View File

@ -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 ;

View File

@ -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$$

View File

@ -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');

View File

@ -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 ;

View File

@ -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
Review

Perque left? Si no hi ha sales...no cal mostrar res

Perque left? Si no hi ha sales...no cal mostrar res
Review

Sí volem que els tickets que no tinguen ventes es marque el problema a la capçalera del ticket.

Sí volem que els tickets que no tinguen ventes es marque el problema a la capçalera del ticket.
WHERE t.shipped >= util.midnight()
AND (s.itemFk = vItemFk OR vItemFk IS NULL)
Review

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.

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.
Review

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