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

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