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

31 lines
569 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
2024-08-20 08:06:10 +00:00
CREATE OR REPLACE DEFINER=`vn`@`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 ;