2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` FUNCTION `vn`.`orderTotalVolumeBoxes`(vOrderId INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
RETURNS decimal(10,3)
|
|
|
|
NOT DETERMINISTIC
|
|
|
|
READS SQL DATA
|
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Devuelve el volumen estimado del ticket sumado, en cajas
|
|
|
|
*
|
|
|
|
* @param vOrder Id del pedido
|
|
|
|
*/
|
|
|
|
DECLARE vVolumeBoxM3 DOUBLE;
|
|
|
|
DECLARE vOrderTotalVolumeBoxes DECIMAL(10,1);
|
|
|
|
DECLARE vVnBoxId VARCHAR(10) DEFAULT '94';
|
|
|
|
|
|
|
|
SELECT volume / 1000000
|
|
|
|
INTO vVolumeBoxM3
|
|
|
|
FROM packaging
|
|
|
|
WHERE id = vVnBoxId;
|
|
|
|
|
|
|
|
SET vOrderTotalVolumeBoxes = orderTotalVolume(vOrderId) / vVolumeBoxM3;
|
|
|
|
|
|
|
|
RETURN vOrderTotalVolumeBoxes;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|