<?php
namespace App\Entity;
use App\Repository\StockItemsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=StockItemsRepository::class)
*/
class StockItems
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "item.core", "stock_item:core", "stock_item@core"
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=64)
* @Groups({
* "item.core", "stock_item:core", "stock_item@core"
* })
*/
private $name;
/**
* @ORM\ManyToOne(targetEntity=Unit::class, inversedBy="stockItems")
* @ORM\JoinColumn(nullable=false)
* @Groups({
* "item.unit",
* "stock_item@unit"
* })
*/
private $unit;
/**
* @ORM\ManyToOne(targetEntity=StockItemCategories::class, inversedBy="stockItems")
* @Groups({
* "item.category"
* })
*/
private $item_category;
/**
* @ORM\ManyToOne(targetEntity=ItemGroups::class, inversedBy="stockItems")
* @Groups({
* "item.group"
* })
*/
private $item_group;
/**
* @ORM\Column(type="string", length=255)
* @Groups({
* "item.core", "stock_item:core", "stock_item@core"
* })
* @ORM\JoinColumn(nullable=true)
*/
private $description;
/**
* @ORM\OneToMany(targetEntity=Stocks::class, mappedBy="stock_item")
* @Groups({
* "stock_item@stocks",
* "item.stocks"
* })
*/
private $stocks;
/**
* Bu colon Table da yer almiyor.
* Hesaplamasi DoctrineSubscriber icinde yapiliyor
* @Groups({
* "item.core", "stock_item:core", "stock_item@core"
* })
*/
private $total_available_quantity;
/**
* Simdikilik Kullanma!!!
* @ORM\OneToMany(targetEntity=SupplierProducts::class, mappedBy="stock_item")
* @Groups({
* "item.supplier.products",
* "stock_item:supplier_products"
* })
*/
private $supplier_products;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "item.core", "stock_item:core", "stock_item@core"
* })
*/
private $norm;
/**
* Bu colon Table da yer almiyor.
* Hesaplamasi DoctrineSubscriber icinde yapiliyor
*/
public function getTotalAvailableQuantity(): float
{
return $this->total_available_quantity;
}
/**
* Bu colon Table da yer almiyor.
* Hesaplamasi DoctrineSubscriber icinde yapiliyor
*/
public function setTotalAvailableQuantity(?float $final_quantity )
{
$this->total_available_quantity = $final_quantity ?? 0;
}
public function __construct()
{
$this->stocks = new ArrayCollection();
$this->supplier_products = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getUnit(): ?Unit
{
return $this->unit;
}
public function setUnit(?Unit $unit): self
{
$this->unit = $unit;
return $this;
}
public function getItemCategory(): ?StockItemCategories
{
return $this->item_category;
}
public function setItemCategory(?StockItemCategories $item_category): self
{
$this->item_category = $item_category;
return $this;
}
public function getItemGroup(): ?ItemGroups
{
return $this->item_group;
}
public function setItemGroup(?ItemGroups $item_group): self
{
$this->item_group = $item_group;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
/**
* @return Collection<int, Stocks>
*/
public function getStocks(): Collection
{
return $this->stocks;
}
public function addStock(Stocks $stock): self
{
if (!$this->stocks->contains($stock)) {
$this->stocks[] = $stock;
$stock->setStockItem($this);
}
return $this;
}
public function removeStock(Stocks $stock): self
{
if ($this->stocks->removeElement($stock)) {
// set the owning side to null (unless already changed)
if ($stock->getStockItem() === $this) {
$stock->setStockItem(null);
}
}
return $this;
}
/**
* @return Collection<int, SupplierProducts>
*/
public function getSupplierProducts(): Collection
{
return $this->supplier_products;
}
public function addSupplierProduct(SupplierProducts $supplierProduct): self
{
if (!$this->supplier_products->contains($supplierProduct)) {
$this->supplier_products[] = $supplierProduct;
$supplierProduct->setStockItem($this);
}
return $this;
}
public function removeSupplierProduct(SupplierProducts $supplierProduct): self
{
if ($this->supplier_products->removeElement($supplierProduct)) {
// set the owning side to null (unless already changed)
if ($supplierProduct->getStockItem() === $this) {
$supplierProduct->setStockItem(null);
}
}
return $this;
}
public function getNorm(): ?string
{
return $this->norm;
}
public function setNorm(?string $norm): self
{
$this->norm = $norm;
return $this;
}
}