2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`ticketBoxesView`(IN vTicketFk INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
|
|
|
|
SELECT s.id,
|
|
|
|
s.itemFk,
|
|
|
|
s.concept,
|
|
|
|
floor(s.quantity / b.packing) as Cajas,
|
|
|
|
b.packing,
|
|
|
|
s.isPicked,
|
|
|
|
i.size
|
|
|
|
FROM ticket t
|
|
|
|
JOIN sale s ON s.ticketFk = t.id
|
|
|
|
JOIN item i ON i.id = s.itemFk
|
|
|
|
JOIN cache.last_buy lb on lb.warehouse_id = t.warehouseFk AND lb.item_id = s.itemFk
|
|
|
|
JOIN buy b on b.id = lb.buy_id
|
|
|
|
JOIN packaging p on p.id = b.packagingFk
|
|
|
|
WHERE s.quantity >= b.packing
|
|
|
|
AND t.id = vTicketFk
|
|
|
|
AND p.isBox
|
|
|
|
GROUP BY s.itemFk;
|
|
|
|
|
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|