2023-11-30 14:15:40 +00:00
|
|
|
DELIMITER $$
|
|
|
|
$$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`hasAnyNegativeBase`() RETURNS tinyint(1)
|
|
|
|
DETERMINISTIC
|
|
|
|
BEGIN
|
|
|
|
|
2024-01-03 11:19:28 +00:00
|
|
|
/**
|
|
|
|
* Calcula si existe alguna base imponible negativa
|
2023-11-30 14:15:40 +00:00
|
|
|
* Requiere la tabla temporal tmp.ticketToInvoice(id) para getTaxBases()
|
|
|
|
*
|
|
|
|
* returns BOOLEAN
|
|
|
|
*/
|
|
|
|
|
|
|
|
DECLARE hasAnyNegativeBase BOOLEAN;
|
|
|
|
|
|
|
|
CALL getTaxBases();
|
|
|
|
|
2024-01-02 12:17:10 +00:00
|
|
|
SELECT negative INTO hasAnyNegativeBase
|
2024-01-03 11:19:28 +00:00
|
|
|
FROM tmp.taxBases
|
|
|
|
LIMIT 1;
|
2023-11-30 14:15:40 +00:00
|
|
|
|
|
|
|
DROP TEMPORARY TABLE
|
|
|
|
tmp.ticketTax,
|
|
|
|
tmp.ticket,
|
|
|
|
tmp.taxBases;
|
|
|
|
|
|
|
|
RETURN hasAnyNegativeBase;
|
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|
2023-12-14 14:56:49 +00:00
|
|
|
|
2024-01-03 11:19:28 +00:00
|
|
|
|