feat: refs #3199 Added one more scope ticketTotal #2447
|
@ -14,19 +14,10 @@ BEGIN
|
|||
DECLARE vTicketFk INT;
|
||||
|
||||
DECLARE cTickets CURSOR FOR
|
||||
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 DATE(t.shipped) > util.VN_CURDATE()
|
||||
AND (
|
||||
(vScope = 'client' AND t.clientFk = vId)
|
||||
OR (vScope = 'address' AND t.addressFk = vId)
|
||||
OR (vScope = 'item' AND itc.itemFk = vId)
|
||||
OR (vScope = 'country' AND itc.countryFk = vId)
|
||||
OR (vScope = 'taxClass' AND itc.taxClassFk = vId)
|
||||
);
|
||||
SELECT id FROM ticket
|
||||
WHERE refFk IS NULL
|
||||
AND ((vScope = 'client' AND clientFk = vId)
|
||||
OR (vScope = 'address' AND addressFk = vId));
|
||||
guillermo marked this conversation as resolved
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND
|
||||
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.
|
||||
SET vDone = TRUE;
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`ticket_recalcItemTaxCountryByScope`(
|
||||
vScope VARCHAR(255),
|
||||
vId INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Recalculates tickets in an scope.
|
||||
*
|
||||
* @param vScope The scope name
|
||||
* @param vId The scope id
|
||||
*/
|
||||
DECLARE vDone BOOL;
|
||||
DECLARE vTicketFk INT;
|
||||
|
||||
DECLARE cTickets CURSOR FOR
|
||||
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 DATE(t.shipped) > util.VN_CURDATE()
|
||||
AND (
|
||||
(vScope = 'item' AND itc.itemFk = vId)
|
||||
OR (vScope = 'country' AND itc.countryFk = vId)
|
||||
OR (vScope = 'taxClass' AND itc.taxClassFk = vId)
|
||||
);
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND
|
||||
SET vDone = TRUE;
|
||||
|
||||
OPEN cTickets;
|
||||
|
||||
myLoop: LOOP
|
||||
SET vDone = FALSE;
|
||||
FETCH cTickets INTO vTicketFk;
|
||||
|
||||
IF vDone THEN
|
||||
LEAVE myLoop;
|
||||
END IF;
|
||||
|
||||
CALL ticket_recalc(vTicketFk, NULL);
|
||||
END LOOP;
|
||||
|
||||
CLOSE cTickets;
|
||||
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