feat: refs #3199 Added one more scope ticketTotal #2447

Merged
guillermo merged 15 commits from 3199-ticket_recalc_itemTaxCountry into dev 2024-08-21 12:32:28 +00:00
1 changed files with 15 additions and 10 deletions
Showing only changes of commit a995d80b46 - Show all commits

View File

@ -14,22 +14,26 @@ BEGIN
DECLARE vTicketFk INT;
DECLARE cTickets CURSOR FOR
SELECT DISTINCT t.id
FROM ticket t
LEFT JOIN tItemCalc tic ON tic.id = t.id
WHERE t.refFk IS NULL
guillermo marked this conversation as resolved
Review

Porque se hace JOIN con itemTaxCountry si no se utiliza ninguno de los campos de la tabla?

Para filtrar por itemFk puede hacerse utilizando directamente s.itemFk

Porque se hace JOIN con `itemTaxCountry` si no se utiliza ninguno de los campos de la tabla? Para filtrar por `itemFk` puede hacerse utilizando directamente `s.itemFk`
Review

Porque quiero que tenga registro en la tabla itemTaxCountry, si no no tiene sentido

Porque quiero que tenga registro en la tabla `itemTaxCountry`, si no no tiene sentido
AND ((vScope = 'client' AND t.clientFk = vId)
OR (vScope = 'address' AND t.addressFk = vId)
guillermo marked this conversation as resolved
Review

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.

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 tic.id)
);
guillermo marked this conversation as resolved Outdated

Juan:

Generar una tabla temporal para que solo pase por sale y itemTaxCountry cuando sea vScope = 'item'.

Juan: Generar una tabla temporal para que solo pase por sale y itemTaxCountry cuando sea vScope = 'item'.
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
CREATE OR REPLACE TEMPORARY TABLE tItemCalc
guillermo marked this conversation as resolved
Review

pk y engine

pk y engine
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 = 'client' AND t.clientFk = vId)
OR (vScope = 'address' AND t.addressFk = vId)
OR (vScope = 'item' AND itc.itemFk = vId)
);
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET vDone = TRUE;
AND (vScope = 'item' AND itc.itemFk = vId);
OPEN cTickets;
myLoop: LOOP
SET vDone = FALSE;
FETCH cTickets INTO vTicketFk;
@ -40,7 +44,8 @@ BEGIN
CALL ticket_recalc(vTicketFk, NULL);
END LOOP;
CLOSE cTickets;
DROP TEMPORARY TABLE tItemCalc;
END$$
DELIMITER ;