fix: refs #7213 problem rounding
gitea/salix/pipeline/pr-master This commit looks good Details

This commit is contained in:
Carlos Andrés 2024-08-30 14:14:06 +02:00
parent beb54aedf8
commit 4ed5811042
1 changed files with 11 additions and 10 deletions

View File

@ -4,8 +4,9 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`sale_setProblemRoun
) )
BEGIN BEGIN
/** /**
* Update rounding problem for all sales related to a buy * Update rounding problem for all sales related to a buy.
* @param vBuyFk Id buy *
* @param vBuyFk Buy id
*/ */
DECLARE vItemFk INT; DECLARE vItemFk INT;
DECLARE vWareHouseFk INT; DECLARE vWareHouseFk INT;
@ -18,16 +19,16 @@ BEGIN
SELECT b.itemFk, t.warehouseInFk SELECT b.itemFk, t.warehouseInFk
INTO vItemFk, vWareHouseFk INTO vItemFk, vWareHouseFk
FROM vn.buy b FROM buy b
JOIN vn.entry e ON e.id = b.entryFk JOIN entry e ON e.id = b.entryFk
JOIN vn.travel t ON t.id = e.travelFk JOIN travel t ON t.id = e.travelFk
WHERE b.id = vBuyFk; WHERE b.id = vBuyFk;
SELECT DATE(MAX(t.shipped)) + INTERVAL 1 DAY, DATE(MIN(t.shipped)) SELECT DATE(MAX(t.shipped)) + INTERVAL 1 DAY, DATE(MIN(t.shipped))
INTO vMaxDated, vMinDated INTO vMaxDated, vMinDated
FROM sale s FROM sale s
JOIN ticket t ON t.id = s.ticketFk JOIN ticket t ON t.id = s.ticketFk
WHERE t.shipped >= CURDATE() WHERE t.shipped >= util.VN_CURDATE()
AND s.itemFk = vItemFk AND s.itemFk = vItemFk
AND s.quantity > 0; AND s.quantity > 0;
@ -55,15 +56,15 @@ BEGIN
CREATE OR REPLACE TEMPORARY TABLE tmp.sale CREATE OR REPLACE TEMPORARY TABLE tmp.sale
(INDEX(saleFk, isProblemCalcNeeded)) (INDEX(saleFk, isProblemCalcNeeded))
SELECT s.id saleFk , ENGINE = MEMORY
SELECT s.id saleFk,
MOD(s.quantity, vGrouping) hasProblem, MOD(s.quantity, vGrouping) hasProblem,
ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded ticket_isProblemCalcNeeded(t.id) isProblemCalcNeeded
FROM sale s FROM sale s
JOIN ticket t ON t.id = s.ticketFk JOIN ticket t ON t.id = s.ticketFk
WHERE s.itemFk = vItemFk WHERE s.itemFk = vItemFk
AND s.quantity > 0 AND s.quantity > 0
AND t.shipped BETWEEN vMinDated AND t.shipped BETWEEN vMinDated AND util.dayEnd(vMaxDated);
AND util.dayEnd(vMaxDated);
CALL sale_setProblem('hasRounding'); CALL sale_setProblem('hasRounding');