688fdd49ee
add webdav client change pdf viewer
200 lines
4.1 KiB
PHP
200 lines
4.1 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\BillRepository;
|
|
use Doctrine\DBAL\Types\Types;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use App\Core\Entity\EntityInterface;
|
|
use App\Core\Doctrine\Timestampable;
|
|
|
|
#[ORM\Entity(repositoryClass: BillRepository::class)]
|
|
#[ORM\HasLifecycleCallbacks]
|
|
class Bill implements EntityInterface
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\GeneratedValue]
|
|
#[ORM\Column]
|
|
private ?int $id = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $reference = null;
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
private ?float $amountTtc = null;
|
|
|
|
#[ORM\Column(nullable: true)]
|
|
private ?float $amountHt = null;
|
|
|
|
#[ORM\Column(options: ["default" => 0])]
|
|
private ?int $status = 0;
|
|
|
|
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
|
|
private ?\DateTimeInterface $date = null;
|
|
|
|
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
|
|
private ?\DateTimeInterface $paymentDeadlineDate = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $file = null;
|
|
|
|
#[ORM\ManyToOne(inversedBy: 'bills')]
|
|
#[ORM\JoinColumn(onDelete: 'SET NULL')]
|
|
private ?BillVendor $vendor = null;
|
|
|
|
#[ORM\ManyToOne(inversedBy: 'bills')]
|
|
#[ORM\JoinColumn(onDelete: 'SET NULL')]
|
|
private ?BillCategory $category = null;
|
|
|
|
use Timestampable;
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getReference(): ?string
|
|
{
|
|
return $this->reference;
|
|
}
|
|
|
|
public function setReference(?string $reference): self
|
|
{
|
|
$this->reference = $reference;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getAmountTtc(): ?float
|
|
{
|
|
return $this->amountTtc;
|
|
}
|
|
|
|
public function setAmountTtc(?float $amountTtc): self
|
|
{
|
|
$this->amountTtc = $amountTtc;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getAmountHt(): ?float
|
|
{
|
|
return $this->amountHt;
|
|
}
|
|
|
|
public function setAmountHt(?float $amountHt): self
|
|
{
|
|
$this->amountHt = $amountHt;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getStatus(): ?int
|
|
{
|
|
return $this->status;
|
|
}
|
|
|
|
public function setStatus(int $status): self
|
|
{
|
|
$this->status = $status;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getHumanStatus(): string
|
|
{
|
|
return BillPeer::value($this->getStatus());
|
|
}
|
|
|
|
public function getDate(): ?\DateTimeInterface
|
|
{
|
|
return $this->date;
|
|
}
|
|
|
|
public function setDate(\DateTimeInterface $date): self
|
|
{
|
|
$this->date = $date;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getPaymentDeadlineDate(): ?\DateTimeInterface
|
|
{
|
|
return $this->paymentDeadlineDate;
|
|
}
|
|
|
|
public function setPaymentDeadlineDate(?\DateTimeInterface $paymentDeadlineDate): self
|
|
{
|
|
$this->paymentDeadlineDate = $paymentDeadlineDate;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getFile(): ?string
|
|
{
|
|
return $this->file;
|
|
}
|
|
|
|
public function setFile(?string $file): self
|
|
{
|
|
$this->file = $file;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getVendor(): ?BillVendor
|
|
{
|
|
return $this->vendor;
|
|
}
|
|
|
|
public function setVendor(?BillVendor $vendor): self
|
|
{
|
|
$this->vendor = $vendor;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getCategory(): ?BillCategory
|
|
{
|
|
return $this->category;
|
|
}
|
|
|
|
public function setCategory(?BillCategory $category): self
|
|
{
|
|
$this->category = $category;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isPdf(): bool
|
|
{
|
|
return (bool) preg_match('/\.pdf/', $this->getFile());
|
|
}
|
|
|
|
public function getRemoteFile(): ?string
|
|
{
|
|
if (!$this->getFile()) {
|
|
return null;
|
|
}
|
|
|
|
if (!$this->getDate()) {
|
|
return null;
|
|
}
|
|
|
|
if (!$this->getCategory()) {
|
|
return null;
|
|
}
|
|
|
|
if (!$this->getVendor()) {
|
|
return null;
|
|
}
|
|
|
|
return implode('/', [
|
|
$this->getDate()->format('Y'),
|
|
$this->getCategory()->getLabel(),
|
|
$this->getVendor()->getLabel(),
|
|
basename($this->getFile()),
|
|
]);
|
|
}
|
|
}
|