fix: refs #7931 Immediately discount order lines from available
gitea/salix/pipeline/pr-test This commit looks good Details

This commit is contained in:
Juan Ferrer 2024-09-05 14:45:17 +02:00
parent a2a5630d17
commit a7bc58a5bc
3 changed files with 35 additions and 5 deletions

View File

@ -1,5 +1,10 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_refresh`(OUT `vCalc` INT, IN `vRefresh` INT, IN `vWarehouse` INT, IN `vDated` DATE) CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_refresh`(
OUT `vCalc` INT,
`vRefresh` INT,
`vWarehouse` INT,
`vDated` DATE
)
proc: BEGIN proc: BEGIN
DECLARE vStartDate DATE; DECLARE vStartDate DATE;
DECLARE vReserveDate DATETIME; DECLARE vReserveDate DATETIME;

View File

@ -0,0 +1,23 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`available_updateItem`(
`vItem` INT,
`vWarehouse` INT,
`vDated` DATE,
`vQuantity` INT
)
BEGIN
DECLARE vCalc INT;
SELECT id INTO vCalc FROM cache_calc
WHERE cacheName = 'available'
AND params = CONCAT_WS('/', vWarehouse, vDated)
AND last_refresh <= NOW();
IF vCalc IS NOT NULL THEN
UPDATE available
SET available = available - vQuantity
WHERE calc_id = vCalc
AND item_id = vItem;
END IF;
END$$
DELIMITER ;

View File

@ -1,8 +1,8 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_addItem`( CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`order_addItem`(
vSelf INT, vSelf INT,
vWarehouse INT, vWarehouse INT,
vItem INT, vItem INT,
vAmount INT) vAmount INT)
BEGIN BEGIN
/** /**
@ -37,7 +37,7 @@ BEGIN
ROLLBACK; ROLLBACK;
RESIGNAL; RESIGNAL;
END; END;
CALL order_calcCatalogFromItem(vSelf, vItem); CALL order_calcCatalogFromItem(vSelf, vItem);
START TRANSACTION; START TRANSACTION;
@ -102,6 +102,8 @@ BEGIN
amount = vAdd, amount = vAdd,
price = vPrice; price = vPrice;
CALL cache.available_updateItem(vItem, vWarehouse, vShipment, vAdd);
SET vRow = LAST_INSERT_ID(); SET vRow = LAST_INSERT_ID();
INSERT INTO orderRowComponent (rowFk, componentFk, price) INSERT INTO orderRowComponent (rowFk, componentFk, price)
@ -121,6 +123,6 @@ BEGIN
END IF; END IF;
COMMIT; COMMIT;
CALL vn.ticketCalculatePurge; CALL vn.ticketCalculatePurge;
END$$ END$$
DELIMITER ; DELIMITER ;