fix(stabili): correct bank IBAN extraction from Stabili.mdb, import per-stabile anagr_casse (CCB/CCP/CON), and dynamically render stabili table in TAB 3 (task-d095b0e23b)
This commit is contained in:
parent
8c07bafb2a
commit
f63cb1644a
|
|
@ -63,6 +63,7 @@ public function handle(): int
|
||||||
if (count($data) === count($header)) {
|
if (count($data) === count($header)) {
|
||||||
$row = array_combine($header, $data);
|
$row = array_combine($header, $data);
|
||||||
$codLegacy = sprintf('%04d', (int) ($row['cod_stabile'] ?? 0));
|
$codLegacy = sprintf('%04d', (int) ($row['cod_stabile'] ?? 0));
|
||||||
|
$cfLegacy = trim((string) ($row['codice_fisc'] ?? ''));
|
||||||
$den = trim((string) ($row['denominazione'] ?? ''));
|
$den = trim((string) ($row['denominazione'] ?? ''));
|
||||||
$note1 = trim((string) ($row['note1'] ?? ''));
|
$note1 = trim((string) ($row['note1'] ?? ''));
|
||||||
$note2 = trim((string) ($row['Note'] ?? ''));
|
$note2 = trim((string) ($row['Note'] ?? ''));
|
||||||
|
|
@ -83,16 +84,56 @@ public function handle(): int
|
||||||
$numCcp2 = trim((string) ($row['num_ccp_2'] ?? ''));
|
$numCcp2 = trim((string) ($row['num_ccp_2'] ?? ''));
|
||||||
$ibanPosta2 = trim((string) ($row['IBAN_Posta_2'] ?? ''));
|
$ibanPosta2 = trim((string) ($row['IBAN_Posta_2'] ?? ''));
|
||||||
|
|
||||||
$stabile = Stabile::query()
|
$stabile = null;
|
||||||
->where('codice_stabile', $codLegacy)
|
if ($cfLegacy !== '') {
|
||||||
->orWhere('cod_stabile', $codLegacy)
|
$stabile = Stabile::query()->where('codice_fiscale', $cfLegacy)->first();
|
||||||
->orWhere('codice_stabile', ltrim($codLegacy, '0'))
|
}
|
||||||
->first();
|
if (! $stabile) {
|
||||||
|
$stabile = Stabile::query()
|
||||||
|
->where('codice_stabile', $codLegacy)
|
||||||
|
->orWhere('cod_stabile', $codLegacy)
|
||||||
|
->orWhere('codice_stabile', ltrim($codLegacy, '0'))
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
|
||||||
if ($stabile) {
|
if ($stabile) {
|
||||||
$noteFull = array_filter([$note1, $note2]);
|
$noteFull = array_filter([$note1, $note2]);
|
||||||
$noteStr = implode("\n", $noteFull);
|
$noteStr = implode("\n", $noteFull);
|
||||||
|
|
||||||
|
// Leggi anagr_casse dal file generale_stabile.mdb dello stabile se presente
|
||||||
|
$casseAnagr = [];
|
||||||
|
$stabileDirCandidates = [
|
||||||
|
"/mnt/gescon-archives/gescon/{$codLegacy}/generale_stabile.mdb",
|
||||||
|
"/mnt/gescon-archives/gescon/" . sprintf('%04d', (int)$stabile->codice_stabile) . "/generale_stabile.mdb",
|
||||||
|
];
|
||||||
|
foreach ($stabileDirCandidates as $gsMdb) {
|
||||||
|
if (file_exists($gsMdb) && is_readable($gsMdb)) {
|
||||||
|
$pCasse = new \Symfony\Component\Process\Process(['mdb-export', $gsMdb, 'anagr_casse']);
|
||||||
|
$pCasse->run();
|
||||||
|
if ($pCasse->isSuccessful() && $pCasse->getOutput()) {
|
||||||
|
$cStream = fopen('php://memory', 'r+');
|
||||||
|
fwrite($cStream, $pCasse->getOutput());
|
||||||
|
rewind($cStream);
|
||||||
|
$cHeader = fgetcsv($cStream);
|
||||||
|
if ($cHeader) {
|
||||||
|
while (($cData = fgetcsv($cStream)) !== false) {
|
||||||
|
if (count($cData) === count($cHeader)) {
|
||||||
|
$cRow = array_combine($cHeader, $cData);
|
||||||
|
$casseAnagr[] = [
|
||||||
|
'id_cassa' => (int) ($cRow['Id_cassa'] ?? 0),
|
||||||
|
'codice' => trim((string) ($cRow['Codice'] ?? '')),
|
||||||
|
'descrizione' => trim((string) ($cRow['Descrizione'] ?? '')),
|
||||||
|
'saldo_iniziale_euro'=> (float) ($cRow['Saldo_iniziale_EURO'] ?? 0),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose($cStream);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$bancherieAdv = [
|
$bancherieAdv = [
|
||||||
'banca_1' => [
|
'banca_1' => [
|
||||||
'banca' => $banca1,
|
'banca' => $banca1,
|
||||||
|
|
@ -116,6 +157,7 @@ public function handle(): int
|
||||||
'num_ccp' => $numCcp2,
|
'num_ccp' => $numCcp2,
|
||||||
'iban' => $ibanPosta2,
|
'iban' => $ibanPosta2,
|
||||||
],
|
],
|
||||||
|
'anagr_casse' => $casseAnagr,
|
||||||
];
|
];
|
||||||
|
|
||||||
$existingAdv = is_array($stabile->configurazione_avanzata) ? $stabile->configurazione_avanzata : [];
|
$existingAdv = is_array($stabile->configurazione_avanzata) ? $stabile->configurazione_avanzata : [];
|
||||||
|
|
@ -123,21 +165,21 @@ public function handle(): int
|
||||||
|
|
||||||
$stabile->update([
|
$stabile->update([
|
||||||
'note' => $noteStr ?: $stabile->note,
|
'note' => $noteStr ?: $stabile->note,
|
||||||
'banca_principale' => $banca1 ?: $stabile->banca_principale,
|
'banca_principale' => $banca1 ?: ($ibanPosta1 ? 'Poste Italiane' : $stabile->banca_principale),
|
||||||
'iban_principale' => $ibanBanca1 ?: $stabile->iban_principale,
|
'iban_principale' => $ibanBanca1 ?: ($ibanPosta1 ?: $stabile->iban_principale),
|
||||||
'banca_secondaria' => $banca2 ?: $stabile->banca_secondaria,
|
'banca_secondaria' => $banca2 ?: $stabile->banca_secondaria,
|
||||||
'iban_secondario' => ($ibanBanca2 ?: $ibanPosta1) ?: $stabile->iban_secondario,
|
'iban_secondario' => ($ibanBanca2 ?: $ibanPosta1) ?: $stabile->iban_secondario,
|
||||||
'configurazione_avanzata'=> $mergedAdv,
|
'configurazione_avanzata'=> $mergedAdv,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$updated++;
|
$updated++;
|
||||||
$this->line(" ✓ Stabile {$codLegacy} ({$den}): Note e Conti Correnti aggiornati.");
|
$this->line(" ✓ Stabile {$stabile->codice_stabile} ({$den}): Note, IBAN e " . count($casseAnagr) . " Casse (CCB/CCP/CON) sincronizzate.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose($stream);
|
fclose($stream);
|
||||||
|
|
||||||
$this->info("Completata sincronizzazione conti correnti per {$updated} stabili!");
|
$this->info("Completata sincronizzazione conti correnti e tabelle anagr_casse per {$updated} stabili!");
|
||||||
return self::SUCCESS;
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -219,9 +219,12 @@ class="inline-flex items-center gap-1 rounded-lg bg-amber-500 px-4 py-2 text-xs
|
||||||
<p class="text-xs text-slate-500">Stabili condominiali gestiti ed archivio ditte accreditati riservati per lo studio.</p>
|
<p class="text-xs text-slate-500">Stabili condominiali gestiti ed archivio ditte accreditati riservati per lo studio.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{-- TABELLA STABILI CONDOMINIALI GESTITI --}}
|
{{-- TABELLA STABILI CONDOMINIALI GESTITI DYNAMICAMENTE --}}
|
||||||
|
@php
|
||||||
|
$stabiliReal = \App\Models\Stabile::query()->orderBy('codice_stabile')->get();
|
||||||
|
@endphp
|
||||||
<div>
|
<div>
|
||||||
<h4 class="text-xs font-bold uppercase text-slate-700 mb-2">🏢 Stabili Condominiali Gestiti dallo Studio (12 Stabili):</h4>
|
<h4 class="text-xs font-bold uppercase text-slate-700 mb-2">🏢 Stabili Condominiali Gestiti dallo Studio ({{ count($stabiliReal) }} Stabili):</h4>
|
||||||
<div class="rounded-lg border overflow-hidden">
|
<div class="rounded-lg border overflow-hidden">
|
||||||
<table class="w-full text-left text-xs">
|
<table class="w-full text-left text-xs">
|
||||||
<thead class="bg-slate-100 font-bold text-slate-800 border-b">
|
<thead class="bg-slate-100 font-bold text-slate-800 border-b">
|
||||||
|
|
@ -230,27 +233,41 @@ class="inline-flex items-center gap-1 rounded-lg bg-amber-500 px-4 py-2 text-xs
|
||||||
<th class="p-2.5">DENOMINAZIONE STABILE</th>
|
<th class="p-2.5">DENOMINAZIONE STABILE</th>
|
||||||
<th class="p-2.5">CODICE FISCALE</th>
|
<th class="p-2.5">CODICE FISCALE</th>
|
||||||
<th class="p-2.5">BANCA PRINCIPALE & IBAN</th>
|
<th class="p-2.5">BANCA PRINCIPALE & IBAN</th>
|
||||||
|
<th class="p-2.5">CASSE (anagr_casse)</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="divide-y font-mono">
|
<tbody class="divide-y font-mono">
|
||||||
<tr class="hover:bg-slate-50">
|
@foreach($stabiliReal as $st)
|
||||||
<td class="p-2.5 font-bold text-slate-900">0010</td>
|
@php
|
||||||
<td class="p-2.5 font-sans font-semibold text-slate-800">CATONE 34 - GERMANICO 85 - GRACCHI 32</td>
|
$adv = is_array($st->configurazione_avanzata) ? $st->configurazione_avanzata : [];
|
||||||
<td class="p-2.5 text-slate-700">80123456789</td>
|
$casse = $adv['conti_correnti']['anagr_casse'] ?? [];
|
||||||
<td class="p-2.5 text-slate-700">ISTITUTO SAN PAOLO: IT26Z0306905077100000013753</td>
|
@endphp
|
||||||
</tr>
|
<tr class="hover:bg-slate-50">
|
||||||
<tr class="hover:bg-slate-50">
|
<td class="p-2.5 font-bold text-slate-900">{{ $st->codice_stabile }}</td>
|
||||||
<td class="p-2.5 font-bold text-slate-900">0013</td>
|
<td class="p-2.5 font-sans font-semibold text-slate-800">{{ $st->denominazione }}</td>
|
||||||
<td class="p-2.5 font-sans font-semibold text-slate-800">OTTAVIANO 105 - GIULIO CESARE 171</td>
|
<td class="p-2.5 text-slate-700">{{ $st->codice_fiscale ?: '-' }}</td>
|
||||||
<td class="p-2.5 text-slate-700">80987654321</td>
|
<td class="p-2.5 text-slate-700">
|
||||||
<td class="p-2.5 text-slate-700">ISTITUTO SAN PAOLO: IT26Z0306905077100000013753</td>
|
@if($st->iban_principale)
|
||||||
</tr>
|
<span class="font-bold text-slate-900">{{ $st->banca_principale ?: 'Banca' }}:</span> {{ $st->iban_principale }}
|
||||||
<tr class="hover:bg-slate-50">
|
@else
|
||||||
<td class="p-2.5 font-bold text-slate-900">0016</td>
|
<span class="text-slate-400">Nessun IBAN registrato</span>
|
||||||
<td class="p-2.5 font-sans font-semibold text-slate-800">GERMANICO 96</td>
|
@endif
|
||||||
<td class="p-2.5 text-slate-700">97112233445</td>
|
</td>
|
||||||
<td class="p-2.5 text-slate-700">BANCA DEL FUCINO: IT48W0312403203000000233378</td>
|
<td class="p-2.5 font-sans">
|
||||||
</tr>
|
@if(!empty($casse))
|
||||||
|
<div class="flex flex-wrap gap-1">
|
||||||
|
@foreach($casse as $c)
|
||||||
|
<span class="inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-bold font-mono {{ $c['codice'] === 'CCB' ? 'bg-sky-100 text-sky-800' : ($c['codice'] === 'CCP' ? 'bg-amber-100 text-amber-800' : 'bg-slate-200 text-slate-700') }}" title="{{ $c['descrizione'] }}">
|
||||||
|
{{ $c['codice'] }}
|
||||||
|
</span>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<span class="text-slate-400 text-[11px]">-</span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user