2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` PROCEDURE `vn`.`sectorCollection_getSale`(vSelf INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
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 ;
|