<?php
namespace App\Entity;
use App\Repository\InvoiceRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: InvoiceRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Invoice
{
use \App\Traits\EntityDateTimeAbleTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'invoices')]
private ?Program $program = null;
#[ORM\ManyToOne(inversedBy: 'invoices')]
private ?Billing $billing = null;
#[ORM\Column(nullable: true)]
private ?float $price = null;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $startDate = null;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $endDate = null;
#[ORM\Column(nullable: true)]
private ?int $method = null;
#[ORM\Column(nullable: true)]
private ?float $fixPrice = null;
#[ORM\Column(nullable: true)]
private ?int $paymentDeadline = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $number = null;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $invoiceDate = null;
#[ORM\ManyToOne(inversedBy: 'invoices')]
private ?InvoiceAddress $address = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $note = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $orderNumber = null;
#[ORM\Column(nullable: true)]
private ?float $amount = null;
#[ORM\Column(nullable: true)]
private ?float $vat = null;
#[ORM\Column(nullable: true)]
private ?float $totalTTC = null;
#[ORM\Column(nullable: true)]
private ?int $paymentMethod = null;
#[ORM\Column(nullable: true)]
private ?int $year = null;
#[ORM\ManyToOne(inversedBy: 'invoices')]
private ?Bank $bank = null;
#[ORM\OneToMany(mappedBy: 'invoice', targetEntity: Payment::class, orphanRemoval: true, cascade: ['persist', 'remove'])]
private Collection $payments;
#[ORM\ManyToOne(inversedBy: 'invoices')]
private ?InvoiceContact $invoiceContact = null;
#[ORM\ManyToOne(inversedBy: 'invoices')]
private ?InvoicedEntity $invoicedEntity = null;
#[ORM\OneToMany(mappedBy: 'invoice', targetEntity: InvoicedEntity::class)]
private Collection $invoicedEntities;
#[ORM\OneToOne(mappedBy: 'invoice', cascade: ['persist', 'remove'])]
private ?InvoiceInfo $invoiceInfo = null;
#[ORM\Column(nullable: true)]
private ?int $receipt = null;
#[ORM\Column(nullable: true)]
private ?float $totalTH = null;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $activeDate = null;
public function __construct()
{
$this->payments = new ArrayCollection();
$this->invoicedEntities = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getProgram(): ?Program
{
return $this->program;
}
public function setProgram(?Program $program): static
{
$this->program = $program;
return $this;
}
public function getBilling(): ?Billing
{
return $this->billing;
}
public function setBilling(?Billing $billing): static
{
$this->billing = $billing;
return $this;
}
public function getPrice(): ?float
{
return $this->price;
}
public function setPrice(?float $price): static
{
$this->price = $price;
return $this;
}
public function getStartDate(): ?\DateTimeInterface
{
return $this->startDate;
}
public function setStartDate(?\DateTimeInterface $startDate): static
{
$this->startDate = $startDate;
return $this;
}
public function getEndDate(): ?\DateTimeInterface
{
return $this->endDate;
}
public function setEndDate(?\DateTimeInterface $endDate): static
{
$this->endDate = $endDate;
return $this;
}
public function getMethod(): ?int
{
return $this->method;
}
public function setMethod(?int $method): static
{
$this->method = $method;
return $this;
}
public function getFixPrice(): ?float
{
return $this->fixPrice;
}
public function setFixPrice(?float $fixPrice): static
{
$this->fixPrice = $fixPrice;
return $this;
}
public function getPaymentDeadline(): ?int
{
return $this->paymentDeadline;
}
public function setPaymentDeadline(?int $paymentDeadline): static
{
$this->paymentDeadline = $paymentDeadline;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
return $this;
}
public function getNumber(): ?string
{
return $this->number;
}
public function setNumber(?string $number): static
{
$this->number = $number;
return $this;
}
public function getInvoiceDate(): ?\DateTimeInterface
{
return $this->invoiceDate;
}
public function setInvoiceDate(\DateTimeInterface $invoiceDate): static
{
$this->invoiceDate = $invoiceDate;
return $this;
}
public function getAddress(): ?InvoiceAddress
{
return $this->address;
}
public function setAddress(?InvoiceAddress $address): static
{
$this->address = $address;
return $this;
}
public function getNote(): ?string
{
return $this->note;
}
public function setNote(?string $note): static
{
$this->note = $note;
return $this;
}
public function getOrderNumber(): ?string
{
return $this->orderNumber;
}
public function setOrderNumber(?string $orderNumber): static
{
$this->orderNumber = $orderNumber;
return $this;
}
public function getAmount(): ?float
{
return $this->amount;
}
public function setAmount(?float $amount): static
{
$this->amount = $amount;
return $this;
}
public function getVat(): ?float
{
return $this->vat;
}
public function setVat(?float $vat): static
{
$this->vat = $vat;
return $this;
}
public function getTotalTTC(): ?float
{
return $this->totalTTC;
}
public function setTotalTTC(?float $totalTTC): static
{
$this->totalTTC = $totalTTC;
return $this;
}
public function getPaymentMethod(): ?int
{
return $this->paymentMethod;
}
public function setPaymentMethod(?int $paymentMethod): static
{
$this->paymentMethod = $paymentMethod;
return $this;
}
public function getYear(): ?int
{
return $this->year;
}
public function setYear(?int $year): static
{
$this->year = $year;
return $this;
}
public function getBank(): ?Bank
{
return $this->bank;
}
public function setBank(?Bank $bank): static
{
$this->bank = $bank;
return $this;
}
/**
* @return Collection<int, Payment>
*/
public function getPayments(): Collection
{
return $this->payments;
}
public function addPayment(Payment $payment): static
{
if (!$this->payments->contains($payment)) {
$this->payments->add($payment);
$payment->setInvoice($this);
}
return $this;
}
public function removePayment(Payment $payment): static
{
if ($this->payments->removeElement($payment)) {
// set the owning side to null (unless already changed)
if ($payment->getInvoice() === $this) {
$payment->setInvoice(null);
}
}
return $this;
}
public function getInvoiceContact(): ?InvoiceContact
{
return $this->invoiceContact;
}
public function setInvoiceContact(?InvoiceContact $invoiceContact): static
{
$this->invoiceContact = $invoiceContact;
return $this;
}
public function getInvoicedEntity(): ?InvoicedEntity
{
return $this->invoicedEntity;
}
public function setInvoicedEntity(?InvoicedEntity $invoicedEntity): static
{
$this->invoicedEntity = $invoicedEntity;
return $this;
}
/**
* @return Collection<int, InvoicedEntity>
*/
public function getInvoicedEntities(): Collection
{
return $this->invoicedEntities;
}
public function addInvoicedEntity(InvoicedEntity $invoicedEntity): static
{
if (!$this->invoicedEntities->contains($invoicedEntity)) {
$this->invoicedEntities->add($invoicedEntity);
$invoicedEntity->setInvoice($this);
}
return $this;
}
public function removeInvoicedEntity(InvoicedEntity $invoicedEntity): static
{
if ($this->invoicedEntities->removeElement($invoicedEntity)) {
// set the owning side to null (unless already changed)
if ($invoicedEntity->getInvoice() === $this) {
$invoicedEntity->setInvoice(null);
}
}
return $this;
}
public function getInvoiceInfo(): ?InvoiceInfo
{
return $this->invoiceInfo;
}
public function setInvoiceInfo(?InvoiceInfo $invoiceInfo): static
{
// unset the owning side of the relation if necessary
if ($invoiceInfo === null && $this->invoiceInfo !== null) {
$this->invoiceInfo->setInvoice(null);
}
// set the owning side of the relation if necessary
if ($invoiceInfo !== null && $invoiceInfo->getInvoice() !== $this) {
$invoiceInfo->setInvoice($this);
}
$this->invoiceInfo = $invoiceInfo;
return $this;
}
public function getReceipt(): ?int
{
return $this->receipt;
}
public function setReceipt(?int $receipt): static
{
$this->receipt = $receipt;
return $this;
}
public function getTotalTH(): ?float
{
return $this->totalTH;
}
public function setTotalTH(?float $totalTH): static
{
$this->totalTH = $totalTH;
return $this;
}
public function getActiveDate(): ?\DateTimeInterface
{
return $this->activeDate;
}
public function setActiveDate(?\DateTimeInterface $activeDate): static
{
$this->activeDate = $activeDate;
return $this;
}
}