7213-Pasar-problemas-a-columnas-calculadas #2396
|
@ -15,7 +15,6 @@ BEGIN
|
||||||
SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume
|
SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume
|
||||||
OR IFNULL(t.totalWithoutVat, 0) < vc.minTicketValue) INTO vIsTooLittle
|
OR IFNULL(t.totalWithoutVat, 0) < vc.minTicketValue) INTO vIsTooLittle
|
||||||
FROM ticket t
|
FROM ticket t
|
||||||
LEFT JOIN sale s ON s.ticketFk = t.id
|
|
||||||
LEFT JOIN saleVolume sv ON sv.ticketFk = t.id
|
LEFT JOIN saleVolume sv ON sv.ticketFk = t.id
|
||||||
JOIN volumeConfig vc
|
JOIN volumeConfig vc
|
||||||
WHERE t.id = vSelf;
|
WHERE t.id = vSelf;
|
||||||
|
|
|
@ -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 ;
|
|
|
@ -76,7 +76,7 @@ BEGIN
|
||||||
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 tTicketRisk;
|
||||||
END IF;
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -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 ;
|
|
|
@ -7,6 +7,7 @@ BEGIN
|
||||||
* Update the issues for sales lines that have or no longer have problems with components, verify
|
* 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
|
* 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
|
CREATE OR REPLACE TEMPORARY TABLE tmp.sale
|
||||||
(INDEX(saleFk))
|
(INDEX(saleFk))
|
||||||
|
@ -16,7 +17,7 @@ BEGIN
|
||||||
JOIN sale s ON s.ticketFk = t.id
|
JOIN sale s ON s.ticketFk = t.id
|
||||||
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 (vComponentFk IS NULL OR sc.componentFk = vComponentFk);
|
||||||
|
|
||||||
CALL sale_setProblem('hasComponentLack');
|
CALL sale_setProblem('hasComponentLack');
|
||||||
|
|
||||||
|
|
|
@ -9,16 +9,16 @@ BEGIN
|
||||||
*/
|
*/
|
||||||
DECLARE vItemFk INT;
|
DECLARE vItemFk INT;
|
||||||
DECLARE vWarehouseFk INT;
|
DECLARE vWarehouseFk INT;
|
||||||
DECLARE vDated DATE;
|
DECLARE vShipped DATE;
|
||||||
DECLARE vQuantity INT;
|
DECLARE vQuantity INT;
|
||||||
|
|
||||||
SELECT s.itemFk, t.warehouseFk, DATE(t.shipped), s.quantity
|
SELECT s.itemFk, t.warehouseFk, t.shipped, s.quantity
|
||||||
INTO vItemFk, vWarehouseFk, vDated, vQuantity
|
INTO vItemFk, vWarehouseFk, vShipped, vQuantity
|
||||||
FROM sale s
|
FROM sale s
|
||||||
JOIN ticket t ON t.id = s.ticketFk
|
JOIN ticket t ON t.id = s.ticketFk
|
||||||
WHERE s.id = vSelf;
|
WHERE s.id = vSelf;
|
||||||
|
|
||||||
CALL buyUltimate(vWarehouseFk, vDated);
|
CALL buyUltimate(vWarehouseFk, vShipped);
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||||
SELECT vSelf saleFk, MOD(vQuantity, bu.`grouping`) hasProblem
|
SELECT vSelf saleFk, MOD(vQuantity, bu.`grouping`) hasProblem
|
||||||
|
|
|
@ -4,8 +4,6 @@ BEGIN
|
||||||
/**
|
/**
|
||||||
* Update the problems of all tickets that have a pending ticketRequest or no longer have it
|
* 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
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||||
(INDEX(ticketFk))
|
(INDEX(ticketFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
|
|
|
@ -8,8 +8,6 @@ BEGIN
|
||||||
* deja de tenerla
|
* deja de tenerla
|
||||||
* @param vSelf Id del ticket de la petición de compra
|
* @param vSelf Id del ticket de la petición de compra
|
||||||
*/
|
*/
|
||||||
DECLARE vHasProblem BOOL;
|
|
||||||
|
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||||
(INDEX(ticketFk))
|
(INDEX(ticketFk))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
|
|
|
@ -10,8 +10,8 @@ BEGIN
|
||||||
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
|
||||||
SET t.hasproblem = TRUE
|
SET ti.hasproblem = TRUE
|
||||||
WHERE c.isTaxDataChecked;
|
WHERE NOT c.isTaxDataChecked;
|
||||||
|
|
||||||
CALL ticket_setProblem('isTaxDataChecked');
|
CALL ticket_setProblem('isTaxDataChecked');
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -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 ;
|
|
Loading…
Reference in New Issue