diff --git a/app/Filament/Pages/Condomini/TabelleMillesimaliArchivio.php b/app/Filament/Pages/Condomini/TabelleMillesimaliArchivio.php index 08c35c8..fcba3e2 100755 --- a/app/Filament/Pages/Condomini/TabelleMillesimaliArchivio.php +++ b/app/Filament/Pages/Condomini/TabelleMillesimaliArchivio.php @@ -1097,7 +1097,6 @@ protected function loadDettaglioTabella(): void ->select([ 'rr.unita_immobiliare_id', 'rr.ruolo_standard', - 'ru.nome_completo', 'ru.ragione_sociale', 'ru.cognome', 'ru.nome', @@ -1138,7 +1137,7 @@ protected function loadDettaglioTabella(): void $proprietarioList = $rOcc->filter(fn($p) => in_array(strtolower(trim((string)$p->ruolo_standard)), ['condomino', 'proprietario', 'comproprietario', 'nudo_proprietario', 'usufruttuario'], true)); $propNames = []; foreach ($proprietarioList as $p) { - $n = trim((string) ($p->nome_completo ?: ($p->ragione_sociale ?: ($p->cognome . ' ' . $p->nome)))); + $n = trim((string) ($p->ragione_sociale ?: (trim(($p->cognome ?? '') . ' ' . ($p->nome ?? ''))))); if ($n !== '' && ! in_array($n, $propNames, true)) { $propNames[] = $n; } diff --git a/app/Filament/Pages/UnitaImmobiliarePage.php b/app/Filament/Pages/UnitaImmobiliarePage.php index 8afa617..d291726 100755 --- a/app/Filament/Pages/UnitaImmobiliarePage.php +++ b/app/Filament/Pages/UnitaImmobiliarePage.php @@ -814,14 +814,60 @@ public function getEstrattoContoNominativoDettaglioProperty(): array if ($prev > 0 || $cons > 0) { $yearRaw = (string) ($dt->legacy_year ?? ''); $humanYear = $this->resolveHumanYearLabel($yearRaw, $codStabile); + $codTab = (string) ($dt->cod_tab ?? '—'); + + $tabMeta = DbSchema::connection('gescon_import')->hasTable('tabelle_millesimali') + ? DB::connection('gescon_import')->table('tabelle_millesimali') + ->where('cod_stabile', $codStabile) + ->where('cod_tabella', $codTab) + ->first() + : null; + + $descrizioneTab = $tabMeta->denominazione ?? ($tabMeta->descrizione ?? $codTab); + $rawTipo = strtoupper((string) ($tabMeta->tipologia ?? 'O')); + $tipoLabel = match($rawTipo) { + 'R' => 'Riscaldamento', + 'S' => 'Straordinaria', + default => 'Ordinaria', + }; + $sortOrder = match($rawTipo) { + 'O' => 1, + 'R' => 2, + 'S' => 3, + default => 4, + }; + + $vociSpesa = []; + if (DbSchema::connection('gescon_import')->hasTable('voc_spe')) { + $vocRows = DB::connection('gescon_import')->table('voc_spe') + ->where('cod_stabile', $codStabile) + ->where('tabella', $codTab) + ->orderBy('cod') + ->get(); + + foreach ($vocRows as $v) { + $vociSpesa[] = [ + 'cod_voce' => (string) ($v->cod ?? '—'), + 'descrizione' => (string) ($v->descriz ?? '—'), + 'perc_proprietario' => (float) ($v->perc_proprietario ?? 100), + 'perc_inquilino' => (float) ($v->perc_inquilino ?? 0), + 'preventivo_euro' => (float) ($v->preventivo_euro ?? $v->importo_euro ?? 0), + 'consuntivo_euro' => (float) ($v->consuntivo_euro ?? 0), + ]; + } + } $dettaglioAddebiti[] = [ 'anno_gestione' => $humanYear, - 'cod_tabella' => (string) ($dt->cod_tab ?? '—'), + 'cod_tabella' => $codTab, + 'descrizione_tab' => $descrizioneTab, + 'tipo_label' => $tipoLabel, + 'sort_order' => $sortOrder, 'millesimi' => (float) ($dt->mm ?? 0), 'preventivo_euro' => $prev, 'consuntivo_euro' => $cons, 'conguaglio_euro' => $cong, + 'voci_spesa' => $vociSpesa, ]; $totalePreventivo += $prev; @@ -829,6 +875,8 @@ public function getEstrattoContoNominativoDettaglioProperty(): array $totaleConguaglio += $cong; } } + + usort($dettaglioAddebiti, fn($a, $b) => $a['sort_order'] <=> $b['sort_order']); } $dettaglioIncassi = []; diff --git a/resources/views/filament/pages/unita-immobiliare.blade.php b/resources/views/filament/pages/unita-immobiliare.blade.php index 1ff2f8c..620cc07 100755 --- a/resources/views/filament/pages/unita-immobiliare.blade.php +++ b/resources/views/filament/pages/unita-immobiliare.blade.php @@ -587,8 +587,13 @@ class="inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-semi {{-- Tabella Addebiti e Ripartizioni --}}
- 📊 Spese e Millesimi Addebitati per Gestione - Estratti da dett_tab / singolo_anno.mdb +
+ 📊 Spese e Millesimi Addebitati a {{ $soggetto['nominativo'] }} + + {{ reset($ecData['addebiti'])['anno_gestione'] ?? 'Anno In Corso' }} + +
+ Suddivise per Gruppo (Ordinaria, Riscaldamento, Straordinaria)
@if(empty($ecData['addebiti']))
Nessun addebito preventivato o consuntivato per questo nominativo.
@@ -597,26 +602,79 @@ class="inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-semi - - + + + + - @foreach($ecData['addebiti'] as $add) - - - - - - - + + + + + + + + + @if(!empty($add['voci_spesa'])) + + + + @endif @endforeach
Anno GestioneCodice Tabella / VociCodice TabellaDescrizione TabellaTipo Gestione Millesimi (mm) Preventivo (€) Consuntivo (€) Conguaglio (€)Voci Spesa
{{ $add['anno_gestione'] }}{{ $add['cod_tabella'] }}{{ number_format($add['millesimi'], 2, ',', '.') }}€ {{ number_format($add['preventivo_euro'], 2, ',', '.') }}€ {{ number_format($add['consuntivo_euro'], 2, ',', '.') }} + @foreach($ecData['addebiti'] as $addIndex => $add) +
{{ $add['cod_tabella'] }}{{ $add['descrizione_tab'] }} + + {{ $add['tipo_label'] }} + + {{ number_format($add['millesimi'], 2, ',', '.') }}€ {{ number_format($add['preventivo_euro'], 2, ',', '.') }}€ {{ number_format($add['consuntivo_euro'], 2, ',', '.') }} € {{ number_format($add['conguaglio_euro'], 2, ',', '.') }} + @if(!empty($add['voci_spesa'])) + + {{ count($add['voci_spesa']) }} voci + 🔍 + + @else + + @endif +