2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getUnitVolume`(vSelf INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
RETURNS int(11)
|
|
|
|
DETERMINISTIC
|
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Calculates the unit volume occupied by a buy.
|
|
|
|
*
|
|
|
|
* @param vSelf The buy id
|
|
|
|
* @return The unit volume in cubic centimeters
|
|
|
|
*/
|
|
|
|
DECLARE vItem INT;
|
|
|
|
DECLARE vPackaging VARCHAR(10);
|
|
|
|
DECLARE vPacking INT;
|
|
|
|
|
|
|
|
SELECT itemFk, packagingFk, packing
|
|
|
|
INTO vItem, vPackaging, vPacking
|
|
|
|
FROM buy
|
|
|
|
WHERE id = vSelf;
|
|
|
|
|
|
|
|
RETURN IFNULL(ROUND(item_getVolume(vItem, vPackaging) / vPacking), 0);
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|