fix: refs #7213 Hotfix-ticket_isTooLittle-group-by-addressFk #2895
|
@ -20,13 +20,12 @@ BEGIN
|
|||
)
|
||||
SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume
|
||||
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
|
||||
FROM tickets ts
|
||||
JOIN vn.ticket t ON t.addressFk = ts.addressFk
|
||||
LEFT JOIN vn.saleVolume sv ON sv.ticketFk = t.id
|
||||
JOIN vn.volumeConfig vc
|
||||
WHERE t.shipped BETWEEN ts.dated AND util.dayEnd(ts.dated)
|
||||
AND sv.litros > 0
|
||||
AND t.totalWithoutVat > 0;
|
||||
AND ticket_isProblemCalcNeeded(t.id);
|
||||
|
||||
RETURN vIsTooLittle;
|
||||
END$$
|
||||
|
|
|
@ -17,9 +17,9 @@ BEGIN
|
|||
FROM vn.ticket
|
||||
WHERE id = vSelf
|
||||
)
|
||||
SELECT vSelf ticketFk,
|
||||
ticket_isTooLittle(vSelf) hasProblem,
|
||||
ticket_isProblemCalcNeeded(vSelf) isProblemCalcNeeded
|
||||
SELECT t.id ticketFk,
|
||||
carlosap marked this conversation as resolved
Outdated
|
||||
ticket_isTooLittle(t.id) hasProblem,
|
||||
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
|
||||
FROM vn.ticket t
|
||||
JOIN tickets ts ON ts.addressFk = t.addressFk
|
||||
WHERE t.shipped BETWEEN ts.dated AND util.dayEnd(ts.dated);
|
||||
|
|
Loading…
Reference in New Issue
Ací estás pasant per cada ticket per la funció
vn.ticket_isTooLittle()
, no et fa falta, jo ficaria el SELECT amb el ticket vSelf dalt en una variable, ja que tots els tickets te van a donar lo mateix.Entenc tot lo demes, ja que si que te interesa cridar a la funció
ticket_isProblemCalcNeeded
per cada ticket.