2024-05-09 05:07:10 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION vn.sectorCollection_hasSalesReserved(vSelf INT) RETURNS tinyint(1)
|
2024-05-08 08:59:19 +00:00
|
|
|
DETERMINISTIC
|
|
|
|
BEGIN
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Devuelve si sectorCollection tiene reservas
|
|
|
|
* @param vSelf Id de sectorCollection
|
|
|
|
*
|
|
|
|
* returns BOOLEAN
|
|
|
|
*/
|
|
|
|
|
|
|
|
DECLARE vHasSalesReserved BOOLEAN;
|
|
|
|
|
|
|
|
|
|
|
|
SELECT DISTINCT COUNT(*)>0 INTO vHasSalesReserved
|
|
|
|
FROM vn.sectorCollection sc
|
|
|
|
JOIN vn.sectorCollectionSaleGroup scsg ON sc.id = scsg.sectorCollectionFk
|
|
|
|
JOIN vn.saleGroup sg ON sg.id = scsg.saleGroupFk
|
|
|
|
JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = sg.id
|
|
|
|
JOIN vn.sale s ON s.id = sgd.saleFk
|
|
|
|
JOIN vn.itemShelvingSale iss ON iss.saleFk = s.id
|
|
|
|
JOIN vn.saleTracking st ON st.saleFk = s.id
|
|
|
|
WHERE sc.id = vSelf;
|
|
|
|
|
|
|
|
RETURN vHasSalesReserved;
|
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|