Skip to content

Commit

Permalink
[TASK] #518 Commented the algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Glushko committed Feb 17, 2018
1 parent adfa7f7 commit 1f3cf0b
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public function execute(OrderInterface $order): ShippingAlgorithmResultInterface
$itemSku = $orderItem->getSku();
$qtyToDeliver = $orderItem->getQtyOrdered();

//check if order item is not delivered yet
if ($orderItem->isDeleted() || $orderItem->getParentItemId() || $this->isZero($qtyToDeliver)) {
continue;
}
Expand All @@ -142,6 +143,7 @@ public function execute(OrderInterface $order): ShippingAlgorithmResultInterface
$sourceItemQty = $sourceItem->getQuantity();
$qtyToDeduct = min($sourceItemQty, $qtyToDeliver);

// check if source has some qty of SKU, so it's possible to take them into account
if ($this->isZero($sourceItemQty)) {
continue;
}
Expand All @@ -158,6 +160,8 @@ public function execute(OrderInterface $order): ShippingAlgorithmResultInterface
$qtyToDeliver -= $qtyToDeduct;
}

// if we go throw all sources from the stock and there is still some qty to delivery,
// then it doesn't have enough items to delivery
if (!$this->isZero($qtyToDeliver)) {
$isShippable = false;
}
Expand Down

0 comments on commit 1f3cf0b

Please sign in to comment.