7213-Pasar-problemas-a-columnas-calculadas #2396
|
@ -15,7 +15,6 @@ 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
|
||||
LEFT JOIN saleVolume sv ON sv.ticketFk = t.id
|
||||
carlosap marked this conversation as resolved
Outdated
|
||||
JOIN volumeConfig vc
|
||||
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
|
||||
SET t.risk = tr.amount;
|
||||
carlosap marked this conversation as resolved
Outdated
jgallego
commented
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
jgallego
commented
if exist no es posa if exist no es posa
|
||||
END IF;
|
||||
END$$
|
||||
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
|
||||
* 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
jgallego
commented
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');
|
||||
|
||||
|
|
|
@ -9,16 +9,16 @@ BEGIN
|
|||
*/
|
||||
DECLARE vItemFk INT;
|
||||
DECLARE vWarehouseFk INT;
|
||||
DECLARE vDated DATE;
|
||||
DECLARE vShipped DATE;
|
||||
carlosap marked this conversation as resolved
Outdated
jgallego
commented
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
jgallego
commented
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
|
||||
|
|
|
@ -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
jgallego
commented
no es gasta esta variable no es gasta esta variable
|
||||
(INDEX(ticketFk))
|
||||
ENGINE = MEMORY
|
||||
|
|
|
@ -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
jgallego
commented
no es gasta no es gasta
|
||||
(INDEX(ticketFk))
|
||||
ENGINE = MEMORY
|
||||
|
|
|
@ -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
jgallego
commented
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
jgallego
commented
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$$
|
||||
|
|
|
@ -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
la taula sale no es gasta, pots llevarla