Merge branch 'dev' into 7670-addSaleRenewPrice
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Robert Ferrús 2024-07-12 07:31:05 +00:00
commit 8f2185e85a
2 changed files with 47 additions and 12 deletions

View File

@ -5,14 +5,32 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblem`(
BEGIN
/**
* Update column sale.problem with a problem code
*
* @param vProblemCode Code to set or unset
* @table tmp.sale(saleFk, hasProblem)
*/
UPDATE sale s
JOIN tmp.sale ts ON ts.saleFk = s.id
SET s.problem = CONCAT(
IF(ts.hasProblem,
CONCAT(s.problem, ',', vProblemCode),
REPLACE(s.problem, vProblemCode , '')));
DECLARE vSaleFk INT;
DECLARE vHasProblem INT;
DECLARE vDone BOOL;
DECLARE vSaleList CURSOR FOR SELECT saleFk, hasProblem FROM tmp.sale;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
OPEN vSaleList;
l: LOOP
SET vDone = FALSE;
FETCH vSaleList INTO vSaleFk, vHasProblem;
IF vDone THEN
LEAVE l;
END IF;
UPDATE sale
SET problem = CONCAT(
IF(vHasProblem,
CONCAT(problem, ',', vProblemCode),
REPLACE(problem, vProblemCode , '')))
WHERE id = vSaleFk;
END LOOP;
CLOSE vSaleList;
END$$
DELIMITER ;

View File

@ -9,11 +9,28 @@ BEGIN
* @param vProblemCode Code to set or unset
* @table tmp.ticket(ticketFk, hasProblem)
*/
UPDATE ticket t
JOIN tmp.ticket tt ON tt.ticketFk = t.id
SET t.problem = CONCAT(
IF(tt.hasProblem,
DECLARE vTicketFk INT;
DECLARE vHasProblem INT;
DECLARE vDone BOOL;
DECLARE vTicketList CURSOR FOR SELECT ticketFk, hasProblem FROM tmp.ticket;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
OPEN vTicketList;
l: LOOP
SET vDone = FALSE;
FETCH vTicketList INTO vTicketFk, vHasProblem;
IF vDone THEN
LEAVE l;
END IF;
UPDATE ticket
SET problem = CONCAT(
IF(vHasProblem,
CONCAT(problem, ',', vProblemCode),
REPLACE(problem, vProblemCode , '')));
REPLACE(problem, vProblemCode , '')))
WHERE id = vTicketFk;
END LOOP;
CLOSE vTicketList;
END$$
DELIMITER ;