/** * @param Product $product * @param int $quantity (can be negative) * @param UuidInterface $inventoryLocationId * @param InventoryTransactionType $transactionType * @throws EntityNotFoundException * @throws EntityValidatorException */ public function adjustInventory(Product $product, $quantity, UuidInterface $inventoryLocationId, InventoryTransactionType $transactionType) { $inventoryLocation = $this->inventoryLocationRepository->findOneById($inventoryLocationId); if ($quantity > 0) { $sourceLocation = null; $destinationLocation = $inventoryLocation; } else { $sourceLocation = $inventoryLocation; $destinationLocation = null; } $this->transferProduct($product, abs($quantity), 'Adjusting inventory: ' . $transactionType->getName(), $sourceLocation, $destinationLocation, $transactionType); }
public function testFindOneByIdThrowsNotFoundException() { $this->setExpectedException(EntityNotFoundException::class, 'InventoryLocation not found'); $this->inventoryLocationRepository->findOneById($this->dummyData->getId()); }