fix: refs #7213 Hotfix-ticket_isTooLittle-group-by-addressFk #2895

Merged
carlosap merged 3 commits from Hotfix-ticket_isTooLittle-group-by-addressFk into master 2024-08-28 14:41:49 +00:00
2 changed files with 7 additions and 8 deletions
Showing only changes of commit 1ec9e5bf09 - Show all commits

View File

@ -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$$

View File

@ -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

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.

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.
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);