src/Entity/Inventory/InventoryItem.php line 21
<?php
namespace App\Entity\Inventory;
use App\Entity\Common as Common;
use App\Entity\Purchasing\LineItem;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Ignore;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Table(name: 'inventory_item')]
#[ORM\Index(columns: ['line_item_id'], name: 'inventory_item_line_item_id_idx')]
#[ORM\Index(columns: ['warehouse_id'], name: 'inventory_item_warehouse_id_idx')]
#[ORM\Index(columns: ['created_by'], name: 'inventory_item_created_by_idx')]
#[ORM\Index(columns: ['updated_by'], name: 'inventory_item_updated_by_idx')]
#[ORM\UniqueConstraint(name: 'inventory_item_warehouse_id_item_id_key', columns: ['warehouse_id', 'line_item_id'])]
#[ORM\Entity]
class InventoryItem
{
use Common\Blameable;
use Common\Trackable;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'inventory_item_id_seq')]
#[ORM\Column(type: Types::INTEGER)]
private ?int $id = null;
#[ORM\ManyToOne(targetEntity: LineItem::class, inversedBy: 'inventoriedItems')]
#[ORM\JoinColumn(name: 'line_item_id', referencedColumnName: 'id', nullable: false)]
private ?LineItem $lineItem = null;
#[ORM\ManyToOne(targetEntity: Warehouse::class, inversedBy: 'inventoriedItems')]
#[ORM\JoinColumn(name: 'warehouse_id', referencedColumnName: 'id', nullable: false)]
private ?Warehouse $warehouse = null;
/** @var Collection<int, ItemMovement> */
#[ORM\OneToMany(mappedBy: 'inventoryItem', targetEntity: ItemMovement::class)]
#[Ignore]
private Collection $movements;
/** @var Collection<int, WithdrawalItem> */
#[ORM\OneToMany(mappedBy: 'inventoryItem', targetEntity: WithdrawalItem::class)]
private Collection $withdrawalItems;
#[Assert\Type(type: Types::INTEGER)]
#[ORM\Column(type: Types::INTEGER)]
private ?int $availableQuantity = null;
#[Assert\Type(type: Types::INTEGER)]
#[ORM\Column(type: Types::INTEGER)]
private ?int $quarantinedQuantity = null;
#[Assert\Type(type: Types::INTEGER)]
#[ORM\Column(type: Types::INTEGER)]
private ?int $bookedQuantity = null;
#[Assert\Type(type: Types::FLOAT)]
#[ORM\Column(type: Types::DECIMAL, precision: 18, scale: 5)]
private ?float $unitPrice = null;
#[Assert\Type(type: Types::FLOAT)]
#[ORM\Column(type: Types::DECIMAL, precision: 18, scale: 5)]
private ?float $value = null;
public function __construct()
{
$this->movements = new ArrayCollection();
$this->withdrawalItems = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getAvailableQuantity(): ?int
{
return $this->availableQuantity;
}
public function setAvailableQuantity(int $availableQuantity): static
{
$this->availableQuantity = $availableQuantity;
return $this;
}
public function getQuarantinedQuantity(): ?int
{
return $this->quarantinedQuantity;
}
public function setQuarantinedQuantity(int $quarantinedQuantity): static
{
$this->quarantinedQuantity = $quarantinedQuantity;
return $this;
}
public function getBookedQuantity(): ?int
{
return $this->bookedQuantity;
}
public function setBookedQuantity(int $bookedQuantity): static
{
$this->bookedQuantity = $bookedQuantity;
return $this;
}
public function getUnitPrice(): ?string
{
return $this->unitPrice;
}
public function setUnitPrice(string $unitPrice): static
{
$this->unitPrice = $unitPrice;
return $this;
}
public function getValue(): ?string
{
return $this->value;
}
public function setValue(string $value): static
{
$this->value = $value;
return $this;
}
public function getLineItem(): ?LineItem
{
return $this->lineItem;
}
public function setLineItem(?LineItem $lineItem): static
{
$this->lineItem = $lineItem;
return $this;
}
public function getWarehouse(): ?Warehouse
{
return $this->warehouse;
}
public function setWarehouse(?Warehouse $warehouse): static
{
$this->warehouse = $warehouse;
return $this;
}
/**
* @return Collection<int, ItemMovement>
*/
public function getMovements(): Collection
{
return $this->movements;
}
public function addMovement(ItemMovement $movement): static
{
if (!$this->movements->contains($movement)) {
$this->movements->add($movement);
$movement->setInventoryItem($this);
}
return $this;
}
public function removeMovement(ItemMovement $movement): static
{
if ($this->movements->removeElement($movement)) {
// set the owning side to null (unless already changed)
if ($movement->getInventoryItem() === $this) {
$movement->setInventoryItem(null);
}
}
return $this;
}
/**
* @return Collection<int, WithdrawalItem>
*/
public function getWithdrawalItems(): Collection
{
return $this->withdrawalItems;
}
public function addWithdrawalItem(WithdrawalItem $withdrawalItem): static
{
if (!$this->withdrawalItems->contains($withdrawalItem)) {
$this->withdrawalItems->add($withdrawalItem);
$withdrawalItem->setInventoryItem($this);
}
return $this;
}
public function removeWithdrawalItem(WithdrawalItem $withdrawalItem): static
{
if ($this->withdrawalItems->removeElement($withdrawalItem)) {
// set the owning side to null (unless already changed)
if ($withdrawalItem->getInventoryItem() === $this) {
$withdrawalItem->setInventoryItem(null);
}
}
return $this;
}
}