<?phpnamespace App\Entity\Prescriber;use App\Entity\ProspectOnStore;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Gedmo\Mapping\Annotation as Gedmo;/** * @ORM\Entity(repositoryClass=PrescriberRemunerationRepository::class) */class PrescriberRemuneration{ /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private int $id; /** * @ORM\ManyToOne(targetEntity=Prescriber::class, inversedBy="prescriberRemunerations") * @ORM\JoinColumn(nullable=false) */ private Prescriber $prescriber; /** * @ORM\OneToMany(targetEntity=ProspectOnStore::class, mappedBy="prescriberRemuneration") */ private Collection $prospectsOnStore; private array $computedRemunerations = []; /** * @ORM\Column(type="float") */ private float $amount = 0; /** * @ORM\Column(type="datetime_immutable") * @Gedmo\Timestampable(on="create") */ private $createdAt; public function __construct() { $this->prospectsOnStore = new ArrayCollection(); } public function getPrescriber(): ?Prescriber { return $this->prescriber; } public function setPrescriber(?Prescriber $prescriber): self { $this->prescriber = $prescriber; return $this; } /** * @return Collection<int, ProspectOnStore> */ public function getProspectsOnStore(): Collection { return $this->prospectsOnStore; } public function addProspectsOnStore(ProspectOnStore $prospectsOnStore): self { if (!$this->prospectsOnStore->contains($prospectsOnStore)) { $this->prospectsOnStore[] = $prospectsOnStore; $prospectsOnStore->setPrescriberRemuneration($this); } return $this; } public function removeProspectsOnStore(ProspectOnStore $prospectsOnStore): self { if ($this->prospectsOnStore->removeElement($prospectsOnStore)) { // set the owning side to null (unless already changed) if ($prospectsOnStore->getPrescriberRemuneration() === $this) { $prospectsOnStore->setPrescriberRemuneration(null); } } return $this; } public function getComputedRemunerations(): array { return $this->computedRemunerations; } public function addComputedRemuneration(ProspectOnStore $pos, float $price): self { $this->computedRemunerations[$pos->getId()] = [ 'pos' => $pos, 'state' => $pos->getQualification() ? $pos->getQualification()->getState() : null, 'price' => $price ]; $this->amount += $price; return $this; } public function getId(): ?int { return $this->id; } public function getAmount(): float { return $this->amount; } public function setAmount(float $amount): self { $this->amount = $amount; return $this; } public function getCreatedAt(): ?\DateTimeImmutable { return $this->createdAt; } public function setCreatedAt(\DateTimeImmutable $createdAt): self { $this->createdAt = $createdAt; return $this; }}