8069-Overstocking #3051
|
@ -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
|
||||
pako marked this conversation as resolved
|
||||
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$$
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
cal pensar, si hi ha 20 disponibles, pero el client demana 100?
a.available <= 0 soluciona el tema. Quan la cistella de la compra està fora de hora, eixa quantitat no s'ha tingut en compte en el càlcul del disponible