hotFix(ticket): refs #7225 fix advanced and movable
gitea/salix/pipeline/pr-master There was a failure building this commit
Details
gitea/salix/pipeline/pr-master There was a failure building this commit
Details
This commit is contained in:
parent
6f0038e4cc
commit
cc06698214
|
@ -8,38 +8,14 @@ BEGIN
|
|||
* @param vDateToAdvance Fecha a cuando se quiere adelantar.
|
||||
* @param vWarehouseFk Almacén
|
||||
*/
|
||||
DECLARE vDateInventory DATE;
|
||||
|
||||
SELECT inventoried INTO vDateInventory FROM config;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.stock
|
||||
(itemFk INT PRIMARY KEY,
|
||||
amount INT)
|
||||
ENGINE = MEMORY;
|
||||
|
||||
INSERT INTO tmp.stock(itemFk, amount)
|
||||
SELECT itemFk, SUM(quantity) amount FROM
|
||||
(
|
||||
SELECT itemFk, quantity
|
||||
FROM itemTicketOut
|
||||
WHERE shipped >= vDateInventory
|
||||
AND shipped < vDateFuture
|
||||
AND warehouseFk = vWarehouseFk
|
||||
UNION ALL
|
||||
SELECT itemFk, quantity
|
||||
FROM itemEntryIn
|
||||
WHERE landed >= vDateInventory
|
||||
AND landed <= vDateToAdvance
|
||||
AND isVirtualStock = FALSE
|
||||
AND warehouseInFk = vWarehouseFk
|
||||
UNION ALL
|
||||
SELECT itemFk, quantity
|
||||
FROM itemEntryOut
|
||||
WHERE shipped >= vDateInventory
|
||||
AND shipped < vDateFuture
|
||||
AND warehouseOutFk = vWarehouseFk
|
||||
) t
|
||||
GROUP BY itemFk HAVING amount != 0;
|
||||
CALL item_getStock(vWarehouseFk, vDateToAdvance, NULL);
|
||||
CALL item_getMinacum(
|
||||
vWarehouseFk,
|
||||
vDateToAdvance,
|
||||
DATEDIFF(DATE_SUB(vDateFuture, INTERVAL 1 DAY), vDateToAdvance),
|
||||
NULL
|
||||
);
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.filter
|
||||
(INDEX (id))
|
||||
|
@ -87,7 +63,7 @@ BEGIN
|
|||
count(s.id) futureLines,
|
||||
GROUP_CONCAT(DISTINCT ipt.code ORDER BY ipt.code) futureIpt,
|
||||
CAST(SUM(litros) AS DECIMAL(10,0)) futureLiters,
|
||||
SUM((s.quantity <= IFNULL(st.amount,0))) hasStock,
|
||||
SUM(s.quantity <= (IFNULL(il.stock,0) + IFNULL(im.amount, 0))) hasStock,
|
||||
z.id futureZoneFk,
|
||||
z.name futureZoneName,
|
||||
st.classColor,
|
||||
|
@ -107,7 +83,9 @@ BEGIN
|
|||
JOIN agencyMode am ON t.agencyModeFk = am.id
|
||||
JOIN zone z ON t.zoneFk = z.id
|
||||
LEFT JOIN itemPackingType ipt ON ipt.code = i.itemPackingTypeFk
|
||||
LEFT JOIN tmp.stock st ON st.itemFk = i.id
|
||||
LEFT JOIN tmp.itemMinacum im ON im.itemFk = i.id
|
||||
AND im.warehouseFk = vWarehouseFk
|
||||
LEFT JOIN tmp.itemList il ON il.itemFk = i.id
|
||||
WHERE t.shipped BETWEEN vDateFuture AND util.dayend(vDateFuture)
|
||||
AND t.warehouseFk = vWarehouseFk
|
||||
GROUP BY t.id
|
||||
|
@ -146,6 +124,8 @@ BEGIN
|
|||
) dest ON dest.addressFk = origin.addressFk
|
||||
WHERE origin.hasStock;
|
||||
|
||||
DROP TEMPORARY TABLE tmp.stock;
|
||||
DROP TEMPORARY TABLE IF EXISTS
|
||||
tmp.itemList,
|
||||
tmp.itemMinacum;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
|
@ -21,7 +21,7 @@ BEGIN
|
|||
WHERE t.id = vTicketFk;
|
||||
|
||||
-- Añadimos un dia más para calcular el stock hasta vNewShipped inclusive
|
||||
CALL item_getStock(vWarehouseFk, DATE_ADD(vNewShipped, INTERVAL 1 DAY), NULL);
|
||||
CALL item_getStock(vWarehouseFk, vNewShipped, NULL);
|
||||
CALL item_getMinacum(
|
||||
vWarehouseFk,
|
||||
vNewShipped,
|
||||
|
|
Loading…
Reference in New Issue