32 lines
648 B
MySQL
32 lines
648 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `hedera`.`order_getTotal`(vSelf INT)
|
||
|
RETURNS decimal(10,2)
|
||
|
DETERMINISTIC
|
||
|
READS SQL DATA
|
||
|
BEGIN
|
||
|
/**
|
||
|
* Obtiene el total de un pedido con el IVA y el recargo de
|
||
|
* equivalencia incluidos.
|
||
|
*
|
||
|
* @param vSelf El identificador del pedido
|
||
|
* @return El total del pedido
|
||
|
*/
|
||
|
DECLARE vTotal DECIMAL(10,2);
|
||
|
|
||
|
DROP TEMPORARY TABLE IF EXISTS tmp.`order`;
|
||
|
CREATE TEMPORARY TABLE tmp.`order`
|
||
|
ENGINE = MEMORY
|
||
|
SELECT vSelf orderFk;
|
||
|
|
||
|
CALL order_getTotal;
|
||
|
|
||
|
SELECT total INTO vTotal FROM tmp.orderTotal;
|
||
|
|
||
|
DROP TEMPORARY TABLE
|
||
|
tmp.`order`,
|
||
|
tmp.orderTotal;
|
||
|
|
||
|
RETURN vTotal;
|
||
|
END$$
|
||
|
DELIMITER ;
|