31 lines
569 B
SQL
31 lines
569 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`hasAnyPositiveBase`()
|
|
RETURNS tinyint(1)
|
|
DETERMINISTIC
|
|
BEGIN
|
|
|
|
/**
|
|
* Calcula si existe alguna base imponible positiva
|
|
* Requiere la tabla temporal tmp.ticketToInvoice(id) para getTaxBases()
|
|
*
|
|
* returns BOOLEAN
|
|
*/
|
|
|
|
DECLARE hasAnyPositiveBase BOOLEAN;
|
|
|
|
CALL getTaxBases();
|
|
|
|
SELECT positive INTO hasAnyPositiveBase
|
|
FROM tmp.taxBases
|
|
LIMIT 1;
|
|
|
|
DROP TEMPORARY TABLE
|
|
tmp.ticketTax,
|
|
tmp.ticket,
|
|
tmp.taxBases;
|
|
|
|
RETURN hasAnyPositiveBase;
|
|
|
|
END$$
|
|
DELIMITER ;
|