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

34 lines
823 B
MySQL
Raw Normal View History

2024-01-31 06:11:03 +00:00
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`itemShelvingSale_setPicked`(
2024-01-31 06:11:03 +00:00
vSaleGroupFk INT(10)
)
BEGIN
/**
* Gestiona la reserva de un vn.saleGroup actualizando vn.itemShelvingSale.isPicked
* y cambiando el estado de la vn.sale
*
* @param vSaleGroupFk Id saleGroupFk
*/
DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
IF NOT (SELECT COUNT(*) FROM saleGroup WHERE id = vSaleGroupFk) THEN
CALL util.throw('Sale group not exists');
END IF;
START TRANSACTION;
UPDATE itemShelvingSale iss
JOIN sale s ON s.id = iss.saleFk
JOIN saleGroupDetail sg ON sg.saleFk = s.id
SET iss.isPicked = TRUE
WHERE sg.saleGroupFk = vSaleGroupFk;
CALL saleTracking_addPreparedSaleGroup(vSaleGroupFk);
COMMIT;
END$$
DELIMITER ;