37 lines
670 B
SQL
37 lines
670 B
SQL
USE `hedera`;
|
|
DROP FUNCTION IF EXISTS `orderGetTotal`;
|
|
|
|
DELIMITER $$
|
|
USE `hedera`$$
|
|
|
|
CREATE DEFINER=`root`@`%` FUNCTION `orderGetTotal`(vOrder INT) RETURNS decimal(10,2)
|
|
READS SQL DATA
|
|
DETERMINISTIC
|
|
BEGIN
|
|
/**
|
|
* Obtiene el total de un pedido con el IVA y el recargo de
|
|
* equivalencia incluidos.
|
|
*
|
|
* @param vOrder 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 vOrder orderFk;
|
|
|
|
CALL orderGetTotal;
|
|
|
|
SELECT total INTO vTotal FROM tmp.orderTotal;
|
|
|
|
DROP TEMPORARY TABLE
|
|
tmp.order,
|
|
tmp.orderTotal;
|
|
|
|
RETURN vTotal;
|
|
END$$
|
|
|
|
DELIMITER ;
|