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

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