7965-unifyProblems #2990

Open
carlosap wants to merge 20 commits from 7965-unifyProblems into dev
2 changed files with 18 additions and 20 deletions
Showing only changes of commit 2d8bda2b56 - Show all commits

View File

@ -48,6 +48,14 @@ BEGIN
JOIN sector s ON s.id = p.sectorFk
GROUP BY ish.itemFk, s.warehouseFk;
-- Componentes: Algún componente obligatorio no se ha calcualdo
INSERT INTO tmp.saleProblems(saleFk, hasComponentLack)
SELECT s.id, TRUE
FROM tmp.sale ts
JOIN sale s ON s.id = ts.saleFk
WHERE FIND_IN_SET('hasComponentLack', s.problem)
GROUP BY s.id;
-- Disponible, faltas, inventario y retrasos
OPEN vCursor;
l: LOOP
@ -78,9 +86,9 @@ BEGIN
AND av.calc_id = vAvailableCache
LEFT JOIN tItemShelving tis ON tis.itemFk = i.id
AND tis.warehouseFk = t.warehouseFk
WHERE (v.visible < s.quantity AND v.visible IS NOT NULL)
AND (av.available < s.quantity AND av.available IS NOT NULL)
AND (tis.visible < s.quantity AND tis.visible IS NOT NULL)
WHERE (s.quantity > v.visible OR (s.quantity > 0 AND v.visible IS NULL))
AND (av.available < 0 OR av.available IS NULL)
AND (s.quantity > tis.visible OR tis.visible IS NULL)
AND NOT s.isPicked
AND NOT s.reserved
AND ic.merchandise
@ -88,7 +96,8 @@ BEGIN
AND NOT i.generic
AND util.VN_CURDATE() = vDate
AND t.warehouseFk = vWarehouseFk
GROUP BY s.id;
GROUP BY s.id
ON DUPLICATE KEY UPDATE hasItemShortage = TRUE;
-- Inventario: Visible suficiente, pero ubicado menor a la cantidad vendida
INSERT INTO tmp.saleProblems(saleFk, hasItemLost)
@ -103,8 +112,8 @@ BEGIN
AND v.calc_id = vVisibleCache
LEFT JOIN tItemShelving tis ON tis.itemFk = i.id
AND tis.warehouseFk = t.warehouseFk
WHERE (v.visible >= s.quantity AND v.visible IS NOT NULL)
AND (tis.visible < s.quantity AND tis.visible IS NOT NULL)
WHERE (v.visible >= s.quantity OR v.visible IS NULL)
AND (s.quantity > tis.visible AND tis.visible IS NOT NULL)
AND s.quantity > 0
AND NOT s.isPicked
AND NOT s.reserved
@ -116,15 +125,6 @@ BEGIN
GROUP BY s.id
ON DUPLICATE KEY UPDATE hasItemLost = TRUE;
-- Componentes: Algún componente obligatorio no se ha calcualdo
INSERT INTO tmp.saleProblems(saleFk, hasComponentLack)
SELECT s.id, TRUE
FROM tmp.sale ts
JOIN sale s ON s.id = ts.saleFk
WHERE FIND_IN_SET('hasComponentLack', s.problem)
GROUP BY s.id
ON DUPLICATE KEY UPDATE hasComponentLack = TRUE;
-- Retraso: Disponible suficiente, pero no visible ni ubicado
INSERT INTO tmp.saleProblems(saleFk, hasItemDelay)
SELECT s.id, TRUE
@ -140,9 +140,9 @@ BEGIN
AND av.calc_id = vAvailableCache
LEFT JOIN tItemShelving tis ON tis.itemFk = i.id
AND tis.warehouseFk = t.warehouseFk
WHERE (v.visible < s.quantity AND v.visible IS NOT NULL)
AND (av.available < s.quantity AND av.available IS NOT NULL)
AND (tis.visible < s.quantity AND tis.visible IS NOT NULL)
WHERE (s.quantity > v.visible AND v.visible IS NULL)
AND (av.available >= 0 OR av.available IS NULL)
AND (s.quantity > tis.visible AND tis.visible IS NOT NULL)
AND s.quantity > 0
AND NOT s.isPicked
AND NOT s.reserved

View File

@ -18,8 +18,6 @@ BEGIN
FROM tmp.ticket tt
JOIN ticket t ON t.id = tt.ticketFk
JOIN sale s ON s.ticketFk = t.id
WHERE t.shipped BETWEEN util.VN_CURDATE()
AND util.dayEnd(util.VN_CURDATE() + INTERVAL IF(vIsTodayRelative, 9.9, 1.9) DAY)
GROUP BY s.id;
CALL sale_getProblems(vIsTodayRelative);