<?php
namespace App\Entity;
use App\Repository\StockIssueRepository;
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=StockIssueRepository::class)
* @ORM\Table(name="stock_issue", options={"comment":"This table stores stock issues and related with Stock transactions"})
*/
class StockIssue
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "stock_issue@core",
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Groups({
* "stock_issue@core",
* })
*/
private $issue_name;
/**
* This stock issue does not necessarily have to be linked to a project order — it may have been issued for another reason.
* @ORM\ManyToOne(targetEntity=ProjectOrders::class, inversedBy="stock_issues")
* @ORM\JoinColumn(nullable=true)
* @Groups({
* "stock_issue@project_order",
* })
*/
private $project_order;
/**
* Absolute should be user
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="stock_out_issues")
* @ORM\JoinColumn(nullable=false, options={})
* @Groups({
* "stock_issue@issued_by",
* })
*/
private $issued_by;
/**
* Absolute should not be user, although it worker, can any person be issued stock
* @ORM\ManyToOne(targetEntity=Worker::class)
* @Groups({
* "stock_issue@issued_to",
* })
*/
private $issued_to;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
* @Groups({
* "stock_issue@core",
* })
*/
private $delivered_at;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "stock_issue@core",
* })
*/
private $notes;
/**
* @ORM\Column(type="datetime_immutable")
* @Groups({
* "stock_issue@core",
* })
*/
private $created_at;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
* @Groups({
* "stock_issue@core",
* })
*/
private $updated_at;
/**
* @ORM\OneToMany(targetEntity=StockIssuePositions::class, mappedBy="stock_issue", cascade={"persist", "remove"}, orphanRemoval=true)
* @Groups({
* "stock_issue@positions",
* })
*/
private $stock_issue_positions;
public function __construct()
{
$this->stock_issue_positions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getIssueName(): ?string
{
return $this->issue_name;
}
public function setIssueName(string $issue_name): self
{
$this->issue_name = $issue_name;
return $this;
}
public function getProjectOrder(): ?ProjectOrders
{
return $this->project_order;
}
public function setProjectOrder(?ProjectOrders $project_order): self
{
$this->project_order = $project_order;
return $this;
}
public function getIssuedBy(): ?User
{
return $this->issued_by;
}
public function setIssuedBy(?User $issued_by): self
{
$this->issued_by = $issued_by;
return $this;
}
public function getIssuedTo(): ?Worker
{
return $this->issued_to;
}
public function setIssuedTo(?Worker $issued_to): self
{
$this->issued_to = $issued_to;
return $this;
}
public function getDeliveredAt(): ?\DateTimeImmutable
{
return $this->delivered_at;
}
public function setDeliveredAt(?\DateTimeImmutable $delivered_at): self
{
$this->delivered_at = $delivered_at;
return $this;
}
public function getNotes(): ?string
{
return $this->notes;
}
public function setNotes(?string $notes): self
{
$this->notes = $notes;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeImmutable $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updated_at;
}
public function setUpdatedAt(?\DateTimeImmutable $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
/**
* @return Collection<int, StockIssuePositions>
*/
public function getStockIssuePositions(): Collection
{
return $this->stock_issue_positions;
}
public function addStockIssuePosition(StockIssuePositions $stockIssuePosition): self
{
if (!$this->stock_issue_positions->contains($stockIssuePosition)) {
$this->stock_issue_positions[] = $stockIssuePosition;
$stockIssuePosition->setStockIssue($this);
}
return $this;
}
public function removeStockIssuePosition(StockIssuePositions $stockIssuePosition): self
{
if ($this->stock_issue_positions->removeElement($stockIssuePosition)) {
// set the owning side to null (unless already changed)
if ($stockIssuePosition->getStockIssue() === $this) {
$stockIssuePosition->setStockIssue(null);
}
}
return $this;
}
}