salix/db/routines/vn/procedures/sectorCollection_getMyParti...

19 lines
740 B
MySQL
Raw Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sectorCollection_getMyPartial`()
BEGIN
/**
* Devuelve las colecciones del sector que corresponden al usuario conectado, y que estan incompletas
*
*/
SELECT DISTINCT sc.id collectionFk, sc.created
FROM vn.sectorCollection sc
LEFT JOIN vn.sectorCollectionSaleGroup scsg ON scsg.sectorCollectionFk = sc.id
LEFT JOIN vn.saleGroupDetail sgd ON sgd.saleGroupFk = scsg.saleGroupFk
LEFT JOIN vn.sale sl ON sl.id = sgd.saleFk
LEFT JOIN itemShelvingSale iss ON iss.saleFk = sl.id
WHERE sc.userFk = account.myUser_getId()
AND (scsg.sectorCollectionFk IS NULL OR NOT iss.isPicked)
AND sc.created > util.VN_CURDATE() - INTERVAL 1 DAY;
END$$
DELIMITER ;