src/Entity/ProspectOnStore.php line 43

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