feat: auto-détection type entreprise + RNA pour associations
Customer entity : - Ajout champ rna (VARCHAR 20, nullable) pour identifiant RNA associations - Migration : ALTER TABLE customer ADD rna Recherche entreprise (entreprise-search.js) : - resolveTypeCompany() : mapping nature_juridique vers type formulaire 92xx/91xx/93xx → association, 10xx → auto-entrepreneur, 54xx/55xx → sarl, 57xx → sas, 52xx → eurl, 65xx → sci - Auto-remplissage typeCompany depuis nature_juridique - Récupération RNA depuis complements.identifiant_association - Badge "Association" affiché dans les résultats si nature_juridique 92xx - RNA affiché dans les résultats (ex: RNA W502004724) Template create.html.twig : - Ajout champ "RNA (associations)" dans la section Entreprise ClientsController : - populateCustomerData : ajout setRna depuis le formulaire Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -27,12 +27,27 @@ const buildRcs = (siren, city) => {
|
||||
return 'RCS ' + capitalize(city) + ' ' + siren
|
||||
}
|
||||
|
||||
const resolveTypeCompany = (natureJuridique) => {
|
||||
if (!natureJuridique) return ''
|
||||
const code = String(natureJuridique)
|
||||
if (code.startsWith('92') || code.startsWith('91') || code.startsWith('93')) return 'association'
|
||||
if (code.startsWith('10')) return 'auto-entrepreneur'
|
||||
if (code.startsWith('54') || code.startsWith('55')) return 'sarl'
|
||||
if (code.startsWith('57')) return 'sas'
|
||||
if (code.startsWith('52')) return 'eurl'
|
||||
if (code.startsWith('55') && code === '5599') return 'sa'
|
||||
if (code.startsWith('65')) return 'sci'
|
||||
return ''
|
||||
}
|
||||
|
||||
const renderResult = (e, onSelect) => {
|
||||
const s = e.siege || {}
|
||||
const d = (e.dirigeants && e.dirigeants[0]) || {}
|
||||
const actif = e.etat_administratif === 'A'
|
||||
const addr = [s.numero_voie, s.type_voie, s.libelle_voie].filter(Boolean).join(' ')
|
||||
const ape = e.activite_principale || ''
|
||||
const rna = (e.complements && e.complements.identifiant_association) || ''
|
||||
const isAsso = resolveTypeCompany(e.nature_juridique) === 'association'
|
||||
|
||||
const div = document.createElement('div')
|
||||
div.className = 'glass p-4 cursor-pointer hover:bg-white/80 transition-all'
|
||||
@@ -44,9 +59,11 @@ const renderResult = (e, onSelect) => {
|
||||
SIREN <span class="font-mono font-bold">${e.siren || '?'}</span>
|
||||
${s.siret ? ' — SIRET <span class="font-mono font-bold">' + s.siret + '</span>' : ''}
|
||||
${ape ? ' — APE <span class="font-mono font-bold">' + ape + '</span>' : ''}
|
||||
${rna ? ' — RNA <span class="font-mono font-bold">' + rna + '</span>' : ''}
|
||||
</div>
|
||||
<div class="text-xs text-gray-400 mt-1">${s.geo_adresse || s.adresse || ''}</div>
|
||||
${d.nom ? '<div class="text-xs text-gray-400 mt-1">Dirigeant : ' + (d.prenoms || '') + ' ' + d.nom + '</div>' : ''}
|
||||
${isAsso ? '<div class="text-xs mt-1"><span class="px-1.5 py-0.5 bg-indigo-100 text-indigo-800 font-bold text-[10px] uppercase" style="border-radius:4px;">Association</span></div>' : ''}
|
||||
</div>
|
||||
<span class="shrink-0 px-2 py-1 text-[10px] font-bold uppercase ${actif ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'}" style="border-radius: 6px;">
|
||||
${actif ? 'Actif' : 'Ferme'}
|
||||
@@ -63,6 +80,12 @@ const renderResult = (e, onSelect) => {
|
||||
fillField('zipCode', s.code_postal || '')
|
||||
fillField('city', s.libelle_commune || '')
|
||||
|
||||
const typeCompany = resolveTypeCompany(e.nature_juridique)
|
||||
if (typeCompany) fillField('typeCompany', typeCompany)
|
||||
|
||||
const rna = (e.complements && e.complements.identifiant_association) || ''
|
||||
if (rna) fillField('rna', rna)
|
||||
|
||||
const prenom = (d.prenoms || '').split(' ')[0]
|
||||
fillFieldIfEmpty('firstName', capitalize(prenom))
|
||||
fillFieldIfEmpty('lastName', capitalize(d.nom))
|
||||
|
||||
31
migrations/Version20260404090416.php
Normal file
31
migrations/Version20260404090416.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20260404090416 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE customer ADD rna VARCHAR(20) DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE customer DROP rna');
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,7 @@ class ClientsController extends AbstractController
|
||||
$customer->setRcs(trim($request->request->getString('rcs')) ?: null);
|
||||
$customer->setNumTva(trim($request->request->getString('numTva')) ?: null);
|
||||
$customer->setApe(trim($request->request->getString('ape')) ?: null);
|
||||
$customer->setRna(trim($request->request->getString('rna')) ?: null);
|
||||
$customer->setAddress(trim($request->request->getString('address')) ?: null);
|
||||
$customer->setAddress2(trim($request->request->getString('address2')) ?: null);
|
||||
$customer->setZipCode(trim($request->request->getString('zipCode')) ?: null);
|
||||
|
||||
@@ -86,6 +86,9 @@ class Customer
|
||||
#[ORM\Column(length: 10, nullable: true)]
|
||||
private ?string $ape = null;
|
||||
|
||||
#[ORM\Column(length: 20, nullable: true)]
|
||||
private ?string $rna = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $stripeCustomerId = null;
|
||||
|
||||
@@ -316,6 +319,18 @@ class Customer
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRna(): ?string
|
||||
{
|
||||
return $this->rna;
|
||||
}
|
||||
|
||||
public function setRna(?string $rna): static
|
||||
{
|
||||
$this->rna = $rna;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStripeCustomerId(): ?string
|
||||
{
|
||||
return $this->stripeCustomerId;
|
||||
|
||||
@@ -103,6 +103,11 @@
|
||||
<input type="text" id="ape" name="ape" maxlength="10" placeholder="62.01Z"
|
||||
class="w-full px-4 py-3 input-glass text-sm font-medium">
|
||||
</div>
|
||||
<div>
|
||||
<label for="rna" class="block text-xs font-bold uppercase tracking-wider mb-2">RNA (associations)</label>
|
||||
<input type="text" id="rna" name="rna" maxlength="20" placeholder="W123456789"
|
||||
class="w-full px-4 py-3 input-glass text-sm font-medium">
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user