Ejemplo n.º 1
0
            $current_stock = intval($products_stock[$stock_id]);
            //CURRENT OPEN ORDERS
            $already_ordered = $class_do->refillOpenOrdersQuantity($segment_id, $pid, $aid);
            //Check if we have too much refill
            $over_refill = $current_stock + $already_ordered - $target_after_levelling;
            $logger->write("- article {$pid}-{$aid}, Total orders = {$row['total_qty']}" . ", Over refill = {$over_refill}");
            if ($over_refill > 0) {
                //cancel orders
                $order_ids = explode(',', $row['order_ids']);
                $order_status = explode(',', $row['order_status']);
                $canceled_qty = 0;
                foreach ($order_ids as $key => $order_id) {
                    //AR is always 1 qty, so cancel all orders
                    //1 by 1 until total over_refill is reached
                    $new_status = $class_do->doCancelOrders($order_id, $order_status[$key], 'auto-set');
                    if (statusIsCancelConfirmed($new_status)) {
                        $canceled_qty++;
                        $canceled_qty_total++;
                        $logger->write("  > cancel {$canceled_qty}, ID: {$order_id}");
                        if ($canceled_qty >= $over_refill) {
                            break;
                        }
                    } else {
                        $logger->write("  > cancel failed, ID: {$order_id}");
                    }
                }
            }
        }
        $logger->write("Total canceled Qty = {$canceled_qty_total}");
    }
}
Ejemplo n.º 2
0
 /**
  * Check if an item is canceled and confirmed
  * @param Int $status Item status
  * @return Boolean
  */
 public static function isStatusCancelConfirmed($status)
 {
     return statusIsCancelConfirmed($status);
 }