2024-01-30 14:07:13 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`buy_checkItem`()
|
2024-01-30 14:07:13 +00:00
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Checks if the item has weightByPiece or size null on any buy.
|
|
|
|
*
|
|
|
|
* @param tmp.buysToCheck(id as INT).
|
|
|
|
*/
|
2024-09-09 06:28:27 +00:00
|
|
|
DECLARE vHasVolumetricAgency INT;
|
|
|
|
DECLARE vItemFk INT;
|
2024-01-30 14:07:13 +00:00
|
|
|
|
2024-09-09 06:28:27 +00:00
|
|
|
SELECT a.hasWeightVolumetric, i.id INTO vHasVolumetricAgency, vItemFk
|
2024-01-30 14:07:13 +00:00
|
|
|
FROM entry e
|
|
|
|
JOIN travel t ON t.id = e.travelFk
|
|
|
|
JOIN agencyMode a ON a.id = t.agencyModeFk
|
|
|
|
JOIN buy b ON b.entryFk = e.id
|
|
|
|
JOIN item i ON i.id = b.itemFk
|
|
|
|
JOIN tmp.buysToCheck bt ON bt.id = b.id
|
|
|
|
WHERE (i.weightByPiece IS NULL OR i.`size` IS NULL)
|
2024-01-31 13:58:08 +00:00
|
|
|
AND a.hasWeightVolumetric
|
2024-01-30 14:07:13 +00:00
|
|
|
LIMIT 1;
|
|
|
|
|
2024-09-09 06:28:27 +00:00
|
|
|
DROP TEMPORARY TABLE tmp.buysToCheck;
|
2024-01-30 14:07:13 +00:00
|
|
|
|
2024-09-09 06:28:27 +00:00
|
|
|
IF vHasVolumetricAgency THEN
|
|
|
|
CALL util.throw(CONCAT('Missing size/weight in buy line at agency, item: ', vItemFk));
|
|
|
|
END IF;
|
2024-01-30 14:07:13 +00:00
|
|
|
END$$
|
2024-09-09 06:28:27 +00:00
|
|
|
DELIMITER ;
|