Hotfix: refs #7213 ticket_isTooLittle group by addressFk
gitea/salix/pipeline/pr-master This commit looks good
Details
gitea/salix/pipeline/pr-master This commit looks good
Details
This commit is contained in:
parent
1ec9e5bf09
commit
423ba8c218
|
@ -2,7 +2,7 @@ DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_isTooLittle`(
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`ticket_isTooLittle`(
|
||||||
vSelf INT
|
vSelf INT
|
||||||
)
|
)
|
||||||
RETURNS tinyint(1)
|
RETURNS BOOL
|
||||||
READS SQL DATA
|
READS SQL DATA
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
|
@ -11,20 +11,20 @@ BEGIN
|
||||||
* @param vSelf Id ticket
|
* @param vSelf Id ticket
|
||||||
* @return BOOL
|
* @return BOOL
|
||||||
*/
|
*/
|
||||||
DECLARE vIsTooLittle TINYINT(1);
|
DECLARE vIsTooLittle BOOL;
|
||||||
|
|
||||||
WITH tickets AS (
|
WITH ticketData AS (
|
||||||
SELECT addressFk, DATE(shipped) dated
|
SELECT addressFk, DATE(shipped) dated
|
||||||
FROM vn.ticket
|
FROM vn.ticket
|
||||||
WHERE id = vSelf
|
WHERE id = vSelf
|
||||||
)
|
)
|
||||||
SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume
|
SELECT (SUM(IFNULL(sv.litros, 0)) < vc.minTicketVolume
|
||||||
AND SUM(IFNULL(t.totalWithoutVat, 0)) < vc.minTicketValue) INTO vIsTooLittle
|
AND SUM(IFNULL(t.totalWithoutVat, 0)) < vc.minTicketValue) INTO vIsTooLittle
|
||||||
FROM tickets ts
|
FROM ticketData td
|
||||||
JOIN vn.ticket t ON t.addressFk = ts.addressFk
|
JOIN vn.ticket t ON t.addressFk = td.addressFk
|
||||||
LEFT JOIN vn.saleVolume sv ON sv.ticketFk = t.id
|
LEFT JOIN vn.saleVolume sv ON sv.ticketFk = t.id
|
||||||
JOIN vn.volumeConfig vc
|
JOIN vn.volumeConfig vc
|
||||||
WHERE t.shipped BETWEEN ts.dated AND util.dayEnd(ts.dated)
|
WHERE t.shipped BETWEEN td.dated AND util.dayEnd(td.dated)
|
||||||
AND ticket_isProblemCalcNeeded(t.id);
|
AND ticket_isProblemCalcNeeded(t.id);
|
||||||
|
|
||||||
RETURN vIsTooLittle;
|
RETURN vIsTooLittle;
|
||||||
|
|
|
@ -8,21 +8,24 @@ BEGIN
|
||||||
*
|
*
|
||||||
* @param vSelf Id del ticket
|
* @param vSelf Id del ticket
|
||||||
*/
|
*/
|
||||||
|
DECLARE vTicketIsTooLittle BOOL;
|
||||||
|
|
||||||
|
SELECT ticket_isTooLittle(vSelf) INTO vTicketIsTooLittle;
|
||||||
|
|
||||||
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 (
|
WITH ticketData AS (
|
||||||
SELECT addressFk, DATE(shipped) dated
|
SELECT addressFk, DATE(shipped) dated
|
||||||
FROM vn.ticket
|
FROM vn.ticket
|
||||||
WHERE id = vSelf
|
WHERE id = vSelf
|
||||||
)
|
)
|
||||||
SELECT t.id ticketFk,
|
SELECT t.id ticketFk,
|
||||||
ticket_isTooLittle(t.id) hasProblem,
|
vTicketIsTooLittle hasProblem,
|
||||||
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
|
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
|
||||||
FROM vn.ticket t
|
FROM vn.ticket t
|
||||||
JOIN tickets ts ON ts.addressFk = t.addressFk
|
JOIN ticketData td ON td.addressFk = t.addressFk
|
||||||
WHERE t.shipped BETWEEN ts.dated AND util.dayEnd(ts.dated);
|
WHERE t.shipped BETWEEN td.dated AND util.dayEnd(td.dated);
|
||||||
|
|
||||||
CALL ticket_setProblem('isTooLittle');
|
CALL ticket_setProblem('isTooLittle');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue