src/Entity/Suppliers.php line 43

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SuppliersRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Entity\Warehouse;
  8. use phpDocumentor\Reflection\Types\This;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. /**
  12.  * ORM\Entity(repositoryClass=SuppliersRepository::class)
  13.  * ORM\Table(
  14.  *       name="suppliers",
  15.  *       uniqueConstraints={
  16.  *           ORM\UniqueConstraint(columns={"company", "location_id"}),
  17.  *       },
  18.  *  )
  19.  * UniqueEntity(
  20.  *       fields={"alias", "company", "location_id"},
  21.  *       message="Supplier already registered|Supplier with combination (%s %s) is already registered"
  22.  *  )
  23.  */
  24. /**
  25.  * @ORM\Entity(repositoryClass=SuppliersRepository::class)
  26.  * @ORM\Table(
  27.  *       name="suppliers",
  28.  *       uniqueConstraints={
  29.  *           @ORM\UniqueConstraint(columns={"company", "location_id"}),
  30.  *       },
  31.  *  )
  32.  * @UniqueEntity(
  33.  *       fields={"alias", "company", "location"},
  34.  *       message="Supplier already registered|Supplier with combination (%s %s) is already registered"
  35.  *  )
  36.  */
  37. class Suppliers
  38. {
  39.     /**
  40.      * @ORM\Id
  41.      * @ORM\GeneratedValue
  42.      * @ORM\Column(type="integer")
  43.      * @Groups({
  44.      *          "project.details.orders",
  45.      *          "order.detail",
  46.      *          "supplier.base",
  47.      *          "material.base",
  48.      *
  49.      *          "project.orders.expense.minify.list.version",
  50.      *
  51.      *     "supplier.core",
  52.      *     "supplier:core",
  53.      *
  54.      *     "supplier@core",
  55.      *     "supplier@base"
  56.      *
  57.      * })
  58.      */
  59.     private $id;
  60.     /**
  61.      * @deprecated use company
  62.      * @ORM\Column(type="string", length=255, nullable=true)
  63.      * @Groups({
  64.      *          "project.details.orders",
  65.      *          "order.detail",
  66.      *          "supplier.base",
  67.      *          "material.base",
  68.      *
  69.      *     "supplier.core", "supplier:core", "supplier@core", "supplier@base"
  70.      *     })
  71.      */
  72.     private $name;
  73.     /**
  74.      * @ORM\Column(type="string", length=64, nullable=true)
  75.      * @Groups({
  76.      *           "supplier.base",
  77.      *
  78.      *     "supplier.core", "supplier:core", "supplier@core"
  79.      *      })
  80.      */
  81.     private $city;
  82.     /**
  83.      * @ORM\OneToMany(targetEntity=ProjectOrderExtraCosts::class, mappedBy="supplier")
  84.      */
  85.     private $projectOrderExtraCosts;
  86.     /**
  87.      * @ORM\OneToMany(targetEntity=Material::class, mappedBy="supplier")
  88.      * @Groups({"supplier@materials"})
  89.      */
  90.     private $materials;
  91.     /**
  92.      * @ORM\OneToMany(targetEntity=SupplierOrders::class, mappedBy="supplier")
  93.      */
  94.     private $supplierOrders;
  95.     /**
  96.      * @ORM\OneToMany(targetEntity=ProjectOrderExpenses::class, mappedBy="supplier", orphanRemoval=true)
  97.      */
  98.     private $projectOrderExpenses;
  99.     /**
  100.      * @ORM\Column(type="string", length=64, nullable=true)
  101.      * @Groups({
  102.      *     "supplier.base",
  103.      *     "supplier.expenses",
  104.      *
  105.      *     "supplier@core"
  106.      * })
  107.      */
  108.     private $alias;
  109.     /**
  110.      * @ORM\Column(type="string", length=64, nullable=true)
  111.      * @Groups({
  112.      *     "supplier.base",
  113.      *     "project.orders.expense.minify.version",
  114.      *     "supplier.core", "supplier:core",
  115.      *
  116.      *     "supplier@core",
  117.      *     "supplier@base"
  118.      * })
  119.      */
  120.     private $company;
  121.     /**
  122.      * @ORM\Column(type="string", length=255, nullable=true)
  123.      * @Groups({
  124.      *     "supplier.base",
  125.      *     "project.orders.expense.minify.list.version",
  126.      *     "supplier.core", "supplier:core",
  127.      *
  128.      *     "supplier@core"
  129.      *  })
  130.      */
  131.     private $terms_to_payment;
  132.     /**
  133.      * @deprecated use Location
  134.      * @ORM\OneToMany(targetEntity=Addresses::class, mappedBy="supplier")
  135.      * @Groups({
  136.      *     "supplier.base",
  137.      *     "supplier.address",
  138.      *
  139.      *     "supplier@address"
  140.      * })
  141.      */
  142.     private $addresses;
  143.     /**
  144.      * TODO Bu Location yada Address ???
  145.      * @ORM\ManyToOne(targetEntity=Addresses::class, inversedBy="suppliers")
  146.      * @Groups({
  147.      *     "supplier.base",
  148.      *     "supplier.core", "supplier:core", "supplier@core"
  149.      * })
  150.      * @ORM\JoinColumn(onDelete="SET NULL")
  151.      */
  152.     private $address;
  153.     /**
  154.      * @ORM\Column(type="string", length=64, nullable=true)
  155.      * @Groups({
  156.      *     "supplier.base",
  157.      *     "supplier.core", "supplier:core", "supplier@core"
  158.      * })
  159.      */
  160.     private $tax;
  161.     /**
  162.      * @ORM\Column(type="string", length=255, nullable=true)
  163.      * @Groups({
  164.      *     "supplier.base",
  165.      *     "supplier.core", "supplier:core", "supplier@core"
  166.      * })
  167.      */
  168.     private $email;
  169.     /**
  170.      * @ORM\OneToMany(targetEntity=Stocks::class, mappedBy="supplier")
  171.      */
  172.     private $stocks;
  173.     /**
  174.      * @ORM\OneToMany(targetEntity=SupplierProducts::class, mappedBy="supplier")
  175.      * @Groups({
  176.      *     "supplier.products",
  177.      *     "supplier@products"
  178.      *  })
  179.      */
  180.     private $supplier_products;
  181.     /**
  182.      * @ORM\ManyToOne(targetEntity=Locations::class, inversedBy="suppliers")
  183.      * @Groups({
  184.      *     "supplier@location"
  185.      * })
  186.      */
  187.     private $location;
  188.     /**
  189.      * @ORM\OneToMany(targetEntity=SupplierEducation::class, mappedBy="supplier", orphanRemoval=true)
  190.      * @Groups({
  191.      *      "supplier@educations"
  192.      *  })
  193.      */
  194.     private $supplier_educations;
  195.     /**
  196.      * @ORM\Column(type="text", nullable=true)
  197.      * @Groups({
  198.      *     "supplier.core", "supplier:core", "supplier@core"
  199.      * })
  200.      */
  201.     private $order_confirmation_content;
  202.     /**
  203.      * @ORM\Column(type="decimal", precision=12, scale=2, nullable=true)
  204.      * @Groups({"supplier@core"})
  205.      */
  206.     private $monthly_limit;
  207.     /**
  208.      * @ORM\OneToMany(targetEntity=SupplierContactPersons::class, mappedBy="supplier", orphanRemoval=true, cascade={"persist", "remove"})
  209.      * @Groups({
  210.      *     "supplier@contact_persons"
  211.      * })
  212.      */
  213.     private $supplier_contact_persons;
  214.     public function __construct()
  215.     {
  216.         $this->projectOrderExtraCosts = new ArrayCollection();
  217.         $this->materials = new ArrayCollection();
  218.         $this->supplierOrders = new ArrayCollection();
  219.         $this->projectOrderExpenses = new ArrayCollection();
  220.         $this->addresses = new ArrayCollection();
  221.         $this->stocks = new ArrayCollection();
  222.         $this->supplier_products = new ArrayCollection();
  223.         $this->supplier_educations = new ArrayCollection();
  224.         $this->supplier_contact_persons = new ArrayCollection();
  225.     }
  226.     public function getId(): ?int
  227.     {
  228.         return $this->id;
  229.     }
  230.     public function getName(): ?string
  231.     {
  232.         return $this->name;
  233.     }
  234.     public function setName(?string $name): self
  235.     {
  236.         $this->name $name;
  237.         return $this;
  238.     }
  239.     public function getCity(): ?string
  240.     {
  241.         return $this->city;
  242.     }
  243.     public function setCity(?string $city): self
  244.     {
  245.         $this->city $city;
  246.         return $this;
  247.     }
  248.     /**
  249.      * @return Collection<int, ProjectOrderExtraCosts>
  250.      */
  251.     public function getProjectOrderExtraCosts(): Collection
  252.     {
  253.         return $this->projectOrderExtraCosts;
  254.     }
  255.     public function addProjectOrderExtraCost(ProjectOrderExtraCosts $projectOrderExtraCost): self
  256.     {
  257.         if (!$this->projectOrderExtraCosts->contains($projectOrderExtraCost)) {
  258.             $this->projectOrderExtraCosts[] = $projectOrderExtraCost;
  259.             $projectOrderExtraCost->setSupplier($this);
  260.         }
  261.         return $this;
  262.     }
  263.     public function removeProjectOrderExtraCost(ProjectOrderExtraCosts $projectOrderExtraCost): self
  264.     {
  265.         if ($this->projectOrderExtraCosts->removeElement($projectOrderExtraCost)) {
  266.             // set the owning side to null (unless already changed)
  267.             if ($projectOrderExtraCost->getSupplier() === $this) {
  268.                 $projectOrderExtraCost->setSupplier(null);
  269.             }
  270.         }
  271.         return $this;
  272.     }
  273.     /**
  274.      * @return Collection<int, Material>
  275.      */
  276.     public function getMaterials(): Collection
  277.     {
  278.         return $this->materials;
  279.     }
  280.     public function addMaterial(Material $material): self
  281.     {
  282.         if (!$this->materials->contains($material)) {
  283.             $this->materials[] = $material;
  284.             $material->setSupplier($this);
  285.         }
  286.         return $this;
  287.     }
  288.     public function removeMaterial(Material $material): self
  289.     {
  290.         if ($this->materials->removeElement($material)) {
  291.             // set the owning side to null (unless already changed)
  292.             if ($material->getSupplier() === $this) {
  293.                 $material->setSupplier(null);
  294.             }
  295.         }
  296.         return $this;
  297.     }
  298.     /**
  299.      * @return Collection<int, SupplierOrders>
  300.      */
  301.     public function getSupplierOrders(): Collection
  302.     {
  303.         return $this->supplierOrders;
  304.     }
  305.     public function addSupplierOrder(SupplierOrders $supplierOrder): self
  306.     {
  307.         if (!$this->supplierOrders->contains($supplierOrder)) {
  308.             $this->supplierOrders[] = $supplierOrder;
  309.             $supplierOrder->setSupplier($this);
  310.         }
  311.         return $this;
  312.     }
  313.     public function removeSupplierOrder(SupplierOrders $supplierOrder): self
  314.     {
  315.         if ($this->supplierOrders->removeElement($supplierOrder)) {
  316.             // set the owning side to null (unless already changed)
  317.             if ($supplierOrder->getSupplier() === $this) {
  318.                 $supplierOrder->setSupplier(null);
  319.             }
  320.         }
  321.         return $this;
  322.     }
  323.     /**
  324.      * @return Collection<int, ProjectOrderExpenses>
  325.      */
  326.     public function getProjectOrderExpenses(): Collection
  327.     {
  328.         return $this->projectOrderExpenses;
  329.     }
  330.     public function addProjectOrderExpense(ProjectOrderExpenses $projectOrderExpense): self
  331.     {
  332.         if (!$this->projectOrderExpenses->contains($projectOrderExpense)) {
  333.             $this->projectOrderExpenses[] = $projectOrderExpense;
  334.             $projectOrderExpense->setSupplier($this);
  335.         }
  336.         return $this;
  337.     }
  338.     public function removeProjectOrderExpense(ProjectOrderExpenses $projectOrderExpense): self
  339.     {
  340.         if ($this->projectOrderExpenses->removeElement($projectOrderExpense)) {
  341.             // set the owning side to null (unless already changed)
  342.             if ($projectOrderExpense->getSupplier() === $this) {
  343.                 $projectOrderExpense->setSupplier(null);
  344.             }
  345.         }
  346.         return $this;
  347.     }
  348.     public function getAlias(): ?string
  349.     {
  350.         return $this->alias;
  351.     }
  352.     public function setAlias(?string $alias): self
  353.     {
  354.         $this->alias $alias;
  355.         return $this;
  356.     }
  357.     public function getCompany(): ?string
  358.     {
  359.         return $this->company;
  360.     }
  361.     public function setCompany(?string $company): self
  362.     {
  363.         $this->company $company;
  364.         return $this;
  365.     }
  366.     public function getTermsToPayment(): ?string
  367.     {
  368.         return $this->terms_to_payment;
  369.     }
  370.     public function setTermsToPayment(?string $terms_to_payment): self
  371.     {
  372.         $this->terms_to_payment $terms_to_payment;
  373.         return $this;
  374.     }
  375.     /**
  376.      * @return Collection<int, Addresses>
  377.      */
  378.     public function getAddresses(): Collection
  379.     {
  380.         return $this->addresses;
  381.     }
  382.     /**
  383.      * @deprecated use Location
  384.     */
  385.     public function addAdress(Addresses $adress): self
  386.     {
  387.         if (!$this->addresses->contains($adress)) {
  388.             $this->addresses[] = $adress;
  389.             $adress->setSupplier($this);
  390.         }
  391.         return $this;
  392.     }
  393.     /**
  394.      * @deprecated use Location
  395.      */
  396.     public function removeAdress(Addresses $adress): self
  397.     {
  398.         if ($this->addresses->removeElement($adress)) {
  399.             // set the owning side to null (unless already changed)
  400.             if ($adress->getSupplier() === $this) {
  401.                 $adress->setSupplier(null);
  402.             }
  403.         }
  404.         return $this;
  405.     }
  406.     public function getAddress(): ?Addresses
  407.     {
  408.         return $this->address;
  409.     }
  410.     public function setAddress(?Addresses $address): self
  411.     {
  412.         $this->address $address;
  413.         return $this;
  414.     }
  415.     public function getTax(): ?string
  416.     {
  417.         return $this->tax;
  418.     }
  419.     public function setTax(?string $tax): self
  420.     {
  421.         $this->tax $tax;
  422.         return $this;
  423.     }
  424.     public function getEmail(): ?string
  425.     {
  426.         return $this->email;
  427.     }
  428.     public function setEmail(?string $email): self
  429.     {
  430.         $this->email $email;
  431.         return $this;
  432.     }
  433.     public function getMonthlyLimit(): ?float
  434.     {
  435.         return $this->monthly_limit !== null ? (float)$this->monthly_limit null;
  436.     }
  437.     public function setMonthlyLimit(?float $monthly_limit): self
  438.     {
  439.         $this->monthly_limit $monthly_limit;
  440.         return $this;
  441.     }
  442.     /**
  443.      * @return Collection<int, Stocks>
  444.      */
  445.     public function getStocks(): Collection
  446.     {
  447.         return $this->stocks;
  448.     }
  449.     public function addStock(Stocks $stock): self
  450.     {
  451.         if (!$this->stocks->contains($stock)) {
  452.             $this->stocks[] = $stock;
  453.             $stock->setSupplier($this);
  454.         }
  455.         return $this;
  456.     }
  457.     public function removeStock(Stocks $stock): self
  458.     {
  459.         if ($this->stocks->removeElement($stock)) {
  460.             // set the owning side to null (unless already changed)
  461.             if ($stock->getSupplier() === $this) {
  462.                 $stock->setSupplier(null);
  463.             }
  464.         }
  465.         return $this;
  466.     }
  467.     /**
  468.      * @return Collection<int, SupplierProducts>
  469.      */
  470.     public function getSupplierProducts(): Collection
  471.     {
  472.         return $this->supplier_products;
  473.     }
  474.     public function addSupplierProduct(SupplierProducts $supplierProduct): self
  475.     {
  476.         if (!$this->supplier_products->contains($supplierProduct)) {
  477.             $this->supplier_products[] = $supplierProduct;
  478.             $supplierProduct->setSupplier($this);
  479.         }
  480.         return $this;
  481.     }
  482.     public function removeSupplierProduct(SupplierProducts $supplierProduct): self
  483.     {
  484.         if ($this->supplier_products->removeElement($supplierProduct)) {
  485.             // set the owning side to null (unless already changed)
  486.             if ($supplierProduct->getSupplier() === $this) {
  487.                 $supplierProduct->setSupplier(null);
  488.             }
  489.         }
  490.         return $this;
  491.     }
  492.     public function getLocation(): ?Locations
  493.     {
  494.         return $this->location;
  495.     }
  496.     public function setLocation(?Locations $location): self
  497.     {
  498.         $this->location $location;
  499.         return $this;
  500.     }
  501.     /**
  502.      * @return Collection<int, SupplierEducation>
  503.      */
  504.     public function getSupplierEducations(): Collection
  505.     {
  506.         return $this->supplier_educations;
  507.     }
  508.     public function addSupplierAiEducation(SupplierEducation $supplierAiEducation): self
  509.     {
  510.         if (!$this->supplier_educations->contains($supplierAiEducation)) {
  511.             $this->supplier_educations[] = $supplierAiEducation;
  512.             $supplierAiEducation->setSupplier($this);
  513.         }
  514.         return $this;
  515.     }
  516.     public function removeSupplierAiEducation(SupplierEducation $supplierAiEducation): self
  517.     {
  518.         if ($this->supplier_educations->removeElement($supplierAiEducation)) {
  519.             // set the owning side to null (unless already changed)
  520.             if ($supplierAiEducation->getSupplier() === $this) {
  521.                 $supplierAiEducation->setSupplier(null);
  522.             }
  523.         }
  524.         return $this;
  525.     }
  526.     /**
  527.      * @return Collection<int, SupplierContactPersons>
  528.      */
  529.     public function getSupplierContactPersons(): Collection
  530.     {
  531.         return $this->supplier_contact_persons;
  532.     }
  533.     public function addSupplierContactPerson(SupplierContactPersons $supplierContactPerson): self
  534.     {
  535.         if (!$this->supplier_contact_persons->contains($supplierContactPerson)) {
  536.             $this->supplier_contact_persons[] = $supplierContactPerson;
  537.             $supplierContactPerson->setSupplier($this);
  538.         }
  539.         return $this;
  540.     }
  541.     public function removeSupplierContactPerson(SupplierContactPersons $supplierContactPerson): self
  542.     {
  543.         if ($this->supplier_contact_persons->removeElement($supplierContactPerson)) {
  544.             if ($supplierContactPerson->getSupplier() === $this) {
  545.                 $supplierContactPerson->setSupplier(null);
  546.             }
  547.         }
  548.         return $this;
  549.     }
  550.     public function getOrderConfirmationContent(): ?string
  551.     {
  552.         return $this->order_confirmation_content;
  553.     }
  554.     public function setOrderConfirmationContent(?string $order_confirmation_content): self
  555.     {
  556.         $this->order_confirmation_content $order_confirmation_content;
  557.         return $this;
  558.     }
  559. }