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:
Serreau Jovann
2026-04-04 11:04:43 +02:00
parent db7f4eda7c
commit ec0c0366c4
5 changed files with 75 additions and 0 deletions

View File

@@ -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 ? ' &mdash; SIRET <span class="font-mono font-bold">' + s.siret + '</span>' : ''}
${ape ? ' &mdash; APE <span class="font-mono font-bold">' + ape + '</span>' : ''}
${rna ? ' &mdash; 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))