src/Entity/StockTransfer.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\StockTransferRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=StockTransferRepository::class)
  9.  * @ORM\Table(name="stock_transfer")
  10.  */
  11. class StockTransfer
  12. {
  13.     public const STATUS_DRAFT 'draft';
  14.     public const STATUS_CONFIRMED 'confirmed';
  15.     public const STATUS_CANCELLED 'cancelled';
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=30, unique=true)
  24.      */
  25.     private $reference;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity=Warehouse::class, inversedBy="sourceTransfers")
  28.      * @ORM\JoinColumn(name="source_warehouse_id", referencedColumnName="id", nullable=false, onDelete="RESTRICT")
  29.      */
  30.     private $sourceWarehouse;
  31.     /**
  32.      * @ORM\ManyToOne(targetEntity=Warehouse::class, inversedBy="targetTransfers")
  33.      * @ORM\JoinColumn(name="target_warehouse_id", referencedColumnName="id", nullable=false, onDelete="RESTRICT")
  34.      */
  35.     private $targetWarehouse;
  36.     /**
  37.      * @ORM\Column(type="string", length=20, options={"default":"draft"})
  38.      */
  39.     private $status self::STATUS_DRAFT;
  40.     /**
  41.      * @ORM\Column(name="created_by", type="integer", nullable=true)
  42.      */
  43.     private $createdBy;
  44.     /**
  45.      * @ORM\Column(name="created_at", type="datetime")
  46.      */
  47.     private $createdAt;
  48.     /**
  49.      * @ORM\Column(name="validated_at", type="datetime", nullable=true)
  50.      */
  51.     private $validatedAt;
  52.     /**
  53.      * @ORM\Column(type="text", nullable=true)
  54.      */
  55.     private $notes;
  56.     /**
  57.      * @ORM\OneToMany(targetEntity=StockTransferLine::class, mappedBy="transfer", cascade={"persist","remove"}, orphanRemoval=true)
  58.      */
  59.     private $lines;
  60.     public function __construct()
  61.     {
  62.         $this->lines = new ArrayCollection();
  63.         $this->createdAt = new \DateTime();
  64.     }
  65.     public function getId(): ?int
  66.     {
  67.         return $this->id;
  68.     }
  69.     public function getReference(): ?string
  70.     {
  71.         return $this->reference;
  72.     }
  73.     public function setReference(string $reference): self
  74.     {
  75.         $this->reference trim($reference);
  76.         return $this;
  77.     }
  78.     public function getSourceWarehouse(): ?Warehouse
  79.     {
  80.         return $this->sourceWarehouse;
  81.     }
  82.     public function setSourceWarehouse(?Warehouse $sourceWarehouse): self
  83.     {
  84.         $this->sourceWarehouse $sourceWarehouse;
  85.         return $this;
  86.     }
  87.     public function getTargetWarehouse(): ?Warehouse
  88.     {
  89.         return $this->targetWarehouse;
  90.     }
  91.     public function setTargetWarehouse(?Warehouse $targetWarehouse): self
  92.     {
  93.         $this->targetWarehouse $targetWarehouse;
  94.         return $this;
  95.     }
  96.     public function getStatus(): ?string
  97.     {
  98.         return $this->status;
  99.     }
  100.     public function setStatus(string $status): self
  101.     {
  102.         $this->status $status;
  103.         return $this;
  104.     }
  105.     public function getCreatedBy(): ?int
  106.     {
  107.         return $this->createdBy;
  108.     }
  109.     public function setCreatedBy(?int $createdBy): self
  110.     {
  111.         $this->createdBy $createdBy;
  112.         return $this;
  113.     }
  114.     public function getCreatedAt(): ?\DateTimeInterface
  115.     {
  116.         return $this->createdAt;
  117.     }
  118.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  119.     {
  120.         $this->createdAt $createdAt;
  121.         return $this;
  122.     }
  123.     public function getValidatedAt(): ?\DateTimeInterface
  124.     {
  125.         return $this->validatedAt;
  126.     }
  127.     public function setValidatedAt(?\DateTimeInterface $validatedAt): self
  128.     {
  129.         $this->validatedAt $validatedAt;
  130.         return $this;
  131.     }
  132.     public function getNotes(): ?string
  133.     {
  134.         return $this->notes;
  135.     }
  136.     public function setNotes(?string $notes): self
  137.     {
  138.         $this->notes $notes !== null trim($notes) : null;
  139.         return $this;
  140.     }
  141.     /**
  142.      * @return Collection|StockTransferLine[]
  143.      */
  144.     public function getLines(): Collection
  145.     {
  146.         return $this->lines;
  147.     }
  148.     public function addLine(StockTransferLine $line): self
  149.     {
  150.         if (!$this->lines->contains($line)) {
  151.             $this->lines[] = $line;
  152.             $line->setTransfer($this);
  153.         }
  154.         return $this;
  155.     }
  156.     public function removeLine(StockTransferLine $line): self
  157.     {
  158.         if ($this->lines->removeElement($line)) {
  159.             if ($line->getTransfer() === $this) {
  160.                 $line->setTransfer(null);
  161.             }
  162.         }
  163.         return $this;
  164.     }
  165.     public function isDraft(): bool
  166.     {
  167.         return $this->status === self::STATUS_DRAFT;
  168.     }
  169.     public function isConfirmed(): bool
  170.     {
  171.         return $this->status === self::STATUS_CONFIRMED;
  172.     }
  173. }