From 35837061522f4780cffbe23f621c065c85473903 Mon Sep 17 00:00:00 2001 From: michele Date: Fri, 28 Aug 2026 21:30:12 +0200 Subject: [PATCH] feat(unita-immobiliare): convert raw year codes (0013, 0014, 0015) to human management years and dates (task-d095b0e23b) --- app/Filament/Pages/UnitaImmobiliarePage.php | 46 +++++++++++++++++-- .../pages/unita-immobiliare.blade.php | 4 +- .../ui-wireframes/unita-immobiliare.md | 41 +++++++++-------- 3 files changed, 66 insertions(+), 25 deletions(-) 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']))
@@ -549,7 +549,7 @@ class="inline-flex items-center gap-1.5 rounded-lg bg-indigo-600 px-3 py-2 text- wire:click="selectNominativoKey('{{ $tItem['key'] }}')" class="inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-semibold transition border {{ ($soggetto['key'] ?? '') === $tItem['key'] ? 'bg-indigo-700 text-white border-indigo-700 shadow-md ring-2 ring-indigo-500/20' : 'bg-white text-slate-700 border-slate-200 hover:bg-slate-100' }}"> {{ $tItem['nominativo'] }} - ({{ implode(', ', array_slice($tItem['years'], -2)) }}) + ({{ implode(', ', array_slice($tItem['year_labels'] ?? $tItem['years'], -1)) }}) @endforeach
diff --git a/skill-netgescon/ui-wireframes/unita-immobiliare.md b/skill-netgescon/ui-wireframes/unita-immobiliare.md index 197e457..953f406 100644 --- a/skill-netgescon/ui-wireframes/unita-immobiliare.md +++ b/skill-netgescon/ui-wireframes/unita-immobiliare.md @@ -1,4 +1,4 @@ -# ASCII Wireframe - Scheda Unità Immobiliare (Barra Iconica Unificata & Estratto Conto per Nominativo) +# ASCII Wireframe - Scheda Unità Immobiliare (Barra Iconica Unificata & Gestioni Conversione Umana) URL: `http://192.168.0.205:8000/admin-filament/unita-immobiliare?unita_id=249` @@ -7,7 +7,7 @@ # ASCII Wireframe - Scheda Unità Immobiliare (Barra Iconica Unificata & Estratt | NETGESCON · CENTRO STELLA [ Utente: SuperAdmin v ] | +-----------------------------------------------------------------------------------------------------------------------+ | BARRA PULSANTINI ICONICI COMPATTI UNIFICATA: | -| [ 🏢 Elenco Stabili ] [ 🏠 Unità Immobiliare ] [ 📐 Millesimi ] [ 🏛️ Catasto ] | +| [ 🏢 Elenco Stabili ] [ 👥 Elenco Nominativi ] [ 🏠 Unità Immobiliare ] [ 📐 Millesimi ] [ 🏛️ Catasto ] | | Sotto-Tab: [ 📊 Riepilogo ] [ 👥 Nominativi & Subentri ] [ 🧾 Estratto Conto & Pagamenti ] [ 📐 Millesimi ] [ 🏛️ Catasto ] | +-----------------------------------------------------------------------------------------------------------------------+ | Stabile: [ 0013 - VIA OTTAVIANO 105 v ] Seleziona Unità: [<- Prec.] [ Scala B - Int. 8 (ID 249) v ] [Succ. ->] | @@ -15,14 +15,17 @@ # ASCII Wireframe - Scheda Unità Immobiliare (Barra Iconica Unificata & Estratt | | | TAB 1: 👥 NOMINATIVI & TIMELINE SUBENTRI (Scala B - Int. 8) | | +-----------------------------------------------------------------------------------------------------------------+ | -| | [•] MAURELLI Rossana (Condomino / Proprietario) · ID Condomino: #18 · Gestioni: 0003, 0004 ... 0015 | | +| | [•] MAURELLI Rossana (Condomino / Proprietario) · ID Condomino: #18 | | +| | Gestioni Storiche: Anno 2024 (01/01/2024 - 31/12/2024) | Anno 2025 (01/01/2025 - 31/12/2025) | | | | [ 🧾 Vedi Estratto Conto per Nominativo ] | | | | | | -| | [•] RANCHINO Valentina (Condomino / Proprietario) · ID Condomino: #82 · Gestioni: 0009, 0011, 0013, 0014, 0015 | | +| | [•] RANCHINO Valentina (Condomino / Proprietario) · ID Condomino: #82 | | +| | Gestioni Storiche: Anno 2022 (01/01/2022 - 31/12/2022) | Anno 2023 (01/01/2023 - 31/12/2023) | | | | Info: Attivo fino al 28/09/2023 poi subentra RANCHINO Valentina | | | | [ 🧾 Vedi Estratto Conto per Nominativo ] | | | | | | -| | [•] D'ANIELLO Andrea (Condomino / Proprietario) · ID Condomino: #83 · Gestioni: 0013, 0014, 0015 | | +| | [•] D'ANIELLO Andrea (Condomino / Proprietario) · ID Condomino: #83 | | +| | Gestioni Storiche: Anno 2024 (01/01/2024 - 31/12/2024) | Anno 2026 (01/01/2026 - 31/12/2026) | | | | Info: Subentrato dal 10/03/2024 | | | | [ 🧾 Vedi Estratto Conto per Nominativo ] | | | +-----------------------------------------------------------------------------------------------------------------+ | @@ -34,20 +37,20 @@ # ASCII Wireframe - Scheda Unità Immobiliare (Barra Iconica Unificata & Estratt | | KPI: Totale Prev: € 1.189,91 | Totale Cons: € 466,68 | Totale Incassato: € 0,00 | Saldo Finale: € -466,68 | | | +-----------------------------------------------------------------------------------------------------------------+ | | | 📊 SPESE E MILLESIMI ADDEBITATI PER GESTIONE (Da dett_tab / singolo_anno.mdb) | | -| | ANNO GESTIONE | TABELLA / VOCE | MILLESIMI (mm) | PREVENTIVO (€) | CONSUNTIVO (€) | CONGUAGLIO (€) | | -| | --------------+----------------+----------------+----------------+----------------+--------------------------------| | -| | 0015 | TAB.A | 12,00 mm | € 123,79 | € 0,00 | € -123,79 | | -| | 0015 | TAB.B | 17,00 mm | € 34,07 | € 0,00 | € -34,07 | | -| | 0015 | ASC.B | 1,00 mm | € 211,84 | € 0,00 | € -211,84 | | -| | 0015 | TAB.AA | 12,00 mm | € 2,27 | € 0,00 | € -2,27 | | -| | 0015 | TAB.BA | 17,00 mm | € 156,43 | € 0,00 | € -156,43 | | -| | 0015 | SC.BA | 130,00 mm | € 149,24 | € 0,00 | € -149,24 | | -| | 0015 | L08.ST | 12,00 mm | € 3,59 | € 0,00 | € -3,59 | | -| | 0015 | L12.ST | 12,00 mm | € 147,26 | € 0,00 | € -147,26 | | -| | 0015 | ACQUA | 0,00 mm | € 267,92 | € 0,00 | € -267,92 | | -| | 0015 | INDIV. | 0,00 mm | € 93,50 | € 0,00 | € -93,50 | | -| | 0015 | CONG.O | 0,00 mm | € 0,00 | € 367,17 | € +367,17 | | -| | 0015 | Det_03 | 12,00 mm | € 0,00 | € 99,51 | € +99,51 | | +| | ANNO GESTIONE | TABELLA | MILLESIMI (mm) | PREVENTIVO (€) | CONSUNTIVO (€) | CONGUAGLIO (€)| | +| | ---------------------------------------+---------+----------------+----------------+----------------+---------------| | +| | Anno 2026 (01/01/2026 - 31/12/2026) | TAB.A | 12,00 mm | € 123,79 | € 0,00 | € -123,79 | | +| | Anno 2026 (01/01/2026 - 31/12/2026) | TAB.B | 17,00 mm | € 34,07 | € 0,00 | € -34,07 | | +| | Anno 2026 (01/01/2026 - 31/12/2026) | ASC.B | 1,00 mm | € 211,84 | € 0,00 | € -211,84 | | +| | Anno 2026 (01/01/2026 - 31/12/2026) | TAB.AA | 12,00 mm | € 2,27 | € 0,00 | € -2,27 | | +| | Anno 2026 (01/01/2026 - 31/12/2026) | TAB.BA | 17,00 mm | € 156,43 | € 0,00 | € -156,43 | | +| | Anno 2026 (01/01/2026 - 31/12/2026) | SC.BA | 130,00 mm | € 149,24 | € 0,00 | € -149,24 | | +| | Anno 2026 (01/01/2026 - 31/12/2026) | L08.ST | 12,00 mm | € 3,59 | € 0,00 | € -3,59 | | +| | Anno 2026 (01/01/2026 - 31/12/2026) | L12.ST | 12,00 mm | € 147,26 | € 0,00 | € -147,26 | | +| | Anno 2026 (01/01/2026 - 31/12/2026) | ACQUA | 0,00 mm | € 267,92 | € 0,00 | € -267,92 | | +| | Anno 2026 (01/01/2026 - 31/12/2026) | INDIV. | 0,00 mm | € 93,50 | € 0,00 | € -93,50 | | +| | Anno 2026 (01/01/2026 - 31/12/2026) | CONG.O | 0,00 mm | € 0,00 | € 367,17 | € +367,17 | | +| | Anno 2026 (01/01/2026 - 31/12/2026) | Det_03 | 12,00 mm | € 0,00 | € 99,51 | € +99,51 | | | +-----------------------------------------------------------------------------------------------------------------+ | +-----------------------------------------------------------------------------------------------------------------------+ ```