salix/db/routines/vn/functions/hasAnyNegativeBase.sql

31 lines
575 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` FUNCTION `vn`.`hasAnyNegativeBase`()
RETURNS tinyint(1)
DETERMINISTIC
BEGIN
2024-02-15 09:04:15 +00:00
/**
* Calcula si existe alguna base imponible negativa
* Requiere la tabla temporal tmp.ticketToInvoice(id) para getTaxBases()
*
* returns BOOLEAN
*/
2024-02-15 09:04:15 +00:00
DECLARE hasAnyNegativeBase BOOLEAN;
2024-02-15 09:04:15 +00:00
CALL getTaxBases();
2024-02-15 09:04:15 +00:00
SELECT negative INTO hasAnyNegativeBase
FROM tmp.taxBases
LIMIT 1;
2024-02-15 09:04:15 +00:00
DROP TEMPORARY TABLE
tmp.ticketTax,
tmp.ticket,
tmp.taxBases;
RETURN hasAnyNegativeBase;
END$$
DELIMITER ;