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