30 lines
780 B
SQL
30 lines
780 B
SQL
DELIMITER $$
|
|
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 ;
|