src/Entity/Invoice.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\Invoice\Status;
  4. use App\Repository\InvoiceRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass=InvoiceRepository::class)
  8.  */
  9. class Invoice
  10. {
  11.     /**
  12.      * @ORM\Id
  13.      * @ORM\GeneratedValue
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\Column(type="datetime")
  19.      */
  20.     private $createdAt;
  21.     /**
  22.      * @ORM\Column(type="enum", options={"values"="invoice_enum", "default"="new"})
  23.      */
  24.     private $status Status::STATUS_NEW;
  25.     /**
  26.      * @ORM\Column(type="integer", nullable=true)
  27.      */
  28.     private $amount;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity=Candidate::class)
  31.      * @ORM\JoinColumn(nullable=false)
  32.      */
  33.     private $candidate;
  34.     /**
  35.      * @ORM\ManyToOne(targetEntity=FinanceCategory::class)
  36.      * @ORM\JoinColumn(nullable=true)
  37.      */
  38.     private $financeCategory;
  39.     /**
  40.      * @ORM\ManyToOne(targetEntity=Person::class)
  41.      * @ORM\JoinColumn(nullable=true)
  42.      */
  43.     private $person;
  44.     /**
  45.      * @ORM\OneToOne(targetEntity=Transaction::class, inversedBy="invoice", cascade={"persist", "remove"})
  46.      */
  47.     private $transaction;
  48.     public function __construct()
  49.     {
  50.         $this->createdAt = new \DateTime();
  51.     }
  52.     public function __toString()
  53.     {
  54.         $ce $this->getCandidate() ? $this->getCandidate()->getCalendarEvent() : null;
  55.         return ($this->getPerson() ? $this->getPerson()->__toString() : "–") . " – "
  56.             . ($ce $ce->getNameText() : "–");
  57.     }
  58.     public function getId(): ?int
  59.     {
  60.         return $this->id;
  61.     }
  62.     public function getCreatedAt(): ?\DateTimeInterface
  63.     {
  64.         return $this->createdAt;
  65.     }
  66.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  67.     {
  68.         $this->createdAt $createdAt;
  69.         return $this;
  70.     }
  71.     public function getStatus()
  72.     {
  73.         return $this->status;
  74.     }
  75.     public function setStatus($status): self
  76.     {
  77.         $this->status $status;
  78.         return $this;
  79.     }
  80.     public function getStatusText(): string
  81.     {
  82.         return Status::getText($this->status);
  83.     }
  84.     public function getStatusCssClass($prefix null): string
  85.     {
  86.         return Status::getCssClass($this->status$prefix);
  87.     }
  88.     public function isNewStatus(): bool
  89.     {
  90.         return $this->status === Status::STATUS_NEW;
  91.     }
  92.     public function isDeletedStatus(): bool
  93.     {
  94.         return $this->status === Status::STATUS_DELETED;
  95.     }
  96.     public function isPaidStatus(): bool
  97.     {
  98.         return $this->status === Status::STATUS_PAID;
  99.     }
  100.     public function isReservedStatus(): bool
  101.     {
  102.         return $this->status === Status::STATUS_RESERVED;
  103.     }
  104.     public function getAmount(): ?int
  105.     {
  106.         return $this->amount;
  107.     }
  108.     public function setAmount(?int $amount): self
  109.     {
  110.         $this->amount $amount;
  111.         return $this;
  112.     }
  113.     public function getCandidate(): ?Candidate
  114.     {
  115.         return $this->candidate;
  116.     }
  117.     public function setCandidate(?Candidate $candidate): self
  118.     {
  119.         $this->candidate $candidate;
  120.         if ($candidate) {
  121.             $candidate->setInvoice($this);
  122.         }
  123.         return $this;
  124.     }
  125.     public function getFinanceCategory(): ?FinanceCategory
  126.     {
  127.         return $this->financeCategory;
  128.     }
  129.     public function setFinanceCategory(?FinanceCategory $financeCategory): self
  130.     {
  131.         $this->financeCategory $financeCategory;
  132.         return $this;
  133.     }
  134.     public function getPerson(): ?Person
  135.     {
  136.         return $this->person;
  137.     }
  138.     public function setPerson(?Person $person): self
  139.     {
  140.         $this->person $person;
  141.         return $this;
  142.     }
  143.     public function getTransaction(): ?Transaction
  144.     {
  145.         return $this->transaction;
  146.     }
  147.     public function setTransaction(?Transaction $transaction): self
  148.     {
  149.         $this->transaction $transaction;
  150.         return $this;
  151.     }
  152. }