This commit is contained in:
parent
961d05ab35
commit
cc78355aad
|
@ -8,7 +8,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getMinacum`(
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Cálculo del mínimo acumulado, para un item/almacén
|
* Cálculo del mínimo acumulado, para un item/almacén
|
||||||
* especificado, en caso de NULL para todo.
|
* especificado, en caso de NULL para todos.
|
||||||
*
|
*
|
||||||
* @param vWarehouseFk Id warehouse
|
* @param vWarehouseFk Id warehouse
|
||||||
* @param vDated Fecha inicio
|
* @param vDated Fecha inicio
|
||||||
|
@ -47,7 +47,7 @@ BEGIN
|
||||||
JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
WHERE t.landed BETWEEN vDated AND vDatedTo
|
WHERE t.landed BETWEEN vDated AND vDatedTo
|
||||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||||
AND !e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND b.quantity <> 0
|
AND b.quantity <> 0
|
||||||
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
|
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
@ -60,10 +60,10 @@ BEGIN
|
||||||
JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
WHERE t.shipped BETWEEN vDated AND vDatedTo
|
WHERE t.shipped BETWEEN vDated AND vDatedTo
|
||||||
AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk)
|
AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk)
|
||||||
AND !e.isExcludedFromAvailable
|
AND NOT e.isExcludedFromAvailable
|
||||||
AND b.quantity <> 0
|
AND b.quantity <> 0
|
||||||
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
|
AND (vItemFk IS NULL OR b.itemFk = vItemFk)
|
||||||
AND !e.isRaid
|
AND NOT e.isRaid
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT r.itemFk,
|
SELECT r.itemFk,
|
||||||
r.shipment,
|
r.shipment,
|
||||||
|
@ -71,11 +71,11 @@ BEGIN
|
||||||
r.warehouseFk
|
r.warehouseFk
|
||||||
FROM hedera.orderRow r
|
FROM hedera.orderRow r
|
||||||
JOIN hedera.`order` o ON o.id = r.orderFk
|
JOIN hedera.`order` o ON o.id = r.orderFk
|
||||||
JOIN vn.client c ON c.id = o.customer_id
|
JOIN client c ON c.id = o.customer_id
|
||||||
WHERE r.shipment BETWEEN vDated AND vDatedTo
|
WHERE r.shipment BETWEEN vDated AND vDatedTo
|
||||||
AND (vWarehouseFk IS NULL OR r.warehouseFk = vWarehouseFk)
|
AND (vWarehouseFk IS NULL OR r.warehouseFk = vWarehouseFk)
|
||||||
AND r.created >= (
|
AND r.created >= (
|
||||||
SELECT SUBTIME(util.VN_NOW(), reserveTime)
|
SELECT util.VN_NOW() - INTERVAL TIME_TO_SEC(reserveTime) SECOND
|
||||||
FROM hedera.orderConfig
|
FROM hedera.orderConfig
|
||||||
)
|
)
|
||||||
AND NOT o.confirmed
|
AND NOT o.confirmed
|
||||||
|
@ -89,11 +89,11 @@ BEGIN
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.itemMinacum
|
CREATE OR REPLACE TEMPORARY TABLE tmp.itemMinacum
|
||||||
(INDEX(itemFk))
|
(INDEX(itemFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
SELECT i.itemFk,
|
SELECT itemFk,
|
||||||
i.warehouseFk,
|
warehouseFk,
|
||||||
i.quantity amount
|
quantity amount
|
||||||
FROM tmp.itemAtp i
|
FROM tmp.itemAtp
|
||||||
HAVING amount <> 0;
|
WHERE quantity <> 0;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE
|
DROP TEMPORARY TABLE
|
||||||
tmp.itemAtp,
|
tmp.itemAtp,
|
||||||
|
|
Loading…
Reference in New Issue