src/Entity/ProjectOrderBillings.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProjectOrderBillingsRepository;
  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. /**
  11.  * @ORM\Entity(repositoryClass=ProjectOrderBillingsRepository::class)
  12.  * @UniqueEntity(
  13.  *     fields={"project_order", "position_nr"},
  14.  *     message="Billing already exists|Billing with combination %s %s already exists!"
  15.  * )
  16.  */
  17. class ProjectOrderBillings
  18. {
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      * @Groups({
  24.      *     "order_billing@core",
  25.      *     "order_billing@base"
  26.      * })
  27.      */
  28.     private $id;
  29.     /**
  30.      * @ORM\OneToMany(targetEntity=InvoicePositions::class, mappedBy="order_billing", cascade={"persist", "remove"}, orphanRemoval=true)
  31.      * @Groups({
  32.      *      "order_billing@invoice_position"
  33.      *  })
  34.      */
  35.     private $invoice_positions;
  36.     /**
  37.      * @ORM\ManyToOne(targetEntity=ProjectOrders::class, inversedBy="order_billings")
  38.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  39.      * @Groups({
  40.      *     "order_billing@project_order"
  41.      * })
  42.      */
  43.     private $project_order;
  44.     /**
  45.      * @ORM\Column(type="date_immutable", nullable=true)
  46.      * @Groups({
  47.      *     "order_billing@core"
  48.      * })
  49.      */
  50.     private $sent_at;
  51.     /**
  52.      * @ORM\Column(type="string", length=64)
  53.      * @Groups({
  54.      *     "order_billing@core",
  55.      *     "order_billing@base"
  56.      * })
  57.      */
  58.     private $position_nr;
  59.     /**
  60.      * @ORM\Column(type="integer", nullable=true)
  61.      * @Groups({
  62.      *     "order_billing@core"
  63.      * })
  64.      *
  65.      */
  66.     private $quantity;
  67.     /**
  68.      * @ORM\Column(type="float", nullable=true)
  69.      * @Groups({
  70.      *       "order_billing@core"
  71.      * })
  72.      */
  73.     private $price;
  74.     /**
  75.      * @ORM\Column(type="datetime_immutable")
  76.      * @Groups({
  77.      *     "order_billing@core"
  78.      * })
  79.      */
  80.     private $created_at;
  81.     /**
  82.      * @ORM\Column(type="string", length=255, nullable=true)
  83.      * @Groups({
  84.      *     "order_billing@core"
  85.      * })
  86.      */
  87.     private $content;
  88.     /**
  89.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="project_order_billings")
  90.      */
  91.     private $adder;
  92.     /**
  93.      * @deprecated use this in invoice
  94.      * @ORM\Column(type="integer", nullable=true)
  95.      * @Groups({
  96.      *      "order_billing@core"
  97.      *  })
  98.      */
  99.     private $due_days;
  100.     /**
  101.      * @deprecated use this in invoice
  102.      * @ORM\Column(type="date_immutable", nullable=true)
  103.      * @Groups({
  104.      *      "order_billing@core"
  105.      *  })
  106.      */
  107.     private $due_at;
  108.     /**
  109.      * @ORM\Column(type="float", nullable=true)
  110.      * @Groups({
  111.      *     "order_billing@core"
  112.      * })
  113.      */
  114.     private $unit;
  115.     /**
  116.      * @ORM\ManyToOne(targetEntity=Unit::class, inversedBy="project_order_billings")
  117.      * @Groups({
  118.      *      "order_billing@unit_type"
  119.      *  })
  120.      */
  121.     private $unit_type;
  122.     /**
  123.      * @ORM\OneToOne(targetEntity=ProjectOrderBillingMetrics::class, mappedBy="billing", cascade={"persist", "remove"})
  124.      * @Groups({
  125.      *       "order_billing@core"
  126.      * })
  127.      */
  128.     private $billing_metrics;
  129.     public function __construct()
  130.     {
  131.         $this->invoice_positions = new ArrayCollection();
  132.     }
  133.     public function getId(): ?int
  134.     {
  135.         return $this->id;
  136.     }
  137.     /**
  138.      * @return Collection<int, InvoicePositions>
  139.      */
  140.     public function getInvoicePositions(): Collection
  141.     {
  142.         return $this->invoice_positions;
  143.     }
  144.     public function addInvoicePosition(InvoicePositions $invoicePosition): self
  145.     {
  146.         if (!$this->invoice_positions->contains($invoicePosition)) {
  147.             $this->invoice_positions[] = $invoicePosition;
  148.             $invoicePosition->setOrderBilling($this);
  149.         }
  150.         return $this;
  151.     }
  152.     public function removeInvoicePosition(InvoicePositions $invoicePosition): self
  153.     {
  154.         if ($this->invoice_positions->removeElement($invoicePosition)) {
  155.             // set the owning side to null (unless already changed)
  156.             if ($invoicePosition->getOrderBilling() === $this) {
  157.                 $invoicePosition->setOrderBilling(null);
  158.             }
  159.         }
  160.         return $this;
  161.     }
  162.     public function getProjectOrder(): ?ProjectOrders
  163.     {
  164.         return $this->project_order;
  165.     }
  166.     public function setProjectOrder(?ProjectOrders $project_order): self
  167.     {
  168.         $this->project_order $project_order;
  169.         return $this;
  170.     }
  171.     public function getSentAt(): ?\DateTimeImmutable
  172.     {
  173.         return $this->sent_at;
  174.     }
  175.     public function setSentAt(?\DateTimeImmutable $sent_at): self
  176.     {
  177.         $this->sent_at $sent_at;
  178.         return $this;
  179.     }
  180.     public function getPositionNr(): ?string
  181.     {
  182.         return $this->position_nr;
  183.     }
  184.     public function setPositionNr(string $position_nr): self
  185.     {
  186.         $this->position_nr $position_nr;
  187.         return $this;
  188.     }
  189.     public function getQuantity(): ?int
  190.     {
  191.         return $this->quantity ?? 1;
  192.     }
  193.     public function setQuantity(?int $quantity): self
  194.     {
  195.         $this->quantity $quantity;
  196.         return $this;
  197.     }
  198.     public function getPrice(): ?float
  199.     {
  200.         return $this->price;
  201.     }
  202.     public function setPrice(?float $price): self
  203.     {
  204.         $this->price $price;
  205.         return $this;
  206.     }
  207.     public function getCreatedAt(): ?\DateTimeImmutable
  208.     {
  209.         return $this->created_at;
  210.     }
  211.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  212.     {
  213.         $this->created_at $created_at;
  214.         return $this;
  215.     }
  216.     public function getContent(): ?string
  217.     {
  218.         return $this->content;
  219.     }
  220.     public function setContent(?string $content): self
  221.     {
  222.         $this->content $content;
  223.         return $this;
  224.     }
  225.     public function getAdder(): ?User
  226.     {
  227.         return $this->adder;
  228.     }
  229.     public function setAdder(?User $adder): self
  230.     {
  231.         $this->adder $adder;
  232.         return $this;
  233.     }
  234.     /**
  235.      * @deprecated use this in invoice
  236.      */
  237.     public function getDueDays(): ?int
  238.     {
  239.         return $this->due_days;
  240.     }
  241.     /**
  242.      * @deprecated use this in invoice
  243.      */
  244.     public function setDueDays(?int $due_days): self
  245.     {
  246.         $this->due_days $due_days;
  247.         return $this;
  248.     }
  249.     /**
  250.      * @deprecated use this in invoice
  251.     */
  252.     public function getDueAt(): ?\DateTimeImmutable
  253.     {
  254.         return $this->due_at;
  255.     }
  256.     /**
  257.      * @deprecated use this in invoice
  258.      */
  259.     public function setDueAt(?\DateTimeImmutable $due_at): self
  260.     {
  261.         $this->due_at $due_at;
  262.         return $this;
  263.     }
  264.     public function getUnit(): ?float
  265.     {
  266.         return $this->unit;
  267.     }
  268.     public function setUnit(?float $unit): self
  269.     {
  270.         $this->unit $unit;
  271.         return $this;
  272.     }
  273.     public function getUnitType(): ?Unit
  274.     {
  275.         return $this->unit_type;
  276.     }
  277.     public function setUnitType(?Unit $unit_type): self
  278.     {
  279.         $this->unit_type $unit_type;
  280.         return $this;
  281.     }
  282.     public function getBillingMetrics(): ?ProjectOrderBillingMetrics
  283.     {
  284.         return $this->billing_metrics;
  285.     }
  286.     public function setBillingMetrics(ProjectOrderBillingMetrics $billing_metrics): self
  287.     {
  288.         // set the owning side of the relation if necessary
  289.         if ($billing_metrics->getBilling() !== $this) {
  290.             $billing_metrics->setBilling($this);
  291.         }
  292.         $this->billing_metrics $billing_metrics;
  293.         return $this;
  294.     }
  295. }