Merge branch 'master' into 6403-fixObservation
gitea/salix/pipeline/pr-master This commit looks good
Details
gitea/salix/pipeline/pr-master This commit looks good
Details
This commit is contained in:
commit
795ca14def
|
@ -20,9 +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, amount stock, amount visible
|
SELECT s.item_id, SUM(s.amount) stock, SUM(s.amount) visible
|
||||||
FROM cache.stock
|
FROM stock s
|
||||||
WHERE warehouse_id = v_warehouse;
|
JOIN vn.warehouse w ON w.id = s.warehouse_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);
|
||||||
|
|
|
@ -21,6 +21,7 @@ BEGIN
|
||||||
FROM itemTicketOut i
|
FROM itemTicketOut i
|
||||||
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
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT DISTINCT st.saleFk
|
SELECT DISTINCT st.saleFk
|
||||||
FROM saleTracking st
|
FROM saleTracking st
|
||||||
|
@ -28,26 +29,31 @@ BEGIN
|
||||||
WHERE st.created > vDated
|
WHERE st.created > vDated
|
||||||
AND (s.isPicked OR st.isChecked)
|
AND (s.isPicked OR st.isChecked)
|
||||||
) stPrevious ON `stPrevious`.`saleFk` = i.saleFk
|
) stPrevious ON `stPrevious`.`saleFk` = i.saleFk
|
||||||
WHERE IFNULL(vWarehouseFk, i.warehouseFk) = i.warehouseFk
|
WHERE (vWarehouseFk IS NULL OR i.warehouseFk = vWarehouseFk)
|
||||||
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 itemFk, quantity
|
SELECT iei.itemFk, iei.quantity
|
||||||
FROM itemEntryIn
|
FROM itemEntryIn iei
|
||||||
WHERE isReceived
|
JOIN warehouse w ON w.id = iei.warehouseInFk
|
||||||
AND landed >= vDated AND landed < vTomorrow
|
WHERE iei.isReceived
|
||||||
AND IFNULL(vWarehouseFk, warehouseInFk) = warehouseInFk
|
AND iei.landed >= vDated AND iei.landed < vTomorrow
|
||||||
AND (vSelf IS NULL OR itemFk = vSelf)
|
AND (vWarehouseFk IS NULL OR iei.warehouseInFk = vWarehouseFk)
|
||||||
AND NOT isVirtualStock
|
AND (vSelf IS NULL OR iei.itemFk = vSelf)
|
||||||
|
AND NOT iei.isVirtualStock
|
||||||
|
AND w.isComparative
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT itemFk, quantity
|
SELECT ieo.itemFk, ieo.quantity
|
||||||
FROM itemEntryOut
|
FROM itemEntryOut ieo
|
||||||
WHERE isDelivered
|
JOIN warehouse w ON w.id = ieo.warehouseOutFk
|
||||||
AND shipped >= vDated
|
WHERE ieo.isDelivered
|
||||||
AND shipped < vTomorrow
|
AND ieo.shipped >= vDated
|
||||||
AND IFNULL(vWarehouseFk, warehouseOutFk) = warehouseOutFk
|
AND ieo.shipped < vTomorrow
|
||||||
AND (vSelf IS NULL OR itemFk = vSelf)
|
AND (vWarehouseFk IS NULL OR ieo.warehouseOutFk = vWarehouseFk)
|
||||||
|
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