8179-testToMaster #3176
|
@ -0,0 +1,26 @@
|
|||
DELIMITER $$
|
||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `hedera`.`orderRow_updateOverstocking`(
|
||||
vWarehouseFk INT
|
||||
)
|
||||
BEGIN
|
||||
/**
|
||||
* Set amount = 0 to avoid overbooking sales
|
||||
*
|
||||
* @param vWarehouseFk vn.warehouse.id
|
||||
*/
|
||||
DECLARE vCalcFk INT;
|
||||
|
||||
CALL cache.available_refresh(vCalcFk, FALSE, vWarehouseFk, 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
|
||||
SET r.amount = 0
|
||||
WHERE ADDTIME(o.rowUpdated, oc.reserveTime) < NOW()
|
||||
AND a.available <= 0
|
||||
AND r.shipment BETWEEN CURDATE() AND util.dayEnd(CURDATE())
|
||||
AND NOT o.confirmed
|
||||
AND r.warehouseFk = vWarehouseFk;
|
||||
END$$
|
||||
DELIMITER ;
|
Loading…
Reference in New Issue