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