feat: Turn issues into calculated columns refs#7213
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Carlos Andrés 2024-05-02 18:13:12 +02:00
parent 27e3ae897a
commit e28a5eb478
26 changed files with 71 additions and 73 deletions

View File

@ -1,18 +1,20 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`sale_hasComponentLack`(vSelf INT) CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`sale_hasComponentLack`(
RETURNS tinyint(1) vSelf INT
)RETURNS tinyint(1)
READS SQL DATA READS SQL DATA
BEGIN BEGIN
/** /**
* Comprueba si la línea de sale tiene todos lo componentes obligatorios * Check if a sales line has all the required components.
* *
* @param vSelf Id de sale
* @return BOOL * @return BOOL
*/ */
DECLARE vHasComponentLack TINYINT(1); DECLARE vHasComponentLack TINYINT(1);
WITH componentRequired AS( WITH componentRequired AS(
SELECT COUNT(*)total SELECT COUNT(*) total
FROM vn.component FROM vn.component
WHERE isRequired WHERE isRequired
)SELECT SUM(IF(c.isRequired, TRUE, FALSE)) <> cr.total INTO vHasComponentLack )SELECT SUM(IF(c.isRequired, TRUE, FALSE)) <> cr.total INTO vHasComponentLack
FROM vn.sale s FROM vn.sale s

View File

@ -1,11 +1,12 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_isTooLittle`(vSelf INT) CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_isTooLittle`(
vSelf INT
)
RETURNS tinyint(1) RETURNS tinyint(1)
READS SQL DATA READS SQL DATA
BEGIN BEGIN
/** /**
* Comprueba si el ticket es pequeño en función de los parámtros de configuración * Check if the ticket is small based on the volume and amount parameters.
* teniendo en cuenta el volumen y el importe
* *
* @return BOOL * @return BOOL
*/ */

View File

@ -4,9 +4,9 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getRoundingProb
) )
BEGIN BEGIN
/** /**
* Actualiza los problemas de redondeo para las líneas de venta relacionadas con un buy * Update the rounding problems for sales lines related to a buy.
* *
* @param vSelf Id de ticket * @param vSelf Id ticket
*/ */
DECLARE vWarehouseFk INT; DECLARE vWarehouseFk INT;
DECLARE vDated DATE; DECLARE vDated DATE;

View File

@ -3,19 +3,19 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_risk`(
vSelf INT) vSelf INT)
BEGIN BEGIN
/** /**
* Actualiza el riesgo de los tickets pendientes de un cliente * Update the risk for a client with pending tickets
* *
* @param vSelf Id del cliente * @param vSelf Id cliente
*/ */
DECLARE vHasDebt BOOL; DECLARE vHasDebt BOOL;
SELECT COUNT(*) INTO vHasDebt SELECT COUNT(*) INTO vHasDebt
FROM `client` FROM `client`
WHERE id = vSelf WHERE id = vSelf
AND typeFk = 'normal'; AND typeFk = 'normal';
IF vHasDebt THEN IF vHasDebt THEN
CREATE OR REPLACE TEMPORARY TABLE tTicketRisk CREATE OR REPLACE TEMPORARY TABLE tTicketRisk
(KEY (ticketFk)) (KEY (ticketFk))
ENGINE = MEMORY ENGINE = MEMORY
@ -45,7 +45,7 @@ BEGIN
AND status = 'ok' AND status = 'ok'
) sub ) sub
), uninvoiced AS( ), uninvoiced AS(
SELECT DATE(t.shipped) dated, SUM(t.totalWithVat)amount SELECT DATE(t.shipped) dated, SUM(t.totalWithVat) amount
FROM vn.ticket t FROM vn.ticket t
JOIN dated d JOIN dated d
WHERE t.clientFk = vSelf WHERE t.clientFk = vSelf
@ -71,11 +71,11 @@ BEGIN
SELECT ti.ticketFk, r.amount SELECT ti.ticketFk, r.amount
FROM ticket ti FROM ticket ti
JOIN risk r ON r.dated = ti.dated; JOIN risk r ON r.dated = ti.dated;
UPDATE ticket t UPDATE ticket t
JOIN tTicketRisk tr ON tr.ticketFk = t.id JOIN tTicketRisk tr ON tr.ticketFk = t.id
SET t.risk = tr.amount; SET t.risk = tr.amount;
DROP TEMPORARY TABLE IF EXISTS tTicketRisk; DROP TEMPORARY TABLE IF EXISTS tTicketRisk;
END IF; END IF;
END$$ END$$

View File

@ -2,7 +2,7 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_riskAll`() CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`client_riskAll`()
BEGIN BEGIN
/** /**
* Actualiza el riesgo todos los clientes * Update the risk for all clients with pending tickets
* *
*/ */
DECLARE vDone BOOL; DECLARE vDone BOOL;
@ -10,7 +10,7 @@ BEGIN
DECLARE cClients CURSOR FOR DECLARE cClients CURSOR FOR
SELECT id SELECT id
FROM vn.client; FROM client;
DECLARE CONTINUE HANDLER FOR NOT FOUND DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE; SET vDone = TRUE;
@ -20,7 +20,7 @@ BEGIN
SET vDone = FALSE; SET vDone = FALSE;
FETCH cClients INTO vClientFk; FETCH cClients INTO vClientFk;
IF vDone THEN LEAVE myLoop; END IF; IF vDone THEN LEAVE myLoop; END IF;
CALL vn.client_risk(vClientFk); CALL client_risk(vClientFk);
END LOOP; END LOOP;
CLOSE cClients; CLOSE cClients;
END$$ END$$

