2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`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()
|
2024-01-15 11:31:03 +00:00
|
|
|
*
|
|
|
|
* returns BOOLEAN
|
|
|
|
*/
|
|
|
|
|
2024-02-15 09:04:15 +00:00
|
|
|
DECLARE hasAnyNegativeBase BOOLEAN;
|
2024-01-15 11:31:03 +00:00
|
|
|
|
2024-02-15 09:04:15 +00:00
|
|
|
CALL getTaxBases();
|
2024-01-15 11:31:03 +00:00
|
|
|
|
2024-02-15 09:04:15 +00:00
|
|
|
SELECT negative INTO hasAnyNegativeBase
|
|
|
|
FROM tmp.taxBases
|
|
|
|
LIMIT 1;
|
2024-01-15 11:31:03 +00:00
|
|
|
|
2024-02-15 09:04:15 +00:00
|
|
|
DROP TEMPORARY TABLE
|
|
|
|
tmp.ticketTax,
|
|
|
|
tmp.ticket,
|
|
|
|
tmp.taxBases;
|
2024-01-15 11:31:03 +00:00
|
|
|
|
|
|
|
RETURN hasAnyNegativeBase;
|
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|