private function isLocationValidForMoveOperation()
 {
     if ($this->type->isMove() && $this->inventoryLocation === null) {
         return false;
     }
     return true;
 }
 public function testCreateByIdThrowsExceptionWhenInvalid()
 {
     $this->setExpectedException(InvalidArgumentException::class);
     InventoryTransactionType::createById(999);
 }
示例#3
0
 public function getInventoryTransactionType()
 {
     return InventoryTransactionType::hold();
 }
 public function handle(AdjustInventoryCommand $command)
 {
     $product = $this->productService->findOneById($command->getProductId());
     $this->inventoryService->adjustInventory($product, $command->getQuantity(), $command->getInventoryLocationId(), InventoryTransactionType::createById($command->getTransactionTypeId()));
 }
 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());
 }
 /**
  * @param Product $product
  * @param int $quantity
  * @param UuidInterface $inventoryLocationId
  * @throws EntityNotFoundException
  * @throws EntityValidatorException
  */
 public function reduceProductForShrinkage(Product $product, $quantity, UuidInterface $inventoryLocationId)
 {
     $this->adjustInventory($product, abs($quantity) * -1, $inventoryLocationId, InventoryTransactionType::shrinkage());
 }