View File

@ -4,8 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_getComponentLa
) )
BEGIN BEGIN
/** /**
* Actualiza los problemas para las líneas de ventas que tienen o dejan de tener problemas * Update the problems for sales lines that have or no longer have problems with components,
* con los componentes, verifica que esten o no todos los componenetes obligatorios * verify whether all mandatory components are present or not
* *
* @param vSelf Id del sale * @param vSelf Id del sale
*/ */
@ -13,7 +13,7 @@ BEGIN
(INDEX(saleFk)) (INDEX(saleFk))
ENGINE = MEMORY ENGINE = MEMORY
SELECT vSelf saleFk, sale_hasComponentLack(vSelf) hasProblem; SELECT vSelf saleFk, sale_hasComponentLack(vSelf) hasProblem;
CALL sale_setProblem('hasComponentLack'); CALL sale_setProblem('hasComponentLack');
DROP TEMPORARY TABLE tmp.sale; DROP TEMPORARY TABLE tmp.sale;

View File

@ -2,10 +2,9 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_getComponentLackProblemAll`() CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_getComponentLackProblemAll`()
BEGIN BEGIN
/** /**
* Actualiza los problemas para las líneas de ventas que tienen o dejan de tener problemas * Update the problems for all pending sales lines that have or no longer have problems
* con los componentes, verifica que esten o no todos los componenetes obligatorios * with components, verify whether all mandatory components are present or not
* *
* @param vSelf Id del sale
*/ */
CREATE OR REPLACE TEMPORARY TABLE tmp.sale CREATE OR REPLACE TEMPORARY TABLE tmp.sale
(INDEX(saleFk)) (INDEX(saleFk))

View File

@ -4,8 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_getComponentLa
) )
BEGIN BEGIN
/** /**
* Actualiza los problemas para las líneas de ventas que tienen o dejan de tener problemas * Update the issues for sales lines that have or no longer have problems with components, verify
* con los componentes que derivan de cambios en la tabla vn.component * whether all mandatory components are present or not resulting from changes in the table vn.component
* *
*/ */
CREATE OR REPLACE TEMPORARY TABLE tmp.sale CREATE OR REPLACE TEMPORARY TABLE tmp.sale
@ -17,7 +17,7 @@ BEGIN
LEFT JOIN saleComponent sc ON sc.saleFk = s.id LEFT JOIN saleComponent sc ON sc.saleFk = s.id
WHERE t.shipped >= util.midnight() WHERE t.shipped >= util.midnight()
AND sc.componentFk = vComponentFk; AND sc.componentFk = vComponentFk;
CALL sale_setProblem('hasComponentLack'); CALL sale_setProblem('hasComponentLack');
DROP TEMPORARY TABLE tmp.sale; DROP TEMPORARY TABLE tmp.sale;

View File

@ -4,9 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_getRoundingPro
) )
BEGIN BEGIN
/** /**
* Actualiza los problemas de redondeo para las líneas de venta * Update the rounding problem for a sales line
* * @param vSelf Id sale
* @param vSelf Id de sale
*/ */
DECLARE vItemFk INT; DECLARE vItemFk INT;
DECLARE vWarehouseFk INT; DECLARE vWarehouseFk INT;

