diff --git a/app/Filament/Pages/UnitaImmobiliarePage.php b/app/Filament/Pages/UnitaImmobiliarePage.php
index a30b471..8afa617 100755
--- a/app/Filament/Pages/UnitaImmobiliarePage.php
+++ b/app/Filament/Pages/UnitaImmobiliarePage.php
@@ -672,6 +672,36 @@ public function setTab(string $tab): void
$this->tab = $tab;
}
+ public function resolveHumanYearLabel(string $yearCode, string $codStabile): string
+ {
+ $yearCode = trim($yearCode);
+ if ($yearCode === '') {
+ return '—';
+ }
+
+ if (DbSchema::connection('gescon_import')->hasTable('gestioni_annuali')) {
+ $row = DB::connection('gescon_import')->table('gestioni_annuali')
+ ->where('cod_stabile', $codStabile)
+ ->where('cartella', $yearCode)
+ ->first();
+
+ if ($row) {
+ $yearStr = $row->anno_ordinario ?: $row->descrizione;
+ $dal = $row->ordinaria_dal ? date('d/m/Y', strtotime($row->ordinaria_dal)) : null;
+ $al = $row->ordinaria_al ? date('d/m/Y', strtotime($row->ordinaria_al)) : null;
+
+ if ($yearStr) {
+ if ($dal && $al) {
+ return "Anno {$yearStr} ({$dal} - {$al})";
+ }
+ return "Anno {$yearStr}";
+ }
+ }
+ }
+
+ return 'Anno ' . (is_numeric($yearCode) ? (int) $yearCode : $yearCode);
+ }
+
public function getTimelineSubentriCompletaProperty(): array
{
if (! $this->unita || ! $this->unita->stabile) {
@@ -715,6 +745,7 @@ public function getTimelineSubentriCompletaProperty(): array
'ruolo' => ! empty($c->inquilino) ? 'Inquilino' : 'Condomino / Proprietario',
'cod_conds' => [],
'years' => [],
+ 'year_labels' => [],
'codice_fiscale' => $c->codice_fiscale ?? null,
'dettaglio_subentro' => $c->attivo_fino_al ?: ($c->subentrato_dal ?: ($c->inquil_dal ?: null)),
];
@@ -725,7 +756,8 @@ public function getTimelineSubentriCompletaProperty(): array
}
$yearStr = (string) ($c->source_year ?? $c->legacy_year ?? '');
if ($yearStr !== '' && ! in_array($yearStr, $timeline[$key]['years'], true)) {
- $timeline[$key]['years'][] = $yearStr;
+ $timeline[$key]['years'][] = $yearStr;
+ $timeline[$key]['year_labels'][] = $this->resolveHumanYearLabel($yearStr, $codStabile);
}
}
@@ -780,8 +812,11 @@ public function getEstrattoContoNominativoDettaglioProperty(): array
$cong = $cons - $prev;
if ($prev > 0 || $cons > 0) {
+ $yearRaw = (string) ($dt->legacy_year ?? '');
+ $humanYear = $this->resolveHumanYearLabel($yearRaw, $codStabile);
+
$dettaglioAddebiti[] = [
- 'anno_gestione' => (string) ($dt->legacy_year ?? '—'),
+ 'anno_gestione' => $humanYear,
'cod_tabella' => (string) ($dt->cod_tab ?? '—'),
'millesimi' => (float) ($dt->mm ?? 0),
'preventivo_euro' => $prev,
@@ -806,11 +841,14 @@ public function getEstrattoContoNominativoDettaglioProperty(): array
->get();
foreach ($incassiRows as $inc) {
- $imp = (float) ($inc->importo_euro ?? $inc->importo_pagato_euro ?? 0);
+ $imp = (float) ($inc->importo_euro ?? $inc->importo_pagato_euro ?? 0);
+ $yearRef = (string) ($inc->anno_rif ?? '');
+ $humanYr = $yearRef !== '' ? $this->resolveHumanYearLabel($yearRef, $codStabile) : '—';
+
$dettaglioIncassi[] = [
'data_pagamento' => (string) ($inc->data_pagamento ?? '—'),
'cod_cassa' => (string) ($inc->cod_cassa ?? '—'),
- 'anno_rif' => (string) ($inc->anno_rif ?? '—'),
+ 'anno_rif' => $humanYr,
'importo_euro' => $imp,
'descrizione' => (string) ($inc->descrizione ?? '—'),
];
diff --git a/resources/views/filament/pages/unita-immobiliare.blade.php b/resources/views/filament/pages/unita-immobiliare.blade.php
index 3485ca7..1ff2f8c 100755
--- a/resources/views/filament/pages/unita-immobiliare.blade.php
+++ b/resources/views/filament/pages/unita-immobiliare.blade.php
@@ -506,7 +506,7 @@ class="inline-flex items-center gap-2 rounded-lg border px-3 py-2 text-sm font-s
CF: {{ $item['codice_fiscale'] }}
@endif
ID Condomino: #{{ $item['id_cond'] }}
- Gestioni: {{ implode(', ', $item['years']) }}
+ Gestioni: {{ implode(' | ', $item['year_labels'] ?? $item['years']) }}
@if(!empty($item['dettaglio_subentro']))