fix: refs #7505 visible_refresh support warehouse null and added isComparative
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
5d2e9c6210
commit
a9aa47fef1
|
@ -20,10 +20,12 @@ proc:BEGIN
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.itemVisible
|
CREATE OR REPLACE TEMPORARY TABLE tmp.itemVisible
|
||||||
(PRIMARY KEY (item_id))
|
(PRIMARY KEY (item_id))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT item_id, SUM(amount) stock, SUM(amount) visible
|
SELECT s.item_id, SUM(s.amount) stock, SUM(s.amount) visible
|
||||||
FROM cache.stock
|
FROM cache.stock s
|
||||||
WHERE (v_warehouse IS NULL OR warehouse_id = v_warehouse)
|
JOIN warehouse w ON w.id = s.warehouse_id
|
||||||
GROUP BY item_id;
|
WHERE (v_warehouse IS NULL OR s.warehouse_id = v_warehouse)
|
||||||
|
AND w.isComparative
|
||||||
|
GROUP BY s.item_id;
|
||||||
|
|
||||||
-- Calculamos los movimientos confirmados de hoy
|
-- Calculamos los movimientos confirmados de hoy
|
||||||
CALL vn.item_calcVisible(NULL, v_warehouse);
|
CALL vn.item_calcVisible(NULL, v_warehouse);
|
||||||
|
|
|
@ -22,7 +22,6 @@ BEGIN
|
||||||
LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk
|
LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk
|
||||||
JOIN `state` s ON s.id = ts.stateFk
|
JOIN `state` s ON s.id = ts.stateFk
|
||||||
JOIN warehouse w ON w.id = i.warehouseFk
|
JOIN warehouse w ON w.id = i.warehouseFk
|
||||||
AND w.isComparative
|
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT DISTINCT st.saleFk
|
SELECT DISTINCT st.saleFk
|
||||||
FROM saleTracking st
|
FROM saleTracking st
|
||||||
|
@ -34,26 +33,27 @@ BEGIN
|
||||||
AND (vSelf IS NULL OR i.itemFk = vSelf)
|
AND (vSelf IS NULL OR i.itemFk = vSelf)
|
||||||
AND (s.isPicked OR i.reserved OR stPrevious.saleFk)
|
AND (s.isPicked OR i.reserved OR stPrevious.saleFk)
|
||||||
AND i.shipped >= vDated AND i.shipped < vTomorrow
|
AND i.shipped >= vDated AND i.shipped < vTomorrow
|
||||||
|
AND w.isComparative
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT iei.itemFk, iei.quantity
|
SELECT iei.itemFk, iei.quantity
|
||||||
FROM itemEntryIn iei
|
FROM itemEntryIn iei
|
||||||
JOIN warehouse w ON w.id = iei.warehouseInFk
|
JOIN warehouse w ON w.id = iei.warehouseInFk
|
||||||
AND w.isComparative
|
|
||||||
WHERE iei.isReceived
|
WHERE iei.isReceived
|
||||||
AND iei.landed >= vDated AND iei.landed < vTomorrow
|
AND iei.landed >= vDated AND iei.landed < vTomorrow
|
||||||
AND (vWarehouseFk IS NULL OR iei.warehouseInFk = vWarehouseFk)
|
AND (vWarehouseFk IS NULL OR iei.warehouseInFk = vWarehouseFk)
|
||||||
AND (vSelf IS NULL OR iei.itemFk = vSelf)
|
AND (vSelf IS NULL OR iei.itemFk = vSelf)
|
||||||
AND NOT iei.isVirtualStock
|
AND NOT iei.isVirtualStock
|
||||||
|
AND w.isComparative
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT ieo.itemFk, ieo.quantity
|
SELECT ieo.itemFk, ieo.quantity
|
||||||
FROM itemEntryOut ieo
|
FROM itemEntryOut ieo
|
||||||
JOIN warehouse w ON w.id = ieo.warehouseOutFk
|
JOIN warehouse w ON w.id = ieo.warehouseOutFk
|
||||||
AND w.isComparative
|
|
||||||
WHERE ieo.isDelivered
|
WHERE ieo.isDelivered
|
||||||
AND ieo.shipped >= vDated
|
AND ieo.shipped >= vDated
|
||||||
AND ieo.shipped < vTomorrow
|
AND ieo.shipped < vTomorrow
|
||||||
AND (vWarehouseFk IS NULL OR ieo.warehouseOutFk = vWarehouseFk)
|
AND (vWarehouseFk IS NULL OR ieo.warehouseOutFk = vWarehouseFk)
|
||||||
AND (vSelf IS NULL OR ieo.itemFk = vSelf)
|
AND (vSelf IS NULL OR ieo.itemFk = vSelf)
|
||||||
|
AND w.isComparative
|
||||||
) t
|
) t
|
||||||
GROUP BY itemFk
|
GROUP BY itemFk
|
||||||
ON DUPLICATE KEY UPDATE
|
ON DUPLICATE KEY UPDATE
|
||||||
|
|
Loading…
Reference in New Issue