feat: refs #3199 Added one more scope ticketTotal #2447
|
@ -14,10 +14,17 @@ 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
|
||||
JOIN sale s ON s.ticketFk = t.id
|
||||
JOIN itemTaxCountry itc ON itc.itemFk = s.itemFk
|
||||
guillermo marked this conversation as resolved
|
||||
WHERE t.refFk IS NULL
|
||||
AND DATE(t.shipped) > util.VN_CURDATE()
|
||||
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.
|
||||
AND (
|
||||
(vScope = 'client' AND t.clientFk = vId)
|
||||
OR (vScope = 'address' AND t.addressFk = vId)
|
||||
OR (vScope = 'item' AND itc.itemFk = vId)
|
||||
);
|
||||
|
||||
guillermo marked this conversation as resolved
jgallego
commented
pk y engine pk y engine
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND
|
||||
SET vDone = TRUE;
|
||||
|
|
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