src/Entity/ChannelUserData/Cursus/Founder.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity\ChannelUserData\Cursus;
  3. use Nellapp\Bundle\SDKBundle\TrackData\Attribute\TrackEntity;
  4. use Nellapp\Bundle\SDKBundle\TrackData\Attribute\TrackField;
  5. use App\Enum\ChannelUserData\Activity\CursusActivityTagEnum;
  6. use App\Repository\ChannelUserData\Cursus\FounderRepository;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Nellapp\Bundle\SDKBundle\Enum\ChannelUserData\FounderTypeEnum;
  9. use Nellapp\Bundle\SDKBundle\Utils\NellappFormatService;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. #[
  12. ORM\Entity(repositoryClass: FounderRepository::class),
  13. ORM\Table(name: 'channel_user_data_cursus_founder'),
  14. TrackEntity(
  15. name: 'founder.entity.track_data.entity.name',
  16. fieldGroups: [
  17. 'informations' => [
  18. 'tags' => [CursusActivityTagEnum::FOUNDING],
  19. ],
  20. ],
  21. ),
  22. ]
  23. class Founder
  24. {
  25. #[ORM\Id, ORM\GeneratedValue]
  26. #[ORM\Column(type: 'integer')]
  27. private ?int $id = null;
  28. #[ORM\ManyToOne(targetEntity: AbstractCursus::class, inversedBy: 'founders')]
  29. #[ORM\JoinColumn(nullable: false, onDelete: "CASCADE")]
  30. private ?AbstractCursus $cursus = null;
  31. #[ORM\Column(type: 'integer', nullable: false)]
  32. private ?int $founderOrder = null;
  33. #[ORM\Column(type: 'integer', nullable: false)]
  34. #[Assert\NotBlank(groups: ['Default'])]
  35. #[TrackField(name: 'founder.entity.founderType.label_trackdata.label', fieldKey: 'informations', callable: 'getStatusKey' , callableClass: FounderTypeEnum::class)]
  36. private ?int $founderType = null;
  37. #[ORM\Column(type: 'string', nullable: true)]
  38. #[Assert\Length(max: 255)]
  39. #[TrackField(name: 'founder.entity.founderOtherType.label', fieldKey: 'informations')]
  40. private ?string $founderOtherType = null;
  41. #[ORM\Column(type: 'string')]
  42. #[
  43. Assert\NotBlank,
  44. Assert\Length(max: 255)
  45. ]
  46. #[TrackField(name: 'founder.entity.caseNumber.label', fieldKey: 'informations')]
  47. private ?string $caseNumber = null;
  48. #[ORM\Column(type: 'string', nullable: true)]
  49. #[Assert\Length(max: 255)]
  50. #[TrackField(name: 'founder.entity.identifier.label', fieldKey: 'informations')]
  51. private ?string $identifier = null;
  52. #[ORM\Column(type: 'decimal', scale: 2)]
  53. #[
  54. Assert\NotBlank,
  55. Assert\PositiveOrZero(message: 'founder.entity.amount.PositiveOrZero.message'),
  56. ]
  57. #[TrackField(name: 'founder.entity.amount.label', fieldKey: 'informations')]
  58. private string $amount = '0.00';
  59. #[ORM\Column(type: 'integer')]
  60. #[
  61. Assert\NotBlank,
  62. Assert\PositiveOrZero(message: 'founder.entity.amountTime.PositiveOrZero.message')
  63. ]
  64. #[TrackField(name: 'founder.entity.amountTime.label', fieldKey: 'informations', callable: 'formatDuration', callableClass: NellappFormatService::class)]
  65. private int $amountTime = 0;
  66. #[ORM\OneToOne(mappedBy: 'founder', targetEntity: PurchaseOrder::class, cascade: ['persist'], orphanRemoval: true)]
  67. #[Assert\Valid(groups: ['Default'])]
  68. private ?PurchaseOrder $purchaseOrder = null;
  69. #[ORM\OneToOne(mappedBy: 'founder', targetEntity: Adviser::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
  70. #[Assert\Valid(groups: ['Default'])]
  71. private ?Adviser $adviser = null;
  72. public function getId(): ?int
  73. {
  74. return $this->id;
  75. }
  76. public function __toString(): string
  77. {
  78. if ($this->founderType === FounderTypeEnum::OTHER && $this->founderOtherType !== null) {
  79. return $this->founderOtherType;
  80. } elseif ($this->founderType !== null) {
  81. return FounderTypeEnum::getStatusKey($this->founderType);
  82. }
  83. return '';
  84. }
  85. public function getFounderOrder(): ?int
  86. {
  87. return $this->founderOrder;
  88. }
  89. public function setFounderOrder(?int $founderOrder): Founder
  90. {
  91. $this->founderOrder = $founderOrder;
  92. return $this;
  93. }
  94. public function getFounderType(): ?int
  95. {
  96. return $this->founderType;
  97. }
  98. public function setFounderType(?int $founderType): Founder
  99. {
  100. $this->founderType = $founderType;
  101. return $this;
  102. }
  103. public function getFounderOtherType(): ?string
  104. {
  105. return $this->founderOtherType;
  106. }
  107. public function setFounderOtherType(?string $founderOtherType): Founder
  108. {
  109. $this->founderOtherType = $founderOtherType;
  110. return $this;
  111. }
  112. public function getCaseNumber(): ?string
  113. {
  114. return $this->caseNumber;
  115. }
  116. public function setCaseNumber(?string $caseNumber): Founder
  117. {
  118. $this->caseNumber = $caseNumber;
  119. return $this;
  120. }
  121. public function getIdentifier(): ?string
  122. {
  123. return $this->identifier;
  124. }
  125. public function setIdentifier(?string $identifier): Founder
  126. {
  127. $this->identifier = $identifier;
  128. return $this;
  129. }
  130. public function getAmount(): float
  131. {
  132. return (float) $this->amount;
  133. }
  134. public function setAmount(string $amount): Founder
  135. {
  136. $this->amount = number_format($amount, 2, '.', '');
  137. return $this;
  138. }
  139. public function getAmountTime(): int
  140. {
  141. return $this->amountTime;
  142. }
  143. public function setAmountTime(int $amountTime): Founder
  144. {
  145. $this->amountTime = $amountTime;
  146. return $this;
  147. }
  148. public function getCursus(): ?AbstractCursus
  149. {
  150. return $this->cursus;
  151. }
  152. public function setCursus(?AbstractCursus $cursus): Founder
  153. {
  154. $this->cursus = $cursus;
  155. return $this;
  156. }
  157. public function getAdviser(): ?Adviser
  158. {
  159. return $this->adviser;
  160. }
  161. public function setAdviser(?Adviser $adviser): Founder
  162. {
  163. $this->adviser = $adviser;
  164. $this->adviser?->setFounder($this);
  165. return $this;
  166. }
  167. public function getPurchaseOrder(): ?PurchaseOrder
  168. {
  169. return $this->purchaseOrder;
  170. }
  171. public function setPurchaseOrder(?PurchaseOrder $purchaseOrder): Founder
  172. {
  173. $this->purchaseOrder = $purchaseOrder;
  174. $this->purchaseOrder?->setFounder($this);
  175. return $this;
  176. }
  177. }