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-03 10:19:05 +02:00
parent 9905d7254d
commit 7659a39b42
10 changed files with 10 additions and 87 deletions

View File

@ -14,8 +14,7 @@ BEGIN
SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume
OR IFNULL(t.totalWithoutVat, 0) < vc.minTicketValue) INTO vIsTooLittle
FROM ticket t
LEFT JOIN sale s ON s.ticketFk = t.id
FROM ticket t
LEFT JOIN saleVolume sv ON sv.ticketFk = t.id
JOIN volumeConfig vc
WHERE t.id = vSelf;

View File

@ -1,33 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`buy_getRoundingProblem`(
vSelf INT
)
BEGIN
/**
* Update the rounding problems for sales lines related to a buy.
*
* @param vSelf Id ticket
*/
DECLARE vWarehouseFk INT;
DECLARE vDated DATE;
SELECT warehouseFk, DATE(shipped)
INTO vWarehouseFk, vDated
FROM ticket
WHERE id = vSelf;
CALL buyUltimate(vWarehouseFk, vDated);
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
SELECT s.id saleFk , MOD(s.quantity, b.`grouping`) hasProblem
FROM ticket t
JOIN sale s ON s.ticketFk = tl.ticketFk
JOIN tmp.buyUltimate bu ON bu.itemFk = s.itemFk
JOIN buy b ON b.id = bu.buyFk
WHERE t.id = vSelf;
CALL sale_setProblem('hasRounding');
DROP TEMPORARY TABLE tmp.ticket;
END$$
DELIMITER ;

View File

@ -76,7 +76,7 @@ BEGIN
JOIN tTicketRisk tr ON tr.ticketFk = t.id
SET t.risk = tr.amount;
DROP TEMPORARY TABLE IF EXISTS tTicketRisk;
DROP TEMPORARY TABLE tTicketRisk;
END IF;
END$$
DELIMITER ;

View File

@ -1,21 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_getComponentLackProblemAll`()
BEGIN
/**
* Update the problems for all pending sales lines that have or no longer have problems
* with components, verify whether all mandatory components are present or not
*
*/
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
(INDEX(saleFk))
ENGINE = MEMORY
SELECT s.id saleFk, sale_hasComponentLack(s.id) hasProblem
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
WHERE t.shipped >= util.midnight();
CALL sale_setProblem('hasComponentLack');
DROP TEMPORARY TABLE tmp.sale;
END$$
DELIMITER ;

View File

@ -7,6 +7,7 @@ BEGIN
* Update the issues for sales lines that have or no longer have problems with components, verify
* whether all mandatory components are present or not resulting from changes in the table vn.component
*
* @param vComponentFk Id component
*/
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
(INDEX(saleFk))
@ -16,7 +17,7 @@ BEGIN
JOIN sale s ON s.ticketFk = t.id
LEFT JOIN saleComponent sc ON sc.saleFk = s.id
WHERE t.shipped >= util.midnight()
AND sc.componentFk = vComponentFk;
AND (vComponentFk IS NULL OR sc.componentFk = vComponentFk);
CALL sale_setProblem('hasComponentLack');

View File

@ -9,16 +9,16 @@ BEGIN
*/
DECLARE vItemFk INT;
DECLARE vWarehouseFk INT;
DECLARE vDated DATE;
DECLARE vShipped DATE;
DECLARE vQuantity INT;
SELECT s.itemFk, t.warehouseFk, DATE(t.shipped), s.quantity
INTO vItemFk, vWarehouseFk, vDated, vQuantity
SELECT s.itemFk, t.warehouseFk, t.shipped, s.quantity
INTO vItemFk, vWarehouseFk, vShipped, vQuantity
FROM sale s
JOIN ticket t ON t.id = s.ticketFk
WHERE s.id = vSelf;
CALL buyUltimate(vWarehouseFk, vDated);
CALL buyUltimate(vWarehouseFk, vShipped);
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
SELECT vSelf saleFk, MOD(vQuantity, bu.`grouping`) hasProblem

View File

@ -4,8 +4,6 @@ BEGIN
/**
* Update the problems of all tickets that have a pending ticketRequest or no longer have it
*/
DECLARE vHasProblem BOOL;
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
(INDEX(ticketFk))
ENGINE = MEMORY

View File

@ -8,8 +8,6 @@ BEGIN
* deja de tenerla
* @param vSelf Id del ticket de la petición de compra
*/
DECLARE vHasProblem BOOL;
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
(INDEX(ticketFk))
ENGINE = MEMORY

View File

@ -10,8 +10,8 @@ BEGIN
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.isTaxDataChecked;
SET ti.hasproblem = TRUE
WHERE NOT c.isTaxDataChecked;
CALL ticket_setProblem('isTaxDataChecked');
END$$

View File

@ -1,19 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_getTooLittleProblemAll`()
BEGIN
/**
* Update the problems for all tickets when the ticket is too small or is no longer so
*
*/
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
(INDEX(ticketFk))
ENGINE = MEMORY
SELECT id ticketFk, ticket_isTooLittle(id) hasProblem
FROM ticket
WHERE shipped >= util.midnight();
CALL ticket_setProblem('isTooLittle');
DROP TEMPORARY TABLE tmp.ticket;
END$$
DELIMITER ;