<?php
namespace App\Entity\Channel\Payment;
use App\Entity\Channel\Channel;
use App\Entity\Common\LicenseEmbeddable;
use App\Repository\Channel\Payment\LicensesOrderRepository;
use Doctrine\ORM\Mapping as ORM;
use DrosalysWeb\ObjectExtensions\Blame\Model\BlameInterface;
use DrosalysWeb\ObjectExtensions\Blame\Model\BlameTrait;
use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampInterface;
use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampTrait;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
#[
ORM\Entity(repositoryClass: LicensesOrderRepository::class),
ORM\Table(name: 'channel_licenses_order'),
// UniqueEntity(fields: ['orderNumber'], message: 'licenses_order.unique_entity.message')
]
class LicensesOrder implements BlameInterface, TimestampInterface
{
use BlameTrait;
use TimestampTrait;
#[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\ManyToOne(targetEntity: Channel::class)]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private ?Channel $channel = null;
#[ORM\Embedded(class: LicenseEmbeddable::class)]
#[Assert\Valid]
private ?LicenseEmbeddable $license = null;
#[ORM\Column(type: 'string', length: 11, nullable: true)]
#[Assert\Regex('/^FA\d{8}$/')]
private ?string $orderNumber = null;
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $status = null;
#[ORM\Column(type: 'integer', nullable: false)]
private ?int $tva = null;
#[ORM\Column(type: 'boolean', nullable: false)]
private bool $archived = false;
public function getId(): ?int
{
return $this->id;
}
public function getChannel(): ?Channel
{
return $this->channel;
}
public function setChannel(?Channel $channel): LicensesOrder
{
$this->channel = $channel;
return $this;
}
public function getLicense(): ?LicenseEmbeddable
{
return $this->license;
}
public function setLicense(?LicenseEmbeddable $license): static
{
$this->license = $license;
return $this;
}
public function getOrderNumber(): ?string
{
return $this->orderNumber;
}
public function setOrderNumber(?string $orderNumber): LicensesOrder
{
$this->orderNumber = $orderNumber;
return $this;
}
public function getTva(): ?int
{
return $this->tva;
}
public function setTva(?int $tva): void
{
$this->tva = $tva;
}
public function getTvaDisplayed(): float
{
return $this->tva !== null ? $this->tva / 100 : 0;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(?int $status): LicensesOrder
{
$this->status = $status;
return $this;
}
public function isArchived(): bool
{
return $this->archived;
}
public function setArchived(bool $archived): LicensesOrder
{
$this->archived = $archived;
return $this;
}
public function toggleIsArchived(): LicensesOrder
{
$this->archived = !$this->archived;
return $this;
}
}