7631_testToMaster_2426 #2634
|
@ -1,5 +1,5 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getAtp`(vDated DATE)
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_getAtp`(vDated DATE)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Calcula el valor mínimo acumulado para cada artículo ordenado por fecha y
|
* Calcula el valor mínimo acumulado para cada artículo ordenado por fecha y
|
||||||
|
@ -44,5 +44,5 @@ BEGIN
|
||||||
GROUP BY itemFk, wareHouseFk;
|
GROUP BY itemFk, wareHouseFk;
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tItemOrdered;
|
DROP TEMPORARY TABLE tItemOrdered;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -30,6 +30,7 @@ BEGIN
|
||||||
FROM sale s
|
FROM sale s
|
||||||
JOIN ticket t ON t.id = s.ticketFk
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo
|
WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo
|
||||||
|
AND t.warehouseFk
|
||||||
AND s.quantity != 0
|
AND s.quantity != 0
|
||||||
AND (vItemFk IS NULL OR s.itemFk = vItemFk)
|
AND (vItemFk IS NULL OR s.itemFk = vItemFk)
|
||||||
AND (vWarehouseFk IS NULL OR t.warehouseFk = vWarehouseFk)
|
AND (vWarehouseFk IS NULL OR t.warehouseFk = vWarehouseFk)
|
||||||
|
@ -40,7 +41,7 @@ BEGIN
|
||||||
t.warehouseInFk
|
t.warehouseInFk
|
||||||
FROM buy b
|
FROM buy b
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
LEFT JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
WHERE t.landed BETWEEN vDatedFrom AND vDatedTo
|
WHERE t.landed BETWEEN vDatedFrom AND vDatedTo
|
||||||
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
AND (vWarehouseFk IS NULL OR t.warehouseInFk = vWarehouseFk)
|
||||||
AND !e.isExcludedFromAvailable
|
AND !e.isExcludedFromAvailable
|
||||||
|
@ -53,7 +54,7 @@ BEGIN
|
||||||
t.warehouseOutFk
|
t.warehouseOutFk
|
||||||
FROM buy b
|
FROM buy b
|
||||||
JOIN entry e ON e.id = b.entryFk
|
JOIN entry e ON e.id = b.entryFk
|
||||||
LEFT JOIN travel t ON t.id = e.travelFk
|
JOIN travel t ON t.id = e.travelFk
|
||||||
WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo
|
WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo
|
||||||
AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk)
|
AND (vWarehouseFk IS NULL OR t.warehouseOutFk = vWarehouseFk)
|
||||||
AND !e.isExcludedFromAvailable
|
AND !e.isExcludedFromAvailable
|
||||||
|
|
|
@ -21,9 +21,6 @@ BEGIN
|
||||||
|
|
||||||
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated);
|
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated);
|
||||||
|
|
||||||
-- Añadido temporalmente para que no se cuelgue la db
|
|
||||||
SET vShowType = TRUE;
|
|
||||||
|
|
||||||
WITH itemTags AS (
|
WITH itemTags AS (
|
||||||
SELECT i.id,
|
SELECT i.id,
|
||||||
typeFk,
|
typeFk,
|
||||||
|
@ -38,7 +35,7 @@ BEGIN
|
||||||
t.name,
|
t.name,
|
||||||
it.value
|
it.value
|
||||||
FROM vn.item i
|
FROM vn.item i
|
||||||
LEFT JOIN vn.itemTag it ON it.itemFk = i.id
|
LEFT JOIN vn.itemTag it FORCE INDEX(itemTagItemPriority) ON it.itemFk = i.id
|
||||||
AND it.priority = vPriority
|
AND it.priority = vPriority
|
||||||
LEFT JOIN vn.tag t ON t.id = it.tagFk
|
LEFT JOIN vn.tag t ON t.id = it.tagFk
|
||||||
WHERE i.id = vSelf
|
WHERE i.id = vSelf
|
||||||
|
@ -68,7 +65,7 @@ BEGIN
|
||||||
iss.visible located,
|
iss.visible located,
|
||||||
b.price2
|
b.price2
|
||||||
FROM vn.item i
|
FROM vn.item i
|
||||||
JOIN cache.available a ON a.item_id = i.id
|
JOIN cache.available a FORCE INDEX (calc_id) ON a.item_id = i.id
|
||||||
AND a.calc_id = vCalcFk
|
AND a.calc_id = vCalcFk
|
||||||
LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id
|
LEFT JOIN vn.itemProposal ip ON ip.mateFk = i.id
|
||||||
AND ip.itemFk = vSelf
|
AND ip.itemFk = vSelf
|
||||||
|
|
Loading…
Reference in New Issue