Hotfix: refs #7213 ticket_isTooLittle group by addressFk
This commit is contained in:
parent
4a3f884173
commit
9a2351b958
|
@ -12,13 +12,21 @@ BEGIN
|
||||||
* @return BOOL
|
* @return BOOL
|
||||||
*/
|
*/
|
||||||
DECLARE vIsTooLittle TINYINT(1);
|
DECLARE vIsTooLittle TINYINT(1);
|
||||||
|
|
||||||
|
WITH tickets AS (
|
||||||
|
SELECT addressFk, DATE(shipped) dated
|
||||||
|
FROM vn.ticket
|
||||||
|
WHERE id = vSelf
|
||||||
|
)
|
||||||
SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume
|
SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume
|
||||||
AND IFNULL(t.totalWithoutVat, 0) < vc.minTicketValue) INTO vIsTooLittle
|
AND SUM(IFNULL(t.totalWithoutVat, 0)) < vc.minTicketValue) INTO vIsTooLittle
|
||||||
FROM ticket t
|
FROM vn.ticket t
|
||||||
LEFT JOIN saleVolume sv ON sv.ticketFk = t.id
|
JOIN tickets ts ON ts.addressFk = t.addressFk
|
||||||
JOIN volumeConfig vc
|
JOIN vn.volumeConfig vc
|
||||||
WHERE t.id = vSelf;
|
LEFT JOIN vn.saleVolume sv ON sv.ticketFk = t.id
|
||||||
|
WHERE t.shipped BETWEEN ts.dated AND util.dayEnd(ts.dated)
|
||||||
|
AND sv.litros > 0
|
||||||
|
AND t.totalWithoutVat > 0;
|
||||||
|
|
||||||
RETURN vIsTooLittle;
|
RETURN vIsTooLittle;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -12,13 +12,20 @@ BEGIN
|
||||||
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
CREATE OR REPLACE TEMPORARY TABLE tmp.ticket
|
||||||
(INDEX(ticketFk, isProblemCalcNeeded))
|
(INDEX(ticketFk, isProblemCalcNeeded))
|
||||||
ENGINE = MEMORY
|
ENGINE = MEMORY
|
||||||
|
WITH tickets AS (
|
||||||
|
SELECT addressFk, DATE(shipped) dated
|
||||||
|
FROM vn.ticket
|
||||||
|
WHERE id = vSelf
|
||||||
|
)
|
||||||
SELECT vSelf ticketFk,
|
SELECT vSelf ticketFk,
|
||||||
ticket_isTooLittle(vSelf) hasProblem,
|
ticket_isTooLittle(vSelf) hasProblem,
|
||||||
ticket_isProblemCalcNeeded(vSelf) isProblemCalcNeeded;
|
ticket_isProblemCalcNeeded(vSelf) isProblemCalcNeeded
|
||||||
|
FROM vn.ticket t
|
||||||
|
JOIN tickets ts ON ts.addressFk = t.addressFk
|
||||||
|
WHERE t.shipped BETWEEN ts.dated AND util.dayEnd(ts.dated);
|
||||||
|
|
||||||
CALL ticket_setProblem('isTooLittle');
|
CALL ticket_setProblem('isTooLittle');
|
||||||
|
|
||||||
DROP TEMPORARY TABLE tmp.ticket;
|
DROP TEMPORARY TABLE tmp.ticket;
|
||||||
|
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
Loading…
Reference in New Issue