src/V4/Model/Prospect/Prospect.php line 269

Open in your IDE?
  1. <?php
  2. namespace App\V4\Model\Prospect;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiProperty;
  5. use ApiPlatform\Core\Annotation\ApiResource;
  6. use App\Model\CustomerFile\CustomerFile;
  7. use App\Model\IriNormalizableInterface;
  8. use App\Model\NormalizeAsIRITrait;
  9. use App\Model\ProspectSubscription\ProspectSubscription;
  10. use App\Model\SpecificFieldAwareTrait;
  11. use App\Model\SpecificFieldsAwareInterface;
  12. use App\Model\Traits\BlamableTrait;
  13. use App\Model\Traits\ImportableObjectTrait;
  14. use App\Model\Traits\TimestampableTrait;
  15. use App\V4\Entity\ActionableEntityInterface;
  16. use App\V4\Model\Address\Address;
  17. use App\V4\Model\Company\Company;
  18. use App\V4\Model\Contact\Contact;
  19. use App\V4\Model\CustomerFileAwareInterface;
  20. use App\V4\Model\Origin\Origin;
  21. use App\V4\Model\Params\Params;
  22. use App\V4\Model\Potential\Potential;
  23. use App\V4\Model\ProspectSpecificField\ProspectSpecificField;
  24. use App\V4\Model\ProspectType\ProspectType;
  25. use App\V4\Model\Quote\Quote;
  26. use App\V4\Model\SpecificField\SpecificField;
  27. use App\V4\Model\Task\Task;
  28. use App\V4\Model\TVA\TVA;
  29. use DateTime;
  30. use Doctrine\Common\Collections\ArrayCollection;
  31. use Doctrine\Common\Collections\Collection;
  32. use Symfony\Component\Serializer\Annotation\Groups;
  33. use Symfony\Component\Serializer\Annotation\MaxDepth;
  34. use Symfony\Component\Validator\Constraints as Assert;
  35. //Ici le formulaire d'édition est en POST, car il nécessite du form-data qui ne fonctionne pas avec PATCH ou PUT
  36. /**
  37.  * @ApiResource(
  38.  *     attributes={
  39.  *         "api_allow_update": true
  40.  *     },
  41.  *     collectionOperations={
  42.  *         "get": {
  43.  *             "normalization_context": {
  44.  *                  "groups": {"prospect:list"}
  45.  *             },
  46.  *             "security": "is_granted(constant('App\\V4\\Voters\\ProspectVoter::PROSPECT_SHOW_LIST'), 'App\V4\Voters\ProspectVoter')"
  47.  *         },
  48.  *         "post_individual": {
  49.  *             "method": "POST",
  50.  *             "deserialize": false,
  51.  *             "write": false,
  52.  *             "controller": "App\V4\Controller\Prospect\ProspectDataPersisterAction",
  53.  *             "path": "/V4/prospects/individual",
  54.  *             "input_formats": {
  55.  *                 "multipart": {"multipart/form-data"}
  56.  *             },
  57.  *             "normalization_context": {
  58.  *                  "groups": {"prospect:read"}
  59.  *             },
  60.  *             "denormalization_context": {
  61.  *                  "groups": {}
  62.  *             }
  63.  *         },
  64.  *         "post_company": {
  65.  *             "method": "POST",
  66.  *             "deserialize": false,
  67.  *             "write": false,
  68.  *             "controller": "App\V4\Controller\Prospect\ProspectDataPersisterAction",
  69.  *             "path": "/V4/prospects/business",
  70.  *             "input_formats": {
  71.  *                 "multipart": {"multipart/form-data"}
  72.  *             },
  73.  *             "normalization_context": {
  74.  *                  "groups": {"prospect:read"}
  75.  *             },
  76.  *             "denormalization_context": {
  77.  *                  "groups": {}
  78.  *             }
  79.  *         },
  80.  *         "get_search": {
  81.  *             "method": "GET",
  82.  *             "path": "/V4/prospects/search/form",
  83.  *             "controller": App\V4\Controller\Prospect\GetProspectSearchFormAction::class,
  84.  *         },
  85.  *         "post_search": {
  86.  *             "method": "POST",
  87.  *             "deserialize": false,
  88.  *             "path": "/V4/prospects/search/form",
  89.  *             "normalization_context": {
  90.  *                  "groups": {"prospect:list"}
  91.  *             },
  92.  *             "controller": App\V4\Controller\Prospect\PostProspectSearchFormAction::class,
  93.  *         },
  94.  *         "get_contacts": {
  95.  *             "method": "GET",
  96.  *             "path": "/V4/prospects/{id}/contacts",
  97.  *             "normalization_context": {
  98.  *                  "groups": {"contact:list"}
  99.  *             },
  100.  *             "controller": App\V4\Controller\Contact\GetContactsByProspectAction::class
  101.  *         },
  102.  *         "get_tasks": {
  103.  *             "method": "GET",
  104.  *             "path": "/V4/prospects/{id}/tasks",
  105.  *             "normalization_context": {
  106.  *                  "groups": {"task:list"}
  107.  *             },
  108.  *             "controller": App\V4\Controller\Task\GetTasksByProspectAction::class
  109.  *         },
  110.  *         "get_resume_tasks": {
  111.  *             "method": "GET",
  112.  *             "path": "/V4/prospects/{id}/tasks_resume",
  113.  *             "controller": App\V4\Controller\Task\GetResumeTasksByProspectAction::class
  114.  *         },
  115.  *         "get_quotes": {
  116.  *             "method": "GET",
  117.  *             "path": "/V4/prospects/{id}/quotes",
  118.  *             "normalization_context": {
  119.  *                  "groups": {"quote:list"}
  120.  *             },
  121.  *             "controller": App\V4\Controller\Quote\GetQuotesByProspectAction::class
  122.  *         },
  123.  *         "get_names": {
  124.  *             "method": "GET",
  125.  *             "path": "/V4/prospects/get_names",
  126.  *             "controller": App\V4\Controller\Prospect\GetProspectsNamesAction::class
  127.  *         },
  128.  *          "get_customer_code": {
  129.  *              "method": "GET",
  130.  *              "path": "/V4/prospects/customer-code/{customerCode}",
  131.  *              "controller": App\V4\Action\Prospect\GetProspectByCustomerCodeAction::class
  132.  *         },
  133.  *         "post_export_request": {
  134.  *             "method": "POST",
  135.  *             "path": "/v4/export/prospect",
  136.  *             "controller": App\V4\Action\Export\EntityExportRequestAction::class,
  137.  *             "swagger_context": {
  138.  *                 "summary": "Demande de création d'export de prospects",
  139.  *                 "description": "Demande de création d'export de prospects où 'ids' sont les ids des prospects et 'fields' les champs souhaités",
  140.  *                 "parameters": {
  141.  *                     {
  142.  *                         "in": "body",
  143.  *                         "name": "body",
  144.  *                         "schema": {
  145.  *                             "type": "object",
  146.  *                             "properties": {
  147.  *                                 "ids": {
  148.  *                                     "type": "array",
  149.  *                                     "items": {"type": "string"}
  150.  *                                 },
  151.  *                                 "fields": {
  152.  *                                      "type": "array",
  153.  *                                      "items": {"type": "string"}
  154.  *                                 }
  155.  *                             }
  156.  *                         }
  157.  *                     }
  158.  *                 },
  159.  *                 "responses": {
  160.  *                     "201": {
  161.  *                         "description": "Création de l'export avec succès",
  162.  *                         "schema": {
  163.  *                             "type": "object",
  164.  *                             "properties": {
  165.  *                                 "message": {"type": "string", "example": "export_request_created"},
  166.  *                             }
  167.  *                         }
  168.  *                     },
  169.  *                     "400": {
  170.  *                         "description": "Utilisateur non trouvé ou champs 'fields' ou 'ids' manquant dans le body request",
  171.  *                         "schema": {
  172.  *                             "type": "object",
  173.  *                             "properties": {
  174.  *                                 "message": {"type": "string", "example": "user_not_found or missing_fields_or_ids"},
  175.  *                             }
  176.  *                         }
  177.  *                     },
  178.  *                     "422": {
  179.  *                         "description": "Les champs 'fields' ou 'ids' du body request sont vides ou l'entité demandée est invalide",
  180.  *                         "schema": {
  181.  *                             "type": "object",
  182.  *                             "properties": {
  183.  *                                 "message": {"type": "string", "example": "empty_fields_or_ids or entity_not_valid"},
  184.  *                             }
  185.  *                         }
  186.  *                     },
  187.  *                 },
  188.  *             }
  189.  *         },
  190.  *         "post_export_download": {
  191.  *             "method": "POST",
  192.  *             "path": "/v4/export/download/prospect/{id}",
  193.  *             "controller": App\V4\Action\Export\EntityExportDownloadAction::class,
  194.  *             "swagger_context": {
  195.  *                 "summary": "Demande de téléchargement d'un export prospects",
  196.  *                 "description": "Demande de téléchargement d'un export prospects ou 'id' est le nom du fichier d'export",
  197.  *                 "requestBody": {},
  198.  *                 "parameters": {
  199.  *                     {
  200.  *                         "in": "path",
  201.  *                         "name": "id",
  202.  *                         "type": "string",
  203.  *                         "required": "true"
  204.  *                     }
  205.  *                 },
  206.  *                 "responses": {
  207.  *                     "200": {
  208.  *                         "description": "Téléchargement de l'export réalisé avec succès"
  209.  *                     },
  210.  *                     "401": {
  211.  *                         "description": "Utilisateur non trouvé ou non connecté",
  212.  *                         "schema": {
  213.  *                             "type": "object",
  214.  *                             "properties": {
  215.  *                                 "message": {"type": "string", "example": "need_authenticated"},
  216.  *                             }
  217.  *                         }
  218.  *                     },
  219.  *                     "404": {
  220.  *                         "description": "Fichier introuvable",
  221.  *                         "schema": {
  222.  *                             "type": "object",
  223.  *                             "properties": {
  224.  *                                 "message": {"type": "string", "example": "export_not_found"},
  225.  *                             }
  226.  *                         }
  227.  *                     },
  228.  *                 },
  229.  *             }
  230.  *          }
  231.  *     },
  232.  *     itemOperations={
  233.  *         "get_form": {
  234.  *             "method": "GET",
  235.  *             "path": "/V4/prospects/{id}/form",
  236.  *             "controller": App\V4\Controller\Prospect\GetProspectFormAction::class
  237.  *         },
  238.  *         "put_prospect": {
  239.  *             "method": "POST",
  240.  *             "deserialize": false,
  241.  *             "write": false,
  242.  *             "controller": "App\V4\Controller\Prospect\ProspectDataPersisterAction",
  243.  *             "path": "/V4/prospects/{id}",
  244.  *             "input_formats": {
  245.  *                 "multipart": {"multipart/form-data"}
  246.  *             },
  247.  *             "normalization_context": {
  248.  *                  "groups": {"prospect:read"}
  249.  *             },
  250.  *             "denormalization_context": {
  251.  *                  "groups": {}
  252.  *             }
  253.  *         },
  254.  *         "delete_prospect": {
  255.  *             "method": "DELETE",
  256.  *             "deserialize": false,
  257.  *             "write": false,
  258.  *             "controller": "App\V4\Controller\Prospect\ProspectDataPersisterAction",
  259.  *             "path": "/V4/prospects/{id}"
  260.  *         }
  261.  *     }
  262.  * )
  263.  *
  264.  * @ApiFilter(App\Filters\PagingFilter::class)
  265.  */
  266. class Prospect implements IriNormalizableInterfaceSpecificFieldsAwareInterfaceActionableEntityInterfaceCustomerFileAwareInterface
  267. {
  268.     public const SPECIFIC_FIELD_CLASS_NAME ProspectSpecificField::class;
  269.     const GROUP_TYPE_INDIVIDUAL 'individual';
  270.     const GROUP_TYPE_BUSINESS 'business';
  271.     const ID_BEGIN_IS_UNKNOWN 'unknown_';
  272.     use TimestampableTrait;
  273.     use BlamableTrait;
  274.     use ImportableObjectTrait;
  275.     use NormalizeAsIRITrait;
  276.     use SpecificFieldAwareTrait;
  277.     /**
  278.      * @ApiProperty(identifier=true)
  279.      *
  280.      * @var string
  281.      *
  282.      * @Groups({
  283.      *     "prospect:list", "prospect:read",
  284.      *     "contact:list", "contact:read", "contact:write", "contact:update",
  285.      *     "task:list", "task:read", "task:write", "task:update",
  286.      *     "quote:list", "quote:read", "quote:write", "quote:update"
  287.      * })
  288.      */
  289.     private $id;
  290.     /**
  291.      * @var Potential|null
  292.      *
  293.      * @Groups({"prospect:list", "prospect:read", "prospect:write", "prospect:update"})
  294.      */
  295.     private $potential;
  296.     /**
  297.      * @var string|null
  298.      *
  299.      * @Groups({"prospect:list", "prospect:read", "prospect:write", "prospect:update"})
  300.      */
  301.     private $externalId;
  302.     /**
  303.      * @var string|null
  304.      */
  305.     private $customerId;
  306.     /**
  307.      * @var string|null
  308.      *
  309.      * @Groups({"prospect:list", "prospect:read", "prospect:write", "prospect:update"})
  310.      */
  311.     private $customerCode;
  312.     /**
  313.      * @var ProspectType|null
  314.      *
  315.      * @Groups({
  316.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update",
  317.      *     "quote:list", "quote:read"
  318.      * })
  319.      */
  320.     private $prospectType;
  321.     /**
  322.      * @var TVA|null
  323.      *
  324.      * @Groups({"prospect:list", "prospect:read", "prospect:write", "prospect:update"})
  325.      */
  326.     private $tva;
  327.     /**
  328.      * @var Origin|null
  329.      *
  330.      * @Groups({"prospect:list", "prospect:read", "prospect:write", "prospect:update"})
  331.      */
  332.     private $origin;
  333.     /**
  334.      * @var string|null
  335.      *
  336.      * @Groups({"prospect:list", "prospect:read", "prospect:write", "prospect:update"})
  337.      */
  338.     private $description;
  339.     /**
  340.      * @var string|null
  341.      *
  342.      * @Groups({"prospect:list", "prospect:read", "prospect:write", "prospect:update"})
  343.      */
  344.     private $groupName;
  345.     /**
  346.      * @var string|null
  347.      *
  348.      * @Groups({"prospect:list", "prospect:read", "prospect:write", "prospect:update"})
  349.      */
  350.     private $memo;
  351.     /**
  352.      * @var Contact|null
  353.      *
  354.      * @Assert\Type(type="App\V4\Model\Contact\Contact")
  355.      * @Assert\NotNull(
  356.      *     message="Ce champs ne peut pas être vide"
  357.      * )
  358.      *
  359.      * @Groups({"prospect:list", "prospect:read", "prospect:write", "prospect:update"})
  360.      */
  361.     private $contact;
  362.     /**
  363.      * @var Contact[]|Collection
  364.      *
  365.      * @Groups({"prospect:list", "prospect:read", "prospect:write", "prospect:update"})
  366.      */
  367.     private $contacts;
  368.     /**
  369.      * @var Company|null
  370.      *
  371.      * @Groups({"prospect:list", "prospect:read", "prospect:write", "prospect:update"})
  372.      */
  373.     private $company;
  374.     /**
  375.      * @todo refacto doit devenir une entity UserInfo
  376.      *
  377.      * @var string|null
  378.      *
  379.      * @Groups({"prospect:list", "prospect:read", "prospect:write", "prospect:update"})
  380.      */
  381.     private $managedBy;
  382.     /**
  383.      * @var Task[]|Collection
  384.      *
  385.      * @Groups({"prospect:list", "prospect:read"})
  386.      */
  387.     private $tasks;
  388.     /**
  389.      * @var Quote[]|Collection
  390.      *
  391.      * @Groups({"prospect:list", "prospect:read"})
  392.      */
  393.     private $quotes;
  394.     /**
  395.      * @var ProspectSpecificField[]|Collection
  396.      *
  397.      * @MaxDepth(2)
  398.      *
  399.      * @Groups({"prospect:list", "prospect:read", "prospect:write", "prospect:update"})
  400.      */
  401.     private $specificFields;
  402.     /**
  403.      * @var CustomerFile[]|Collection
  404.      *
  405.      * @Groups({"prospect:read", "prospect:write", "prospect:update"})
  406.      */
  407.     private $customerFiles;
  408.     /**
  409.      * @todo refacto ce devrait etre section tout court
  410.      *
  411.      * @var string|null
  412.      *
  413.      * @Groups({"prospect:read", "prospect:write", "prospect:update"})
  414.      * @MaxDepth(1)
  415.      */
  416.     private $sectionName;
  417.     /**
  418.      * Champ destiné au formulaire de recherche.
  419.      *
  420.      * @var string|null
  421.      *
  422.      * @Groups({
  423.      *     "prospect:list", "prospect:read", "prospect:write", "prospect:update",
  424.      *     "quote:list", "quote:read"
  425.      * })
  426.      */
  427.     private $fullName;
  428.     /**
  429.      * @var Collection|ProspectSubscription[]
  430.      *
  431.      * @Groups({"prospect:read"})
  432.      */
  433.     private $prospectSubscriptions;
  434.     /**
  435.      * @var string
  436.      */
  437.     private $managedByRealName;
  438.     /**
  439.      * @var DateTime|null
  440.      *
  441.      * @Groups({"prospect:list", "prospect:read", "prospect:write", "prospect:update"})
  442.      */
  443.     private $customerSince;
  444.     public function __construct()
  445.     {
  446.         $this->contacts = new ArrayCollection();
  447.         $this->tasks = new ArrayCollection();
  448.         $this->quotes = new ArrayCollection();
  449.         $this->specificFields = new ArrayCollection();
  450.         $this->prospectSubscriptions = new ArrayCollection();
  451.     }
  452.     /**
  453.      * @return bool
  454.      */
  455.     public function isUnknown(): bool
  456.     {
  457.         return str_starts_with($this->idself::ID_BEGIN_IS_UNKNOWN);
  458.     }
  459.     /**
  460.      * @return bool|null
  461.      */
  462.     public function isCLient(): ?bool
  463.     {
  464.         return $this->getProspectType() instanceof Params $this->getProspectType()->getIsClient() : false;
  465.     }
  466.     /**
  467.      * @return ?string
  468.      *
  469.      * @Groups({"prospect:list", "prospect:read"})
  470.      */
  471.     public function getFullname(): ?string
  472.     {
  473.         if (null !== $this->fullName) {
  474.             return $this->fullName;
  475.         }
  476.         if ($this->company instanceof Company) {
  477.             return $this->company->getName();
  478.         }
  479.         if ($this->contact instanceof Contact) {
  480.             return $this->contact->getName();
  481.         }
  482.         return null;
  483.     }
  484.     /**
  485.      * @return Address|null
  486.      *
  487.      * @Groups({"prospect:list", "prospect:read"})
  488.      */
  489.     public function getMainAddress(): ?Address
  490.     {
  491.         return $this->contact $this->contact->getMainAddress() : null;
  492.     }
  493.     /**
  494.      * @return Address|null
  495.      *
  496.      * @Groups({"prospect:list", "prospect:read"})
  497.      */
  498.     public function getDeliveryAddress(): ?Address
  499.     {
  500.         return $this->contact $this->contact->getDeliveryAddress() : null;
  501.     }
  502.     /**
  503.      * @param string|null $fullname
  504.      *
  505.      * @return Prospect
  506.      *
  507.      * @Groups({"prospect:list", "prospect:read"})
  508.      */
  509.     public function setFullname(?string $fullname): Prospect
  510.     {
  511.         $this->fullName $fullname;
  512.         return $this;
  513.     }
  514.     /**
  515.      * @return string
  516.      *
  517.      * @Groups({
  518.      *     "prospect:list"
  519.      * })
  520.      */
  521.     public function getType(): string
  522.     {
  523.         return $this->company self::GROUP_TYPE_BUSINESS self::GROUP_TYPE_INDIVIDUAL;
  524.     }
  525.     /**
  526.      * @return bool
  527.      */
  528.     public function isBusiness(): bool
  529.     {
  530.         return self::GROUP_TYPE_BUSINESS === $this->getType();
  531.     }
  532.     /**
  533.      * @return string|null
  534.      */
  535.     public function getId(): ?string
  536.     {
  537.         return $this->id;
  538.     }
  539.     /**
  540.      * @param string|null $id
  541.      *
  542.      * @return $this
  543.      */
  544.     public function setId(?string $id): self
  545.     {
  546.         $this->id $id;
  547.         return $this;
  548.     }
  549.     /**
  550.      * @return Params|null
  551.      */
  552.     public function getPotential(): ?Params
  553.     {
  554.         return $this->potential;
  555.     }
  556.     /**
  557.      * @param Params|null $potential
  558.      *
  559.      * @return $this
  560.      */
  561.     public function setPotential(?Params $potential): self
  562.     {
  563.         $this->potential $potential;
  564.         return $this;
  565.     }
  566.     /**
  567.      * @return string|null
  568.      */
  569.     public function getExternalId(): ?string
  570.     {
  571.         return $this->externalId;
  572.     }
  573.     /**
  574.      * @param string|null $externalId
  575.      *
  576.      * @return $this
  577.      */
  578.     public function setExternalId(?string $externalId): self
  579.     {
  580.         $this->externalId $externalId;
  581.         return $this;
  582.     }
  583.     /**
  584.      * @return string|null
  585.      */
  586.     public function getCustomerId(): ?string
  587.     {
  588.         return $this->customerId;
  589.     }
  590.     /**
  591.      * @param string|null $customerId
  592.      *
  593.      * @return $this
  594.      */
  595.     public function setCustomerId(?string $customerId): self
  596.     {
  597.         $this->customerId $customerId;
  598.         return $this;
  599.     }
  600.     /**
  601.      * @return Contact|null
  602.      */
  603.     public function getContact(): ?Contact
  604.     {
  605.         return $this->contact;
  606.     }
  607.     /**
  608.      * @param Contact|null $contact
  609.      *
  610.      * @return $this
  611.      */
  612.     public function setContact($contact): self
  613.     {
  614.         $this->contact $contact;
  615.         return $this;
  616.     }
  617.     /**
  618.      * @return Contact[]|Collection
  619.      */
  620.     public function getContacts(): Collection
  621.     {
  622.         return $this->contacts;
  623.     }
  624.     /**
  625.      * @param Contact $contact
  626.      *
  627.      * @return $this
  628.      */
  629.     public function addContact(Contact $contact): self
  630.     {
  631.         if (!$this->contacts->contains($contact)) {
  632.             $this->contacts->add($contact);
  633.             if ($this->contact) {
  634.                 $this->contact->setProspect($this);
  635.             }
  636.         }
  637.         return $this;
  638.     }
  639.     /**
  640.      * @param Contact $contact
  641.      *
  642.      * @return $this
  643.      */
  644.     public function removeContact(Contact $contact): self
  645.     {
  646.         if ($this->contacts->contains($contact)) {
  647.             $this->contacts->removeElement($contact);
  648.             if ($contact->getProspect() === $this) {
  649.                 $contact->setProspect(null);
  650.             }
  651.         }
  652.         return $this;
  653.     }
  654.     /**
  655.      * @return Company|null
  656.      *
  657.      * @Groups({"list", "read", "list_contact"})
  658.      */
  659.     public function getCompany(): ?Company
  660.     {
  661.         return $this->company;
  662.     }
  663.     /**
  664.      * @param Company|null $company
  665.      *
  666.      * @return $this
  667.      */
  668.     public function setCompany(?Company $company): self
  669.     {
  670.         $this->company $company;
  671.         return $this;
  672.     }
  673.     /**
  674.      * @return Task[]|Collection
  675.      */
  676.     public function getTasks()
  677.     {
  678.         return $this->tasks;
  679.     }
  680.     /**
  681.      * @param Task $task
  682.      *
  683.      * @return $this
  684.      */
  685.     public function addTask(Task $task): self
  686.     {
  687.         if (!$this->tasks->contains($task)) {
  688.             $this->tasks->add($task);
  689.             $task->setProspect($this);
  690.         }
  691.         return $this;
  692.     }
  693.     /**
  694.      * @param Task $task
  695.      *
  696.      * @return $this
  697.      */
  698.     public function removeTask(Task $task): self
  699.     {
  700.         if ($this->tasks->contains($task)) {
  701.             $this->tasks->removeElement($task);
  702.             if ($task->getProspect() === $this) {
  703.                 $task->setProspect(null);
  704.             }
  705.         }
  706.         return $this;
  707.     }
  708.     /**
  709.      * @return Quote[]|Collection
  710.      */
  711.     public function getQuotes(): ?Collection
  712.     {
  713.         return $this->quotes;
  714.     }
  715.     /**
  716.      * {@inheritdoc}
  717.      */
  718.     public function getSpecificFields(): Collection
  719.     {
  720.         return $this->specificFields;
  721.     }
  722.     /**
  723.      * {@inheritdoc}
  724.      */
  725.     public function getSpecificFieldByFieldId(string $id): ?SpecificField
  726.     {
  727.         foreach ($this->specificFields as $specificField) {
  728.             if ($specificField->getFieldId() === $id) {
  729.                 return $specificField;
  730.             }
  731.         }
  732.         return null;
  733.     }
  734.     /**
  735.      * @see ImportableObjectTrait::class
  736.      *
  737.      * @param ProspectSpecificField $specificField
  738.      *
  739.      * @return $this
  740.      */
  741.     public function addProspectSpecificField(ProspectSpecificField $specificField): self
  742.     {
  743.         return $this->addSpecificField($specificField);
  744.     }
  745.     /**
  746.      * {@inheritdoc}
  747.      */
  748.     public function addSpecificField($specificField): SpecificFieldsAwareInterface
  749.     {
  750.         $this->specificFields[] = $specificField;
  751.         return $this;
  752.     }
  753.     /**
  754.      * {@inheritdoc}
  755.      */
  756.     public function setSpecificFields(Collection $specificFields): self
  757.     {
  758.         $this->specificFields $specificFields;
  759.         return $this;
  760.     }
  761.     /**
  762.      * @return string|null
  763.      */
  764.     public function getManagedBy(): ?string
  765.     {
  766.         return $this->managedBy;
  767.     }
  768.     /**
  769.      * @todo refacto doit devenir une entity UserInfo
  770.      *
  771.      * @param string|null $managedBy
  772.      *
  773.      * @return Prospect
  774.      */
  775.     public function setManagedBy(?string $managedBy): Prospect
  776.     {
  777.         $this->managedBy $managedBy;
  778.         return $this;
  779.     }
  780.     /**
  781.      * @return string|null
  782.      */
  783.     public function getCustomerCode(): ?string
  784.     {
  785.         return $this->customerCode;
  786.     }
  787.     /**
  788.      * @param string|null $customerCode
  789.      *
  790.      * @return Prospect
  791.      */
  792.     public function setCustomerCode(?string $customerCode): Prospect
  793.     {
  794.         $this->customerCode $customerCode;
  795.         return $this;
  796.     }
  797.     /**
  798.      * @return Params|null
  799.      */
  800.     public function getProspectType(): ?Params
  801.     {
  802.         return $this->prospectType;
  803.     }
  804.     /**
  805.      * @param Params|null $prospectType
  806.      *
  807.      * @return Prospect
  808.      */
  809.     public function setProspectType(?Params $prospectType): Prospect
  810.     {
  811.         $this->prospectType $prospectType;
  812.         return $this;
  813.     }
  814.     /**
  815.      * @return Params|null
  816.      */
  817.     public function getOrigin(): ?Params
  818.     {
  819.         return $this->origin;
  820.     }
  821.     /**
  822.      * @param Params|null $origin
  823.      *
  824.      * @return Prospect
  825.      */
  826.     public function setOrigin(?Params $origin): Prospect
  827.     {
  828.         $this->origin $origin;
  829.         return $this;
  830.     }
  831.     /**
  832.      * @return string|null
  833.      */
  834.     public function getDescription(): ?string
  835.     {
  836.         return $this->description;
  837.     }
  838.     /**
  839.      * @param string|null $description
  840.      *
  841.      * @return Prospect
  842.      */
  843.     public function setDescription(?string $description): Prospect
  844.     {
  845.         $this->description $description;
  846.         return $this;
  847.     }
  848.     /**
  849.      * @return string|null
  850.      */
  851.     public function getMemo(): ?string
  852.     {
  853.         return $this->memo;
  854.     }
  855.     /**
  856.      * @param string|null $memo
  857.      *
  858.      * @return Prospect
  859.      */
  860.     public function setMemo(?string $memo): Prospect
  861.     {
  862.         $this->memo $memo;
  863.         return $this;
  864.     }
  865.     /**
  866.      * @return Params|null
  867.      */
  868.     public function getTva(): ?Params
  869.     {
  870.         return $this->tva;
  871.     }
  872.     /**
  873.      * @param Params|null $tva
  874.      *
  875.      * @return Prospect
  876.      */
  877.     public function setTva(?Params $tva): Prospect
  878.     {
  879.         $this->tva $tva;
  880.         return $this;
  881.     }
  882.     /**
  883.      * @return string|null
  884.      */
  885.     public function getGroupName(): ?string
  886.     {
  887.         return $this->groupName;
  888.     }
  889.     /**
  890.      * @param string|null $groupName
  891.      *
  892.      * @return Prospect
  893.      */
  894.     public function setGroupName(?string $groupName): Prospect
  895.     {
  896.         $this->groupName $groupName;
  897.         return $this;
  898.     }
  899.     /**
  900.      * @return CustomerFile[]
  901.      */
  902.     public function getCustomerFiles()
  903.     {
  904.         return $this->customerFiles;
  905.     }
  906.     /**
  907.      * @param CustomerFile $customerFile
  908.      *
  909.      * @return Prospect
  910.      */
  911.     public function addCustomerFile(CustomerFile $customerFile): self
  912.     {
  913.         $this->customerFiles[] = $customerFile;
  914.         return $this;
  915.     }
  916.     /**
  917.      * @param CustomerFile $customerFile
  918.      *
  919.      * @return Prospect
  920.      */
  921.     public function removeCustomerFile(CustomerFile $customerFile): self
  922.     {
  923.         $index array_search($customerFile$this->customerFilestrue);
  924.         if (false !== $index) {
  925.             unset($this->customerFiles[$index]);
  926.         }
  927.         return $this;
  928.     }
  929.     /**
  930.      * @param CustomerFile[] $customerFiles
  931.      *
  932.      * @return Prospect
  933.      */
  934.     public function setCustomerFiles(array $customerFiles): self
  935.     {
  936.         $this->customerFiles $customerFiles;
  937.         return $this;
  938.     }
  939.     /**
  940.      * Set the deliveryAddress.
  941.      *
  942.      * @return Prospect
  943.      */
  944.     public function setDeliveryAddressFromContact(): Prospect
  945.     {
  946.         if (!$this->getContact() instanceof Contact) {
  947.             return $this;
  948.         }
  949.         foreach ($this->getContact()->getAddresses() as $address) {
  950.             if (Address::TYPE_DELIVERY_ADDRESS === $address->getTypeAddress()) {
  951.                 $this->getContact()->setDeliveryAddress($address);
  952.             }
  953.         }
  954.         return $this;
  955.     }
  956.     /**
  957.      * @return string|null
  958.      */
  959.     public function getSectionName(): ?string
  960.     {
  961.         return $this->sectionName;
  962.     }
  963.     /**
  964.      * @param string|null $sectionName
  965.      *
  966.      * @return Prospect
  967.      */
  968.     public function setSectionName(?string $sectionName): Prospect
  969.     {
  970.         $this->sectionName $sectionName;
  971.         return $this;
  972.     }
  973.     /**
  974.      * @return ProspectSubscription[]|Collection
  975.      */
  976.     public function getProspectSubscriptions()
  977.     {
  978.         return $this->prospectSubscriptions;
  979.     }
  980.     /**
  981.      * @param ProspectSubscription[]|Collection $prospectSubscriptions
  982.      *
  983.      * @return self
  984.      */
  985.     public function setProspectSubscriptions(array $prospectSubscriptions): self
  986.     {
  987.         $this->prospectSubscriptions $prospectSubscriptions;
  988.         return $this;
  989.     }
  990.     /**
  991.      * @param ProspectSubscription $prospectSubscription
  992.      *
  993.      * @return self
  994.      */
  995.     public function addProspectSubscription(ProspectSubscription $prospectSubscription): self
  996.     {
  997.         if (!$this->prospectSubscriptions->contains($prospectSubscription)) {
  998.             $this->prospectSubscriptions[] = $prospectSubscription;
  999.         }
  1000.         return $this;
  1001.     }
  1002.     /**
  1003.      * @param ProspectSubscription $prospectSubscription
  1004.      *
  1005.      * @return self
  1006.      */
  1007.     public function removeProspectSubscription(ProspectSubscription $prospectSubscription): self
  1008.     {
  1009.         if ($this->prospectSubscriptions->contains($prospectSubscription)) {
  1010.             $this->prospectSubscriptions->removeElement($prospectSubscription);
  1011.         }
  1012.         return $this;
  1013.     }
  1014.     /**
  1015.      * @return string
  1016.      */
  1017.     public function getManagedByRealName()
  1018.     {
  1019.         return $this->managedByRealName;
  1020.     }
  1021.     /**
  1022.      * @param string $managedByRealName
  1023.      *
  1024.      * @return $this
  1025.      */
  1026.     public function setManagedByRealName(string $managedByRealName): self
  1027.     {
  1028.         $this->managedByRealName $managedByRealName;
  1029.         return $this;
  1030.     }
  1031.     public function getCustomerSince(): ?DateTime
  1032.     {
  1033.         return $this->customerSince;
  1034.     }
  1035.     public function setCustomerSince(?DateTime $customerSince): self
  1036.     {
  1037.         $this->customerSince $customerSince;
  1038.         return $this;
  1039.     }
  1040. }