View File

@ -4,8 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblem`(
) )
BEGIN BEGIN
/** /**
* Actualiza en la tabla sale la columna problema * Update column sale.problem with a problem code
* @table tmp.sale(saleFk, hasProblem) Identificadores de los sales a actualizar * @table tmp.sale(saleFk, hasProblem)
*/ */
UPDATE sale s UPDATE sale s
JOIN tmp.sale ts ON ts.saleFk = s.id JOIN tmp.sale ts ON ts.saleFk = s.id

View File

@ -1,9 +1,8 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getFreezeProblem`() CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getFreezeProblem`()
proc: BEGIN BEGIN
/** /**
* Actualiza los problemas de los ticket de hoy y a fututo cuyo cliente * Update the problem of tickets whose client is frozen or unfrozen
* se encuentra congelado o deja de estarlo
* *
* @table tmp.ticket(ticketFk, hasProblem) * @table tmp.ticket(ticketFk, hasProblem)
*/ */

View File

@ -2,8 +2,8 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getFreezeProblemAll`() CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getFreezeProblemAll`()
proc: BEGIN proc: BEGIN
/** /**
* Actualiza los problemas de los ticket de hoy y a fututo cuyo cliente * Update the problem of all tickets whose client is frozen or unfrozen
* se encuentra congelado o deja de estarlo *
*/ */
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
(INDEX(ticketFk)) (INDEX(ticketFk))
@ -11,7 +11,7 @@ proc: BEGIN
SELECT t.id ticketFk, FALSE hasProblem SELECT t.id ticketFk, FALSE hasProblem
FROM ticket t FROM ticket t
WHERE t.shipped >= util.midnight(); WHERE t.shipped >= util.midnight();
CALL ticket_getFreezeProblem(); CALL ticket_getFreezeProblem();
DROP TEMPORARY TABLE tmp.ticket; DROP TEMPORARY TABLE tmp.ticket;

View File

@ -4,8 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getFreezePro
) )
proc: BEGIN proc: BEGIN
/** /**
* Actualiza los problemas de los ticket de hoy y a fututo cuyo cliente * Update the problem of all client tickets whose client is frozen or unfrozen
* se encuentra congelado o deja de estarlo * @param vClientFk Id client
*/ */
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
(INDEX(ticketFk)) (INDEX(ticketFk))

View File

@ -2,8 +2,8 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getRequestProblem`() CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getRequestProblem`()
BEGIN BEGIN
/** /**
* Actualiza los problemas de tickets que tienen una petición de compra pendiente o * Update the problems of tickets that have a pending ticketRequest or no longer have it
* deja de tenerla *
* @table tmp.ticket(ticketFk, hasProblem) * @table tmp.ticket(ticketFk, hasProblem)
*/ */
UPDATE tmp.ticket t UPDATE tmp.ticket t

View File

@ -2,8 +2,7 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getRequestProblemAll`() CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getRequestProblemAll`()
BEGIN BEGIN
/** /**
* Actualiza los problemas de tickets pendientes de preparar que tiene una petición * Update the problems of all tickets that have a pending ticketRequest or no longer have it
* de compra pendiente o deja de tenerla
*/ */
DECLARE vHasProblem BOOL; DECLARE vHasProblem BOOL;

View File

@ -4,9 +4,9 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getRiskProbl
) )
BEGIN BEGIN
/** /**
* Actualiza los problema de riesgo para un ticket en concreto * Update the risk problem for a specific ticket
* *
* @param vSelf Id del ticket * @param vSelf Id ticket
*/ */
DECLARE vHasRisk BOOL; DECLARE vHasRisk BOOL;
DECLARE vHasHighRisk BOOL; DECLARE vHasHighRisk BOOL;

View File

@ -2,9 +2,8 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getRiskProblemAll`() CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getRiskProblemAll`()
BEGIN BEGIN
/** /**
* Actualiza los problema de riesgo para un ticket en concreto * Update the risk problem for all tickets
* *
* @param vSelf Id del ticket
*/ */
CREATE OR REPLACE TEMPORARY TABLE tRisk CREATE OR REPLACE TEMPORARY TABLE tRisk
(KEY (ticketFk)) (KEY (ticketFk))

View File

@ -4,7 +4,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getRoundingP
) )
BEGIN BEGIN
/** /**
* Actualiza los problemas de redondeo para las líneas de venta de un ticket * Update the rounding problem for the sales lines of a ticket
* *
* @param vSelf Id de ticket * @param vSelf Id de ticket
*/ */

View File

@ -1,12 +1,12 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getTaxDataCheckedProblem`() CREATE OR REPLACE DEFINER=`root`@`localhost`
proc: BEGIN PROCEDURE `vn`.`ticket_getTaxDataCheckedProblem`()
BEGIN
/** /**
* Actualiza los problemas de los ticket de hoy y a fututo * Update the problem of tickets, depending on whether
* cuyo cliente tenga o no los datos comprobados * the client taxDataCheched is verified or not
* *
*/ */
UPDATE tmp.ticket t UPDATE tmp.ticket t
JOIN ticket ti ON ti.id = t.ticketFk JOIN ticket ti ON ti.id = t.ticketFk
JOIN client c ON c.id = ti.clientFk JOIN client c ON c.id = ti.clientFk

