feat: refs #8069 new proc
This commit is contained in:
parent
fd262e32c1
commit
03ea7580d8
|
@ -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