2024-03-18 16:51:35 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE
|
2024-05-23 14:35:36 +00:00
|
|
|
`vn`.`itemShelvingSale_addBySectorCollection`(vSectorCollectionFk INT(11))
|
2024-03-18 16:51:35 +00:00
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Reserva cantidades con ubicaciones para el contenido de una preparación previa
|
|
|
|
* de la cual ya tiene generada la asociación del saleGroup con sectorCollection
|
|
|
|
*
|
|
|
|
* @param vSectorCollectionFk Identificador de sectorCollection
|
|
|
|
*/
|
2024-05-23 14:35:36 +00:00
|
|
|
DECLARE vDone BOOL DEFAULT FALSE;
|
|
|
|
DECLARE vSaleFk INT;
|
2024-07-17 14:09:09 +00:00
|
|
|
DECLARE vSectorFk INT;
|
2024-05-23 14:35:36 +00:00
|
|
|
DECLARE vSales CURSOR FOR
|
2024-08-13 09:37:08 +00:00
|
|
|
SELECT DISTINCT s.id
|
2024-03-18 16:51:35 +00:00
|
|
|
FROM sectorCollectionSaleGroup sc
|
|
|
|
JOIN saleGroupDetail sg ON sg.saleGroupFk = sc.saleGroupFk
|
|
|
|
JOIN sale s ON sg.saleFk = s.id
|
|
|
|
JOIN saleTracking str ON str.saleFk = s.id
|
|
|
|
JOIN `state` st ON st.id = str.stateFk
|
|
|
|
AND st.code = 'PREVIOUS_PREPARATION'
|
2024-05-08 08:59:19 +00:00
|
|
|
LEFT JOIN itemShelvingSale iss ON iss.saleFk = s.id
|
2024-03-18 16:51:35 +00:00
|
|
|
WHERE sc.sectorCollectionFk = vSectorCollectionFk
|
2024-05-08 08:59:19 +00:00
|
|
|
AND str.workerFk = account.myUser_getId()
|
|
|
|
AND iss.id IS NULL;
|
|
|
|
|
2024-05-23 14:35:36 +00:00
|
|
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
|
|
|
|
2024-07-17 14:09:09 +00:00
|
|
|
SELECT sectorFk INTO vSectorFk
|
|
|
|
FROM operator
|
|
|
|
WHERE workerFk = account.myUser_getId();
|
|
|
|
|
2024-09-11 05:08:36 +00:00
|
|
|
CALL util.debugAdd('itemShelvingSale_addBySectorCollection',CONCAT(vSectorCollectionFk,' - ', account.myUser_getId()));
|
|
|
|
|
2024-05-23 14:35:36 +00:00
|
|
|
OPEN vSales;
|
|
|
|
l: LOOP
|
|
|
|
SET vDone = FALSE;
|
|
|
|
FETCH vSales INTO vSaleFk;
|
|
|
|
|
|
|
|
IF vDone THEN
|
|
|
|
LEAVE l;
|
|
|
|
END IF;
|
2024-03-18 16:51:35 +00:00
|
|
|
|
2024-07-17 14:09:09 +00:00
|
|
|
CALL itemShelvingSale_addBySale(vSaleFk, vSectorFk);
|
2024-05-23 14:35:36 +00:00
|
|
|
END LOOP;
|
|
|
|
CLOSE vSales;
|
2024-03-18 16:51:35 +00:00
|
|
|
END$$
|
2024-05-23 14:35:36 +00:00
|
|
|
DELIMITER ;
|