feat(directory) : add contact/address/report tables, migrate inline addresses, drop inline columns

This commit is contained in:
Matthieu
2026-06-22 12:11:11 +02:00
parent 33ba90a00d
commit 354d7c34ba
12 changed files with 279 additions and 167 deletions
+53 -16
View File
@@ -12,6 +12,7 @@ use App\Module\Absence\Domain\Enum\AbsenceType;
use App\Module\Core\Application\Rbac\RbacSeeder;
use App\Module\Core\Domain\Entity\User;
use App\Module\Core\Domain\Enum\ContractType;
use App\Module\Directory\Domain\Entity\Address;
use App\Module\Directory\Domain\Entity\Client;
use App\Module\Directory\Domain\Entity\Prospect;
use App\Module\Directory\Domain\Enum\ProspectStatus;
@@ -83,66 +84,102 @@ class AppFixtures extends Fixture
$clientLiot->setName('LIOT');
$clientLiot->setEmail('contact@liot.fr');
$clientLiot->setPhone('05 50 50 50 50');
$clientLiot->setStreet('14 allée d\'argenson');
$clientLiot->setCity('Poitiers');
$clientLiot->setPostalCode('86100');
$manager->persist($clientLiot);
$addressLiot = new Address();
$addressLiot->setLabel('Principale');
$addressLiot->setStreet('14 allée d\'argenson');
$addressLiot->setCity('Poitiers');
$addressLiot->setPostalCode('86100');
$addressLiot->setCountry('FR');
$addressLiot->setClient($clientLiot);
$manager->persist($addressLiot);
$clientAcme = new Client();
$clientAcme->setName('ACME Corp');
$clientAcme->setEmail('contact@acme.com');
$clientAcme->setPhone('01 23 45 67 89');
$clientAcme->setStreet('10 rue de la Paix');
$clientAcme->setCity('Paris');
$clientAcme->setPostalCode('75002');
$manager->persist($clientAcme);
$addressAcme = new Address();
$addressAcme->setLabel('Principale');
$addressAcme->setStreet('10 rue de la Paix');
$addressAcme->setCity('Paris');
$addressAcme->setPostalCode('75002');
$addressAcme->setCountry('FR');
$addressAcme->setClient($clientAcme);
$manager->persist($addressAcme);
$clientNova = new Client();
$clientNova->setName('Nova Tech');
$clientNova->setEmail('info@novatech.io');
$clientNova->setPhone('04 56 78 90 12');
$clientNova->setStreet('5 avenue Jean Jaurès');
$clientNova->setCity('Lyon');
$clientNova->setPostalCode('69007');
$manager->persist($clientNova);
$addressNova = new Address();
$addressNova->setLabel('Principale');
$addressNova->setStreet('5 avenue Jean Jaurès');
$addressNova->setCity('Lyon');
$addressNova->setPostalCode('69007');
$addressNova->setCountry('FR');
$addressNova->setClient($clientNova);
$manager->persist($addressNova);
// Prospects
$prospectLead = new Prospect();
$prospectLead->setName('Marie Dupont');
$prospectLead->setCompany('Atelier Dupont');
$prospectLead->setEmail('marie@atelier-dupont.fr');
$prospectLead->setPhone('06 11 22 33 44');
$prospectLead->setCity('Nantes');
$prospectLead->setPostalCode('44000');
$prospectLead->setStatus(ProspectStatus::New);
$prospectLead->setSource('Site web');
$prospectLead->setNotes('Demande de devis via le formulaire de contact.');
$manager->persist($prospectLead);
$addressLead = new Address();
$addressLead->setLabel('Principale');
$addressLead->setCity('Nantes');
$addressLead->setPostalCode('44000');
$addressLead->setCountry('FR');
$addressLead->setProspect($prospectLead);
$manager->persist($addressLead);
$prospectQualified = new Prospect();
$prospectQualified->setName('Jean Martin');
$prospectQualified->setCompany('Martin & Fils');
$prospectQualified->setEmail('contact@martin-fils.fr');
$prospectQualified->setPhone('07 55 66 77 88');
$prospectQualified->setStreet('22 rue du Commerce');
$prospectQualified->setCity('Bordeaux');
$prospectQualified->setPostalCode('33000');
$prospectQualified->setStatus(ProspectStatus::Qualified);
$prospectQualified->setSource('Salon professionnel');
$manager->persist($prospectQualified);
$addressQualified = new Address();
$addressQualified->setLabel('Principale');
$addressQualified->setStreet('22 rue du Commerce');
$addressQualified->setCity('Bordeaux');
$addressQualified->setPostalCode('33000');
$addressQualified->setCountry('FR');
$addressQualified->setProspect($prospectQualified);
$manager->persist($addressQualified);
$prospectWon = new Prospect();
$prospectWon->setName('Sophie Bernard');
$prospectWon->setCompany('ACME Corp');
$prospectWon->setEmail('contact@acme.com');
$prospectWon->setPhone('01 23 45 67 89');
$prospectWon->setCity('Paris');
$prospectWon->setPostalCode('75002');
$prospectWon->setStatus(ProspectStatus::Won);
$prospectWon->setSource('Recommandation');
$prospectWon->setConvertedClient($clientAcme);
$manager->persist($prospectWon);
$addressWon = new Address();
$addressWon->setLabel('Principale');
$addressWon->setCity('Paris');
$addressWon->setPostalCode('75002');
$addressWon->setCountry('FR');
$addressWon->setProspect($prospectWon);
$manager->persist($addressWon);
// Workflow par défaut
$standardWorkflow = new Workflow();
$standardWorkflow->setName('Standard');
@@ -58,18 +58,6 @@ class Client implements ClientInterface, TimestampableInterface, BlamableInterfa
#[Groups(['client:read', 'client:write'])]
private ?string $phone = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['client:read', 'client:write'])]
private ?string $street = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['client:read', 'client:write'])]
private ?string $city = null;
#[ORM\Column(length: 20, nullable: true)]
#[Groups(['client:read', 'client:write'])]
private ?string $postalCode = null;
/** @var Collection<int, ProjectInterface> */
#[ORM\OneToMany(targetEntity: ProjectInterface::class, mappedBy: 'client')]
private Collection $projects;
@@ -120,42 +108,6 @@ class Client implements ClientInterface, TimestampableInterface, BlamableInterfa
return $this;
}
public function getStreet(): ?string
{
return $this->street;
}
public function setStreet(?string $street): static
{
$this->street = $street;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): static
{
$this->city = $city;
return $this;
}
public function getPostalCode(): ?string
{
return $this->postalCode;
}
public function setPostalCode(?string $postalCode): static
{
$this->postalCode = $postalCode;
return $this;
}
/** @return Collection<int, ProjectInterface> */
public function getProjects(): Collection
{
@@ -71,18 +71,6 @@ class Prospect implements TimestampableInterface, BlamableInterface
#[Groups(['prospect:read', 'prospect:write'])]
private ?string $phone = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['prospect:read', 'prospect:write'])]
private ?string $street = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['prospect:read', 'prospect:write'])]
private ?string $city = null;
#[ORM\Column(length: 20, nullable: true)]
#[Groups(['prospect:read', 'prospect:write'])]
private ?string $postalCode = null;
#[ORM\Column(type: Types::STRING, length: 32, enumType: ProspectStatus::class)]
#[Groups(['prospect:read', 'prospect:write'])]
private ProspectStatus $status = ProspectStatus::New;
@@ -153,42 +141,6 @@ class Prospect implements TimestampableInterface, BlamableInterface
return $this;
}
public function getStreet(): ?string
{
return $this->street;
}
public function setStreet(?string $street): static
{
$this->street = $street;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): static
{
$this->city = $city;
return $this;
}
public function getPostalCode(): ?string
{
return $this->postalCode;
}
public function setPostalCode(?string $postalCode): static
{
$this->postalCode = $postalCode;
return $this;
}
public function getStatus(): ProspectStatus
{
return $this->status;
@@ -47,9 +47,6 @@ final readonly class ConvertProspectProcessor implements ProcessorInterface
$client->setName($prospect->getCompany() ?: (string) $prospect->getName());
$client->setEmail($prospect->getEmail());
$client->setPhone($prospect->getPhone());
$client->setStreet($prospect->getStreet());
$client->setCity($prospect->getCity());
$client->setPostalCode($prospect->getPostalCode());
$this->entityManager->persist($client);
@@ -41,9 +41,6 @@ class ConvertProspectTool
$client->setName($prospect->getCompany() ?: (string) $prospect->getName());
$client->setEmail($prospect->getEmail());
$client->setPhone($prospect->getPhone());
$client->setStreet($prospect->getStreet());
$client->setCity($prospect->getCity());
$client->setPostalCode($prospect->getPostalCode());
$this->entityManager->persist($client);
@@ -23,9 +23,6 @@ class CreateClientTool
string $name,
?string $email = null,
?string $phone = null,
?string $street = null,
?string $city = null,
?string $postalCode = null,
): string {
if (!$this->security->isGranted('ROLE_ADMIN')) {
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
@@ -35,9 +32,6 @@ class CreateClientTool
$client->setName($name);
$client->setEmail($email);
$client->setPhone($phone);
$client->setStreet($street);
$client->setCity($city);
$client->setPostalCode($postalCode);
$this->entityManager->persist($client);
$this->entityManager->flush();
@@ -28,9 +28,6 @@ class CreateProspectTool
?string $company = null,
?string $email = null,
?string $phone = null,
?string $street = null,
?string $city = null,
?string $postalCode = null,
?string $status = null,
?string $source = null,
?string $notes = null,
@@ -44,9 +41,6 @@ class CreateProspectTool
$prospect->setCompany($company);
$prospect->setEmail($email);
$prospect->setPhone($phone);
$prospect->setStreet($street);
$prospect->setCity($city);
$prospect->setPostalCode($postalCode);
$prospect->setSource($source);
$prospect->setNotes($notes);
@@ -28,9 +28,6 @@ class UpdateClientTool
?string $name = null,
?string $email = null,
?string $phone = null,
?string $street = null,
?string $city = null,
?string $postalCode = null,
): string {
if (!$this->security->isGranted('ROLE_ADMIN')) {
throw new AccessDeniedException('Access denied: ROLE_ADMIN required.');
@@ -50,15 +47,6 @@ class UpdateClientTool
if (null !== $phone) {
$client->setPhone($phone);
}
if (null !== $street) {
$client->setStreet($street);
}
if (null !== $city) {
$client->setCity($city);
}
if (null !== $postalCode) {
$client->setPostalCode($postalCode);
}
$this->entityManager->flush();
@@ -30,9 +30,6 @@ class UpdateProspectTool
?string $company = null,
?string $email = null,
?string $phone = null,
?string $street = null,
?string $city = null,
?string $postalCode = null,
?string $status = null,
?string $source = null,
?string $notes = null,
@@ -58,15 +55,6 @@ class UpdateProspectTool
if (null !== $phone) {
$prospect->setPhone($phone);
}
if (null !== $street) {
$prospect->setStreet($street);
}
if (null !== $city) {
$prospect->setCity($city);
}
if (null !== $postalCode) {
$prospect->setPostalCode($postalCode);
}
if (null !== $status) {
$statusEnum = ProspectStatus::tryFrom($status);
if (null === $statusEnum) {
+4 -10
View File
@@ -366,13 +366,10 @@ final class Serializer
public static function client(Client $c): array
{
return [
'id' => $c->getId(),
'name' => $c->getName(),
'email' => $c->getEmail(),
'phone' => $c->getPhone(),
'street' => $c->getStreet(),
'city' => $c->getCity(),
'postalCode' => $c->getPostalCode(),
'id' => $c->getId(),
'name' => $c->getName(),
'email' => $c->getEmail(),
'phone' => $c->getPhone(),
];
}
@@ -389,9 +386,6 @@ final class Serializer
'company' => $p->getCompany(),
'email' => $p->getEmail(),
'phone' => $p->getPhone(),
'street' => $p->getStreet(),
'city' => $p->getCity(),
'postalCode' => $p->getPostalCode(),
'status' => $p->getStatus()->value,
'statusLabel' => $p->getStatus()->label(),
'source' => $p->getSource(),