feat: refs #3199 Added one more scope ticketTotal #2447
|
@ -14,16 +14,28 @@ BEGIN
|
|||
DECLARE vTicketFk INT;
|
||||
|
||||
DECLARE cTickets CURSOR FOR
|
||||
SELECT id FROM ticket
|
||||
WHERE refFk IS NULL
|
||||
AND ((vScope = 'client' AND clientFk = vId)
|
||||
OR (vScope = 'address' AND addressFk = vId));
|
||||
SELECT DISTINCT t.id
|
||||
FROM ticket t
|
||||
LEFT JOIN tItems ti ON ti.id = t.id
|
||||
WHERE t.refFk IS NULL
|
||||
guillermo marked this conversation as resolved
|
||||
AND ((vScope = 'client' AND t.clientFk = vId)
|
||||
OR (vScope = 'address' AND t.addressFk = vId)
|
||||
guillermo marked this conversation as resolved
juan
commented
Si se pasa la columna Ademas, el filtro no aplica, ya que en caso de recalcular totales, queremos hacerlo de todos aquellos tickets no facturados. Si se pasa la columna `t.shipped` por la funcion `DATE` no se utilizara el indice y la tabla `ticket` es demasiado grande como para aplicar filtros sin índice.
Ademas, el filtro no aplica, ya que en caso de recalcular totales, queremos hacerlo de todos aquellos tickets no facturados.
|
||||
OR (vScope = 'item' AND ti.id)
|
||||
);
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND
|
||||
SET vDone = TRUE;
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||
|
||||
CREATE OR REPLACE TEMPORARY TABLE tItems
|
||||
guillermo marked this conversation as resolved
jgallego
commented
pk y engine pk y engine
|
||||
(PRIMARY KEY (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT DISTINCT t.id
|
||||
FROM ticket t
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN itemTaxCountry itc ON itc.itemFk = s.itemFk
|
||||
WHERE t.refFk IS NULL
|
||||
AND (vScope = 'item' AND itc.itemFk = vId);
|
||||
|
||||
OPEN cTickets;
|
||||
|
||||
myLoop: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH cTickets INTO vTicketFk;
|
||||
|
@ -34,7 +46,8 @@ BEGIN
|
|||
|
||||
CALL ticket_recalc(vTicketFk, NULL);
|
||||
END LOOP;
|
||||
|
||||
CLOSE cTickets;
|
||||
|
||||
DROP TEMPORARY TABLE tItems;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
|
|
Loading…
Reference in New Issue
Porque se hace JOIN con
itemTaxCountry
si no se utiliza ninguno de los campos de la tabla?Para filtrar por
itemFk
puede hacerse utilizando directamentes.itemFk
Porque quiero que tenga registro en la tabla
itemTaxCountry
, si no no tiene sentido