Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function isStockSufficient(StockableInterface $stockable, $quantity)
 {
     if (true === $this->backorders || $stockable->isAvailableOnDemand()) {
         return true;
     }
     return $quantity <= $stockable->getOnHand() - $stockable->getOnHold();
 }
 function it_recognizes_stockable_as_sufficient_if_on_hand_minus_on_hold_quantity_is_equal_to_the_required_quantity(StockableInterface $stockable)
 {
     $stockable->isTracked()->willReturn(true);
     $stockable->getOnHand()->willReturn(10);
     $stockable->getOnHold()->willReturn(5);
     $this->isStockSufficient($stockable, 5)->shouldReturn(true);
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function release(StockableInterface $stockable, $quantity)
 {
     if ($quantity < 0) {
         throw new \InvalidArgumentException('Quantity of units must be greater than 0.');
     }
     $this->eventDispatcher->dispatch(SyliusStockableEvents::PRE_RELEASE, new GenericEvent($stockable));
     $stockable->setOnHold($stockable->getOnHold() - $quantity);
     $this->eventDispatcher->dispatch(SyliusStockableEvents::POST_RELEASE, new GenericEvent($stockable));
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function isStockSufficient(StockableInterface $stockable, $quantity)
 {
     if ($stockable instanceof SoftDeletableInterface && $stockable->isDeleted()) {
         return false;
     }
     if ($this->backorders || $stockable->isAvailableOnDemand()) {
         return true;
     }
     return $quantity <= $stockable->getOnHand() - $stockable->getOnHold();
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function isStockSufficient(StockableInterface $stockable, $quantity)
 {
     return !$stockable->isTracked() || $quantity <= $stockable->getOnHand() - $stockable->getOnHold();
 }
Пример #6
0
 function it_recognizes_stockable_stock_sufficient_if_on_hand_quantity_is_greater_than_required_quantity(StockableInterface $stockable)
 {
     $this->beConstructedWith(false);
     $stockable->isAvailableOnDemand()->willReturn(false);
     $stockable->getOnHand()->willReturn(10);
     $stockable->getOnHold()->willReturn(0);
     $this->isStockSufficient($stockable, 5)->shouldReturn(true);
     $stockable->getOnHand()->willReturn(15);
     $this->isStockSufficient($stockable, 15)->shouldReturn(true);
 }