[FIX] Simulator + ServicesController: allineamento a schema DB reale
simulate-nis2.php: - sector: ict → ict_services, healthcare → health (enum DB corretto) - employee_count (non employees_count) per OrganizationController ServicesController::provision(): - INSERT organizations: rimossi campi non esistenti (legal_form, ateco_code, etc.) - Usa colonne reali: name, vat_number, employee_count, sector, entity_type, is_active - entity_type: voluntary → not_applicable (enum non supporta voluntary) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
eb31a0a504
commit
48317e0556
@ -548,8 +548,12 @@ class ServicesController extends BaseController
|
||||
];
|
||||
$rawSector = strtolower($company['sector'] ?? 'ict');
|
||||
$nis2Sector = $sectorMap[$rawSector] ?? $rawSector;
|
||||
$nis2EntityType = in_array($company['nis2_entity_type'] ?? '', ['essential', 'important', 'voluntary'])
|
||||
? $company['nis2_entity_type'] : 'important';
|
||||
$rawEntityType = $company['nis2_entity_type'] ?? 'important';
|
||||
$nis2EntityType = match($rawEntityType) {
|
||||
'essential' => 'essential',
|
||||
'voluntary' => 'not_applicable',
|
||||
default => 'important',
|
||||
};
|
||||
|
||||
if ($existing) {
|
||||
$orgId = (int) $existing['id'];
|
||||
@ -557,22 +561,16 @@ class ServicesController extends BaseController
|
||||
// ── 4. Crea organizzazione ───────────────────────────────────
|
||||
Database::query(
|
||||
'INSERT INTO organizations
|
||||
(name, legal_form, vat_number, fiscal_code, ateco_code, ateco_description,
|
||||
legal_address, pec, phone, annual_turnover_eur, employees,
|
||||
sector, nis2_entity_type, status,
|
||||
(name, vat_number, fiscal_code,
|
||||
annual_turnover_eur, employee_count,
|
||||
sector, entity_type, is_active,
|
||||
provisioned_by, provisioned_at, license_plan, license_expires_at,
|
||||
license_max_users, lg231_company_id, lg231_order_id)
|
||||
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,\'active\',?,NOW(),?,?,?,?,?)',
|
||||
VALUES (?,?,?,?,?,?,?,1,?,NOW(),?,?,?,?,?)',
|
||||
[
|
||||
$ragioneSociale,
|
||||
$company['forma_giuridica'] ?? null,
|
||||
$partitaIva,
|
||||
$company['codice_fiscale'] ?? null,
|
||||
$company['ateco_code'] ?? null,
|
||||
$company['ateco_description'] ?? null,
|
||||
$company['sede_legale'] ?? null,
|
||||
$company['pec'] ?? null,
|
||||
$company['telefono'] ?? null,
|
||||
$company['fatturato_annuo'] ?? null,
|
||||
$company['numero_dipendenti'] ?? null,
|
||||
$nis2Sector,
|
||||
|
||||
@ -426,7 +426,7 @@ $COMPANIES = [
|
||||
'ateco_desc' => 'Produzione di software non connesso all\'edizione',
|
||||
'employees' => 320,
|
||||
'annual_turnover'=> 18500000,
|
||||
'sector' => 'ict',
|
||||
'sector' => 'ict_services',
|
||||
'nis2_type' => 'essential',
|
||||
'city' => 'Milano',
|
||||
'province' => 'MI',
|
||||
@ -468,7 +468,7 @@ $COMPANIES = [
|
||||
'ateco_desc' => 'Servizi ospedalieri',
|
||||
'employees' => 750,
|
||||
'annual_turnover'=> 42000000,
|
||||
'sector' => 'healthcare',
|
||||
'sector' => 'health',
|
||||
'nis2_type' => 'important',
|
||||
'city' => 'Roma',
|
||||
'province' => 'RM',
|
||||
@ -644,7 +644,7 @@ foreach ($COMPANIES as $slug => $comp) {
|
||||
'vat_number' => $comp['vat_number'],
|
||||
'ateco_code' => $comp['ateco_code'],
|
||||
'sector' => $comp['sector'],
|
||||
'employees_count' => $comp['employees'],
|
||||
'employee_count' => $comp['employees'],
|
||||
'annual_turnover_eur' => $comp['annual_turnover'],
|
||||
'city' => $comp['city'],
|
||||
'province' => $comp['province'],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user