<?php
namespace App\Entity;
use App\Repository\SupplierProductsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\MaxDepth;
/**
* @ORM\Entity(repositoryClass=SupplierProductsRepository::class)
*/
class SupplierProducts
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "supplier:product:core", "supplier_product:core", "supplier_product@core"
* })
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Suppliers::class, inversedBy="supplierProducts")
* @Groups({
* "supplier:product:supplier", "supplier_product:supplier", "supplier_product@supplier"
* })
*/
private $supplier;
/**
* @MaxDepth(1)
* @ORM\ManyToOne(targetEntity=StockItems::class, inversedBy="supplierProducts")
* @Groups({
* "supplier:product:stock:items",
* "supplier_product:stock_item"
* })
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
private $stock_item;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "supplier:product:core", "supplier_product:core", "supplier_product@core"
* })
*/
private $ean;
/**
* @ORM\OneToMany(targetEntity=Stocks::class, mappedBy="supplied_product")
*/
private $stocks;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "supplier_product@core"
* })
*/
private $buying_price;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "supplier_product@core"
* })
*/
private $sales_margin;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "supplier_product@core"
* })
*/
private $sales_price;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "supplier:product:core", "supplier_product@core"
* })
*/
private $article_nr;
public function __construct()
{
$this->stocks = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getSupplier(): ?Suppliers
{
return $this->supplier;
}
public function setSupplier(?Suppliers $supplier): self
{
$this->supplier = $supplier;
return $this;
}
public function getStockItem(): ?StockItems
{
return $this->stock_item;
}
public function setStockItem(?StockItems $stock_item): self
{
$this->stock_item = $stock_item;
return $this;
}
public function getEan(): ?string
{
return $this->ean;
}
public function setEan(?string $ean): self
{
$this->ean = $ean;
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->setSuppliedProduct($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->getSuppliedProduct() === $this) {
$stock->setSuppliedProduct(null);
}
}
return $this;
}
public function getBuyingPrice(): ?float
{
return $this->buying_price;
}
public function setBuyingPrice(?float $buying_price): self
{
$this->buying_price = $buying_price;
return $this;
}
public function getSalesMargin(): ?float
{
return $this->sales_margin;
}
public function setSalesMargin(?float $sales_margin): self
{
$this->sales_margin = $sales_margin;
return $this;
}
public function getSalesPrice(): ?float
{
return $this->sales_price;
}
public function setSalesPrice(?float $sales_price): self
{
$this->sales_price = $sales_price;
return $this;
}
public function getArticleNr(): ?string
{
return $this->article_nr;
}
public function setArticleNr(?string $article_nr): self
{
$this->article_nr = $article_nr;
return $this;
}
}