update structure

This commit is contained in:
Bernat 2018-07-19 09:44:58 +02:00
parent fb81c473c1
commit eb159453cf
4 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,20 @@
USE `vn`;
DROP function IF EXISTS `orderTotalVolume`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` FUNCTION `orderTotalVolume`(vOrderId INT) RETURNS decimal(10,3)
BEGIN
-- Devuelte el volumen total de la orden sumada
DECLARE vWarehouseId INTEGER;
DECLARE vVolume DECIMAL(10,3);
SELECT IFNULL(SUM(o.amount * r.cm3)/1000000,0) INTO vVolume
FROM hedera.orderRow o
JOIN bi.rotacion r on r.Id_Article = o.itemFk AND r.warehouse_id = o.warehouseFk
WHERE o.orderFk = vOrderId;
RETURN vVolume;
END$$
DELIMITER ;

View File

@ -0,0 +1,27 @@
USE `vn`;
DROP function IF EXISTS `orderTotalVolumeBoxes`;
DELIMITER $$
USE `vn`$$
CREATE DEFINER=`root`@`%` FUNCTION `orderTotalVolumeBoxes`(vOrderId INT) RETURNS decimal(10,3)
BEGIN
/*
* Devuelve el volumen estimado del ticket sumado, en cajas
*
* idT Numero de ticket
*
*/
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 ;