src/Entity/ProspectOnStore.php line 45

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Enum\BusinessModelEnum;
  4. use App\Entity\Enum\ProspectOnStoreCreationModeEnum;
  5. use App\Entity\Enum\ProspectOnStoreStatusEnum;
  6. use App\Entity\Prescriber\Prescriber;
  7. use App\Entity\Prescriber\PrescriberRemuneration;
  8. use DateTime;
  9. use DateTimeInterface;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Gedmo\Mapping\Annotation as Gedmo;
  14. use ApiPlatform\Core\Annotation\ApiResource;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. /**
  18.  * @ORM\Entity(repositoryClass="App\Repository\ProspectOnStoreRepository")
  19.  * @ORM\EntityListeners({"App\Listener\ProspectOnStoreListener"})
  20.  * @ApiResource(
  21.  *     itemOperations={
  22.  *          "get"={"security"="is_granted('ROLE_API')"},
  23.  *          "patch"={"security"="is_granted('ROLE_API') and object.isWaitingQualification()"},
  24.  *          "qualify"={
  25.  *              "security"="is_granted('ROLE_API')",
  26.  *              "method"="POST",
  27.  *              "path"="/prospect/{id}/qualify",
  28.  *               "controller"=App\Controller\Api\QualifyProspectAction::class,
  29.  *          },
  30.  *          "getFromHubspot"={
  31.  *               "security"="is_granted('ROLE_API')",
  32.  *               "method"="GET",
  33.  *               "path"="/hubspot/prospect_on_stores/{hubspotId}",
  34.  *                "controller"=App\Controller\Api\getPosFromHubspotAction::class,
  35.  *                  "read"=false
  36.  *           }
  37.  *     },
  38.  *     normalizationContext={"groups"={"pos:read"}},
  39.  *     denormalizationContext={"groups"={"pos:write", "prospect:write"}}
  40.  * )
  41.  */
  42. class ProspectOnStore
  43. {
  44.     /**
  45.      * @ORM\Id()
  46.      * @ORM\GeneratedValue()
  47.      * @ORM\Column(type="integer")
  48.      * @Groups({"pos:read"})
  49.      */
  50.     private $id;
  51.     /**
  52.      * @ORM\Column(type="datetime")
  53.      * @Gedmo\Timestampable(on="create")
  54.      */
  55.     private $created;
  56.     /**
  57.      * @ORM\ManyToOne(targetEntity="App\Entity\Store", inversedBy="prospectsOnStore", fetch="EAGER")
  58.      * @ORM\JoinColumn(nullable=false)
  59.      * @Groups({"pos:write", "pos:read"})
  60.      */
  61.     private $store;
  62.     /**
  63.      * @ORM\ManyToOne(targetEntity="App\Entity\Prospect", inversedBy="prospectsOnStore")
  64.      * @ORM\JoinColumn(nullable=false)
  65.      * @Groups({"pos:write", "pos:read"})
  66.      */
  67.     private $prospect;
  68.     /**
  69.      *  @deprecated
  70.      * @ORM\Column(type="integer", nullable=true)
  71.      */
  72.     private $creditCost;
  73.     /**
  74.      * @ORM\OneToOne(targetEntity=CreditCost::class, inversedBy="prospectOnStore", cascade={"persist", "remove"})
  75.      */
  76.     private ?CreditCost $cost null;
  77.     /**
  78.      * @ORM\OneToMany(targetEntity="App\Entity\MediaoptinDelivery", mappedBy="prospectOnStore", cascade={"persist", "remove"})
  79.      */
  80.     private $mediaoptinDeliveries;
  81.     /**
  82.      * @ORM\Column(type="boolean", nullable=true)
  83.      */
  84.     private $isDemandForThird;
  85.     /**
  86.      * A freelancer with role "BUSINESS_INTRODUCER" can mark prospect as "delivered" on his BO
  87.      * @ORM\Column(type="boolean", nullable=true)
  88.      */
  89.     private $markDeliveredByBusinessIntroducer;
  90.     /**
  91.      * @ORM\Column(type="boolean")
  92.      * @var boolean
  93.      */
  94.     private $isUnreachableSmsSend false;
  95.     /**
  96.      * @ORM\Column(type="boolean", nullable=true)
  97.      */
  98.     private $waitingQualification;
  99.     /**
  100.      * Note de l'admin (freelancer) sur le prospect
  101.      *
  102.      * @ORM\OneToMany(targetEntity="App\Entity\ProspectOnStoreStatus", mappedBy="prospectOnStore", cascade={"persist", "remove"})
  103.      * @ORM\JoinColumn(nullable=true)
  104.      * @ORM\OrderBy({"created" = "DESC"})
  105.      */
  106.     private $prospectOnStoreStatus;
  107.     /**
  108.      * ProspectDuplicate that has created this prospectOnStore (optional)
  109.      * @ORM\ManyToOne(targetEntity=ProspectDuplicate::class, inversedBy="prospectOnStoresCreated")
  110.      */
  111.     private $prospectDuplicateOrigin;
  112.     /**
  113.      * @ORM\ManyToOne(targetEntity=ProspectOnStoreFeedback::class, inversedBy="prospectOnStoreGenerated")
  114.      */
  115.     private $prospectOnStoreFeedbackOrigin;
  116.     /**
  117.      * @ORM\OneToOne(targetEntity=ProspectOnStoreFeedback::class, inversedBy="prospectOnStore")
  118.      * @ORM\JoinColumn(nullable=true)
  119.      */
  120.     private $feedback;
  121.     /**
  122.      * @ORM\Column(type="datetime", nullable=true)
  123.      */
  124.     private $startDealingWithDate;
  125.     /**
  126.      * Mode d'acquisition du lead (emailing, facebook, ...)
  127.      *
  128.      * @ORM\Column(type="string", length=255, nullable=true)
  129.      */
  130.     private $acquisitionMode;
  131.     /**
  132.      * Base emailing de provenance du lead
  133.      *
  134.      * @ORM\Column(type="string", length=255, nullable=true)
  135.      * @Assert\NotBlank(groups={"API"})
  136.      * @Groups({"prospect:write"})
  137.      */
  138.     private $acquisitionBase;
  139.     /**
  140.      * Url de provenance du lead (dernière URL avant persist)
  141.      *
  142.      * @ORM\Column(type="string", length=255, nullable=true)
  143.      */
  144.     private $acquisitionUrl;
  145.     /**
  146.      * Meta keyword URL
  147.      * @ORM\Column(type="string", length=255, nullable=true)
  148.      */
  149.     private $acquisitionKeyword;
  150.     /**
  151.      * @ORM\Column(type="string", length=5, nullable=true)
  152.      */
  153.     private $creationMode=ProspectOnStoreCreationModeEnum::STANDARD;
  154.     /**
  155.      * @ORM\Column(type="boolean")
  156.      */
  157.     private $delivered=false;
  158.     /**
  159.      * @ORM\Column(type="float", nullable=true)
  160.      */
  161.     private $distanceToStore;
  162.     /**
  163.      * @ORM\Column(type="boolean")
  164.      */
  165.     private $isSpecific=false;
  166.     /**
  167.      * @ORM\Column(type="text", nullable=true)
  168.      */
  169.     private $comment;
  170.     /**
  171.      * @ORM\OneToMany(targetEntity=DeviceSale::class, mappedBy="prospectOnStore", orphanRemoval=true)
  172.      */
  173.     private $deviceSales;
  174.     /**
  175.      * @ORM\Column(type="smallint")
  176.      */
  177.     private ?int $businessModel;
  178.     /**
  179.      * @ORM\OneToOne(targetEntity=Claim::class, inversedBy="prospectOnStore")
  180.      */
  181.     private ?Claim $claim;
  182.     /**
  183.      * @ORM\OneToOne(targetEntity=ProspectOnStoreQualification::class, cascade={"persist", "remove"}, inversedBy="prospectOnStore")
  184.      */
  185.     private ?ProspectOnStoreQualification $qualification=null;
  186.     /**
  187.      * @ORM\ManyToOne(targetEntity=Prescriber::class, inversedBy="prospectsOnStore")
  188.      */
  189.     private ?Prescriber $prescriber=null;
  190.     /**
  191.      * @ORM\ManyToOne(targetEntity=PrescriberRemuneration::class, inversedBy="prospectsOnStore", cascade={"persist"})
  192.      */
  193.     private ?PrescriberRemuneration $prescriberRemuneration=null;
  194.     /**
  195.      * MCA-784: IDs d'administrateurs pour forcer la livraison (ex: "123" ou "123,456")
  196.      * @ORM\Column(type="string", length=255, nullable=true)
  197.      */
  198.     private ?string $forceDeliveredAdminId null;
  199.     public function __construct()
  200.     {
  201.         $this->mediaoptinDeliveries = new ArrayCollection();
  202.         $this->prospectOnStoreStatus = new ArrayCollection();
  203.         $this->deviceSales = new ArrayCollection();
  204.     }
  205.     /**
  206.      * Représente l'entité dans le BO
  207.      * @return string
  208.      */
  209.     public function getLabel(){
  210.         return '#'.$this->getId();
  211.     }
  212.     public function getId(): ?int
  213.     {
  214.         return $this->id;
  215.     }
  216.     public function getStore(): ?Store
  217.     {
  218.         return $this->store;
  219.     }
  220.     public function setStore(?Store $store): self
  221.     {
  222.         $this->store $store;
  223.         $businessModel $store->getAdministrator()->getBusinessModel();
  224.         if(is_null($businessModel)){
  225.             $businessModel BusinessModelEnum::CREDIT;
  226.         }
  227.         $this->businessModel $businessModel;
  228.         return $this;
  229.     }
  230.     public function getProspect(): ?Prospect
  231.     {
  232.         return $this->prospect;
  233.     }
  234.     public function setProspect(?Prospect $prospect): self
  235.     {
  236.         $this->prospect $prospect;
  237.         return $this;
  238.     }
  239.     /**
  240.      *  @deprecated
  241.      * @return int|null
  242.      */
  243.     public function getCreditCost(): ?int
  244.     {
  245.         return $this->creditCost;
  246.     }
  247.     /**
  248.      * @deprecated
  249.      * @param int $creditCost
  250.      * @return $this
  251.      */
  252.     public function setCreditCost(int $creditCost): self
  253.     {
  254.         $this->creditCost $creditCost;
  255.         return $this;
  256.     }
  257.     public function getCost(): ?CreditCost
  258.     {
  259.         return $this->cost;
  260.     }
  261.     public function setCost(?CreditCost $cost): self
  262.     {
  263.         $this->cost $cost;
  264.         $cost->setProspectOnStore($this);
  265.         return $this;
  266.     }
  267.     /**
  268.      * @return Collection|MediaoptinDelivery[]
  269.      */
  270.     public function getMediaoptinDeliveries(): Collection
  271.     {
  272.         return $this->mediaoptinDeliveries;
  273.     }
  274.     public function addMediaoptinDelivery(MediaoptinDelivery $mediaoptinDelivery): self
  275.     {
  276.         if (!$this->mediaoptinDeliveries->contains($mediaoptinDelivery)) {
  277.             $this->mediaoptinDeliveries[] = $mediaoptinDelivery;
  278.             $mediaoptinDelivery->setProspectOnStore($this);
  279.         }
  280.         return $this;
  281.     }
  282.     public function removeMediaoptinDelivery(MediaoptinDelivery $mediaoptinDelivery): self
  283.     {
  284.         if ($this->mediaoptinDeliveries->contains($mediaoptinDelivery)) {
  285.             $this->mediaoptinDeliveries->removeElement($mediaoptinDelivery);
  286.             // set the owning side to null (unless already changed)
  287.             if ($mediaoptinDelivery->getProspectOnStore() === $this) {
  288.                 $mediaoptinDelivery->setProspectOnStore(null);
  289.             }
  290.         }
  291.         return $this;
  292.     }
  293.     public function getIsDemandForThird(): ?bool
  294.     {
  295.         return $this->isDemandForThird;
  296.     }
  297.     public function setIsDemandForThird(?bool $isDemandForThird): self
  298.     {
  299.         $this->isDemandForThird $isDemandForThird;
  300.         return $this;
  301.     }
  302.     /**
  303.      * @return mixed
  304.      */
  305.     public function isMarkDeliveredByBusinessIntroducer()
  306.     {
  307.         return $this->markDeliveredByBusinessIntroducer;
  308.     }
  309.     /**
  310.      * @param mixed $markDeliveredByBusinessIntroducer
  311.      */
  312.     public function setMarkDeliveredByBusinessIntroducer($markDeliveredByBusinessIntroducer): void
  313.     {
  314.         $this->markDeliveredByBusinessIntroducer $markDeliveredByBusinessIntroducer;
  315.     }
  316.     public function getMarkDeliveredByBusinessIntroducer(): ?bool
  317.     {
  318.         return $this->markDeliveredByBusinessIntroducer;
  319.     }
  320.     public function getIsUnreachableSmsSend(): ?bool
  321.     {
  322.         return $this->isUnreachableSmsSend;
  323.     }
  324.     public function setIsUnreachableSmsSend(bool $isUnreachableSmsSend): self
  325.     {
  326.         $this->isUnreachableSmsSend $isUnreachableSmsSend;
  327.         return $this;
  328.     }
  329.     public function getCreated(): ?DateTimeInterface
  330.     {
  331.         return $this->created;
  332.     }
  333.     public function setCreated(DateTimeInterface $created): self
  334.     {
  335.         $this->created $created;
  336.         return $this;
  337.     }
  338.     /**
  339.      *  Return the latest date among the creation date of the POS, OR the validation of the qualification
  340.      * @return DateTimeInterface|null
  341.      */
  342.     public function getCreationOrQualificationValidationDate(): ?DateTimeInterface
  343.     {
  344.         $qualification $this->getProspect()->getQualification();
  345.         if($qualification && $qualification->isValidated()){
  346.             return max($qualification->getValidatedAt(), $this->created) ;
  347.         }
  348.         return $this->created;
  349.     }
  350.     /**
  351.      * @return bool
  352.      */
  353.     public function isWaitingQualification()
  354.     {
  355.         return $this->waitingQualification;
  356.     }
  357.     /**
  358.      * @param bool $waitingQualification
  359.      */
  360.     public function setWaitingQualification(bool $waitingQualification): void
  361.     {
  362.         $this->waitingQualification $waitingQualification;
  363.     }
  364.     /**
  365.      * @return Collection|ProspectOnStoreStatus[]
  366.      */
  367.     public function getProspectOnStoreStatus(): Collection
  368.     {
  369.         return $this->prospectOnStoreStatus;
  370.     }
  371.     /**
  372.      * Verify number of contact attempt status
  373.      * @return bool
  374.      */
  375.     public function hasBeenContactedManyTimes(): bool
  376.     {
  377.         $nbContact 0;
  378.         foreach ($this->getProspectOnStoreStatus() as $status){
  379.             if($status->getStatus() == ProspectOnStoreStatusEnum::TO_CONTACT){
  380.                 $nbContact++;
  381.                 if($nbContact >= 3){
  382.                     return true;
  383.                 }
  384.             }
  385.         }
  386.         return false;
  387.     }
  388.     /**
  389.      * Count number of contact attempt by freelancer
  390.      * @return int
  391.      */
  392.     public function countContactAttempt(): int
  393.     {
  394.         $nbContact 0;
  395.         foreach ($this->getProspectOnStoreStatus() as $status){
  396.             if($status->getStatus() == ProspectOnStoreStatusEnum::TO_CONTACT){
  397.                 $nbContact++;
  398.             }
  399.         }
  400.         return $nbContact;
  401.     }
  402.     /**
  403.      * Verify delay between two contact attempts (for blocked buttons in front)
  404.      * @return bool
  405.      */
  406.     public function isContactAttemptAllowed(): bool
  407.     {
  408.         $now = new DateTime();
  409.         foreach ($this->getProspectOnStoreStatus() as $status){
  410.             if($status->getStatus() == ProspectOnStoreStatusEnum::TO_CONTACT){
  411.                 $diff $status->getCreated()->diff($now);
  412.                 $diffInMinutes $diff->days 24 60 $diff->60 $diff->i;
  413.                 if ($diffInMinutes 15) {
  414.                     return false;
  415.                 }
  416.             }
  417.         }
  418.         return true;
  419.     }
  420.     /**
  421.      * Return the delay (expressed in nb of hours) between the creation (or qualification) of the lead and the creation of the first status.
  422.      * Null if no status
  423.      * @return int|null
  424.      */
  425.     public function getDelayBeforeFirstProspectOnStoreStatus() : ?int
  426.     {
  427.         if($firstStatus $this->getProspectOnStoreStatus()->last()){
  428.             $diff $this->getCreationOrQualificationValidationDate()->diff($firstStatus->getCreated());
  429.             return $diff->format('%h');
  430.         }
  431.         return null;
  432.     }
  433.     public function getLastStatus(){
  434.         return $this->getProspectOnStoreStatus()->first();
  435.     }
  436.     /**
  437.      * Does the status is "RDV PRIS" or later
  438.      * false if no status
  439.      * @return bool
  440.      */
  441.     public function hasStatusAppointmentMadeOrLater() : bool
  442.     {
  443.         $lastStatus $this->getLastStatus();
  444.         if($lastStatus){
  445.             return in_array($lastStatus->getStatus(), ProspectOnStoreStatusEnum::getAvailableTypesAfterAppointment());
  446.         }
  447.         return false;
  448.     }
  449.     public function removeProspectOnStoreStatus(ProspectOnStoreStatus $prospectOnStoreStatus): self
  450.     {
  451.         if ($this->prospectOnStoreStatus->contains($prospectOnStoreStatus)) {
  452.             $this->prospectOnStoreStatus->removeElement($prospectOnStoreStatus);
  453.             // set the owning side to null (unless already changed)
  454.             if ($prospectOnStoreStatus->getProspect() === $this) {
  455.                 $prospectOnStoreStatus->setProspect(null);
  456.             }
  457.         }
  458.         return $this;
  459.     }
  460.     public function getProspectDuplicateOrigin(): ?ProspectDuplicate
  461.     {
  462.         return $this->prospectDuplicateOrigin;
  463.     }
  464.     public function setProspectDuplicateOrigin(?ProspectDuplicate $prospectDuplicateOrigin): self
  465.     {
  466.         $this->prospectDuplicateOrigin $prospectDuplicateOrigin;
  467.         $this->setCreationMode(ProspectOnStoreCreationModeEnum::DUPLICATE);
  468.         return $this;
  469.     }
  470.     /**
  471.      * Specify if this POS has been created from a feedback (user not contacted)
  472.      * @return bool
  473.      */
  474.     public function hasFeedbackOrigin(): bool
  475.     {
  476.         return !is_null($this->prospectOnStoreFeedbackOrigin);
  477.     }
  478.     public function getProspectOnStoreFeedbackOrigin(): ?ProspectOnStoreFeedback
  479.     {
  480.         return $this->prospectOnStoreFeedbackOrigin;
  481.     }
  482.     public function setProspectOnStoreFeedbackOrigin(?ProspectOnStoreFeedback $prospectOnStoreFeedbackOrigin): self
  483.     {
  484.         $this->prospectOnStoreFeedbackOrigin $prospectOnStoreFeedbackOrigin;
  485.         $this->setCreationMode(ProspectOnStoreCreationModeEnum::FEEDBACK);
  486.         return $this;
  487.     }
  488.     /**
  489.      * @return mixed
  490.      */
  491.     public function getFeedback()
  492.     {
  493.         return $this->feedback;
  494.     }
  495.     /**
  496.      * @param mixed $feedback
  497.      */
  498.     public function setFeedback($feedback): void
  499.     {
  500.         $this->feedback $feedback;
  501.     }
  502.     /**
  503.      * @return mixed
  504.      */
  505.     public function getStartDealingWithDate()
  506.     {
  507.         return $this->startDealingWithDate;
  508.     }
  509.     /**
  510.      * @param mixed $startDealingWithDate
  511.      */
  512.     public function setStartDealingWithDate($startDealingWithDate): void
  513.     {
  514.         $this->startDealingWithDate $startDealingWithDate;
  515.     }
  516.     /**
  517.      * set "startDealingDate" as now (if null before)
  518.      * @return true if date as been updated, else false
  519.      */
  520.     public function setStartDealingWithDateAsNow(): bool
  521.     {
  522.         if(is_null($this->startDealingWithDate)){
  523.             $this->setStartDealingWithDate(new DateTime());
  524.             return true;
  525.         }
  526.         return false;
  527.     }
  528.     /**
  529.      * Compute startDealingWithDate based on ProspectOnStoreStatus. Only for ComputePosStartDealingDateCommand.
  530.      * Can be deleted once command executed once.
  531.      * @return bool
  532.      * @deprecated
  533.      */
  534.     public function computeStartDealingWithDate()
  535.     {
  536.         if(is_null($this->startDealingWithDate)){
  537.             if(!$this->getProspectOnStoreStatus()->isEmpty()){
  538.                 $firstStatus $this->getProspectOnStoreStatus()->last();
  539.                 $this->startDealingWithDate $firstStatus->getCreated();
  540.                 return true;
  541.             }
  542.         }
  543.         return false;
  544.     }
  545.     public function getWaitingQualification(): ?bool
  546.     {
  547.         return $this->waitingQualification;
  548.     }
  549.     public function getAcquisitionMode(): ?string
  550.     {
  551.         return $this->acquisitionMode;
  552.     }
  553.     public function setAcquisitionMode(?string $acquisitionMode): self
  554.     {
  555.         $this->acquisitionMode $acquisitionMode;
  556.         return $this;
  557.     }
  558.     public function getAcquisitionBase(): ?string
  559.     {
  560.         return $this->acquisitionBase;
  561.     }
  562.     public function setAcquisitionBase(?string $acquisitionBase): self
  563.     {
  564.         $this->acquisitionBase $acquisitionBase;
  565.         return $this;
  566.     }
  567.     public function getAcquisitionUrl(): ?string
  568.     {
  569.         return $this->acquisitionUrl;
  570.     }
  571.     public function setAcquisitionUrl(?string $acquisitionUrl): self
  572.     {
  573.         $this->acquisitionUrl $acquisitionUrl;
  574.         return $this;
  575.     }
  576.     public function getAcquisitionKeyword(): ?string
  577.     {
  578.         return $this->acquisitionKeyword;
  579.     }
  580.     public function setAcquisitionKeyword(?string $acquisitionKeyword): self
  581.     {
  582.         $this->acquisitionKeyword $acquisitionKeyword;
  583.         return $this;
  584.     }
  585.     public function getCreationMode(): ?string
  586.     {
  587.         return $this->creationMode;
  588.     }
  589.     public function getCreationModeLabel(): ?string
  590.     {
  591.         return ProspectOnStoreCreationModeEnum::getStateName($this->creationMode);
  592.     }
  593.     public function setCreationMode(?string $creationMode): self
  594.     {
  595.         $this->creationMode $creationMode;
  596.         return $this;
  597.     }
  598.     public function isCreatedFromUnreachable(): bool
  599.     {
  600.         return $this->creationMode == ProspectOnStoreCreationModeEnum::UNREACH;
  601.     }
  602.     /**
  603.      * Copy utm from a prospect
  604.      * @param Prospect $prospect
  605.      */
  606.     public function copyUtmFromProspect(Prospect $prospect){
  607.         $this->setAcquisitionUrl($prospect->getAcquisitionUrl());
  608.         $this->setAcquisitionMode($prospect->getAcquisitionMode());
  609.         $this->setAcquisitionBase($prospect->getAcquisitionBase());
  610.         $this->setAcquisitionKeyword($prospect->getAcquisitionKeyword());
  611.     }
  612.     /**
  613.      * @deprecated use isDelivered instead
  614.      * @return bool|null
  615.      */
  616.     public function getDelivered(): ?bool
  617.     {
  618.         return $this->delivered;
  619.     }
  620.     public function isDelivered(): ?bool
  621.     {
  622.         return $this->delivered;
  623.     }
  624.     public function setDelivered(bool $delivered): self
  625.     {
  626.         $this->delivered $delivered;
  627.         return $this;
  628.     }
  629.     public function markDelivered(): self
  630.     {
  631.         return $this->setDelivered(true);
  632.     }
  633.     public function getDistanceToStore(): ?float
  634.     {
  635.         return $this->distanceToStore;
  636.     }
  637.     public function setDistanceToStore(?float $distanceToStore): self
  638.     {
  639.         $this->distanceToStore $distanceToStore;
  640.         return $this;
  641.     }
  642.     public function getIsSpecific(): ?bool
  643.     {
  644.         return $this->isSpecific;
  645.     }
  646.     public function setIsSpecific(bool $isSpecific): self
  647.     {
  648.         $this->isSpecific $isSpecific;
  649.         return $this;
  650.     }
  651.     public function markSpecificWithComment(string $comment){
  652.         $this->setIsSpecific(true);
  653.         $this->appendComment($comment);
  654.     }
  655.     public function getComment(): ?string
  656.     {
  657.         return $this->comment;
  658.     }
  659.     public function setComment(?string $comment): self
  660.     {
  661.         $this->comment $comment;
  662.         return $this;
  663.     }
  664.     public function appendComment(?string $comment): self
  665.     {
  666.         if(is_null($this->comment)){
  667.             $this->setComment($comment);
  668.         }else{
  669.             $this->setComment($this->comment.' | '.$comment);
  670.         }
  671.         return $this;
  672.     }
  673.     /**
  674.      * @return Collection|DeviceSale[]
  675.      */
  676.     public function getDeviceSales(): Collection
  677.     {
  678.         return $this->deviceSales;
  679.     }
  680.     /**
  681.      * @return bool
  682.      */
  683.     public function hasDeviceSales(): bool
  684.     {
  685.         return !$this->deviceSales->isEmpty();
  686.     }
  687.     public function addDeviceSale(DeviceSale $deviceSale): self
  688.     {
  689.         if (!$this->deviceSales->contains($deviceSale)) {
  690.             $this->deviceSales[] = $deviceSale;
  691.             $deviceSale->setProspectOnStore($this);
  692.         }
  693.         return $this;
  694.     }
  695.     public function removeDeviceSale(DeviceSale $deviceSale): self
  696.     {
  697.         if ($this->deviceSales->contains($deviceSale)) {
  698.             $this->deviceSales->removeElement($deviceSale);
  699.             // set the owning side to null (unless already changed)
  700.             if ($deviceSale->getProspectOnStore() === $this) {
  701.                 $deviceSale->setProspectOnStore(null);
  702.             }
  703.         }
  704.         return $this;
  705.     }
  706.     /**
  707.      * @return int|null
  708.      */
  709.     public function getBusinessModel(): ?int
  710.     {
  711.         return $this->businessModel;
  712.     }
  713.     public function getBusinessModelLabel(): string
  714.     {
  715.         return BusinessModelEnum::getModelName($this->businessModel);
  716.     }
  717.     /**
  718.      * @param int|null $businessModel
  719.      */
  720.     public function setBusinessModel(?int $businessModel): void
  721.     {
  722.         $this->businessModel $businessModel;
  723.     }
  724.     public function isBusinessModelPerformance(): bool
  725.     {
  726.         return $this->businessModel == BusinessModelEnum::PERFORMANCE;
  727.     }
  728.     public function isBusinessModelCredit(): bool
  729.     {
  730.         return $this->businessModel == BusinessModelEnum::CREDIT;
  731.     }
  732.     public function isBusinessModelPayAsYouGo(): bool
  733.     {
  734.         return $this->businessModel == BusinessModelEnum::PAY_AS_YOU_GO;
  735.     }
  736.     /**
  737.      * @return Claim|null
  738.      */
  739.     public function getClaim(): ?Claim
  740.     {
  741.         return $this->claim;
  742.     }
  743.     /**
  744.      * @return bool
  745.      */
  746.     public function hasClaim(): bool
  747.     {
  748.         return !is_null($this->claim);
  749.     }
  750.     /**
  751.      * @param Claim|null $claim
  752.      */
  753.     public function setClaim(?Claim $claim): void
  754.     {
  755.         $this->claim $claim;
  756.     }
  757.     /**
  758.      * @Groups({"pos:read"})
  759.      * @return ProspectOnStoreQualification|null
  760.      */
  761.     public function getQualification(): ?ProspectOnStoreQualification
  762.     {
  763.         return $this->qualification;
  764.     }
  765.     public function setQualification(?ProspectOnStoreQualification $qualification): self
  766.     {
  767.         $this->qualification $qualification;
  768.         if(is_null($this->qualification->getProspectOnStore())){
  769.             $this->qualification->setProspectOnStore($this);
  770.         }
  771.         return $this;
  772.     }
  773.     public function getPrescriber(): ?Prescriber
  774.     {
  775.         return $this->prescriber;
  776.     }
  777.     public function setPrescriber(?Prescriber $prescriber): self
  778.     {
  779.         $this->prescriber $prescriber;
  780.         return $this;
  781.     }
  782.     public function getPrescriberRemuneration(): ?PrescriberRemuneration
  783.     {
  784.         return $this->prescriberRemuneration;
  785.     }
  786.     public function setPrescriberRemuneration(?PrescriberRemuneration $prescriberRemuneration): self
  787.     {
  788.         $this->prescriberRemuneration $prescriberRemuneration;
  789.         
  790.         return $this;
  791.     }
  792.     /**
  793.      * MCA-784: Get force delivered admin IDs
  794.      */
  795.     public function getForceDeliveredAdminId(): ?string
  796.     {
  797.         return $this->forceDeliveredAdminId;
  798.     }
  799.     /**
  800.      * MCA-784: Set force delivered admin IDs (ex: "123" ou "123,456")
  801.      */
  802.     public function setForceDeliveredAdminId(?string $forceDeliveredAdminId): self
  803.     {
  804.         $this->forceDeliveredAdminId $forceDeliveredAdminId;
  805.         return $this;
  806.     }
  807. }