2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-07-22 09:52:42 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` FUNCTION `vn`.`hasAnyNegativeBase`()
|
2024-01-15 11:31:03 +00:00
|
|
|
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 ;
|