feat: refs #3199 Added one more scope ticket_recalcByScope
gitea/salix/pipeline/pr-dev Build queued... Details

This commit is contained in:
Guillermo Bonet 2024-05-14 08:59:11 +02:00
parent 2cee9c9c01
commit 9b09bc4efb
1 changed files with 0 additions and 47 deletions

View File

@ -1,47 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_recalcItemTaxCountryByScope`(
vScope VARCHAR(255),
vId INT
)
BEGIN
/**
* Recalculates tickets in an scope.
*
* @param vScope The scope name
* @param vId The scope id
*/
DECLARE vDone BOOL;
DECLARE vTicketFk INT;
DECLARE cTickets CURSOR FOR
SELECT DISTINCT t.id
FROM ticket t
JOIN sale s ON s.ticketFk = t.id
JOIN itemTaxCountry itc ON itc.itemFk = s.itemFk
WHERE t.refFk IS NULL
AND DATE(t.shipped) > util.VN_CURDATE()
AND (
(vScope = 'item' AND itc.itemFk = vId)
OR (vScope = 'country' AND itc.countryFk = vId)
OR (vScope = 'taxClass' AND itc.taxClassFk = vId)
);
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE;
OPEN cTickets;
myLoop: LOOP
SET vDone = FALSE;
FETCH cTickets INTO vTicketFk;
IF vDone THEN
LEAVE myLoop;
END IF;
CALL ticket_recalc(vTicketFk, NULL);
END LOOP;
CLOSE cTickets;
END$$
DELIMITER ;