2024-01-30 14:07:13 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_checkItem`()
|
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Checks if the item has weightByPiece or size null on any buy.
|
|
|
|
*
|
|
|
|
* @param tmp.buysToCheck(id as INT).
|
|
|
|
*/
|
|
|
|
DECLARE hasVolumetricAgency INT;
|
|
|
|
|
|
|
|
SELECT a.hasWeightVolumetric INTO hasVolumetricAgency
|
|
|
|
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;
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE IF EXISTS tmp.buysToCheck;
|
|
|
|
|
|
|
|
IF hasVolumetricAgency THEN
|
|
|
|
CALL util.throw('Some purchase line has an item without size or weight per stem in the volumetric agency.');
|
|
|
|
END IF;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|