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.     public function __construct()
  195.     {
  196.         $this->mediaoptinDeliveries = new ArrayCollection();
  197.         $this->prospectOnStoreStatus = new ArrayCollection();
  198.         $this->deviceSales = new ArrayCollection();
  199.     }
  200.     /**
  201.      * Représente l'entité dans le BO
  202.      * @return string
  203.      */
  204.     public function getLabel(){
  205.         return '#'.$this->getId();
  206.     }
  207.     public function getId(): ?int
  208.     {
  209.         return $this->id;
  210.     }
  211.     public function getStore(): ?Store
  212.     {
  213.         return $this->store;
  214.     }
  215.     public function setStore(?Store $store): self
  216.     {
  217.         $this->store $store;
  218.         $businessModel $store->getAdministrator()->getBusinessModel();
  219.         if(is_null($businessModel)){
  220.             $businessModel BusinessModelEnum::CREDIT;
  221.         }
  222.         $this->businessModel $businessModel;
  223.         return $this;
  224.     }
  225.     public function getProspect(): ?Prospect
  226.     {
  227.         return $this->prospect;
  228.     }
  229.     public function setProspect(?Prospect $prospect): self
  230.     {
  231.         $this->prospect $prospect;
  232.         return $this;
  233.     }
  234.     /**
  235.      *  @deprecated
  236.      * @return int|null
  237.      */
  238.     public function getCreditCost(): ?int
  239.     {
  240.         return $this->creditCost;
  241.     }
  242.     /**
  243.      * @deprecated
  244.      * @param int $creditCost
  245.      * @return $this
  246.      */
  247.     public function setCreditCost(int $creditCost): self
  248.     {
  249.         $this->creditCost $creditCost;
  250.         return $this;
  251.     }
  252.     public function getCost(): ?CreditCost
  253.     {
  254.         return $this->cost;
  255.     }
  256.     public function setCost(?CreditCost $cost): self
  257.     {
  258.         $this->cost $cost;
  259.         $cost->setProspectOnStore($this);
  260.         return $this;
  261.     }
  262.     /**
  263.      * @return Collection|MediaoptinDelivery[]
  264.      */
  265.     public function getMediaoptinDeliveries(): Collection
  266.     {
  267.         return $this->mediaoptinDeliveries;
  268.     }
  269.     public function addMediaoptinDelivery(MediaoptinDelivery $mediaoptinDelivery): self
  270.     {
  271.         if (!$this->mediaoptinDeliveries->contains($mediaoptinDelivery)) {
  272.             $this->mediaoptinDeliveries[] = $mediaoptinDelivery;
  273.             $mediaoptinDelivery->setProspectOnStore($this);
  274.         }
  275.         return $this;
  276.     }
  277.     public function removeMediaoptinDelivery(MediaoptinDelivery $mediaoptinDelivery): self
  278.     {
  279.         if ($this->mediaoptinDeliveries->contains($mediaoptinDelivery)) {
  280.             $this->mediaoptinDeliveries->removeElement($mediaoptinDelivery);
  281.             // set the owning side to null (unless already changed)
  282.             if ($mediaoptinDelivery->getProspectOnStore() === $this) {
  283.                 $mediaoptinDelivery->setProspectOnStore(null);
  284.             }
  285.         }
  286.         return $this;
  287.     }
  288.     public function getIsDemandForThird(): ?bool
  289.     {
  290.         return $this->isDemandForThird;
  291.     }
  292.     public function setIsDemandForThird(?bool $isDemandForThird): self
  293.     {
  294.         $this->isDemandForThird $isDemandForThird;
  295.         return $this;
  296.     }
  297.     /**
  298.      * @return mixed
  299.      */
  300.     public function isMarkDeliveredByBusinessIntroducer()
  301.     {
  302.         return $this->markDeliveredByBusinessIntroducer;
  303.     }
  304.     /**
  305.      * @param mixed $markDeliveredByBusinessIntroducer
  306.      */
  307.     public function setMarkDeliveredByBusinessIntroducer($markDeliveredByBusinessIntroducer): void
  308.     {
  309.         $this->markDeliveredByBusinessIntroducer $markDeliveredByBusinessIntroducer;
  310.     }
  311.     public function getMarkDeliveredByBusinessIntroducer(): ?bool
  312.     {
  313.         return $this->markDeliveredByBusinessIntroducer;
  314.     }
  315.     public function getIsUnreachableSmsSend(): ?bool
  316.     {
  317.         return $this->isUnreachableSmsSend;
  318.     }
  319.     public function setIsUnreachableSmsSend(bool $isUnreachableSmsSend): self
  320.     {
  321.         $this->isUnreachableSmsSend $isUnreachableSmsSend;
  322.         return $this;
  323.     }
  324.     public function getCreated(): ?DateTimeInterface
  325.     {
  326.         return $this->created;
  327.     }
  328.     public function setCreated(DateTimeInterface $created): self
  329.     {
  330.         $this->created $created;
  331.         return $this;
  332.     }
  333.     /**
  334.      *  Return the latest date among the creation date of the POS, OR the validation of the qualification
  335.      * @return DateTimeInterface|null
  336.      */
  337.     public function getCreationOrQualificationValidationDate(): ?DateTimeInterface
  338.     {
  339.         $qualification $this->getProspect()->getQualification();
  340.         if($qualification && $qualification->isValidated()){
  341.             return max($qualification->getValidatedAt(), $this->created) ;
  342.         }
  343.         return $this->created;
  344.     }
  345.     /**
  346.      * @return bool
  347.      */
  348.     public function isWaitingQualification()
  349.     {
  350.         return $this->waitingQualification;
  351.     }
  352.     /**
  353.      * @param bool $waitingQualification
  354.      */
  355.     public function setWaitingQualification(bool $waitingQualification): void
  356.     {
  357.         $this->waitingQualification $waitingQualification;
  358.     }
  359.     /**
  360.      * @return Collection|ProspectOnStoreStatus[]
  361.      */
  362.     public function getProspectOnStoreStatus(): Collection
  363.     {
  364.         return $this->prospectOnStoreStatus;
  365.     }
  366.     /**
  367.      * Verify number of contact attempt status
  368.      * @return bool
  369.      */
  370.     public function hasBeenContactedManyTimes(): bool
  371.     {
  372.         $nbContact 0;
  373.         foreach ($this->getProspectOnStoreStatus() as $status){
  374.             if($status->getStatus() == ProspectOnStoreStatusEnum::TO_CONTACT){
  375.                 $nbContact++;
  376.                 if($nbContact >= 3){
  377.                     return true;
  378.                 }
  379.             }
  380.         }
  381.         return false;
  382.     }
  383.     /**
  384.      * Count number of contact attempt by freelancer
  385.      * @return int
  386.      */
  387.     public function countContactAttempt(): int
  388.     {
  389.         $nbContact 0;
  390.         foreach ($this->getProspectOnStoreStatus() as $status){
  391.             if($status->getStatus() == ProspectOnStoreStatusEnum::TO_CONTACT){
  392.                 $nbContact++;
  393.             }
  394.         }
  395.         return $nbContact;
  396.     }
  397.     /**
  398.      * Verify delay between two contact attempts (for blocked buttons in front)
  399.      * @return bool
  400.      */
  401.     public function isContactAttemptAllowed(): bool
  402.     {
  403.         $now = new DateTime();
  404.         foreach ($this->getProspectOnStoreStatus() as $status){
  405.             if($status->getStatus() == ProspectOnStoreStatusEnum::TO_CONTACT){
  406.                 $diff $status->getCreated()->diff($now);
  407.                 $diffInMinutes $diff->days 24 60 $diff->60 $diff->i;
  408.                 if ($diffInMinutes 15) {
  409.                     return false;
  410.                 }
  411.             }
  412.         }
  413.         return true;
  414.     }
  415.     /**
  416.      * Return the delay (expressed in nb of hours) between the creation (or qualification) of the lead and the creation of the first status.
  417.      * Null if no status
  418.      * @return int|null
  419.      */
  420.     public function getDelayBeforeFirstProspectOnStoreStatus() : ?int
  421.     {
  422.         if($firstStatus $this->getProspectOnStoreStatus()->last()){
  423.             $diff $this->getCreationOrQualificationValidationDate()->diff($firstStatus->getCreated());
  424.             return $diff->format('%h');
  425.         }
  426.         return null;
  427.     }
  428.     public function getLastStatus(){
  429.         return $this->getProspectOnStoreStatus()->first();
  430.     }
  431.     /**
  432.      * Does the status is "RDV PRIS" or later
  433.      * false if no status
  434.      * @return bool
  435.      */
  436.     public function hasStatusAppointmentMadeOrLater() : bool
  437.     {
  438.         $lastStatus $this->getLastStatus();
  439.         if($lastStatus){
  440.             return in_array($lastStatus->getStatus(), ProspectOnStoreStatusEnum::getAvailableTypesAfterAppointment());
  441.         }
  442.         return false;
  443.     }
  444.     public function removeProspectOnStoreStatus(ProspectOnStoreStatus $prospectOnStoreStatus): self
  445.     {
  446.         if ($this->prospectOnStoreStatus->contains($prospectOnStoreStatus)) {
  447.             $this->prospectOnStoreStatus->removeElement($prospectOnStoreStatus);
  448.             // set the owning side to null (unless already changed)
  449.             if ($prospectOnStoreStatus->getProspect() === $this) {
  450.                 $prospectOnStoreStatus->setProspect(null);
  451.             }
  452.         }
  453.         return $this;
  454.     }
  455.     public function getProspectDuplicateOrigin(): ?ProspectDuplicate
  456.     {
  457.         return $this->prospectDuplicateOrigin;
  458.     }
  459.     public function setProspectDuplicateOrigin(?ProspectDuplicate $prospectDuplicateOrigin): self
  460.     {
  461.         $this->prospectDuplicateOrigin $prospectDuplicateOrigin;
  462.         $this->setCreationMode(ProspectOnStoreCreationModeEnum::DUPLICATE);
  463.         return $this;
  464.     }
  465.     /**
  466.      * Specify if this POS has been created from a feedback (user not contacted)
  467.      * @return bool
  468.      */
  469.     public function hasFeedbackOrigin(): bool
  470.     {
  471.         return !is_null($this->prospectOnStoreFeedbackOrigin);
  472.     }
  473.     public function getProspectOnStoreFeedbackOrigin(): ?ProspectOnStoreFeedback
  474.     {
  475.         return $this->prospectOnStoreFeedbackOrigin;
  476.     }
  477.     public function setProspectOnStoreFeedbackOrigin(?ProspectOnStoreFeedback $prospectOnStoreFeedbackOrigin): self
  478.     {
  479.         $this->prospectOnStoreFeedbackOrigin $prospectOnStoreFeedbackOrigin;
  480.         $this->setCreationMode(ProspectOnStoreCreationModeEnum::FEEDBACK);
  481.         return $this;
  482.     }
  483.     /**
  484.      * @return mixed
  485.      */
  486.     public function getFeedback()
  487.     {
  488.         return $this->feedback;
  489.     }
  490.     /**
  491.      * @param mixed $feedback
  492.      */
  493.     public function setFeedback($feedback): void
  494.     {
  495.         $this->feedback $feedback;
  496.     }
  497.     /**
  498.      * @return mixed
  499.      */
  500.     public function getStartDealingWithDate()
  501.     {
  502.         return $this->startDealingWithDate;
  503.     }
  504.     /**
  505.      * @param mixed $startDealingWithDate
  506.      */
  507.     public function setStartDealingWithDate($startDealingWithDate): void
  508.     {
  509.         $this->startDealingWithDate $startDealingWithDate;
  510.     }
  511.     /**
  512.      * set "startDealingDate" as now (if null before)
  513.      * @return true if date as been updated, else false
  514.      */
  515.     public function setStartDealingWithDateAsNow(): bool
  516.     {
  517.         if(is_null($this->startDealingWithDate)){
  518.             $this->setStartDealingWithDate(new DateTime());
  519.             return true;
  520.         }
  521.         return false;
  522.     }
  523.     /**
  524.      * Compute startDealingWithDate based on ProspectOnStoreStatus. Only for ComputePosStartDealingDateCommand.
  525.      * Can be deleted once command executed once.
  526.      * @return bool
  527.      * @deprecated
  528.      */
  529.     public function computeStartDealingWithDate()
  530.     {
  531.         if(is_null($this->startDealingWithDate)){
  532.             if(!$this->getProspectOnStoreStatus()->isEmpty()){
  533.                 $firstStatus $this->getProspectOnStoreStatus()->last();
  534.                 $this->startDealingWithDate $firstStatus->getCreated();
  535.                 return true;
  536.             }
  537.         }
  538.         return false;
  539.     }
  540.     public function getWaitingQualification(): ?bool
  541.     {
  542.         return $this->waitingQualification;
  543.     }
  544.     public function getAcquisitionMode(): ?string
  545.     {
  546.         return $this->acquisitionMode;
  547.     }
  548.     public function setAcquisitionMode(?string $acquisitionMode): self
  549.     {
  550.         $this->acquisitionMode $acquisitionMode;
  551.         return $this;
  552.     }
  553.     public function getAcquisitionBase(): ?string
  554.     {
  555.         return $this->acquisitionBase;
  556.     }
  557.     public function setAcquisitionBase(?string $acquisitionBase): self
  558.     {
  559.         $this->acquisitionBase $acquisitionBase;
  560.         return $this;
  561.     }
  562.     public function getAcquisitionUrl(): ?string
  563.     {
  564.         return $this->acquisitionUrl;
  565.     }
  566.     public function setAcquisitionUrl(?string $acquisitionUrl): self
  567.     {
  568.         $this->acquisitionUrl $acquisitionUrl;
  569.         return $this;
  570.     }
  571.     public function getAcquisitionKeyword(): ?string
  572.     {
  573.         return $this->acquisitionKeyword;
  574.     }
  575.     public function setAcquisitionKeyword(?string $acquisitionKeyword): self
  576.     {
  577.         $this->acquisitionKeyword $acquisitionKeyword;
  578.         return $this;
  579.     }
  580.     public function getCreationMode(): ?string
  581.     {
  582.         return $this->creationMode;
  583.     }
  584.     public function getCreationModeLabel(): ?string
  585.     {
  586.         return ProspectOnStoreCreationModeEnum::getStateName($this->creationMode);
  587.     }
  588.     public function setCreationMode(?string $creationMode): self
  589.     {
  590.         $this->creationMode $creationMode;
  591.         return $this;
  592.     }
  593.     public function isCreatedFromUnreachable(): bool
  594.     {
  595.         return $this->creationMode == ProspectOnStoreCreationModeEnum::UNREACH;
  596.     }
  597.     /**
  598.      * Copy utm from a prospect
  599.      * @param Prospect $prospect
  600.      */
  601.     public function copyUtmFromProspect(Prospect $prospect){
  602.         $this->setAcquisitionUrl($prospect->getAcquisitionUrl());
  603.         $this->setAcquisitionMode($prospect->getAcquisitionMode());
  604.         $this->setAcquisitionBase($prospect->getAcquisitionBase());
  605.         $this->setAcquisitionKeyword($prospect->getAcquisitionKeyword());
  606.     }
  607.     /**
  608.      * @deprecated use isDelivered instead
  609.      * @return bool|null
  610.      */
  611.     public function getDelivered(): ?bool
  612.     {
  613.         return $this->delivered;
  614.     }
  615.     public function isDelivered(): ?bool
  616.     {
  617.         return $this->delivered;
  618.     }
  619.     public function setDelivered(bool $delivered): self
  620.     {
  621.         $this->delivered $delivered;
  622.         return $this;
  623.     }
  624.     public function markDelivered(): self
  625.     {
  626.         return $this->setDelivered(true);
  627.     }
  628.     public function getDistanceToStore(): ?float
  629.     {
  630.         return $this->distanceToStore;
  631.     }
  632.     public function setDistanceToStore(?float $distanceToStore): self
  633.     {
  634.         $this->distanceToStore $distanceToStore;
  635.         return $this;
  636.     }
  637.     public function getIsSpecific(): ?bool
  638.     {
  639.         return $this->isSpecific;
  640.     }
  641.     public function setIsSpecific(bool $isSpecific): self
  642.     {
  643.         $this->isSpecific $isSpecific;
  644.         return $this;
  645.     }
  646.     public function markSpecificWithComment(string $comment){
  647.         $this->setIsSpecific(true);
  648.         $this->appendComment($comment);
  649.     }
  650.     public function getComment(): ?string
  651.     {
  652.         return $this->comment;
  653.     }
  654.     public function setComment(?string $comment): self
  655.     {
  656.         $this->comment $comment;
  657.         return $this;
  658.     }
  659.     public function appendComment(?string $comment): self
  660.     {
  661.         if(is_null($this->comment)){
  662.             $this->setComment($comment);
  663.         }else{
  664.             $this->setComment($this->comment.' | '.$comment);
  665.         }
  666.         return $this;
  667.     }
  668.     /**
  669.      * @return Collection|DeviceSale[]
  670.      */
  671.     public function getDeviceSales(): Collection
  672.     {
  673.         return $this->deviceSales;
  674.     }
  675.     /**
  676.      * @return bool
  677.      */
  678.     public function hasDeviceSales(): bool
  679.     {
  680.         return !$this->deviceSales->isEmpty();
  681.     }
  682.     public function addDeviceSale(DeviceSale $deviceSale): self
  683.     {
  684.         if (!$this->deviceSales->contains($deviceSale)) {
  685.             $this->deviceSales[] = $deviceSale;
  686.             $deviceSale->setProspectOnStore($this);
  687.         }
  688.         return $this;
  689.     }
  690.     public function removeDeviceSale(DeviceSale $deviceSale): self
  691.     {
  692.         if ($this->deviceSales->contains($deviceSale)) {
  693.             $this->deviceSales->removeElement($deviceSale);
  694.             // set the owning side to null (unless already changed)
  695.             if ($deviceSale->getProspectOnStore() === $this) {
  696.                 $deviceSale->setProspectOnStore(null);
  697.             }
  698.         }
  699.         return $this;
  700.     }
  701.     /**
  702.      * @return int|null
  703.      */
  704.     public function getBusinessModel(): ?int
  705.     {
  706.         return $this->businessModel;
  707.     }
  708.     public function getBusinessModelLabel(): string
  709.     {
  710.         return BusinessModelEnum::getModelName($this->businessModel);
  711.     }
  712.     /**
  713.      * @param int|null $businessModel
  714.      */
  715.     public function setBusinessModel(?int $businessModel): void
  716.     {
  717.         $this->businessModel $businessModel;
  718.     }
  719.     public function isBusinessModelPerformance(): bool
  720.     {
  721.         return $this->businessModel == BusinessModelEnum::PERFORMANCE;
  722.     }
  723.     public function isBusinessModelCredit(): bool
  724.     {
  725.         return $this->businessModel == BusinessModelEnum::CREDIT;
  726.     }
  727.     public function isBusinessModelPayAsYouGo(): bool
  728.     {
  729.         return $this->businessModel == BusinessModelEnum::PAY_AS_YOU_GO;
  730.     }
  731.     /**
  732.      * @return Claim|null
  733.      */
  734.     public function getClaim(): ?Claim
  735.     {
  736.         return $this->claim;
  737.     }
  738.     /**
  739.      * @return bool
  740.      */
  741.     public function hasClaim(): bool
  742.     {
  743.         return !is_null($this->claim);
  744.     }
  745.     /**
  746.      * @param Claim|null $claim
  747.      */
  748.     public function setClaim(?Claim $claim): void
  749.     {
  750.         $this->claim $claim;
  751.     }
  752.     /**
  753.      * @Groups({"pos:read"})
  754.      * @return ProspectOnStoreQualification|null
  755.      */
  756.     public function getQualification(): ?ProspectOnStoreQualification
  757.     {
  758.         return $this->qualification;
  759.     }
  760.     public function setQualification(?ProspectOnStoreQualification $qualification): self
  761.     {
  762.         $this->qualification $qualification;
  763.         if(is_null($this->qualification->getProspectOnStore())){
  764.             $this->qualification->setProspectOnStore($this);
  765.         }
  766.         return $this;
  767.     }
  768.     public function getPrescriber(): ?Prescriber
  769.     {
  770.         return $this->prescriber;
  771.     }
  772.     public function setPrescriber(?Prescriber $prescriber): self
  773.     {
  774.         $this->prescriber $prescriber;
  775.         return $this;
  776.     }
  777.     public function getPrescriberRemuneration(): ?PrescriberRemuneration
  778.     {
  779.         return $this->prescriberRemuneration;
  780.     }
  781.     public function setPrescriberRemuneration(?PrescriberRemuneration $prescriberRemuneration): self
  782.     {
  783.         $this->prescriberRemuneration $prescriberRemuneration;
  784.         return $this;
  785.     }
  786. }