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.      * Yüklenen belge dosya adları (mini havuz). Tam path runtime'da DI zone'undan
  53.      * ($billingDocumentReadPath / $billingDocumentWritePath) + dosya adı ile çözülür.
  54.      * @ORM\Column(type="json", nullable=true)
  55.      * @Groups({
  56.      *     "order_billing@core"
  57.      * })
  58.      */
  59.     private $documents;
  60.     /**
  61.      * @ORM\Column(type="string", length=64)
  62.      * @Groups({
  63.      *     "order_billing@core",
  64.      *     "order_billing@base"
  65.      * })
  66.      */
  67.     private $position_nr;
  68.     /**
  69.      * @ORM\Column(type="integer", nullable=true)
  70.      * @Groups({
  71.      *     "order_billing@core"
  72.      * })
  73.      *
  74.      */
  75.     private $quantity;
  76.     /**
  77.      * @ORM\Column(type="float", nullable=true)
  78.      * @Groups({
  79.      *       "order_billing@core"
  80.      * })
  81.      */
  82.     private $price;
  83.     /**
  84.      * @ORM\Column(type="datetime_immutable")
  85.      * @Groups({
  86.      *     "order_billing@core"
  87.      * })
  88.      */
  89.     private $created_at;
  90.     /**
  91.      * @ORM\Column(type="string", length=255, nullable=true)
  92.      * @Groups({
  93.      *     "order_billing@core"
  94.      * })
  95.      */
  96.     private $content;
  97.     /**
  98.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="project_order_billings")
  99.      */
  100.     private $adder;
  101.     /**
  102.      * @deprecated use this in invoice
  103.      * @ORM\Column(type="integer", nullable=true)
  104.      * @Groups({
  105.      *      "order_billing@core"
  106.      *  })
  107.      */
  108.     private $due_days;
  109.     /**
  110.      * @deprecated use this in invoice
  111.      * @ORM\Column(type="date_immutable", nullable=true)
  112.      * @Groups({
  113.      *      "order_billing@core"
  114.      *  })
  115.      */
  116.     private $due_at;
  117.     /**
  118.      * @ORM\Column(type="float", nullable=true)
  119.      * @Groups({
  120.      *     "order_billing@core"
  121.      * })
  122.      */
  123.     private $unit;
  124.     /**
  125.      * @ORM\ManyToOne(targetEntity=Unit::class, inversedBy="project_order_billings")
  126.      * @Groups({
  127.      *      "order_billing@unit_type"
  128.      *  })
  129.      */
  130.     private $unit_type;
  131.     /**
  132.      * @ORM\OneToOne(targetEntity=ProjectOrderBillingMetrics::class, mappedBy="billing", cascade={"persist", "remove"})
  133.      * @Groups({
  134.      *       "order_billing@core"
  135.      * })
  136.      */
  137.     private $billing_metrics;
  138.     public function __construct()
  139.     {
  140.         $this->invoice_positions = new ArrayCollection();
  141.     }
  142.     public function getId(): ?int
  143.     {
  144.         return $this->id;
  145.     }
  146.     /**
  147.      * @return Collection<int, InvoicePositions>
  148.      */
  149.     public function getInvoicePositions(): Collection
  150.     {
  151.         return $this->invoice_positions;
  152.     }
  153.     public function addInvoicePosition(InvoicePositions $invoicePosition): self
  154.     {
  155.         if (!$this->invoice_positions->contains($invoicePosition)) {
  156.             $this->invoice_positions[] = $invoicePosition;
  157.             $invoicePosition->setOrderBilling($this);
  158.         }
  159.         return $this;
  160.     }
  161.     public function removeInvoicePosition(InvoicePositions $invoicePosition): self
  162.     {
  163.         if ($this->invoice_positions->removeElement($invoicePosition)) {
  164.             // set the owning side to null (unless already changed)
  165.             if ($invoicePosition->getOrderBilling() === $this) {
  166.                 $invoicePosition->setOrderBilling(null);
  167.             }
  168.         }
  169.         return $this;
  170.     }
  171.     public function getProjectOrder(): ?ProjectOrders
  172.     {
  173.         return $this->project_order;
  174.     }
  175.     public function setProjectOrder(?ProjectOrders $project_order): self
  176.     {
  177.         $this->project_order $project_order;
  178.         return $this;
  179.     }
  180.     public function getSentAt(): ?\DateTimeImmutable
  181.     {
  182.         return $this->sent_at;
  183.     }
  184.     public function setSentAt(?\DateTimeImmutable $sent_at): self
  185.     {
  186.         $this->sent_at $sent_at;
  187.         return $this;
  188.     }
  189.     public function getPositionNr(): ?string
  190.     {
  191.         return $this->position_nr;
  192.     }
  193.     public function setPositionNr(string $position_nr): self
  194.     {
  195.         $this->position_nr $position_nr;
  196.         return $this;
  197.     }
  198.     public function getQuantity(): ?int
  199.     {
  200.         return $this->quantity ?? 1;
  201.     }
  202.     public function setQuantity(?int $quantity): self
  203.     {
  204.         $this->quantity $quantity;
  205.         return $this;
  206.     }
  207.     public function getPrice(): ?float
  208.     {
  209.         return $this->price;
  210.     }
  211.     public function setPrice(?float $price): self
  212.     {
  213.         $this->price $price;
  214.         return $this;
  215.     }
  216.     public function getCreatedAt(): ?\DateTimeImmutable
  217.     {
  218.         return $this->created_at;
  219.     }
  220.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  221.     {
  222.         $this->created_at $created_at;
  223.         return $this;
  224.     }
  225.     public function getContent(): ?string
  226.     {
  227.         return $this->content;
  228.     }
  229.     public function setContent(?string $content): self
  230.     {
  231.         $this->content $content;
  232.         return $this;
  233.     }
  234.     public function getAdder(): ?User
  235.     {
  236.         return $this->adder;
  237.     }
  238.     public function setAdder(?User $adder): self
  239.     {
  240.         $this->adder $adder;
  241.         return $this;
  242.     }
  243.     /**
  244.      * @deprecated use this in invoice
  245.      */
  246.     public function getDueDays(): ?int
  247.     {
  248.         return $this->due_days;
  249.     }
  250.     /**
  251.      * @deprecated use this in invoice
  252.      */
  253.     public function setDueDays(?int $due_days): self
  254.     {
  255.         $this->due_days $due_days;
  256.         return $this;
  257.     }
  258.     /**
  259.      * @deprecated use this in invoice
  260.     */
  261.     public function getDueAt(): ?\DateTimeImmutable
  262.     {
  263.         return $this->due_at;
  264.     }
  265.     /**
  266.      * @deprecated use this in invoice
  267.      */
  268.     public function setDueAt(?\DateTimeImmutable $due_at): self
  269.     {
  270.         $this->due_at $due_at;
  271.         return $this;
  272.     }
  273.     public function getUnit(): ?float
  274.     {
  275.         return $this->unit;
  276.     }
  277.     public function setUnit(?float $unit): self
  278.     {
  279.         $this->unit $unit;
  280.         return $this;
  281.     }
  282.     public function getUnitType(): ?Unit
  283.     {
  284.         return $this->unit_type;
  285.     }
  286.     public function setUnitType(?Unit $unit_type): self
  287.     {
  288.         $this->unit_type $unit_type;
  289.         return $this;
  290.     }
  291.     public function getBillingMetrics(): ?ProjectOrderBillingMetrics
  292.     {
  293.         return $this->billing_metrics;
  294.     }
  295.     public function setBillingMetrics(ProjectOrderBillingMetrics $billing_metrics): self
  296.     {
  297.         // set the owning side of the relation if necessary
  298.         if ($billing_metrics->getBilling() !== $this) {
  299.             $billing_metrics->setBilling($this);
  300.         }
  301.         $this->billing_metrics $billing_metrics;
  302.         return $this;
  303.     }
  304.     public function getDocuments(): ?array
  305.     {
  306.         return $this->documents;
  307.     }
  308.     public function setDocuments(?array $documents): self
  309.     {
  310.         $this->documents $documents;
  311.         return $this;
  312.     }
  313. }