<?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]
#[ORM\Table(name: 'invoice')]
class Invoice extends BaseEntity
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $invoiceNumber = null;
// totalAmount = Faturanın indirim ve vergi hesaplandıktan sonraki toplam miktarı
#[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 3)]
private ?string $totalAmount = null;
#[ORM\Column(type: Types::DATE_MUTABLE)]
private ?\DateTimeInterface $date = null;
#[ORM\ManyToOne(inversedBy: 'invoices')]
private User $seller;
#[ORM\ManyToOne(inversedBy: 'invoices')]
private ?Warehouse $warehouse = null;
#[ORM\OneToMany(mappedBy: 'invoice', targetEntity: InvoiceItem::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
private Collection $invoiceItems;
#[ORM\Column]
private ?bool $isPublic = null;
#[ORM\OneToMany(mappedBy: 'invoice', targetEntity: Payment::class)]
private Collection $payments;
#[ORM\OneToMany(mappedBy: 'invoice', targetEntity: StockTransaction::class)]
private $stockTransactions;
#[ORM\ManyToOne(targetEntity: Customer::class, inversedBy: 'invoices')]
#[ORM\JoinColumn(nullable: false)]
private Customer $customer;
#[ORM\OneToOne(mappedBy: 'invoice', targetEntity: Sales::class)]
private ?Sales $proforma;
public function __construct()
{
$this->invoiceItems = new ArrayCollection();
$this->payments = new ArrayCollection();
$this->stockTransactions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getInvoiceNumber(): ?string
{
return $this->invoiceNumber;
}
public function setInvoiceNumber(string $invoiceNumber): static
{
$this->invoiceNumber = $invoiceNumber;
return $this;
}
public function getTotalAmount(): ?string
{
return $this->totalAmount;
}
public function setTotalAmount(string $totalAmount): static
{
$this->totalAmount = $totalAmount;
return $this;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): static
{
$this->date = $date;
return $this;
}
public function getSeller(): User
{
return $this->seller;
}
public function setSeller(User $seller): void
{
$this->seller = $seller;
}
public function getWarehouse(): ?Warehouse
{
return $this->warehouse;
}
public function setWarehouse(?Warehouse $warehouse): static
{
$this->warehouse = $warehouse;
return $this;
}
/**
* @return Collection<int, InvoiceItem>
*/
public function getInvoiceItems(): Collection
{
return $this->invoiceItems;
}
public function addInvoiceItem(InvoiceItem $invoiceItem): static
{
if (!$this->invoiceItems->contains($invoiceItem)) {
$this->invoiceItems->add($invoiceItem);
$invoiceItem->setInvoice($this);
}
return $this;
}
public function removeInvoiceItem(InvoiceItem $invoiceItem): static
{
if ($this->invoiceItems->removeElement($invoiceItem)) {
// set the owning side to null (unless already changed)
if ($invoiceItem->getInvoice() === $this) {
$invoiceItem->setInvoice(null);
}
}
return $this;
}
public function isIsPublic(): ?bool
{
return $this->isPublic;
}
public function setIsPublic(bool $isPublic): static
{
$this->isPublic = $isPublic;
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;
}
/**
* @return mixed
*/
public function getStockTransactions()
{
return $this->stockTransactions;
}
/**
* @param mixed $stockTransactions
*/
public function setStockTransactions($stockTransactions): void
{
$this->stockTransactions = $stockTransactions;
}
public function getProforma(): ?Sales
{
return $this->proforma;
}
public function setProforma(?Sales $proforma): void
{
$this->proforma = $proforma;
}
public function getCustomer(): Customer
{
return $this->customer;
}
public function setCustomer(Customer $customer): void
{
$this->customer = $customer;
}
}