src/Entity/Prescriber/PrescriberRemuneration.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Prescriber;
  3. use App\Entity\ProspectOnStore;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. /**
  9.  * @ORM\Entity(repositoryClass=PrescriberRemunerationRepository::class)
  10.  */
  11. class PrescriberRemuneration
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private int $id;
  19.     /**
  20.      * @ORM\ManyToOne(targetEntity=Prescriber::class, inversedBy="prescriberRemunerations")
  21.      * @ORM\JoinColumn(nullable=false)
  22.      */
  23.     private Prescriber $prescriber;
  24.     /**
  25.      * @ORM\OneToMany(targetEntity=ProspectOnStore::class, mappedBy="prescriberRemuneration")
  26.      */
  27.     private Collection $prospectsOnStore;
  28.     private array $computedRemunerations = [];
  29.     /**
  30.      * @ORM\Column(type="float")
  31.      */
  32.     private float $amount 0;
  33.     /**
  34.      * @ORM\Column(type="datetime_immutable")
  35.      * @Gedmo\Timestampable(on="create")
  36.      */
  37.     private $createdAt;
  38.     public function __construct()
  39.     {
  40.         $this->prospectsOnStore = new ArrayCollection();
  41.     }
  42.     public function getPrescriber(): ?Prescriber
  43.     {
  44.         return $this->prescriber;
  45.     }
  46.     public function setPrescriber(?Prescriber $prescriber): self
  47.     {
  48.         $this->prescriber $prescriber;
  49.         return $this;
  50.     }
  51.     /**
  52.      * @return Collection<int, ProspectOnStore>
  53.      */
  54.     public function getProspectsOnStore(): Collection
  55.     {
  56.         return $this->prospectsOnStore;
  57.     }
  58.     public function addProspectsOnStore(ProspectOnStore $prospectsOnStore): self
  59.     {
  60.         if (!$this->prospectsOnStore->contains($prospectsOnStore)) {
  61.             $this->prospectsOnStore[] = $prospectsOnStore;
  62.             $prospectsOnStore->setPrescriberRemuneration($this);
  63.         }
  64.         return $this;
  65.     }
  66.     public function removeProspectsOnStore(ProspectOnStore $prospectsOnStore): self
  67.     {
  68.         if ($this->prospectsOnStore->removeElement($prospectsOnStore)) {
  69.             // set the owning side to null (unless already changed)
  70.             if ($prospectsOnStore->getPrescriberRemuneration() === $this) {
  71.                 $prospectsOnStore->setPrescriberRemuneration(null);
  72.             }
  73.         }
  74.         return $this;
  75.     }
  76.     public function getComputedRemunerations(): array
  77.     {
  78.         return $this->computedRemunerations;
  79.     }
  80.     public function addComputedRemuneration(ProspectOnStore $posfloat $price): self
  81.     {
  82.         $this->computedRemunerations[$pos->getId()] = [
  83.             'pos' => $pos,
  84.             'state' => $pos->getQualification() ? $pos->getQualification()->getState() : null,
  85.             'price' => $price
  86.         ];
  87.         $this->amount += $price;
  88.         return $this;
  89.     }
  90.     public function getId(): ?int
  91.     {
  92.         return $this->id;
  93.     }
  94.     public function getAmount(): float
  95.     {
  96.         return $this->amount;
  97.     }
  98.     public function setAmount(float $amount): self
  99.     {
  100.         $this->amount $amount;
  101.         return $this;
  102.     }
  103.     public function getCreatedAt(): ?\DateTimeImmutable
  104.     {
  105.         return $this->createdAt;
  106.     }
  107.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  108.     {
  109.         $this->createdAt $createdAt;
  110.         return $this;
  111.     }
  112. }