<?php
namespace App\Entity;
use App\Repository\ProjectOrderBillingsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Selectable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=ProjectOrderBillingsRepository::class)
* @UniqueEntity(
* fields={"project_order", "position_nr"},
* message="Billing already exists|Billing with combination %s %s already exists!"
* )
*/
class ProjectOrderBillings
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "order_billing@core",
* "order_billing@base"
* })
*/
private $id;
/**
* @ORM\OneToMany(targetEntity=InvoicePositions::class, mappedBy="order_billing", cascade={"persist", "remove"}, orphanRemoval=true)
* @Groups({
* "order_billing@invoice_position"
* })
*/
private $invoice_positions;
/**
* @ORM\ManyToOne(targetEntity=ProjectOrders::class, inversedBy="order_billings")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
* @Groups({
* "order_billing@project_order"
* })
*/
private $project_order;
/**
* @ORM\Column(type="date_immutable", nullable=true)
* @Groups({
* "order_billing@core"
* })
*/
private $sent_at;
/**
* Yüklenen belge dosya adları (mini havuz). Tam path runtime'da DI zone'undan
* ($billingDocumentReadPath / $billingDocumentWritePath) + dosya adı ile çözülür.
* @ORM\Column(type="json", nullable=true)
* @Groups({
* "order_billing@core"
* })
*/
private $documents;
/**
* @ORM\Column(type="string", length=64)
* @Groups({
* "order_billing@core",
* "order_billing@base"
* })
*/
private $position_nr;
/**
* @ORM\Column(type="integer", nullable=true)
* @Groups({
* "order_billing@core"
* })
*
*/
private $quantity;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "order_billing@core"
* })
*/
private $price;
/**
* @ORM\Column(type="datetime_immutable")
* @Groups({
* "order_billing@core"
* })
*/
private $created_at;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "order_billing@core"
* })
*/
private $content;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="project_order_billings")
*/
private $adder;
/**
* @deprecated use this in invoice
* @ORM\Column(type="integer", nullable=true)
* @Groups({
* "order_billing@core"
* })
*/
private $due_days;
/**
* @deprecated use this in invoice
* @ORM\Column(type="date_immutable", nullable=true)
* @Groups({
* "order_billing@core"
* })
*/
private $due_at;
/**
* @ORM\Column(type="float", nullable=true)
* @Groups({
* "order_billing@core"
* })
*/
private $unit;
/**
* @ORM\ManyToOne(targetEntity=Unit::class, inversedBy="project_order_billings")
* @Groups({
* "order_billing@unit_type"
* })
*/
private $unit_type;
/**
* @ORM\OneToOne(targetEntity=ProjectOrderBillingMetrics::class, mappedBy="billing", cascade={"persist", "remove"})
* @Groups({
* "order_billing@core"
* })
*/
private $billing_metrics;
public function __construct()
{
$this->invoice_positions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection<int, InvoicePositions>
*/
public function getInvoicePositions(): Collection
{
return $this->invoice_positions;
}
public function addInvoicePosition(InvoicePositions $invoicePosition): self
{
if (!$this->invoice_positions->contains($invoicePosition)) {
$this->invoice_positions[] = $invoicePosition;
$invoicePosition->setOrderBilling($this);
}
return $this;
}
public function removeInvoicePosition(InvoicePositions $invoicePosition): self
{
if ($this->invoice_positions->removeElement($invoicePosition)) {
// set the owning side to null (unless already changed)
if ($invoicePosition->getOrderBilling() === $this) {
$invoicePosition->setOrderBilling(null);
}
}
return $this;
}
public function getProjectOrder(): ?ProjectOrders
{
return $this->project_order;
}
public function setProjectOrder(?ProjectOrders $project_order): self
{
$this->project_order = $project_order;
return $this;
}
public function getSentAt(): ?\DateTimeImmutable
{
return $this->sent_at;
}
public function setSentAt(?\DateTimeImmutable $sent_at): self
{
$this->sent_at = $sent_at;
return $this;
}
public function getPositionNr(): ?string
{
return $this->position_nr;
}
public function setPositionNr(string $position_nr): self
{
$this->position_nr = $position_nr;
return $this;
}
public function getQuantity(): ?int
{
return $this->quantity ?? 1;
}
public function setQuantity(?int $quantity): self
{
$this->quantity = $quantity;
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(?float $price): self
{
$this->price = $price;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeImmutable $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
public function getAdder(): ?User
{
return $this->adder;
}
public function setAdder(?User $adder): self
{
$this->adder = $adder;
return $this;
}
/**
* @deprecated use this in invoice
*/
public function getDueDays(): ?int
{
return $this->due_days;
}
/**
* @deprecated use this in invoice
*/
public function setDueDays(?int $due_days): self
{
$this->due_days = $due_days;
return $this;
}
/**
* @deprecated use this in invoice
*/
public function getDueAt(): ?\DateTimeImmutable
{
return $this->due_at;
}
/**
* @deprecated use this in invoice
*/
public function setDueAt(?\DateTimeImmutable $due_at): self
{
$this->due_at = $due_at;
return $this;
}
public function getUnit(): ?float
{
return $this->unit;
}
public function setUnit(?float $unit): self
{
$this->unit = $unit;
return $this;
}
public function getUnitType(): ?Unit
{
return $this->unit_type;
}
public function setUnitType(?Unit $unit_type): self
{
$this->unit_type = $unit_type;
return $this;
}
public function getBillingMetrics(): ?ProjectOrderBillingMetrics
{
return $this->billing_metrics;
}
public function setBillingMetrics(ProjectOrderBillingMetrics $billing_metrics): self
{
// set the owning side of the relation if necessary
if ($billing_metrics->getBilling() !== $this) {
$billing_metrics->setBilling($this);
}
$this->billing_metrics = $billing_metrics;
return $this;
}
public function getDocuments(): ?array
{
return $this->documents;
}
public function setDocuments(?array $documents): self
{
$this->documents = $documents;
return $this;
}
}