7213-Pasar-problemas-a-columnas-calculadas #2396

Merged
carlosap merged 15 commits from 7213-Pasar-problemas-a-columnas-calculadas into dev 2024-05-14 09:35:52 +00:00
10 changed files with 10 additions and 87 deletions
Showing only changes of commit 7659a39b42 - Show all commits

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
carlosap marked this conversation as resolved Outdated

la taula sale no es gasta, pots llevarla

la taula sale no es gasta, pots llevarla
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;
carlosap marked this conversation as resolved Outdated

no cal actualizar tb el camp problem?

no cal actualizar tb el camp problem?
DROP TEMPORARY TABLE IF EXISTS tTicketRisk;
DROP TEMPORARY TABLE tTicketRisk;
carlosap marked this conversation as resolved Outdated

if exist no es posa

if exist no es posa
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()
carlosap marked this conversation as resolved Outdated

es codi repetit, fusional en el de dalt, si li pases vComponentFk fas una cosa y si pases NULL ho mira per a tots.

es codi repetit, fusional en el de dalt, si li pases vComponentFk fas una cosa y si pases NULL ho mira per a tots.
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;
carlosap marked this conversation as resolved Outdated

vShipped es mes concret

vShipped es mes concret
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
carlosap marked this conversation as resolved Outdated

no cal DATE(

no cal DATE(
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
jgallego marked this conversation as resolved Outdated

no es gasta esta variable

no es gasta esta variable
(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
carlosap marked this conversation as resolved Outdated

no es gasta

no es gasta
(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
carlosap marked this conversation as resolved Outdated

si actualices y despues la borres no val per a res, deuries actualizar la taula ticket en este cas ti

si actualices y despues la borres no val per a res, deuries actualizar la taula ticket en este cas ti
SET t.hasproblem = TRUE
WHERE c.isTaxDataChecked;
SET ti.hasproblem = TRUE
carlosap marked this conversation as resolved Outdated

esta condicio deu ser al revés, es un problema quan no te el datos comprovats

esta condicio deu ser al revés, es un problema quan no te el datos comprovats
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 ;