feat: refs #6822 changes transaction
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
bb36667616
commit
5f63017853
|
@ -17,10 +17,11 @@ BEGIN
|
|||
RESIGNAL;
|
||||
END;
|
||||
|
||||
START TRANSACTION;
|
||||
-- Clonar la entrada
|
||||
CALL entry_clone(vOriginalEntry,vNewEntryFk);
|
||||
|
||||
START TRANSACTION;
|
||||
|
||||
-- Hay que crear un nuevo travel, con salida hoy y llegada mañana y asignar la entrada nueva al nuevo travel.
|
||||
INSERT INTO travel(
|
||||
shipped,
|
||||
|
@ -68,8 +69,8 @@ BEGIN
|
|||
WHERE e.id = vOriginalEntry;
|
||||
|
||||
-- Actualizar la nueva entrada con lo que no está ubicado HOY, descontando lo vendido HOY de esas ubicaciones
|
||||
UPDATE buy b
|
||||
JOIN (
|
||||
CREATE OR REPLACE TEMPORARY TABLE tBuy
|
||||
ENGINE = MEMORY
|
||||
SELECT tBuy.itemFk, IFNULL(iss.visible,0) visible, tBuy.totalQuantity, IFNULL(sales.sold,0) sold
|
||||
FROM (SELECT b.itemFk, SUM(b.quantity) totalQuantity
|
||||
FROM buy b
|
||||
|
@ -96,8 +97,10 @@ BEGIN
|
|||
AND s2.parked = util.VN_CURDATE()
|
||||
GROUP BY s.itemFk) sales ON sales.itemFk = tBuy.itemFk
|
||||
WHERE visible = tBuy.totalQuantity
|
||||
OR iss.itemFk IS NULL
|
||||
) sub ON sub.itemFk = b.itemFk
|
||||
OR iss.itemFk IS NULL;
|
||||
|
||||
UPDATE buy b
|
||||
JOIN (SELECT * FROM tBuy) sub ON sub.itemFk = b.itemFk
|
||||
SET b.quantity = sub.totalQuantity - sub.visible - sub.sold
|
||||
WHERE b.entryFk = vNewEntryFk;
|
||||
|
||||
|
@ -107,10 +110,12 @@ BEGIN
|
|||
WHERE b.entryFk = vNewEntryFk
|
||||
AND b.quantity = 0;
|
||||
|
||||
COMMIT;
|
||||
|
||||
SET vNewEntry = vNewEntryFk;
|
||||
|
||||
CALL cache.visible_refresh(@c,TRUE,7);
|
||||
CALL cache.available_refresh(@c, TRUE, 7, util.VN_CURDATE());
|
||||
COMMIT;
|
||||
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
Loading…
Reference in New Issue