public function testGetters()
 {
     $this->assertSame('Move', InventoryTransactionType::move()->getName());
     $this->assertSame('Hold', InventoryTransactionType::hold()->getName());
     $this->assertSame('New Products', InventoryTransactionType::newProducts()->getName());
     $this->assertSame('Shipped', InventoryTransactionType::shipped()->getName());
     $this->assertSame('Returned', InventoryTransactionType::returned()->getName());
     $this->assertSame('Promotion', InventoryTransactionType::promotion()->getName());
     $this->assertSame('Damaged', InventoryTransactionType::damaged()->getName());
     $this->assertSame('Shrinkage', InventoryTransactionType::shrinkage()->getName());
 }
 /**
  * @param Product $product
  * @param int $quantity
  * @throws InventoryException
  * @throws InsufficientInventoryException
  * @throws EntityValidatorException
  */
 public function reserveProduct(Product $product, $quantity)
 {
     if (!$product->isInventoryRequired()) {
         // TODO: Investigate throwing exception in this case
         return;
     }
     try {
         $inventoryHoldLocation = $this->inventoryLocationRepository->findOneById($this->inventoryHoldLocationId);
     } catch (EntityNotFoundException $e) {
         throw InventoryException::missingInventoryHoldLocation();
     }
     try {
         $inventoryLocationId = $this->inventoryTransactionRepository->findInventoryIdForProductAndQuantity($product, $quantity);
         $inventoryLocation = $this->inventoryLocationRepository->findOneById($inventoryLocationId);
     } catch (EntityNotFoundException $e) {
         throw new InsufficientInventoryException();
     }
     $this->transferProduct($product, $quantity, 'Hold ' . ngettext('item', 'items', $quantity) . ' for order', $inventoryLocation, $inventoryHoldLocation, InventoryTransactionType::hold());
 }
Example #3
0
 public function getInventoryTransactionType()
 {
     return InventoryTransactionType::hold();
 }
 public function testHoldInventoryForOrderShipment()
 {
     $warehouse = $this->dummyData->getWarehouse();
     $product = $this->dummyData->getProduct();
     $widgetBinLocation = $this->dummyData->getInventoryLocation($warehouse);
     $debitTransaction = new InventoryTransaction($widgetBinLocation, InventoryTransactionType::hold());
     $debitTransaction->setProduct($product);
     $debitTransaction->setDebitQuantity(2);
     $debitTransaction->setMemo('Hold 2 Widgets for order #123');
     $customerHoldingLocation = new InventoryLocation($warehouse, 'Reserve for Customer', 'HOLD');
     $creditTransaction = new InventoryTransaction($customerHoldingLocation, InventoryTransactionType::hold());
     $creditTransaction->setProduct($product);
     $creditTransaction->setCreditQuantity(2);
     $creditTransaction->setMemo('Hold 2 Widgets for order #123');
     $this->assertEntityValid($debitTransaction);
     $this->assertEntityValid($creditTransaction);
     $this->assertTrue($debitTransaction->getType()->isHold());
 }