diff --git a/db/routines/vn/procedures/client_setRiskAll.sql b/db/routines/vn/procedures/client_setRiskAll.sql deleted file mode 100644 index 6fe867e22..000000000 --- a/db/routines/vn/procedures/client_setRiskAll.sql +++ /dev/null @@ -1,27 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_setRiskAll`() -BEGIN -/** - * Update the risk for all clients with pending tickets - * - */ - DECLARE vDone BOOL; - DECLARE vClientFk INT; - - DECLARE cClients CURSOR FOR - SELECT id - FROM client; - - DECLARE CONTINUE HANDLER FOR NOT FOUND - SET vDone = TRUE; - - OPEN cClients; - myLoop: LOOP - SET vDone = FALSE; - FETCH cClients INTO vClientFk; - IF vDone THEN LEAVE myLoop; END IF; - CALL client_setRisk(vClientFk); - END LOOP; - CLOSE cClients; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setFreezeProblem.sql b/db/routines/vn/procedures/ticket_setFreezeProblem.sql deleted file mode 100644 index fb9a50b58..000000000 --- a/db/routines/vn/procedures/ticket_setFreezeProblem.sql +++ /dev/null @@ -1,17 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setFreezeProblem`() -BEGIN -/** - * Update the problem of tickets whose client is frozen or unfrozen - * - * @table tmp.ticket(ticketFk, hasProblem) - */ - UPDATE tmp.ticket t - JOIN ticket ti ON ti.id = t.ticketFk - JOIN client c ON c.id = ti.clientFk - SET t.hasProblem = TRUE - WHERE c.isFreezed; - - CALL ticket_setProblem('hasTicketRequest'); -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setFreezeProblemAll.sql b/db/routines/vn/procedures/ticket_setFreezeProblemAll.sql deleted file mode 100644 index 17d0c4545..000000000 --- a/db/routines/vn/procedures/ticket_setFreezeProblemAll.sql +++ /dev/null @@ -1,19 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setFreezeProblemAll`() -proc: BEGIN -/** - * Update the problem of all tickets whose client is frozen or unfrozen - * - */ - CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (INDEX(ticketFk)) - ENGINE = MEMORY - SELECT t.id ticketFk, FALSE hasProblem - FROM ticket t - WHERE t.shipped >= util.midnight(); - - CALL ticket_getFreezeProblem(); - - DROP TEMPORARY TABLE tmp.ticket; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setFreezeProblemByClient.sql b/db/routines/vn/procedures/ticket_setFreezeProblemByClient.sql deleted file mode 100644 index 4dd167781..000000000 --- a/db/routines/vn/procedures/ticket_setFreezeProblemByClient.sql +++ /dev/null @@ -1,22 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setFreezeProblemByClient`( - vClientFk INT -) -proc: BEGIN -/** - * Update the problem of all client tickets whose client is frozen or unfrozen - * @param vClientFk Id client - */ - CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (INDEX(ticketFk)) - ENGINE = MEMORY - SELECT t.id ticketFk, FALSE hasProblem - FROM ticket t - WHERE t.clientFk = vClientFk - AND t.shipped >= util.midnight(); - - CALL ticket_getFreezeProblem(); - - DROP TEMPORARY TABLE tmp.ticket; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setProblemFreeze.sql b/db/routines/vn/procedures/ticket_setProblemFreeze.sql new file mode 100644 index 000000000..bdb32b3fe --- /dev/null +++ b/db/routines/vn/procedures/ticket_setProblemFreeze.sql @@ -0,0 +1,29 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemFreeze`( + vClientFk INT +) +BEGIN +/** + * Update the problem of tickets whose client is frozen or unfrozen + * + * @param vClientFk Id Cliente, if NULL all clients + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + (INDEX(ticketFk)) + ENGINE = MEMORY + SELECT t.id ticketFk, FALSE hasProblem + FROM ticket t + WHERE t.shipped >= util.midnight() + AND (vClientFk IS NULL OR t.clientFk = vClientFk); + + UPDATE tmp.ticket t + JOIN ticket ti ON ti.id = t.ticketFk + JOIN client c ON c.id = ti.clientFk + SET t.hasProblem = TRUE + WHERE c.isFreezed; + + CALL ticket_setProblem('hasTicketRequest'); + + DROP TEMPORARY TABLE tmp.ticket; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setProblemRequest.sql b/db/routines/vn/procedures/ticket_setProblemRequest.sql new file mode 100644 index 000000000..13d918ab9 --- /dev/null +++ b/db/routines/vn/procedures/ticket_setProblemRequest.sql @@ -0,0 +1,30 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRequest`( + vSelf INT +) +BEGIN +/** + * Update the problems of tickets that have a pending ticketRequest or no longer have it + * + * @param vSelf Id ticket, if NULL ALL tickets + */ + + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + (INDEX(ticketFk)) + ENGINE = MEMORY + SELECT t.id ticketFk, FALSE hasProblem + FROM ticket t + WHERE t.shipped >= util.midnight() + AND (vSelf IS NULL OR t.id = vSelf); + + + UPDATE tmp.ticket t + JOIN ticketRequest tr ON tr.ticketFk = t.ticketFk + SET t.hasProblem = TRUE + WHERE tr.isOK IS NULL; + + CALL ticket_setProblem('hasTicketRequest'); + + DROP TEMPORARY TABLE tmp.ticket; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setRiskProblem.sql b/db/routines/vn/procedures/ticket_setProblemRisk.sql similarity index 95% rename from db/routines/vn/procedures/ticket_setRiskProblem.sql rename to db/routines/vn/procedures/ticket_setProblemRisk.sql index 1e014578f..7c499f5ba 100644 --- a/db/routines/vn/procedures/ticket_setRiskProblem.sql +++ b/db/routines/vn/procedures/ticket_setProblemRisk.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRiskProblem`( +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRisk`( vSelf INT ) BEGIN diff --git a/db/routines/vn/procedures/ticket_setRoundingProblem.sql b/db/routines/vn/procedures/ticket_setProblemRounding.sql similarity index 95% rename from db/routines/vn/procedures/ticket_setRoundingProblem.sql rename to db/routines/vn/procedures/ticket_setProblemRounding.sql index 92cda37cd..272a48151 100644 --- a/db/routines/vn/procedures/ticket_setRoundingProblem.sql +++ b/db/routines/vn/procedures/ticket_setProblemRounding.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRoundingProblem`( +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemRounding`( vSelf INT ) BEGIN diff --git a/db/routines/vn/procedures/ticket_setProblemTaxDataChecked.sql b/db/routines/vn/procedures/ticket_setProblemTaxDataChecked.sql new file mode 100644 index 000000000..18d81c037 --- /dev/null +++ b/db/routines/vn/procedures/ticket_setProblemTaxDataChecked.sql @@ -0,0 +1,24 @@ +DELIMITER $$ +CREATE OR REPLACE DEFINER=`root`@`localhost` + PROCEDURE `vn`.`ticket_setProblemTaxDataChecked`(vSelf INT) +BEGIN +/** + * Update the problem of tickets, depending on whether + * the client taxDataCheched is verified or not + * + * @param vSelf Id ticket, if NULL ALL tickets + */ + CREATE OR REPLACE TEMPORARY TABLE tmp.ticket + (INDEX(ticketFk)) + ENGINE = MEMORY + SELECT t.id ticketFk, IF(c.isTaxDataChecked, FALSE, TRUE) hasProblem + FROM ticket t + JOIN client c ON c.id = t.clientFk + WHERE t.shipped >= util.midnight() + AND (c.id = vClientFk OR vClientFk IS NULL); + + CALL ticket_setProblem('isTaxDataChecked'); + + DROP TEMPORARY TABLE tmp.ticket; +END$$ +DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setTooLittleProblem.sql b/db/routines/vn/procedures/ticket_setProblemTooLittle.sql similarity index 92% rename from db/routines/vn/procedures/ticket_setTooLittleProblem.sql rename to db/routines/vn/procedures/ticket_setProblemTooLittle.sql index 08f566f86..98a0787af 100644 --- a/db/routines/vn/procedures/ticket_setTooLittleProblem.sql +++ b/db/routines/vn/procedures/ticket_setProblemTooLittle.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setTooLittleProblem`( +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemTooLittle`( vSelf INT ) BEGIN diff --git a/db/routines/vn/procedures/ticket_setTooLittleProblemConfig.sql b/db/routines/vn/procedures/ticket_setProblemTooLittleConfig.sql similarity index 91% rename from db/routines/vn/procedures/ticket_setTooLittleProblemConfig.sql rename to db/routines/vn/procedures/ticket_setProblemTooLittleConfig.sql index 48643d27c..3df0752e5 100644 --- a/db/routines/vn/procedures/ticket_setTooLittleProblemConfig.sql +++ b/db/routines/vn/procedures/ticket_setProblemTooLittleConfig.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setTooLittleProblemConfig`() +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemTooLittleConfig`() BEGIN /** * Update the problems when the ticket is too small or is no longer so, diff --git a/db/routines/vn/procedures/ticket_setTooLittleProblemItemCost.sql b/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql similarity index 93% rename from db/routines/vn/procedures/ticket_setTooLittleProblemItemCost.sql rename to db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql index 89c6d08ed..215b4d7db 100644 --- a/db/routines/vn/procedures/ticket_setTooLittleProblemItemCost.sql +++ b/db/routines/vn/procedures/ticket_setProblemTooLittleItemCost.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setTooLittleProblemItemCost`( +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblemTooLittleItemCost`( vItemFk INT ) BEGIN diff --git a/db/routines/vn/procedures/ticket_setRequestProblem.sql b/db/routines/vn/procedures/ticket_setRequestProblem.sql deleted file mode 100644 index cf05c7255..000000000 --- a/db/routines/vn/procedures/ticket_setRequestProblem.sql +++ /dev/null @@ -1,16 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRequestProblem`() -BEGIN -/** - * Update the problems of tickets that have a pending ticketRequest or no longer have it - * - * @table tmp.ticket(ticketFk, hasProblem) - */ - UPDATE tmp.ticket t - JOIN ticketRequest tr ON tr.ticketFk = t.ticketFk - SET t.hasProblem = TRUE - WHERE tr.isOK IS NULL; - - CALL ticket_setProblem('hasTicketRequest'); -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setRequestProblemAll.sql b/db/routines/vn/procedures/ticket_setRequestProblemAll.sql deleted file mode 100644 index 5cf26efa6..000000000 --- a/db/routines/vn/procedures/ticket_setRequestProblemAll.sql +++ /dev/null @@ -1,18 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRequestProblemAll`() -BEGIN -/** - * Update the problems of all tickets that have a pending ticketRequest or no longer have it - */ - CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (INDEX(ticketFk)) - ENGINE = MEMORY - SELECT t.id ticketFk, FALSE hasProblem - FROM ticket t - WHERE t.shipped >= util.midnight(); - - CALL ticket_getRequestProblem(); - - DROP TEMPORARY TABLE tmp.ticket; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setRequestProblemByTicket.sql b/db/routines/vn/procedures/ticket_setRequestProblemByTicket.sql deleted file mode 100644 index 323692142..000000000 --- a/db/routines/vn/procedures/ticket_setRequestProblemByTicket.sql +++ /dev/null @@ -1,22 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRequestProblemByTicket`( - vSelf INT -) -BEGIN -/** - * Actualiza los problemas de un ticket que tiene una peticiĆ³n de compra pendiente o - * deja de tenerla - * @param vSelf Id del ticket de la peticiĆ³n de compra - */ - CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (INDEX(ticketFk)) - ENGINE = MEMORY - SELECT t.id ticketFk, FALSE hasProblem - FROM ticket t - WHERE t.id = vSelf; - - CALL ticket_getRequestProblem(); - - DROP TEMPORARY TABLE tmp.ticket; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/client_setRisk.sql b/db/routines/vn/procedures/ticket_setRisk.sql similarity index 95% rename from db/routines/vn/procedures/client_setRisk.sql rename to db/routines/vn/procedures/ticket_setRisk.sql index 020f554bf..a17df5ffc 100644 --- a/db/routines/vn/procedures/client_setRisk.sql +++ b/db/routines/vn/procedures/ticket_setRisk.sql @@ -1,5 +1,5 @@ DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_setRisk`( +CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRisk`( vSelf INT) BEGIN /** diff --git a/db/routines/vn/procedures/ticket_setRiskProblemAll.sql b/db/routines/vn/procedures/ticket_setRiskProblemAll.sql deleted file mode 100644 index 2cdbe2ae6..000000000 --- a/db/routines/vn/procedures/ticket_setRiskProblemAll.sql +++ /dev/null @@ -1,39 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setRiskProblemAll`() -BEGIN -/** - * Update the risk problem for all tickets - * - */ - CREATE OR REPLACE TEMPORARY TABLE tRisk - (KEY (ticketFk)) - ENGINE = MEMORY - SELECT t.id ticketFk, - t.risk > (c.credit + 10) hasRisk, - ((t.risk - cc.riskTolerance) > (c.credit + 10)) hasHighRisk - FROM client c - JOIN ticket t ON t.clientFk = c.id - JOIN clientConfig cc - WHERE t.shipped >= util.midnight(); - - CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (KEY (ticketFk)) - ENGINE = MEMORY - SELECT ticketFk, hasRisk hasProblem - FROM tRisk; - - CALL ticket_setProblem('hasRisk'); - DROP TEMPORARY TABLE tmp.ticket; - - CREATE TEMPORARY TABLE tmp.ticket - (KEY (ticketFk)) - ENGINE = MEMORY - SELECT ticketFk, hasHighRisk hasProblem - FROM tRisk; - - CALL ticket_setProblem('hasHighRisk'); - - DROP TEMPORARY TABLE tmp.ticket; - DROP TEMPORARY TABLE tRisk; -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setTaxDataCheckedProblem.sql b/db/routines/vn/procedures/ticket_setTaxDataCheckedProblem.sql deleted file mode 100644 index 84f0cdcaa..000000000 --- a/db/routines/vn/procedures/ticket_setTaxDataCheckedProblem.sql +++ /dev/null @@ -1,18 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` - PROCEDURE `vn`.`ticket_setTaxDataCheckedProblem`() -BEGIN -/** - * Update the problem of tickets, depending on whether - * the client taxDataCheched is verified or not - * - */ - UPDATE tmp.ticket t - JOIN ticket ti ON ti.id = t.ticketFk - JOIN client c ON c.id = ti.clientFk - SET ti.hasproblem = TRUE - WHERE NOT c.isTaxDataChecked; - - CALL ticket_setProblem('isTaxDataChecked'); -END$$ -DELIMITER ; \ No newline at end of file diff --git a/db/routines/vn/procedures/ticket_setTaxDataCheckedProblemAll.sql b/db/routines/vn/procedures/ticket_setTaxDataCheckedProblemAll.sql deleted file mode 100644 index 42f1bf42e..000000000 --- a/db/routines/vn/procedures/ticket_setTaxDataCheckedProblemAll.sql +++ /dev/null @@ -1,22 +0,0 @@ -DELIMITER $$ -CREATE OR REPLACE DEFINER=`root`@`localhost` - PROCEDURE `vn`.`ticket_setTaxDataCheckedProblemAll`() -proc: BEGIN -/** - * Update the problem of all tickets, depending on whether - * the client taxDataCheched is verified or not - */ - - CREATE OR REPLACE TEMPORARY TABLE tmp.ticket - (INDEX(ticketFk)) - ENGINE = MEMORY - SELECT t.id ticketFk, FALSE hasProblem - FROM ticket t - JOIN client c ON c.id = t.clientFk - WHERE t.shipped >= util.midnight(); - - CALL ticket_getTaxDataCheckedProblem(); - - DROP TEMPORARY TABLE tmp.ticket; -END$$ -DELIMITER ; \ No newline at end of file