DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`sectorCollection_getSale`(vSelf INT) BEGIN /** * Devuelve las lineas de venta correspondientes a esa coleccion de sector * * @param vSelf Identificador de vn.sectorCollection */ SELECT s.ticketFk, s.itemFk, i.longName, itemPackingTypeFk, subName, s.quantity, w.code workerCode, sgd.saleFk, iss.quantity pickedQuantity, c.salesPersonFk FROM vn.sale s JOIN item i ON i.id = s.itemFk JOIN saleGroupDetail sgd ON sgd.saleFk = s.id JOIN sectorCollectionSaleGroup scsg ON scsg.saleGroupFk = sgd.saleGroupFk JOIN saleTracking st ON st.saleFk = s.id JOIN `state` stt ON stt.id = st.stateFk AND stt.code = 'PREVIOUS_PREPARATION' JOIN worker w ON w.id = st.workerFk JOIN ticket t ON t.id= s.ticketFk JOIN client c ON c.id=t.clientFk LEFT JOIN itemShelvingSaleSum iss ON iss.saleFk = s.id WHERE scsg.sectorCollectionFk = vSelf AND st.workerFk = account.myUser_getId(); END$$ DELIMITER ;