This commit is contained in:
parent
b53f6d4008
commit
fc1ea280fa
|
@ -8,14 +8,14 @@ BEGIN
|
||||||
* @param vOrderFk hedera.order.id
|
* @param vOrderFk hedera.order.id
|
||||||
*/
|
*/
|
||||||
DECLARE vCalcFk INT;
|
DECLARE vCalcFk INT;
|
||||||
DECLARE vDated DATE;
|
|
||||||
DECLARE vDone BOOL;
|
DECLARE vDone BOOL;
|
||||||
DECLARE vWarehouseFk INT;
|
DECLARE vWarehouseFk INT;
|
||||||
|
|
||||||
DECLARE cWarehouses CURSOR FOR
|
DECLARE cWarehouses CURSOR FOR
|
||||||
SELECT DISTINCT warehouseFk, shipment
|
SELECT DISTINCT warehouseFk
|
||||||
FROM orderRow r
|
FROM orderRow
|
||||||
WHERE r.orderFk = vOrderFk;
|
WHERE orderFk = vOrderFk
|
||||||
|
AND shipped = util.VN_CURDATE();
|
||||||
|
|
||||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
|
||||||
|
|
||||||
|
@ -29,24 +29,23 @@ BEGIN
|
||||||
checking: LOOP
|
checking: LOOP
|
||||||
SET vDone = FALSE;
|
SET vDone = FALSE;
|
||||||
|
|
||||||
FETCH cWarehouses INTO vWarehouseFk, vDated;
|
FETCH cWarehouses INTO vWarehouseFk;
|
||||||
|
|
||||||
IF vDone THEN
|
IF vDone THEN
|
||||||
LEAVE checking;
|
LEAVE checking;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, vDated);
|
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, util.VN_CURDATE());
|
||||||
|
|
||||||
UPDATE orderRow r
|
UPDATE orderRow r
|
||||||
JOIN `order` o ON o.id = r.orderFk
|
JOIN `order` o ON o.id = r.orderFk
|
||||||
JOIN orderConfig oc
|
JOIN orderConfig oc
|
||||||
JOIN cache.available a ON a.calc_id = vCalcFk AND a.item_id = r.itemFk
|
JOIN cache.available a ON a.calc_id = vCalcFk AND a.item_id = r.itemFk
|
||||||
SET r.amount = 0
|
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 a.available <= 0
|
||||||
AND r.shipment BETWEEN CURDATE() AND util.dayEnd(CURDATE())
|
AND r.warehouseFk = vWarehouseFk
|
||||||
AND NOT o.confirmed
|
AND r.orderFk = vOrderFk;
|
||||||
AND r.warehouseFk = vWarehouseFk;
|
|
||||||
END LOOP;
|
END LOOP;
|
||||||
CLOSE cWarehouses;
|
CLOSE cWarehouses;
|
||||||
END$$
|
END$$
|
||||||
|
|
|
@ -12,6 +12,7 @@ BEGIN
|
||||||
* @param vUser The user identifier
|
* @param vUser The user identifier
|
||||||
*/
|
*/
|
||||||
DECLARE vHasRows BOOL;
|
DECLARE vHasRows BOOL;
|
||||||
|
DECLARE vHas0Amount BOOL;
|
||||||
DECLARE vDone BOOL;
|
DECLARE vDone BOOL;
|
||||||
DECLARE vWarehouseFk INT;
|
DECLARE vWarehouseFk INT;
|
||||||
DECLARE vShipment DATE;
|
DECLARE vShipment DATE;
|
||||||
|
@ -113,6 +114,18 @@ BEGIN
|
||||||
CALL util.throw('ORDER_EMPTY');
|
CALL util.throw('ORDER_EMPTY');
|
||||||
END IF;
|
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
|
-- Crea los tickets del pedido
|
||||||
OPEN vDates;
|
OPEN vDates;
|
||||||
lDates: LOOP
|
lDates: LOOP
|
||||||
|
|
Loading…
Reference in New Issue