feat: refs #6769 Requested changes
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
a82f7bc025
commit
dab386326f
|
@ -33,35 +33,6 @@ BEGIN
|
|||
CALL util.throw('Config variables are not set');
|
||||
END IF;
|
||||
|
||||
-- Calcula el ultimo dia de vida para cada producto
|
||||
-- Tiene tmp a propósito, porque si no falla al utilizarlo en el WITH
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.itemRange
|
||||
(PRIMARY KEY (itemFk))
|
||||
ENGINE = MEMORY
|
||||
SELECT i.id itemFk,
|
||||
util.dayEnd(c.maxLanded + INTERVAL it.life DAY) ended,
|
||||
it.life
|
||||
FROM item i
|
||||
LEFT JOIN (
|
||||
SELECT b.itemFk, MAX(t.landed) maxLanded
|
||||
FROM buy b
|
||||
JOIN entry e ON b.entryFk = e.id
|
||||
JOIN travel t ON t.id = e.travelFk
|
||||
JOIN warehouse w ON w.id = t.warehouseInFk
|
||||
JOIN item i ON i.id = b.itemFk
|
||||
JOIN itemType it ON it.id = i.typeFk
|
||||
WHERE t.landed BETWEEN vLifeScope AND vDateInventory
|
||||
AND t.warehouseInFk = vWarehouseFk
|
||||
AND t.warehouseOutFk <> vWarehouseInventoryFk
|
||||
AND it.life
|
||||
AND i.id = vItemFk
|
||||
AND NOT e.isExcludedFromAvailable
|
||||
GROUP BY b.itemFk
|
||||
) c ON i.id = c.itemFk
|
||||
JOIN itemType it ON it.id = i.typeFk
|
||||
WHERE i.id = vItemFk
|
||||
HAVING ended >= vDateInventory OR life IS NULL;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tItemDiary
|
||||
ENGINE = MEMORY
|
||||
WITH entriesIn AS (
|
||||
|
@ -210,10 +181,8 @@ BEGIN
|
|||
NULL
|
||||
FROM hedera.orderRow r
|
||||
JOIN hedera.`order` o ON o.id = r.orderFk
|
||||
JOIN tmp.itemRange ir ON ir.itemFk = r.itemFk
|
||||
JOIN vn.client c ON c.id = o.customer_id
|
||||
WHERE r.shipment >= vDateInventory
|
||||
AND (ir.ended IS NULL OR r.shipment <= ir.ended)
|
||||
AND r.warehouseFk = vWarehouseFk
|
||||
AND r.created >= (
|
||||
SELECT SUBTIME(util.VN_NOW(), reserveTime)
|
||||
|
@ -315,8 +284,6 @@ BEGIN
|
|||
WHERE shipped >= vDated;
|
||||
END IF;
|
||||
|
||||
DROP TEMPORARY TABLE
|
||||
tItemDiary,
|
||||
tmp.itemRange;
|
||||
DROP TEMPORARY TABLE tItemDiary;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
Loading…
Reference in New Issue