salix/db/routines/vn/procedures/travel_updatePacking.sql

30 lines
780 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_updatePacking`(vItemFk INT, vPacking INT)
BEGIN
/**
* Actualiza packing para los movimientos de almacén de la subasta al almacén central
*
* @param vItemFk id del item
* @param vPacking nuevo packing
*/
DECLARE vAuctionWarehouseFk INT;
DECLARE vMainWarehouseFk INT;
SELECT warehouseFk INTO vAuctionWarehouseFk
FROM auctionConfig;
SELECT mainWarehouseFk INTO vMainWarehouseFk
FROM config;
UPDATE entry e
JOIN travel t ON t.id = e.travelFk
JOIN buy b on b.entryFk = e.id
SET b.packing = vPacking
WHERE t.shipped >= util.dayEnd(CURDATE())
AND t.warehouseInFk = vMainWarehouseFk
AND t.warehouseOutFk = vAuctionWarehouseFk
AND b.itemFk = vItemFk;
END$$
DELIMITER ;