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`.`ticketGetTotal`(vTicketId INT)
|
2024-01-15 11:31:03 +00:00
|
|
|
RETURNS decimal(10,2)
|
|
|
|
DETERMINISTIC
|
|
|
|
READS SQL DATA
|
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Calcula el total con IVA de un ticket.
|
|
|
|
*
|
|
|
|
* @param vTicketId Identificador del ticket
|
|
|
|
* @return Total del ticket
|
|
|
|
*/
|
|
|
|
DECLARE vTotal DECIMAL(10,2);
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
|
|
|
|
CREATE TEMPORARY TABLE tmp.ticket
|
|
|
|
ENGINE = MEMORY
|
|
|
|
SELECT vTicketId ticketFk;
|
|
|
|
|
|
|
|
CALL ticketGetTotal(NULL);
|
|
|
|
|
|
|
|
SELECT total INTO vTotal FROM tmp.ticketTotal;
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE
|
|
|
|
tmp.ticket,
|
|
|
|
tmp.ticketTotal;
|
|
|
|
|
|
|
|
RETURN vTotal;
|
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|