src/Entity/Inventory/InventoryItem.php line 21

  1. <?php
  2. namespace App\Entity\Inventory;
  3. use App\Entity\Common as Common;
  4. use App\Entity\Purchasing\LineItem;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Ignore;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ORM\Table(name'inventory_item')]
  12. #[ORM\Index(columns: ['line_item_id'], name'inventory_item_line_item_id_idx')]
  13. #[ORM\Index(columns: ['warehouse_id'], name'inventory_item_warehouse_id_idx')]
  14. #[ORM\Index(columns: ['created_by'], name'inventory_item_created_by_idx')]
  15. #[ORM\Index(columns: ['updated_by'], name'inventory_item_updated_by_idx')]
  16. #[ORM\UniqueConstraint(name'inventory_item_warehouse_id_item_id_key'columns: ['warehouse_id''line_item_id'])]
  17. #[ORM\Entity]
  18. class InventoryItem
  19. {
  20.     use Common\Blameable;
  21.     use Common\Trackable;
  22.     #[ORM\Id]
  23.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  24.     #[ORM\SequenceGenerator(sequenceName'inventory_item_id_seq')]
  25.     #[ORM\Column(typeTypes::INTEGER)]
  26.     private ?int $id null;
  27.     #[ORM\ManyToOne(targetEntityLineItem::class, inversedBy'inventoriedItems')]
  28.     #[ORM\JoinColumn(name'line_item_id'referencedColumnName'id'nullablefalse)]
  29.     private ?LineItem $lineItem null;
  30.     #[ORM\ManyToOne(targetEntityWarehouse::class, inversedBy'inventoriedItems')]
  31.     #[ORM\JoinColumn(name'warehouse_id'referencedColumnName'id'nullablefalse)]
  32.     private ?Warehouse $warehouse null;
  33.     /** @var Collection<int, ItemMovement> */
  34.     #[ORM\OneToMany(mappedBy'inventoryItem'targetEntityItemMovement::class)]
  35.     #[Ignore]
  36.     private Collection $movements;
  37.     /** @var Collection<int, WithdrawalItem> */
  38.     #[ORM\OneToMany(mappedBy'inventoryItem'targetEntityWithdrawalItem::class)]
  39.     private Collection $withdrawalItems;
  40.     #[Assert\Type(typeTypes::INTEGER)]
  41.     #[ORM\Column(typeTypes::INTEGER)]
  42.     private ?int $availableQuantity null;
  43.     #[Assert\Type(typeTypes::INTEGER)]
  44.     #[ORM\Column(typeTypes::INTEGER)]
  45.     private ?int $quarantinedQuantity null;
  46.     #[Assert\Type(typeTypes::INTEGER)]
  47.     #[ORM\Column(typeTypes::INTEGER)]
  48.     private ?int $bookedQuantity null;
  49.     #[Assert\Type(typeTypes::FLOAT)]
  50.     #[ORM\Column(typeTypes::DECIMALprecision18scale5)]
  51.     private ?float $unitPrice null;
  52.     #[Assert\Type(typeTypes::FLOAT)]
  53.     #[ORM\Column(typeTypes::DECIMALprecision18scale5)]
  54.     private ?float $value null;
  55.     public function __construct()
  56.     {
  57.         $this->movements = new ArrayCollection();
  58.         $this->withdrawalItems = new ArrayCollection();
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getAvailableQuantity(): ?int
  65.     {
  66.         return $this->availableQuantity;
  67.     }
  68.     public function setAvailableQuantity(int $availableQuantity): static
  69.     {
  70.         $this->availableQuantity $availableQuantity;
  71.         return $this;
  72.     }
  73.     public function getQuarantinedQuantity(): ?int
  74.     {
  75.         return $this->quarantinedQuantity;
  76.     }
  77.     public function setQuarantinedQuantity(int $quarantinedQuantity): static
  78.     {
  79.         $this->quarantinedQuantity $quarantinedQuantity;
  80.         return $this;
  81.     }
  82.     public function getBookedQuantity(): ?int
  83.     {
  84.         return $this->bookedQuantity;
  85.     }
  86.     public function setBookedQuantity(int $bookedQuantity): static
  87.     {
  88.         $this->bookedQuantity $bookedQuantity;
  89.         return $this;
  90.     }
  91.     public function getUnitPrice(): ?string
  92.     {
  93.         return $this->unitPrice;
  94.     }
  95.     public function setUnitPrice(string $unitPrice): static
  96.     {
  97.         $this->unitPrice $unitPrice;
  98.         return $this;
  99.     }
  100.     public function getValue(): ?string
  101.     {
  102.         return $this->value;
  103.     }
  104.     public function setValue(string $value): static
  105.     {
  106.         $this->value $value;
  107.         return $this;
  108.     }
  109.     public function getLineItem(): ?LineItem
  110.     {
  111.         return $this->lineItem;
  112.     }
  113.     public function setLineItem(?LineItem $lineItem): static
  114.     {
  115.         $this->lineItem $lineItem;
  116.         return $this;
  117.     }
  118.     public function getWarehouse(): ?Warehouse
  119.     {
  120.         return $this->warehouse;
  121.     }
  122.     public function setWarehouse(?Warehouse $warehouse): static
  123.     {
  124.         $this->warehouse $warehouse;
  125.         return $this;
  126.     }
  127.     /**
  128.      * @return Collection<int, ItemMovement>
  129.      */
  130.     public function getMovements(): Collection
  131.     {
  132.         return $this->movements;
  133.     }
  134.     public function addMovement(ItemMovement $movement): static
  135.     {
  136.         if (!$this->movements->contains($movement)) {
  137.             $this->movements->add($movement);
  138.             $movement->setInventoryItem($this);
  139.         }
  140.         return $this;
  141.     }
  142.     public function removeMovement(ItemMovement $movement): static
  143.     {
  144.         if ($this->movements->removeElement($movement)) {
  145.             // set the owning side to null (unless already changed)
  146.             if ($movement->getInventoryItem() === $this) {
  147.                 $movement->setInventoryItem(null);
  148.             }
  149.         }
  150.         return $this;
  151.     }
  152.     /**
  153.      * @return Collection<int, WithdrawalItem>
  154.      */
  155.     public function getWithdrawalItems(): Collection
  156.     {
  157.         return $this->withdrawalItems;
  158.     }
  159.     public function addWithdrawalItem(WithdrawalItem $withdrawalItem): static
  160.     {
  161.         if (!$this->withdrawalItems->contains($withdrawalItem)) {
  162.             $this->withdrawalItems->add($withdrawalItem);
  163.             $withdrawalItem->setInventoryItem($this);
  164.         }
  165.         return $this;
  166.     }
  167.     public function removeWithdrawalItem(WithdrawalItem $withdrawalItem): static
  168.     {
  169.         if ($this->withdrawalItems->removeElement($withdrawalItem)) {
  170.             // set the owning side to null (unless already changed)
  171.             if ($withdrawalItem->getInventoryItem() === $this) {
  172.                 $withdrawalItem->setInventoryItem(null);
  173.             }
  174.         }
  175.         return $this;
  176.     }
  177. }