diff --git a/db/routines/vn/procedures/item_getMinacum.sql b/db/routines/vn/procedures/item_getMinacum.sql index 2b51355d5..1decf881d 100644 --- a/db/routines/vn/procedures/item_getMinacum.sql +++ b/db/routines/vn/procedures/item_getMinacum.sql @@ -8,7 +8,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getMinacum`( BEGIN /** * 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 vDated Fecha inicio @@ -47,7 +47,7 @@ BEGIN JOIN travel t ON t.id = e.travelFk WHERE t.landed BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk) - AND !e.isExcludedFromAvailable + AND NOT e.isExcludedFromAvailable AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) UNION ALL @@ -60,10 +60,10 @@ BEGIN JOIN travel t ON t.id = e.travelFk WHERE t.shipped BETWEEN vDated AND vDatedTo AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk) - AND !e.isExcludedFromAvailable + AND NOT e.isExcludedFromAvailable AND b.quantity <> 0 AND (vItemFk IS NULL OR b.itemFk = vItemFk) - AND !e.isRaid + AND NOT e.isRaid UNION ALL SELECT r.itemFk, r.shipment, @@ -71,11 +71,11 @@ BEGIN r.warehouseFk FROM hedera.orderRow r 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 AND (vWarehouseFk IS NULL OR r.warehouseFk = vWarehouseFk) AND r.created >= ( - SELECT SUBTIME(util.VN_NOW(), reserveTime) + SELECT util.VN_NOW() - INTERVAL TIME_TO_SEC(reserveTime) SECOND FROM hedera.orderConfig ) AND NOT o.confirmed @@ -89,11 +89,11 @@ BEGIN CREATE OR REPLACE TEMPORARY TABLE tmp.itemMinacum (INDEX(itemFk)) ENGINE = MEMORY - SELECT i.itemFk, - i.warehouseFk, - i.quantity amount - FROM tmp.itemAtp i - HAVING amount <> 0; + SELECT itemFk, + warehouseFk, + quantity amount + FROM tmp.itemAtp + WHERE quantity <> 0; DROP TEMPORARY TABLE tmp.itemAtp,