<?php
/**
* @author Quentin CHATELAIN (contact@scaledev.fr)
* @copyright 2021 - ScaleDEV SAS, 12 RUE CHARLES MORET, 10120 ST ANDRE LES VERGERS
* @license commercial
*/
declare(strict_types=1);
namespace Bluue\SalesBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Gedmo\Mapping\Annotation as Gedmo;
use Bluue\SalesBundle\Repository\PaymentTermRepository;
use Bluue\SalesBundle\EventListener\PaymentTermListener;
use App\DoctrineExtensions\Timestampable\Traits\UserTimestampableEntity;
use App\DoctrineExtensions\SoftDeleteable\Traits\UserSoftDeleteableEntity;
use App\DoctrineExtensions\IsActiveEntity;
use App\DoctrineExtensions\IsDefaultEntity;
/**
* @ORM\Entity(repositoryClass=PaymentTermRepository::class)
* @ORM\Table(name="sales_bundle__payment_term", indexes={
* @ORM\Index(name="name", columns={"name"}),
* @ORM\Index(name="days_delay", columns={"days_delay"}),
* @ORM\Index(name="end_month", columns={"end_month"}),
* @ORM\Index(name="is_active", columns={"is_active"}),
* @ORM\Index(name="is_default", columns={"is_default"}),
* @ORM\Index(name="deleted_at", columns={"deleted_at"}),
* @ORM\Index(name="created_at", columns={"created_at"}),
* @ORM\Index(name="updated_at", columns={"updated_at"})
* })
* @Gedmo\TranslationEntity(class="Bluue\SalesBundle\Entity\PaymentTermTranslation")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=false)
* @ORM\EntityListeners({PaymentTermListener::class})
*/
class PaymentTerm
{
use UserTimestampableEntity;
use UserSoftDeleteableEntity;
use IsActiveEntity;
use IsDefaultEntity;
/**
* @ORM\Id
* @ORM\Column(type="uuid")
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class=UuidGenerator::class)
*/
private ?Uuid $id = null;
/**
* @Gedmo\Translatable
* @ORM\Column(type="string", length=128)
*/
private ?string $name = null;
/**
* @ORM\Column(type="integer")
*/
private ?int $days_delay = null;
/**
* @ORM\Column(type="boolean")
*/
private bool $end_month = false;
/**
* @ORM\OneToMany(
* targetEntity="PaymentTermTranslation",
* mappedBy="object",
* cascade={"persist", "remove"},
* fetch="EXTRA_LAZY"
* )
*/
private Collection $translations;
public function __construct()
{
$this->translations = new ArrayCollection();
}
/**
* @return Uuid|null
*/
public function getId(): ?Uuid
{
return $this->id;
}
/**
* @return string|null
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string $name
* @return PaymentTerm
*/
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return int|null
*/
public function getDaysDelay(): ?int
{
return $this->days_delay;
}
/**
* @param int $days_delay
* @return PaymentTerm
*/
public function setDaysDelay(int $days_delay): self
{
$this->days_delay = $days_delay;
return $this;
}
/**
* @return bool|null
*/
public function getEndMonth(): ?bool
{
return $this->end_month;
}
/**
* @param bool $end_month
* @return PaymentTerm
*/
public function setEndMonth(bool $end_month): self
{
$this->end_month = $end_month;
return $this;
}
/**
* @return Collection|PaymentTermTranslation[]
*/
public function getTranslations(): Collection
{
return $this->translations;
}
/**
* @param PaymentTermTranslation $t
* @return PaymentTerm
*/
public function addTranslation(PaymentTermTranslation $t): self
{
if (!$this->translations->contains($t)) {
$this->translations[] = $t;
$t->setObject($this);
}
return $this;
}
}