<?php
namespace App\Entity\ChannelUserData\Cursus;
use Nellapp\Bundle\SDKBundle\TrackData\Attribute\TrackEntity;
use Nellapp\Bundle\SDKBundle\TrackData\Attribute\TrackFIeld;
use App\Enum\ChannelUserData\Activity\CursusActivityTagEnum;
use App\Enum\ChannelUserData\FounderTypeEnum;
use App\Repository\ChannelUserData\Cursus\FounderRepository;
use Doctrine\ORM\Mapping as ORM;
use Nellapp\Bundle\SDKBundle\Utils\NellappFormatService;
use Symfony\Component\Validator\Constraints as Assert;
#[
ORM\Entity(repositoryClass: FounderRepository::class),
ORM\Table(name: 'channel_user_data_cursus_founder'),
TrackEntity(
name: 'founder.entity.track_data.entity.name',
fieldGroups: [
'informations' => [
'tags' => [CursusActivityTagEnum::FOUNDING],
],
],
),
]
class Founder
{
#[ORM\Id, ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\ManyToOne(targetEntity: AbstractCursus::class, inversedBy: 'founders')]
#[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
private ?AbstractCursus $cursus = null;
#[ORM\Column(type: 'integer', nullable: false)]
private ?int $founderOrder = null;
#[ORM\Column(type: 'integer', nullable: false)]
#[Assert\NotBlank(groups: ['Default'])]
#[TrackFIeld(name: 'founder.entity.founderType.label_trackdata.label', fieldKey: 'informations', callable: 'getStatusKey' , callableClass: FounderTypeEnum::class)]
private ?int $founderType = null;
#[ORM\Column(type: 'string', nullable: true)]
#[Assert\Length(max: 255)]
#[TrackFIeld(name: 'founder.entity.founderOtherType.label', fieldKey: 'informations')]
private ?string $founderOtherType = null;
#[ORM\Column(type: 'string')]
#[
Assert\NotBlank,
Assert\Length(max: 255)
]
#[TrackFIeld(name: 'founder.entity.caseNumber.label', fieldKey: 'informations')]
private ?string $caseNumber = null;
#[ORM\Column(type: 'string', nullable: true)]
#[Assert\Length(max: 255)]
#[TrackFIeld(name: 'founder.entity.identifier.label', fieldKey: 'informations')]
private ?string $identifier = null;
#[ORM\Column(type: 'decimal', scale: 2)]
#[
Assert\NotBlank,
Assert\PositiveOrZero(message: 'founder.entity.amount.PositiveOrZero.message'),
]
#[TrackFIeld(name: 'founder.entity.amount.label', fieldKey: 'informations')]
private string $amount = '0.00';
#[ORM\Column(type: 'integer')]
#[
Assert\NotBlank,
Assert\PositiveOrZero(message: 'founder.entity.amountTime.PositiveOrZero.message')
]
#[TrackFIeld(name: 'founder.entity.amountTime.label', fieldKey: 'informations', callable: 'formatDuration', callableClass: NellappFormatService::class)]
private int $amountTime = 0;
#[ORM\OneToOne(mappedBy: 'founder', targetEntity: PurchaseOrder::class, cascade: ['persist'], orphanRemoval: true)]
#[Assert\Valid(groups: ['Default'])]
private ?PurchaseOrder $purchaseOrder = null;
#[ORM\OneToOne(mappedBy: 'founder', targetEntity: Adviser::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
#[Assert\Valid(groups: ['Default'])]
private ?Adviser $adviser = null;
public function getId(): ?int
{
return $this->id;
}
public function __toString(): string
{
if ($this->founderType === FounderTypeEnum::OTHER && $this->founderOtherType !== null) {
return $this->founderOtherType;
} elseif ($this->founderType !== null) {
return FounderTypeEnum::getStatusKey($this->founderType);
}
return '';
}
public function getFounderOrder(): ?int
{
return $this->founderOrder;
}
public function setFounderOrder(?int $founderOrder): Founder
{
$this->founderOrder = $founderOrder;
return $this;
}
public function getFounderType(): ?int
{
return $this->founderType;
}
public function setFounderType(?int $founderType): Founder
{
$this->founderType = $founderType;
return $this;
}
public function getFounderOtherType(): ?string
{
return $this->founderOtherType;
}
public function setFounderOtherType(?string $founderOtherType): Founder
{
$this->founderOtherType = $founderOtherType;
return $this;
}
public function getCaseNumber(): ?string
{
return $this->caseNumber;
}
public function setCaseNumber(?string $caseNumber): Founder
{
$this->caseNumber = $caseNumber;
return $this;
}
public function getIdentifier(): ?string
{
return $this->identifier;
}
public function setIdentifier(?string $identifier): Founder
{
$this->identifier = $identifier;
return $this;
}
public function getAmount(): float
{
return (float) $this->amount;
}
public function setAmount(string $amount): Founder
{
$this->amount = number_format($amount, 2, '.', '');
return $this;
}
public function getAmountTime(): int
{
return $this->amountTime;
}
public function setAmountTime(int $amountTime): Founder
{
$this->amountTime = $amountTime;
return $this;
}
public function getCursus(): ?AbstractCursus
{
return $this->cursus;
}
public function setCursus(?AbstractCursus $cursus): Founder
{
$this->cursus = $cursus;
return $this;
}
public function getAdviser(): ?Adviser
{
return $this->adviser;
}
public function setAdviser(?Adviser $adviser): Founder
{
$this->adviser = $adviser;
$this->adviser?->setFounder($this);
return $this;
}
public function getPurchaseOrder(): ?PurchaseOrder
{
return $this->purchaseOrder;
}
public function setPurchaseOrder(?PurchaseOrder $purchaseOrder): Founder
{
$this->purchaseOrder = $purchaseOrder;
$this->purchaseOrder?->setFounder($this);
return $this;
}
}