<?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=true, onDelete="SET NULL")
*/
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;
/**
* Preiseinheit / PE — quantity the buying_price refers to (e.g. 1000 means price per 1000 KG).
* NULL means price is per single unit (default).
*
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "supplier_product@core"
* })
*/
private $price_unit;
/**
* @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;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "supplier_product@core"
* })
*/
private $product_label;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "supplier_product@core"
* })
*/
private $product_description;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "supplier_product@core"
* })
*/
private $quantity;
/**
* @ORM\ManyToOne(targetEntity=Unit::class)
* @Groups({
* "supplier_product@unit_type"
* })
*/
private $unit_type;
/**
* @ORM\OneToMany(targetEntity=SupplierProductFrameworkContract::class, mappedBy="supplier_product")
* @Groups({
* "supplier_product@framework_contracts"
* })
*/
private $framework_contracts;
/**
* @ORM\ManyToOne(targetEntity=ProductCatalog::class, inversedBy="supplier_products")
* @ORM\JoinColumn(nullable=true)
* @Groups({
* "supplier_product@product_catalog"
* })
*/
private $product_catalog;
/**
* @ORM\OneToMany(targetEntity=ProjectOrderExpensePositions::class, mappedBy="supplier_product")
*/
private $project_order_expense_positions;
/**
* @ORM\ManyToMany(targetEntity=Norm::class, inversedBy="supplier_products")
* @ORM\JoinTable(name="supplier_product_norms")
* @Groups({"supplier_product@norms"})
*/
private $norms;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "supplier_product@core"
* })
*/
private $material;
public function __construct()
{
$this->stocks = new ArrayCollection();
$this->framework_contracts = new ArrayCollection();
$this->project_order_expense_positions = new ArrayCollection();
$this->norms = 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 getPriceUnit(): ?float
{
return $this->price_unit;
}
public function setPriceUnit(?float $price_unit): self
{
$this->price_unit = $price_unit;
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;
}
public function getProductLabel(): ?string
{
return $this->product_label;
}
public function setProductLabel(?string $product_label): self
{
$this->product_label = $product_label;
return $this;
}
public function getProductDescription(): ?string
{
return $this->product_description;
}
public function setProductDescription(?string $product_description): self
{
$this->product_description = $product_description;
return $this;
}
public function getQuantity(): ?float
{
return $this->quantity;
}
public function setQuantity(?float $quantity): self
{
$this->quantity = $quantity;
return $this;
}
public function getUnitType(): ?Unit
{
return $this->unit_type;
}
public function setUnitType(?Unit $unit_type): self
{
$this->unit_type = $unit_type;
return $this;
}
/**
* @return Collection<int, SupplierProductFrameworkContract>
*/
public function getFrameworkContracts(): Collection
{
return $this->framework_contracts;
}
public function addFrameworkContract(SupplierProductFrameworkContract $frameworkContract): self
{
if (!$this->framework_contracts->contains($frameworkContract)) {
$this->framework_contracts[] = $frameworkContract;
$frameworkContract->setSupplierProduct($this);
}
return $this;
}
public function removeFrameworkContract(SupplierProductFrameworkContract $frameworkContract): self
{
if ($this->framework_contracts->removeElement($frameworkContract)) {
if ($frameworkContract->getSupplierProduct() === $this) {
$frameworkContract->setSupplierProduct(null);
}
}
return $this;
}
public function getProductCatalog(): ?ProductCatalog
{
return $this->product_catalog;
}
public function setProductCatalog(?ProductCatalog $productCatalog): self
{
$this->product_catalog = $productCatalog;
return $this;
}
/**
* @return Collection<int, ProjectOrderExpensePositions>
*/
public function getProjectOrderExpensePositions(): Collection
{
return $this->project_order_expense_positions;
}
public function addProjectOrderExpensePosition(ProjectOrderExpensePositions $projectOrderExpensePosition): self
{
if (!$this->project_order_expense_positions->contains($projectOrderExpensePosition)) {
$this->project_order_expense_positions[] = $projectOrderExpensePosition;
$projectOrderExpensePosition->setSupplierProduct($this);
}
return $this;
}
public function removeProjectOrderExpensePosition(ProjectOrderExpensePositions $projectOrderExpensePosition): self
{
if ($this->project_order_expense_positions->removeElement($projectOrderExpensePosition)) {
// set the owning side to null (unless already changed)
if ($projectOrderExpensePosition->getSupplierProduct() === $this) {
$projectOrderExpensePosition->setSupplierProduct(null);
}
}
return $this;
}
/**
* @return Collection<int, Norm>
*/
public function getNorms(): Collection
{
return $this->norms;
}
public function addNorm(Norm $norm): self
{
if (!$this->norms->contains($norm)) {
$this->norms[] = $norm;
}
return $this;
}
public function removeNorm(Norm $norm): self
{
$this->norms->removeElement($norm);
return $this;
}
public function getMaterial(): ?string
{
return $this->material;
}
public function setMaterial(?string $material): self
{
$this->material = $material;
return $this;
}
}