src/Entity/Invoices.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\InvoicesRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\Common\Collections\Selectable;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use Doctrine\ORM\Mapping\UniqueConstraint;
  11. /**
  12.  * @ORM\Entity(repositoryClass=InvoicesRepository::class)
  13.  * @ORM\Table(
  14.  *     name="invoices",
  15.  *     uniqueConstraints={
  16.  *         @ORM\UniqueConstraint(columns={"invoice_number"})
  17.  *     }
  18.  * )
  19.  * @UniqueEntity(
  20.  *     fields={"invoice_number"},
  21.  *     message="Invoice already registered|Invoice %s already registered"
  22.  * )
  23.  */
  24. class Invoices
  25. {
  26.     /**
  27.      * @ORM\Id
  28.      * @ORM\GeneratedValue
  29.      * @ORM\Column(type="integer")
  30.      * @Groups({
  31.      *     "invoice@core",
  32.      *     "invoice@base"
  33.      * })
  34.      */
  35.     private $id;
  36.     /**
  37.      * @ORM\Column(type="string", length=64, nullable=true)
  38.      * @Groups({
  39.      *      "invoice@core",
  40.      *      "invoice@base"
  41.      *  })
  42.      */
  43.     private $invoice_number;
  44.     /**
  45.      * @ORM\ManyToOne(targetEntity=PaymentCurrencyTypes::class, inversedBy="invoices")
  46.      * @ORM\JoinColumn(nullable=true    )
  47.      * @Groups({
  48.      *      "invoice@payment_currency"
  49.      *  })
  50.      */
  51.     private $currency;
  52.     /**
  53.      * @ORM\ManyToOne(targetEntity=InvoiceType::class, inversedBy="invoices")
  54.      * @ORM\JoinColumn(nullable=false)
  55.      * @Groups({
  56.      *      "invoice@invoice_type"
  57.      *  })
  58.      */
  59.     private $invoice_type;
  60.     /**
  61.      * @ORM\Column(type="datetime_immutable")
  62.      * @Groups({
  63.      *      "invoice@core"
  64.      *  })
  65.      */
  66.     private $created_at;
  67.     /**
  68.      * @ORM\ManyToOne(targetEntity=ProjectOwner::class, inversedBy="invoices")
  69.      * TODO Temporarily nullable=true otherwise is false
  70.      * @ORM\JoinColumn(nullable=false)
  71.      * @Groups({
  72.      *      "invoice@customer"
  73.      *  })
  74.      */
  75.     private $customer;
  76.     /**
  77.      * @ORM\OneToMany(targetEntity=InvoicePositions::class, mappedBy="invoice", cascade={"persist"}, orphanRemoval=true)
  78.      * @Groups({
  79.      *       "invoice@positions"
  80.      *   })
  81.      */
  82.     private $invoice_positions;
  83.     /**
  84.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="invoices")
  85.      * @Groups({
  86.      *     "invoice@adder"
  87.      * })
  88.      */
  89.     private $adder;
  90.     /**
  91.      * @ORM\Column(type="date_immutable", nullable=true)
  92.      * @Groups({
  93.      *     "invoice@core",
  94.      *     "invoice@base"
  95.      * })
  96.      */
  97.     private $approved_at;
  98.     /**
  99.      * @ORM\Column(type="date_immutable", nullable=true)
  100.      * @Groups({
  101.      *     "invoice@core",
  102.      *     "invoice@base"
  103.      * })
  104.      */
  105.     private $paid_at;
  106.     /**
  107.      * Virtual column manage ove Subscriber
  108.      * @Groups({
  109.      *     "invoice@core"
  110.      * })
  111.     */
  112.     private $paid_status;
  113.     /**
  114.      * @ORM\OneToOne(targetEntity=Vouchers::class, cascade={"persist"})
  115.      * @ORM\JoinColumn(onDelete="SET NULL")
  116.      */
  117.     private $ref_voucher;
  118.     /**
  119.      * @ORM\OneToOne(targetEntity=ProjectOrderInvoices::class, cascade={"persist"})
  120.      * @ORM\JoinColumn(onDelete="SET NULL")
  121.      */
  122.     private $ref_project_order_invoice;
  123.     /**
  124.      * @ORM\Column(type="string", length=255, nullable=true)
  125.      */
  126.     private $note;
  127.     /**
  128.      * @see Virtual Column (Set in DoctrineSubscriber)
  129.      * @Groups({
  130.      *      "invoice@core"
  131.      *  })
  132.      */
  133.     private $week_of_year;
  134.     /**
  135.      * @ORM\OneToOne(targetEntity=InvoiceMetrics::class, mappedBy="invoice", cascade={"persist", "remove"})
  136.      * @Groups({
  137.      *     "invoice@invoice_metrics"
  138.      * })
  139.      */
  140.     private $invoice_metrics;
  141.     /**
  142.      * @ORM\Column(type="integer", nullable=true)
  143.      * @Groups({
  144.      *       "invoice@core"
  145.      *   })
  146.      */
  147.     private $due_days;
  148.     /**
  149.      * @ORM\Column(type="date_immutable", nullable=true)
  150.      * @Groups({
  151.      *       "invoice@core"
  152.      *   })
  153.      */
  154.     private $due_at;
  155.     public function getWeekOfYear() { return $this->week_of_year; }
  156.     public function setWeekOfYear($week_of_year): void $this->week_of_year $week_of_year; }
  157.     public function getPaidStatus() { return $this->paid_status; }
  158.     public function setPaidStatus($paid_status): void $this->paid_status $paid_status; }
  159.     public function __construct()
  160.     {
  161.         $this->invoice_positions = new ArrayCollection();
  162.     }
  163.     public function getId(): ?int
  164.     {
  165.         return $this->id;
  166.     }
  167.     public function getInvoiceNumber(): ?string
  168.     {
  169.         return $this->invoice_number;
  170.     }
  171.     public function setInvoiceNumber(?string $invoice_number): self
  172.     {
  173.         $this->invoice_number $invoice_number;
  174.         return $this;
  175.     }
  176.     public function getCurrency(): ?PaymentCurrencyTypes
  177.     {
  178.         return $this->currency;
  179.     }
  180.     public function setCurrency(?PaymentCurrencyTypes $currency): self
  181.     {
  182.         $this->currency $currency;
  183.         return $this;
  184.     }
  185.     public function getInvoiceType(): ?InvoiceType
  186.     {
  187.         return $this->invoice_type;
  188.     }
  189.     public function setInvoiceType(?InvoiceType $invoice_type): self
  190.     {
  191.         $this->invoice_type $invoice_type;
  192.         return $this;
  193.     }
  194.     public function getCreatedAt(): ?\DateTimeImmutable
  195.     {
  196.         return $this->created_at;
  197.     }
  198.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  199.     {
  200.         $this->created_at $created_at;
  201.         return $this;
  202.     }
  203.     public function getCustomer(): ?ProjectOwner
  204.     {
  205.         return $this->customer;
  206.     }
  207.     public function setCustomer(?ProjectOwner $customer): self
  208.     {
  209.         $this->customer $customer;
  210.         return $this;
  211.     }
  212.     /**
  213.      * @return Collection<int, InvoicePositions>&Selectable
  214.      */
  215.     public function getInvoicePositions(): Collection
  216.     {
  217.         return $this->invoice_positions;
  218.     }
  219.     public function addInvoicePosition(InvoicePositions $invoicePosition): self
  220.     {
  221.         if (!$this->invoice_positions->contains($invoicePosition)) {
  222.             $this->invoice_positions[] = $invoicePosition;
  223.             $invoicePosition->setInvoice($this);
  224.         }
  225.         return $this;
  226.     }
  227.     public function removeInvoicePosition(InvoicePositions $invoicePosition): self
  228.     {
  229.         if ($this->invoice_positions->removeElement($invoicePosition)) {
  230.             // set the owning side to null (unless already changed)
  231.             if ($invoicePosition->getInvoice() === $this) {
  232.                 $invoicePosition->setInvoice(null);
  233.             }
  234.         }
  235.         return $this;
  236.     }
  237.     public function getAdder(): ?User
  238.     {
  239.         return $this->adder;
  240.     }
  241.     public function setAdder(?User $adder): self
  242.     {
  243.         $this->adder $adder;
  244.         return $this;
  245.     }
  246.     public function getApprovedAt(): ?\DateTimeImmutable
  247.     {
  248.         return $this->approved_at;
  249.     }
  250.     public function setApprovedAt(?\DateTimeImmutable $approved_at): self
  251.     {
  252.         $this->approved_at $approved_at;
  253.         return $this;
  254.     }
  255.     public function getPaidAt(): ?\DateTimeImmutable
  256.     {
  257.         return $this->paid_at;
  258.     }
  259.     public function setPaidAt(?\DateTimeImmutable $paid_at): self
  260.     {
  261.         $this->paid_at $paid_at;
  262.         return $this;
  263.     }
  264.     public function getRefVoucher(): ?Vouchers
  265.     {
  266.         return $this->ref_voucher;
  267.     }
  268.     public function setRefVoucher(?Vouchers $ref_voucher): self
  269.     {
  270.         $this->ref_voucher $ref_voucher;
  271.         return $this;
  272.     }
  273.     public function getRefProjectOrderInvoice(): ?ProjectOrderInvoices
  274.     {
  275.         return $this->ref_project_order_invoice;
  276.     }
  277.     public function setRefProjectOrderInvoice(?ProjectOrderInvoices $ref_project_order_invoice): self
  278.     {
  279.         $this->ref_project_order_invoice $ref_project_order_invoice;
  280.         return $this;
  281.     }
  282.     public function getNote(): ?string
  283.     {
  284.         return $this->note;
  285.     }
  286.     public function setNote(?string $note): self
  287.     {
  288.         $this->note $note;
  289.         return $this;
  290.     }
  291.     public function getInvoiceMetrics(): ?InvoiceMetrics
  292.     {
  293.         return $this->invoice_metrics;
  294.     }
  295.     public function setInvoiceMetrics(?InvoiceMetrics $invoice_metrics): self
  296.     {
  297.         // unset the owning side of the relation if necessary
  298.         if ($invoice_metrics === null && $this->invoice_metrics !== null) {
  299.             $this->invoice_metrics->setInvoice(null);
  300.         }
  301.         // set the owning side of the relation if necessary
  302.         if ($invoice_metrics !== null && $invoice_metrics->getInvoice() !== $this) {
  303.             $invoice_metrics->setInvoice($this);
  304.         }
  305.         $this->invoice_metrics $invoice_metrics;
  306.         return $this;
  307.     }
  308.     public function getDueDays(): ?int
  309.     {
  310.         return $this->due_days;
  311.     }
  312.     public function setDueDays(?int $due_days): self
  313.     {
  314.         $this->due_days $due_days;
  315.         return $this;
  316.     }
  317.     public function getDueAt(): ?\DateTimeImmutable
  318.     {
  319.         return $this->due_at;
  320.     }
  321.     public function setDueAt(?\DateTimeImmutable $due_at): self
  322.     {
  323.         $this->due_at $due_at;
  324.         return $this;
  325.     }
  326. }