7965-unifyProblems #2990
|
@ -48,6 +48,14 @@ BEGIN
|
||||||
JOIN sector s ON s.id = p.sectorFk
|
JOIN sector s ON s.id = p.sectorFk
|
||||||
GROUP BY ish.itemFk, s.warehouseFk;
|
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
|
-- Disponible, faltas, inventario y retrasos
|
||||||
OPEN vCursor;
|
OPEN vCursor;
|
||||||
l: LOOP
|
l: LOOP
|
||||||
|
@ -78,9 +86,9 @@ BEGIN
|
||||||
AND av.calc_id = vAvailableCache
|
AND av.calc_id = vAvailableCache
|
||||||
LEFT JOIN tItemShelving tis ON tis.itemFk = i.id
|
LEFT JOIN tItemShelving tis ON tis.itemFk = i.id
|
||||||
AND tis.warehouseFk = t.warehouseFk
|
AND tis.warehouseFk = t.warehouseFk
|
||||||
WHERE (v.visible < s.quantity AND v.visible IS NOT NULL)
|
WHERE (s.quantity > v.visible OR (s.quantity > 0 AND v.visible IS NULL))
|
||||||
AND (av.available < s.quantity AND av.available IS NOT NULL)
|
AND (av.available < 0 OR av.available IS NULL)
|
||||||
AND (tis.visible < s.quantity AND tis.visible IS NOT NULL)
|
AND (s.quantity > tis.visible OR tis.visible IS NULL)
|
||||||
AND NOT s.isPicked
|
AND NOT s.isPicked
|
||||||
AND NOT s.reserved
|
AND NOT s.reserved
|
||||||
AND ic.merchandise
|
AND ic.merchandise
|
||||||
|
@ -88,7 +96,8 @@ BEGIN
|
||||||
AND NOT i.generic
|
AND NOT i.generic
|
||||||
AND util.VN_CURDATE() = vDate
|
AND util.VN_CURDATE() = vDate
|
||||||
AND t.warehouseFk = vWarehouseFk
|
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
|
-- Inventario: Visible suficiente, pero ubicado menor a la cantidad vendida
|
||||||
INSERT INTO tmp.saleProblems(saleFk, hasItemLost)
|
INSERT INTO tmp.saleProblems(saleFk, hasItemLost)
|
||||||
|
@ -103,8 +112,8 @@ BEGIN
|
||||||
AND v.calc_id = vVisibleCache
|
AND v.calc_id = vVisibleCache
|
||||||
LEFT JOIN tItemShelving tis ON tis.itemFk = i.id
|
LEFT JOIN tItemShelving tis ON tis.itemFk = i.id
|
||||||
AND tis.warehouseFk = t.warehouseFk
|
AND tis.warehouseFk = t.warehouseFk
|
||||||
WHERE (v.visible >= s.quantity AND v.visible IS NOT NULL)
|
WHERE (v.visible >= s.quantity OR v.visible IS NULL)
|
||||||
AND (tis.visible < s.quantity AND tis.visible IS NOT NULL)
|
AND (s.quantity > tis.visible AND tis.visible IS NOT NULL)
|
||||||
AND s.quantity > 0
|
AND s.quantity > 0
|
||||||
AND NOT s.isPicked
|
AND NOT s.isPicked
|
||||||
AND NOT s.reserved
|
AND NOT s.reserved
|
||||||
|
@ -116,15 +125,6 @@ BEGIN
|
||||||
GROUP BY s.id
|
GROUP BY s.id
|
||||||
ON DUPLICATE KEY UPDATE hasItemLost = TRUE;
|
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
|
-- Retraso: Disponible suficiente, pero no visible ni ubicado
|
||||||
INSERT INTO tmp.saleProblems(saleFk, hasItemDelay)
|
INSERT INTO tmp.saleProblems(saleFk, hasItemDelay)
|
||||||
SELECT s.id, TRUE
|
SELECT s.id, TRUE
|
||||||
|
@ -140,9 +140,9 @@ BEGIN
|
||||||
AND av.calc_id = vAvailableCache
|
AND av.calc_id = vAvailableCache
|
||||||
LEFT JOIN tItemShelving tis ON tis.itemFk = i.id
|
LEFT JOIN tItemShelving tis ON tis.itemFk = i.id
|
||||||
AND tis.warehouseFk = t.warehouseFk
|
AND tis.warehouseFk = t.warehouseFk
|
||||||
WHERE (v.visible < s.quantity AND v.visible IS NOT NULL)
|
WHERE (s.quantity > v.visible AND v.visible IS NULL)
|
||||||
AND (av.available < s.quantity AND av.available IS NOT NULL)
|
AND (av.available >= 0 OR av.available IS NULL)
|
||||||
AND (tis.visible < s.quantity AND tis.visible IS NOT NULL)
|
AND (s.quantity > tis.visible AND tis.visible IS NOT NULL)
|
||||||
AND s.quantity > 0
|
AND s.quantity > 0
|
||||||
AND NOT s.isPicked
|
AND NOT s.isPicked
|
||||||
AND NOT s.reserved
|
AND NOT s.reserved
|
||||||
|
|
|
@ -18,8 +18,6 @@ BEGIN
|
||||||
FROM tmp.ticket tt
|
FROM tmp.ticket tt
|
||||||
JOIN ticket t ON t.id = tt.ticketFk
|
JOIN ticket t ON t.id = tt.ticketFk
|
||||||
JOIN sale s ON s.ticketFk = t.id
|
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;
|
GROUP BY s.id;
|
||||||
|
|
||||||
CALL sale_getProblems(vIsTodayRelative);
|
CALL sale_getProblems(vIsTodayRelative);
|
||||||
|
|
Loading…
Reference in New Issue