fix: refs #8069 new conception
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Pako Natek 2024-10-02 14:03:57 +02:00
parent b53f6d4008
commit fc1ea280fa
2 changed files with 25 additions and 13 deletions

View File

@ -8,14 +8,14 @@ BEGIN
* @param vOrderFk hedera.order.id
*/
DECLARE vCalcFk INT;
DECLARE vDated DATE;
DECLARE vDone BOOL;
DECLARE vWarehouseFk INT;
DECLARE cWarehouses CURSOR FOR
SELECT DISTINCT warehouseFk, shipment
FROM orderRow r
WHERE r.orderFk = vOrderFk;
SELECT DISTINCT warehouseFk
FROM orderRow
WHERE orderFk = vOrderFk
AND shipped = util.VN_CURDATE();
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
@ -29,24 +29,23 @@ BEGIN
checking: LOOP
SET vDone = FALSE;
FETCH cWarehouses INTO vWarehouseFk, vDated;
FETCH cWarehouses INTO vWarehouseFk;
IF vDone THEN
LEAVE checking;
END IF;
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated);
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, util.VN_CURDATE());
UPDATE orderRow r
JOIN `order` o ON o.id = r.orderFk
JOIN orderConfig oc
JOIN cache.available a ON a.calc_id = vCalcFk AND a.item_id = r.itemFk
JOIN `order` o ON o.id = r.orderFk
JOIN orderConfig oc
JOIN cache.available a ON a.calc_id = vCalcFk AND a.item_id = r.itemFk
SET r.amount = 0
WHERE ADDTIME(o.rowUpdated, oc.reserveTime) < NOW()
WHERE ADDTIME(o.rowUpdated, oc.reserveTime) < util.VN_NOW()
AND a.available <= 0
AND r.shipment BETWEEN CURDATE() AND util.dayEnd(CURDATE())
AND NOT o.confirmed
AND r.warehouseFk = vWarehouseFk;
AND r.warehouseFk = vWarehouseFk
AND r.orderFk = vOrderFk;
END LOOP;
CLOSE cWarehouses;
END$$

View File

@ -12,6 +12,7 @@ BEGIN
* @param vUser The user identifier
*/
DECLARE vHasRows BOOL;
DECLARE vHas0Amount BOOL;
DECLARE vDone BOOL;
DECLARE vWarehouseFk INT;
DECLARE vShipment DATE;
@ -113,6 +114,18 @@ BEGIN
CALL util.throw('ORDER_EMPTY');
END IF;
-- Check if any product has a quantity of 0
SELECT EXISTS (
SELECT id
FROM orderRow
WHERE orderFk = vSelf
AND amount = 0
) INTO vHas0Amount;
IF vHas0Amount THEN
CALL util.throw('Remove lines with quantity = 0 before confirming');
END IF;
-- Crea los tickets del pedido
OPEN vDates;
lDates: LOOP