refactor: refs #7505 item_getVisible refactor #2573

Merged
guillermo merged 13 commits from 7505-item_calcVisible into dev 2024-07-10 05:03:19 +00:00
3 changed files with 21 additions and 22 deletions
Showing only changes of commit 7279feab12 - Show all commits

View File

@ -25,7 +25,7 @@ proc: BEGIN
WHERE warehouse_id = v_warehouse;
-- Calculamos los movimientos confirmados de hoy
CALL vn.item_calcVisible(v_warehouse, util.VN_CURDATE(), NULL);
CALL vn.item_calcVisible(NULL, util.VN_CURDATE(), v_warehouse);
DELETE FROM visible WHERE calc_id = v_calc;
INSERT INTO visible (calc_id, item_id,visible)
guillermo marked this conversation as resolved
Review

el visible no es guarda per dia, no es pot calcular per dia. Tampoc aporta res. El concepte "visible per dia" seria l'stock .

el visible no es guarda per dia, no es pot calcular per dia. Tampoc aporta res. El concepte "visible per dia" seria l'stock .

View File

@ -1,8 +1,8 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`item_calcVisible`(
vWarehouseFk INT,
vDated INT,
vItemFk INT
vSelf INT,
vDated DATE,
vWarehouseFk INT
)
BEGIN
/**
@ -10,7 +10,7 @@ BEGIN
*
* @param vWarehouse Warehouse id
* @param vDated Max date to filter
* @param vItemFk Item id
* @param vSelf Item id
* @param tmp.itemVisible(item_id, stock, visible)
*/
DECLARE vTomorrow DATETIME DEFAULT vDated + INTERVAL 1 DAY;
@ -29,8 +29,8 @@ BEGIN
WHERE st.created > vDated
AND (s.isPicked OR st.isChecked)
) stPrevious ON `stPrevious`.`saleFk` = i.saleFk
WHERE i.warehouseFk = vWarehouseFk
AND (vItemFk IS NULL OR i.itemFk = vItemFk)
WHERE IFNULL(vWarehouseFk, i.warehouseFk) = i.warehouseFk
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
UNION ALL
@ -38,8 +38,8 @@ BEGIN
FROM itemEntryIn
WHERE isReceived
AND landed >= vDated AND landed < vTomorrow
AND warehouseInFk = vWarehouseFk
AND (vItemFk IS NULL OR itemFk = vItemFk)
AND IFNULL(vWarehouseFk, warehouseInFk) = warehouseInFk
AND (vSelf IS NULL OR itemFk = vSelf)
AND NOT isVirtualStock
UNION ALL
SELECT itemFk, quantity
@ -47,8 +47,8 @@ BEGIN
WHERE isDelivered
AND shipped >= vDated
AND shipped < vTomorrow
AND warehouseOutFk = vWarehouseFk
AND (vItemFk IS NULL OR itemFk = vItemFk)
AND IFNULL(vWarehouseFk, warehouseOutFk) = warehouseOutFk
AND (vSelf IS NULL OR itemFk = vSelf)
) t
GROUP BY itemFk
ON DUPLICATE KEY UPDATE

View File

@ -83,19 +83,19 @@ proc: BEGIN
ai.sd = iic.quantity;
-- Cálculo del visible
CALL cache.visible_refresh(vCalc, FALSE, vWarehouseFk);
CALL cache.stock_refresh(false);
CREATE OR REPLACE TEMPORARY TABLE tItemVisibleCalc
CREATE OR REPLACE TEMPORARY TABLE tmp.itemVisible
(PRIMARY KEY (item_id))
ENGINE = MEMORY
SELECT item_id, visible
FROM cache.visible
WHERE calc_id = vCalc;
SELECT item_id, amount stock, amount visible
FROM cache.stock
WHERE warehouse_id = vWarehouseFk;
CALL item_calcVisible(vWarehouseFk, util.VN_CURDATE(), NULL);
CALL item_calcVisible(NULL, vWarehouseFk, util.VN_CURDATE());
UPDATE tmp.itemInventory it
JOIN tItemVisibleCalc ivc ON ivc.item_id = it.id
SET it.visible = it.visible + ivc.visible;
JOIN tmp.itemVisible iv ON iv.item_id = it.id
SET it.visible = it.visible + iv.visible;
-- Calculo del disponible
CREATE OR REPLACE TEMPORARY TABLE tmp.itemCalc
@ -168,7 +168,6 @@ proc: BEGIN
tmp.itemCalc,
tmp.itemAtp,
tItemInventoryCalc,
tItemVisibleCalc,
tmp.itemAtp;
tmp.itemVisible;
END$$
DELIMITER ;