View File

@ -1,9 +1,10 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getTaxDataCheckedProblemAll`() CREATE OR REPLACE DEFINER=`root`@`localhost`
PROCEDURE `vn`.`ticket_getTaxDataCheckedProblemAll`()
proc: BEGIN proc: BEGIN
/** /**
* Actualiza los problemas de los tickets de hoy y a futuro * Update the problem of all tickets, depending on whether
* cuyos clientes tengan o no los datos comprobados * the client taxDataCheched is verified or not
*/ */
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket CREATE OR REPLACE TEMPORARY TABLE tmp.ticket

View File

@ -4,12 +4,11 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getTaxDataCh
) )
proc: BEGIN proc: BEGIN
/** /**
* Actualiza los problemas de los ticket de hoy y a futuro * Update the problem of tickets for a specific client, depending on whether
* cuyo cliente tenga o no los datos comprobados * the client taxDataCheched is verified or not
* *
* @param vClientFk Id del cliente * @param vClientFk Id cliente
*/ */
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
(INDEX(ticketFk)) (INDEX(ticketFk))
ENGINE = MEMORY ENGINE = MEMORY

View File

@ -4,7 +4,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getTooLittle
) )
BEGIN BEGIN
/** /**
* Actualiza los problemas cuando el ticket es demasiado pequeño o deja de serlo * Update the problems when the ticket is too small or is no longer so
* *
* @param vSelf Id del ticket * @param vSelf Id del ticket
*/ */

View File

@ -2,7 +2,7 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getTooLittleProblemAll`() CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getTooLittleProblemAll`()
BEGIN BEGIN
/** /**
* Actualiza los problemas cuando un ticket es demasiado pequeño o deja de serlo * Update the problems for all tickets when the ticket is too small or is no longer so
* *
*/ */
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket CREATE OR REPLACE TEMPORARY TABLE tmp.ticket

View File

@ -2,8 +2,8 @@ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getTooLittleProblemConfig`() CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getTooLittleProblemConfig`()
BEGIN BEGIN
/** /**
* Actualiza los problemas cuando el ticket es demasiado pequeño o deja de serlo, que derivan * Update the problems when the ticket is too small or is no longer so,
* del cambio en la tabla vn.volumeConfig * derived from changes in the volumeConfig table
* *
*/ */
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket CREATE OR REPLACE TEMPORARY TABLE tmp.ticket

View File

@ -4,8 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getTooLittle
) )
BEGIN BEGIN
/** /**
* Actualiza los problemas cuando el ticket es demasiado pequeño o deja de serlo, que derivan * Update the problems when the ticket is too small or is no longer so,
* del cambio en la tabla vn.itemCost * derived from changes in the itemCost table
* *
* @param vItemFk Id del item * @param vItemFk Id del item
*/ */

View File

@ -4,8 +4,8 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_setProblem`(
) )
BEGIN BEGIN
/** /**
* Actualiza en la tabla ticket la columna problema * Update column ticket.problem with a problem code
* @table tmp.ticket(ticketFk, hasProblem) Identificadores de los tickets a actualizar * @table tmp.ticket(ticketFk, hasProblem)
*/ */
UPDATE ticket t UPDATE ticket t
JOIN tmp.ticket tt ON tt.ticketFk = t.id JOIN tmp.ticket tt ON tt.ticketFk = t.id