<?php
namespace App\Entity;
use App\Repository\SuppliersRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Warehouse;
use phpDocumentor\Reflection\Types\This;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* ORM\Entity(repositoryClass=SuppliersRepository::class)
* ORM\Table(
* name="suppliers",
* uniqueConstraints={
* ORM\UniqueConstraint(columns={"company", "location_id"}),
* },
* )
* UniqueEntity(
* fields={"alias", "company", "location_id"},
* message="Supplier already registered|Supplier with combination (%s %s) is already registered"
* )
*/
/**
* @ORM\Entity(repositoryClass=SuppliersRepository::class)
* @ORM\Table(
* name="suppliers",
* uniqueConstraints={
* @ORM\UniqueConstraint(columns={"company", "location_id"}),
* },
* )
* @UniqueEntity(
* fields={"alias", "company", "location"},
* message="Supplier already registered|Supplier with combination (%s %s) is already registered"
* )
*/
class Suppliers
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "project.details.orders",
* "order.detail",
* "supplier.base",
* "material.base",
*
* "project.orders.expense.minify.list.version",
*
* "supplier.core",
* "supplier:core",
*
* "supplier@core",
* "supplier@base"
*
* })
*/
private $id;
/**
* @deprecated use company
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "project.details.orders",
* "order.detail",
* "supplier.base",
* "material.base",
*
* "supplier.core", "supplier:core", "supplier@core", "supplier@base"
* })
*/
private $name;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "supplier.base",
*
* "supplier.core", "supplier:core", "supplier@core"
* })
*/
private $city;
/**
* @ORM\OneToMany(targetEntity=ProjectOrderExtraCosts::class, mappedBy="supplier")
*/
private $projectOrderExtraCosts;
/**
* @ORM\OneToMany(targetEntity=Material::class, mappedBy="supplier")
* @Groups({"supplier@materials"})
*/
private $materials;
/**
* @ORM\OneToMany(targetEntity=SupplierOrders::class, mappedBy="supplier")
*/
private $supplierOrders;
/**
* @ORM\OneToMany(targetEntity=ProjectOrderExpenses::class, mappedBy="supplier", orphanRemoval=true)
*/
private $projectOrderExpenses;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "supplier.base",
* "supplier.expenses",
*
* "supplier@core"
* })
*/
private $alias;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "supplier.base",
* "project.orders.expense.minify.version",
* "supplier.core", "supplier:core",
*
* "supplier@core",
* "supplier@base"
* })
*/
private $company;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "supplier.base",
* "project.orders.expense.minify.list.version",
* "supplier.core", "supplier:core",
*
* "supplier@core"
* })
*/
private $terms_to_payment;
/**
* @deprecated use Location
* @ORM\OneToMany(targetEntity=Addresses::class, mappedBy="supplier")
* @Groups({
* "supplier.base",
* "supplier.address",
*
* "supplier@address"
* })
*/
private $addresses;
/**
* TODO Bu Location yada Address ???
* @ORM\ManyToOne(targetEntity=Addresses::class, inversedBy="suppliers")
* @Groups({
* "supplier.base",
* "supplier.core", "supplier:core", "supplier@core"
* })
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private $address;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "supplier.base",
* "supplier.core", "supplier:core", "supplier@core"
* })
*/
private $tax;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "supplier.base",
* "supplier.core", "supplier:core", "supplier@core"
* })
*/
private $email;
/**
* @ORM\OneToMany(targetEntity=Stocks::class, mappedBy="supplier")
*/
private $stocks;
/**
* @ORM\OneToMany(targetEntity=SupplierProducts::class, mappedBy="supplier")
* @Groups({
* "supplier.products",
* "supplier@products"
* })
*/
private $supplier_products;
/**
* @ORM\ManyToOne(targetEntity=Locations::class, inversedBy="suppliers")
* @Groups({
* "supplier@location"
* })
*/
private $location;
/**
* @ORM\OneToMany(targetEntity=SupplierEducation::class, mappedBy="supplier", orphanRemoval=true)
* @Groups({
* "supplier@educations"
* })
*/
private $supplier_educations;
/**
* @ORM\Column(type="text", nullable=true)
* @Groups({
* "supplier.core", "supplier:core", "supplier@core"
* })
*/
private $order_confirmation_content;
/**
* @ORM\Column(type="decimal", precision=12, scale=2, nullable=true)
* @Groups({"supplier@core"})
*/
private $monthly_limit;
/**
* @ORM\OneToMany(targetEntity=SupplierContactPersons::class, mappedBy="supplier", orphanRemoval=true, cascade={"persist", "remove"})
* @Groups({
* "supplier@contact_persons"
* })
*/
private $supplier_contact_persons;
public function __construct()
{
$this->projectOrderExtraCosts = new ArrayCollection();
$this->materials = new ArrayCollection();
$this->supplierOrders = new ArrayCollection();
$this->projectOrderExpenses = new ArrayCollection();
$this->addresses = new ArrayCollection();
$this->stocks = new ArrayCollection();
$this->supplier_products = new ArrayCollection();
$this->supplier_educations = new ArrayCollection();
$this->supplier_contact_persons = 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 getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
/**
* @return Collection<int, ProjectOrderExtraCosts>
*/
public function getProjectOrderExtraCosts(): Collection
{
return $this->projectOrderExtraCosts;
}
public function addProjectOrderExtraCost(ProjectOrderExtraCosts $projectOrderExtraCost): self
{
if (!$this->projectOrderExtraCosts->contains($projectOrderExtraCost)) {
$this->projectOrderExtraCosts[] = $projectOrderExtraCost;
$projectOrderExtraCost->setSupplier($this);
}
return $this;
}
public function removeProjectOrderExtraCost(ProjectOrderExtraCosts $projectOrderExtraCost): self
{
if ($this->projectOrderExtraCosts->removeElement($projectOrderExtraCost)) {
// set the owning side to null (unless already changed)
if ($projectOrderExtraCost->getSupplier() === $this) {
$projectOrderExtraCost->setSupplier(null);
}
}
return $this;
}
/**
* @return Collection<int, Material>
*/
public function getMaterials(): Collection
{
return $this->materials;
}
public function addMaterial(Material $material): self
{
if (!$this->materials->contains($material)) {
$this->materials[] = $material;
$material->setSupplier($this);
}
return $this;
}
public function removeMaterial(Material $material): self
{
if ($this->materials->removeElement($material)) {
// set the owning side to null (unless already changed)
if ($material->getSupplier() === $this) {
$material->setSupplier(null);
}
}
return $this;
}
/**
* @return Collection<int, SupplierOrders>
*/
public function getSupplierOrders(): Collection
{
return $this->supplierOrders;
}
public function addSupplierOrder(SupplierOrders $supplierOrder): self
{
if (!$this->supplierOrders->contains($supplierOrder)) {
$this->supplierOrders[] = $supplierOrder;
$supplierOrder->setSupplier($this);
}
return $this;
}
public function removeSupplierOrder(SupplierOrders $supplierOrder): self
{
if ($this->supplierOrders->removeElement($supplierOrder)) {
// set the owning side to null (unless already changed)
if ($supplierOrder->getSupplier() === $this) {
$supplierOrder->setSupplier(null);
}
}
return $this;
}
/**
* @return Collection<int, ProjectOrderExpenses>
*/
public function getProjectOrderExpenses(): Collection
{
return $this->projectOrderExpenses;
}
public function addProjectOrderExpense(ProjectOrderExpenses $projectOrderExpense): self
{
if (!$this->projectOrderExpenses->contains($projectOrderExpense)) {
$this->projectOrderExpenses[] = $projectOrderExpense;
$projectOrderExpense->setSupplier($this);
}
return $this;
}
public function removeProjectOrderExpense(ProjectOrderExpenses $projectOrderExpense): self
{
if ($this->projectOrderExpenses->removeElement($projectOrderExpense)) {
// set the owning side to null (unless already changed)
if ($projectOrderExpense->getSupplier() === $this) {
$projectOrderExpense->setSupplier(null);
}
}
return $this;
}
public function getAlias(): ?string
{
return $this->alias;
}
public function setAlias(?string $alias): self
{
$this->alias = $alias;
return $this;
}
public function getCompany(): ?string
{
return $this->company;
}
public function setCompany(?string $company): self
{
$this->company = $company;
return $this;
}
public function getTermsToPayment(): ?string
{
return $this->terms_to_payment;
}
public function setTermsToPayment(?string $terms_to_payment): self
{
$this->terms_to_payment = $terms_to_payment;
return $this;
}
/**
* @return Collection<int, Addresses>
*/
public function getAddresses(): Collection
{
return $this->addresses;
}
/**
* @deprecated use Location
*/
public function addAdress(Addresses $adress): self
{
if (!$this->addresses->contains($adress)) {
$this->addresses[] = $adress;
$adress->setSupplier($this);
}
return $this;
}
/**
* @deprecated use Location
*/
public function removeAdress(Addresses $adress): self
{
if ($this->addresses->removeElement($adress)) {
// set the owning side to null (unless already changed)
if ($adress->getSupplier() === $this) {
$adress->setSupplier(null);
}
}
return $this;
}
public function getAddress(): ?Addresses
{
return $this->address;
}
public function setAddress(?Addresses $address): self
{
$this->address = $address;
return $this;
}
public function getTax(): ?string
{
return $this->tax;
}
public function setTax(?string $tax): self
{
$this->tax = $tax;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getMonthlyLimit(): ?float
{
return $this->monthly_limit !== null ? (float)$this->monthly_limit : null;
}
public function setMonthlyLimit(?float $monthly_limit): self
{
$this->monthly_limit = $monthly_limit;
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->setSupplier($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->getSupplier() === $this) {
$stock->setSupplier(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->setSupplier($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->getSupplier() === $this) {
$supplierProduct->setSupplier(null);
}
}
return $this;
}
public function getLocation(): ?Locations
{
return $this->location;
}
public function setLocation(?Locations $location): self
{
$this->location = $location;
return $this;
}
/**
* @return Collection<int, SupplierEducation>
*/
public function getSupplierEducations(): Collection
{
return $this->supplier_educations;
}
public function addSupplierAiEducation(SupplierEducation $supplierAiEducation): self
{
if (!$this->supplier_educations->contains($supplierAiEducation)) {
$this->supplier_educations[] = $supplierAiEducation;
$supplierAiEducation->setSupplier($this);
}
return $this;
}
public function removeSupplierAiEducation(SupplierEducation $supplierAiEducation): self
{
if ($this->supplier_educations->removeElement($supplierAiEducation)) {
// set the owning side to null (unless already changed)
if ($supplierAiEducation->getSupplier() === $this) {
$supplierAiEducation->setSupplier(null);
}
}
return $this;
}
/**
* @return Collection<int, SupplierContactPersons>
*/
public function getSupplierContactPersons(): Collection
{
return $this->supplier_contact_persons;
}
public function addSupplierContactPerson(SupplierContactPersons $supplierContactPerson): self
{
if (!$this->supplier_contact_persons->contains($supplierContactPerson)) {
$this->supplier_contact_persons[] = $supplierContactPerson;
$supplierContactPerson->setSupplier($this);
}
return $this;
}
public function removeSupplierContactPerson(SupplierContactPersons $supplierContactPerson): self
{
if ($this->supplier_contact_persons->removeElement($supplierContactPerson)) {
if ($supplierContactPerson->getSupplier() === $this) {
$supplierContactPerson->setSupplier(null);
}
}
return $this;
}
public function getOrderConfirmationContent(): ?string
{
return $this->order_confirmation_content;
}
public function setOrderConfirmationContent(?string $order_confirmation_content): self
{
$this->order_confirmation_content = $order_confirmation_content;
return $this;
}
}