2024-05-13 07:54:27 +00:00
|
|
|
DELIMITER $$
|
|
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost`
|
2024-05-13 12:21:01 +00:00
|
|
|
PROCEDURE `vn`.`ticket_setProblemTaxDataChecked`(vClientFk INT)
|
2024-05-13 07:54:27 +00:00
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* Update the problem of tickets, depending on whether
|
|
|
|
* the client taxDataCheched is verified or not
|
|
|
|
*
|
2024-05-13 12:21:01 +00:00
|
|
|
* @param vClientFk Id cliente, if NULL all clients
|
2024-05-13 07:54:27 +00:00
|
|
|
*/
|
|
|
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
2024-06-27 11:01:42 +00:00
|
|
|
(INDEX(ticketFk, isProblemCalcNeeded))
|
2024-05-13 07:54:27 +00:00
|
|
|
ENGINE = MEMORY
|
2024-06-27 11:01:42 +00:00
|
|
|
SELECT t.id ticketFk,
|
|
|
|
IF(c.isTaxDataChecked, FALSE, TRUE) hasProblem,
|
|
|
|
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
|
2024-05-13 07:54:27 +00:00
|
|
|
FROM ticket t
|
|
|
|
JOIN client c ON c.id = t.clientFk
|
2024-06-05 08:11:04 +00:00
|
|
|
WHERE t.shipped >= util.VN_CURDATE()
|
2024-05-13 07:54:27 +00:00
|
|
|
AND (c.id = vClientFk OR vClientFk IS NULL);
|
|
|
|
|
|
|
|
CALL ticket_setProblem('isTaxDataChecked');
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE tmp.ticket;
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|