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
|
||||
(PRIMARY KEY (item_id))
|
||||
ENGINE = MEMORY
|
||||
SELECT item_id, amount stock, amount visible
|
||||
FROM cache.stock
|
||||
WHERE warehouse_id = v_warehouse;
|
||||
SELECT s.item_id, SUM(s.amount) stock, SUM(s.amount) visible
|
||||
FROM stock s
|
||||
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
|
||||
CALL vn.item_calcVisible(NULL, v_warehouse);
|
||||
|
|
|
@ -21,6 +21,7 @@ BEGIN
|
|||
FROM itemTicketOut i
|
||||
LEFT JOIN ticketState ts ON ts.ticketFk = i.ticketFk
|
||||
JOIN `state` s ON s.id = ts.stateFk
|
||||
JOIN warehouse w ON w.id = i.warehouseFk
|
||||
LEFT JOIN (
|
||||
SELECT DISTINCT st.saleFk
|
||||
FROM saleTracking st
|
||||
|
@ -28,26 +29,31 @@ BEGIN
|
|||
WHERE st.created > vDated
|
||||
AND (s.isPicked OR st.isChecked)
|
||||
) 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 (s.isPicked OR i.reserved OR stPrevious.saleFk)
|
||||
AND i.shipped >= vDated AND i.shipped < vTomorrow
|
||||
AND w.isComparative
|
||||
UNION ALL
|
||||
SELECT itemFk, quantity
|
||||
FROM itemEntryIn
|
||||
WHERE isReceived
|
||||
AND landed >= vDated AND landed < vTomorrow
|
||||
AND IFNULL(vWarehouseFk, warehouseInFk) = warehouseInFk
|
||||
AND (vSelf IS NULL OR itemFk = vSelf)
|
||||
AND NOT isVirtualStock
|
||||
SELECT iei.itemFk, iei.quantity
|
||||
FROM itemEntryIn iei
|
||||
JOIN warehouse w ON w.id = iei.warehouseInFk
|
||||
WHERE iei.isReceived
|
||||
AND iei.landed >= vDated AND iei.landed < vTomorrow
|
||||
AND (vWarehouseFk IS NULL OR iei.warehouseInFk = vWarehouseFk)
|
||||
AND (vSelf IS NULL OR iei.itemFk = vSelf)
|
||||
AND NOT iei.isVirtualStock
|
||||
AND w.isComparative
|
||||
UNION ALL
|
||||
SELECT itemFk, quantity
|
||||
FROM itemEntryOut
|
||||
WHERE isDelivered
|
||||
AND shipped >= vDated
|
||||
AND shipped < vTomorrow
|
||||
AND IFNULL(vWarehouseFk, warehouseOutFk) = warehouseOutFk
|
||||
AND (vSelf IS NULL OR itemFk = vSelf)
|
||||
SELECT ieo.itemFk, ieo.quantity
|
||||
FROM itemEntryOut ieo
|
||||
JOIN warehouse w ON w.id = ieo.warehouseOutFk
|
||||
WHERE ieo.isDelivered
|
||||
AND ieo.shipped >= vDated
|
||||
AND ieo.shipped < vTomorrow
|
||||
AND (vWarehouseFk IS NULL OR ieo.warehouseOutFk = vWarehouseFk)
|
||||
AND (vSelf IS NULL OR ieo.itemFk = vSelf)
|
||||
AND w.isComparative
|
||||
) t
|
||||
GROUP BY itemFk
|
||||
ON DUPLICATE KEY UPDATE
|
||||
|
|
Loading…
Reference in New Issue