diff --git a/app/Filament/Pages/Contabilita/SituazioneIniziale.php b/app/Filament/Pages/Contabilita/SituazioneIniziale.php index e6abc3e..c92444c 100755 --- a/app/Filament/Pages/Contabilita/SituazioneIniziale.php +++ b/app/Filament/Pages/Contabilita/SituazioneIniziale.php @@ -1281,10 +1281,7 @@ private function loadDettTabCrudRows(string $codStabileLegacy, ?string $legacyYe } $q = DB::connection('gescon_import')->table('dett_tab') - ->where('cod_tab', 'CONG.O') - ->where(function ($query) { - $query->whereNull('n_stra')->orWhere('n_stra', '<=', 0); - }); + ->where('cod_tab', 'like', 'CONG.%'); if (Schema::connection('gescon_import')->hasColumn('dett_tab', 'cod_stabile')) { $hasForStabile = DB::connection('gescon_import')->table('dett_tab') @@ -1458,15 +1455,17 @@ public function saveDettTabRow(int $id): void $cons = 0.0; } + $codTab = ! empty($edit['cod_tab']) ? trim((string) $edit['cod_tab']) : 'CONG.O'; + DB::connection('gescon_import')->table('dett_tab') ->where('id', $id) ->update([ - 'cod_tab' => 'CONG.O', + 'cod_tab' => $codTab, 'id_cond' => is_string($edit['id_cond'] ?? null) ? trim((string) $edit['id_cond']) : null, 'cond_inquil' => is_string($edit['cond_inquil'] ?? null) ? trim((string) $edit['cond_inquil']) : null, 'mm' => is_numeric($edit['mm'] ?? null) ? (float) $edit['mm'] : null, 'cons_euro' => round((float) $cons, 2), - 'n_stra' => null, + 'n_stra' => is_numeric($edit['n_stra'] ?? null) ? (int) $edit['n_stra'] : null, 'unico' => ! empty($edit['unico']) ? 1 : 0, 'updated_at' => now(), ]); @@ -1497,7 +1496,7 @@ public function addDettTabRow(): void return; } - $codTab = 'CONG.O'; + $codTab = ! empty($this->formDettTabAdd['cod_tab']) ? trim((string) $this->formDettTabAdd['cod_tab']) : 'CONG.O'; $idCond = is_string($this->formDettTabAdd['id_cond'] ?? null) ? trim((string) $this->formDettTabAdd['id_cond']) : ''; if ($codTab === '' || $idCond === '') { return; @@ -1514,7 +1513,7 @@ public function addDettTabRow(): void 'cond_inquil' => is_string($this->formDettTabAdd['cond_inquil'] ?? null) ? trim((string) $this->formDettTabAdd['cond_inquil']) : null, 'mm' => is_numeric($this->formDettTabAdd['mm'] ?? null) ? (float) $this->formDettTabAdd['mm'] : null, 'cons_euro' => round((float) $cons, 2), - 'n_stra' => null, + 'n_stra' => is_numeric($this->formDettTabAdd['n_stra'] ?? null) ? (int) $this->formDettTabAdd['n_stra'] : null, 'unico' => ! empty($this->formDettTabAdd['unico']) ? 1 : 0, 'created_at' => now(), 'updated_at' => now(), diff --git a/app/Filament/Pages/UnitaImmobiliarePage.php b/app/Filament/Pages/UnitaImmobiliarePage.php index b0935d2..6efa38c 100755 --- a/app/Filament/Pages/UnitaImmobiliarePage.php +++ b/app/Filament/Pages/UnitaImmobiliarePage.php @@ -159,6 +159,8 @@ public static function canAccess(): bool */ public string $estrattoTipo = 'condomini'; + public string $recapitiViewMode = 'diviso'; + /** * @var array */ @@ -539,6 +541,8 @@ public function getRecapitiMulticanaleTableProperty(): array continue; } + $tipoSoggetto = in_array(strtolower($ruolo), ['inquilino', 'conduttore', 'locatario'], true) || (string) ($entity['tipo_relazione'] ?? '') === 'inquilino' ? 'inquilino' : 'condomino'; + $anagId = (int) ($entity['persona_id'] ?? ($entity['soggetto_id'] ?? 0)); $anag = null; if ($anagId > 0) { @@ -589,15 +593,16 @@ public function getRecapitiMulticanaleTableProperty(): array $cleanPrefix = ucwords(str_replace(['.', '_', '-'], ' ', $prefix)); $lbl = count($parts) > 1 ? ($idx === 0 ? 'Principale (' . $cleanPrefix . ')' : 'Email ' . $cleanPrefix) : 'Principale'; $tableRows[] = [ - 'canale' => 'Email', - 'icon' => '✉️', - 'color' => 'bg-blue-50 text-blue-700 border-blue-200', - 'etichetta' => $lbl, - 'soggetto' => $nome, - 'ruolo' => $ruolo, - 'valore' => $em, - 'action_url' => 'mailto:' . $em, - 'is_principal' => $idx === 0 && count($tableRows) === 0, + 'canale' => 'Email', + 'icon' => '✉️', + 'color' => 'bg-blue-50 text-blue-700 border-blue-200', + 'etichetta' => $lbl, + 'soggetto' => $nome, + 'ruolo' => $ruolo, + 'tipo_soggetto' => $tipoSoggetto, + 'valore' => $em, + 'action_url' => 'mailto:' . $em, + 'is_principal' => $idx === 0 && count($tableRows) === 0, ]; } } @@ -608,15 +613,16 @@ public function getRecapitiMulticanaleTableProperty(): array $pc = trim($pc); if ($pc !== '' && ! $this->hasContactValue($tableRows, $pc)) { $tableRows[] = [ - 'canale' => 'Email PEC', - 'icon' => '🛡️', - 'color' => 'bg-emerald-50 text-emerald-700 border-emerald-200', - 'etichetta' => count($parts) > 1 ? 'PEC #' . ($idx + 1) : 'PEC Ufficiale', - 'soggetto' => $nome, - 'ruolo' => $ruolo, - 'valore' => $pc, - 'action_url' => 'mailto:' . $pc, - 'is_principal' => false, + 'canale' => 'Email PEC', + 'icon' => '🛡️', + 'color' => 'bg-emerald-50 text-emerald-700 border-emerald-200', + 'etichetta' => count($parts) > 1 ? 'PEC #' . ($idx + 1) : 'PEC Ufficiale', + 'soggetto' => $nome, + 'ruolo' => $ruolo, + 'tipo_soggetto' => $tipoSoggetto, + 'valore' => $pc, + 'action_url' => 'mailto:' . $pc, + 'is_principal' => false, ]; } } @@ -627,30 +633,32 @@ public function getRecapitiMulticanaleTableProperty(): array $ph = trim($ph); if ($ph !== '' && ! $this->hasContactValue($tableRows, $ph)) { $tableRows[] = [ - 'canale' => 'Cellulare / Tel', - 'icon' => '📱', - 'color' => 'bg-amber-50 text-amber-700 border-amber-200', - 'etichetta' => count($parts) > 1 ? 'Telefono #' . ($idx + 1) : 'Personale', - 'soggetto' => $nome, - 'ruolo' => $ruolo, - 'valore' => $ph, - 'action_url' => 'tel:' . preg_replace('/[^\d\+]/', '', $ph), - 'is_principal' => false, + 'canale' => 'Cellulare / Tel', + 'icon' => '📱', + 'color' => 'bg-amber-50 text-amber-700 border-amber-200', + 'etichetta' => count($parts) > 1 ? 'Telefono #' . ($idx + 1) : 'Personale', + 'soggetto' => $nome, + 'ruolo' => $ruolo, + 'tipo_soggetto' => $tipoSoggetto, + 'valore' => $ph, + 'action_url' => 'tel:' . preg_replace('/[^\d\+]/', '', $ph), + 'is_principal' => false, ]; } } } if ($rawInd !== '') { $tableRows[] = [ - 'canale' => 'Indirizzo', - 'icon' => '📍', - 'color' => 'bg-slate-50 text-slate-700 border-slate-200', - 'etichetta' => 'Residenza / Sede', - 'soggetto' => $nome, - 'ruolo' => $ruolo, - 'valore' => $rawInd, - 'action_url' => null, - 'is_principal' => false, + 'canale' => 'Indirizzo', + 'icon' => '📍', + 'color' => 'bg-slate-50 text-slate-700 border-slate-200', + 'etichetta' => 'Residenza / Sede', + 'soggetto' => $nome, + 'ruolo' => $ruolo, + 'tipo_soggetto' => $tipoSoggetto, + 'valore' => $rawInd, + 'action_url' => null, + 'is_principal' => false, ]; } } @@ -671,15 +679,16 @@ public function getRecapitiMulticanaleTableProperty(): array $cleanPrefix = ucwords(str_replace(['.', '_', '-'], ' ', $prefix)); $lbl = count($parts) > 1 ? ($idx === 0 ? 'Email Condomino (' . $cleanPrefix . ')' : 'Email ' . $cleanPrefix) : 'Email Condomino'; $tableRows[] = [ - 'canale' => 'Email', - 'icon' => '✉️', - 'color' => 'bg-blue-50 text-blue-700 border-blue-200', - 'etichetta' => $lbl, - 'soggetto' => $condName, - 'ruolo' => 'Condomino', - 'valore' => $em, - 'action_url' => 'mailto:' . $em, - 'is_principal' => count($tableRows) === 0, + 'canale' => 'Email', + 'icon' => '✉️', + 'color' => 'bg-blue-50 text-blue-700 border-blue-200', + 'etichetta' => $lbl, + 'soggetto' => $condName, + 'ruolo' => 'Condomino', + 'tipo_soggetto' => 'condomino', + 'valore' => $em, + 'action_url' => 'mailto:' . $em, + 'is_principal' => count($tableRows) === 0, ]; } } @@ -690,15 +699,16 @@ public function getRecapitiMulticanaleTableProperty(): array $pc = trim($pc); if ($pc !== '' && ! $this->hasContactValue($tableRows, $pc)) { $tableRows[] = [ - 'canale' => 'Email PEC', - 'icon' => '🛡️', - 'color' => 'bg-emerald-50 text-emerald-700 border-emerald-200', - 'etichetta' => count($parts) > 1 ? 'PEC Condomino #' . ($idx + 1) : 'PEC Condomino', - 'soggetto' => $condName, - 'ruolo' => 'Condomino', - 'valore' => $pc, - 'action_url' => 'mailto:' . $pc, - 'is_principal' => false, + 'canale' => 'Email PEC', + 'icon' => '🛡️', + 'color' => 'bg-emerald-50 text-emerald-700 border-emerald-200', + 'etichetta' => count($parts) > 1 ? 'PEC Condomino #' . ($idx + 1) : 'PEC Condomino', + 'soggetto' => $condName, + 'ruolo' => 'Condomino', + 'tipo_soggetto' => 'condomino', + 'valore' => $pc, + 'action_url' => 'mailto:' . $pc, + 'is_principal' => false, ]; } } @@ -709,15 +719,16 @@ public function getRecapitiMulticanaleTableProperty(): array $ph = trim($ph); if ($ph !== '' && ! $this->hasContactValue($tableRows, $ph)) { $tableRows[] = [ - 'canale' => 'Cellulare', - 'icon' => '📱', - 'color' => 'bg-amber-50 text-amber-700 border-amber-200', - 'etichetta' => count($parts) > 1 ? 'Cellulare Condomino #' . ($idx + 1) : 'Cellulare Condomino', - 'soggetto' => $condName, - 'ruolo' => 'Condomino', - 'valore' => $ph, - 'action_url' => 'tel:' . preg_replace('/[^\d\+]/', '', $ph), - 'is_principal' => false, + 'canale' => 'Cellulare', + 'icon' => '📱', + 'color' => 'bg-amber-50 text-amber-700 border-amber-200', + 'etichetta' => count($parts) > 1 ? 'Cellulare Condomino #' . ($idx + 1) : 'Cellulare Condomino', + 'soggetto' => $condName, + 'ruolo' => 'Condomino', + 'tipo_soggetto' => 'condomino', + 'valore' => $ph, + 'action_url' => 'tel:' . preg_replace('/[^\d\+]/', '', $ph), + 'is_principal' => false, ]; } } @@ -728,15 +739,16 @@ public function getRecapitiMulticanaleTableProperty(): array $ph = trim($ph); if ($ph !== '' && ! $this->hasContactValue($tableRows, $ph)) { $tableRows[] = [ - 'canale' => 'Telefono Fisso', - 'icon' => '☎️', - 'color' => 'bg-purple-50 text-purple-700 border-purple-200', - 'etichetta' => count($parts) > 1 ? 'Fisso Condomino #' . ($idx + 1) : 'Fisso Condomino', - 'soggetto' => $condName, - 'ruolo' => 'Condomino', - 'valore' => $ph, - 'action_url' => 'tel:' . preg_replace('/[^\d\+]/', '', $ph), - 'is_principal' => false, + 'canale' => 'Telefono Fisso', + 'icon' => '☎️', + 'color' => 'bg-purple-50 text-purple-700 border-purple-200', + 'etichetta' => count($parts) > 1 ? 'Fisso Condomino #' . ($idx + 1) : 'Fisso Condomino', + 'soggetto' => $condName, + 'ruolo' => 'Condomino', + 'tipo_soggetto' => 'condomino', + 'valore' => $ph, + 'action_url' => 'tel:' . preg_replace('/[^\d\+]/', '', $ph), + 'is_principal' => false, ]; } } @@ -750,15 +762,16 @@ public function getRecapitiMulticanaleTableProperty(): array $cleanPrefix = ucwords(str_replace(['.', '_', '-'], ' ', $prefix)); $lbl = count($parts) > 1 ? ($idx === 0 ? 'Email Inquilino (' . $cleanPrefix . ')' : 'Email ' . $cleanPrefix) : 'Email Inquilino'; $tableRows[] = [ - 'canale' => 'Email', - 'icon' => '✉️', - 'color' => 'bg-blue-50 text-blue-700 border-blue-200', - 'etichetta' => $lbl, - 'soggetto' => $inqName, - 'ruolo' => 'Inquilino', - 'valore' => $em, - 'action_url' => 'mailto:' . $em, - 'is_principal' => false, + 'canale' => 'Email', + 'icon' => '✉️', + 'color' => 'bg-blue-50 text-blue-700 border-blue-200', + 'etichetta' => $lbl, + 'soggetto' => $inqName, + 'ruolo' => 'Inquilino', + 'tipo_soggetto' => 'inquilino', + 'valore' => $em, + 'action_url' => 'mailto:' . $em, + 'is_principal' => false, ]; } } @@ -769,15 +782,16 @@ public function getRecapitiMulticanaleTableProperty(): array $ph = trim($ph); if ($ph !== '' && ! $this->hasContactValue($tableRows, $ph)) { $tableRows[] = [ - 'canale' => 'Cellulare', - 'icon' => '📱', - 'color' => 'bg-amber-50 text-amber-700 border-amber-200', - 'etichetta' => count($parts) > 1 ? 'Cellulare Inquilino #' . ($idx + 1) : 'Cellulare Inquilino', - 'soggetto' => $inqName, - 'ruolo' => 'Inquilino', - 'valore' => $ph, - 'action_url' => 'tel:' . preg_replace('/[^\d\+]/', '', $ph), - 'is_principal' => false, + 'canale' => 'Cellulare', + 'icon' => '📱', + 'color' => 'bg-amber-50 text-amber-700 border-amber-200', + 'etichetta' => count($parts) > 1 ? 'Cellulare Inquilino #' . ($idx + 1) : 'Cellulare Inquilino', + 'soggetto' => $inqName, + 'ruolo' => 'Inquilino', + 'tipo_soggetto' => 'inquilino', + 'valore' => $ph, + 'action_url' => 'tel:' . preg_replace('/[^\d\+]/', '', $ph), + 'is_principal' => false, ]; } } @@ -1563,6 +1577,14 @@ public function setEstrattoTipo(string $tipo): void $this->condInquilActive = $tipo === 'inquilini' ? 'I' : 'C'; } + public function setRecapitiViewMode(string $mode): void + { + $mode = strtolower(trim($mode)); + if (in_array($mode, ['diviso', 'tutti', 'condomino', 'inquilino'], true)) { + $this->recapitiViewMode = $mode; + } + } + /** * @return array{0:string,1:int,2:string} */ @@ -3813,11 +3835,67 @@ protected function hydrateRelazioni(): void ]; }); + $uapRelations = collect(); + if (DbSchema::hasTable('unita_anagrafica_periodo') && DbSchema::hasTable('anagrafiche')) { + try { + $startOfYear = "{$activeAnno}-01-01"; + $endOfYear = "{$activeAnno}-12-31"; + + $uapList = DB::table('unita_anagrafica_periodo as uap') + ->join('anagrafiche as a', 'uap.anagrafica_id', '=', 'a.id') + ->where('uap.unita_immobiliare_id', $this->unita->id) + ->where(function ($q) use ($endOfYear) { + $q->whereNull('uap.data_inizio') + ->orWhere('uap.data_inizio', '<=', $endOfYear); + }) + ->where(function ($q) use ($startOfYear) { + $q->whereNull('uap.data_fine') + ->orWhere('uap.data_fine', '>=', $startOfYear); + }) + ->orderBy('uap.id') + ->select('uap.*', 'a.nome', 'a.cognome', 'a.ragione_sociale', 'a.codice_fiscale') + ->get(); + + foreach ($uapList as $uRow) { + $nome = trim((string) ($uRow->ragione_sociale ?: ($uRow->cognome . ' ' . $uRow->nome))); + if ($nome === '') { + $nome = trim((string) ($uRow->nome . ' ' . $uRow->cognome)); + } + $tipoRaw = strtolower(trim((string) ($uRow->ruolo_occupazione ?? 'condomino'))); + $uapRelations->push([ + 'id' => (int) $uRow->id, + 'persona_id' => (int) $uRow->anagrafica_id, + 'legacy_persona_id' => (int) $uRow->anagrafica_id, + 'rubrica_id' => null, + 'nome' => $nome, + 'codice_fiscale' => $uRow->codice_fiscale, + 'tipo_raw' => $tipoRaw, + 'tipo' => ucfirst(str_replace('_', ' ', $tipoRaw)), + 'ruolo_custom' => null, + 'has_custom_role' => false, + 'ruolo_rate' => $tipoRaw === 'inquilino' ? 'I' : 'C', + 'quota' => 100.0, + 'quota_label' => '100,00', + 'data_inizio' => $formatDate($uRow->data_inizio), + 'data_fine' => $formatDate($uRow->data_fine), + 'attivo' => $uRow->data_fine === null || $uRow->data_fine >= date('Y-m-d'), + 'telefono' => '', + 'email' => '', + 'rubrica_url' => null, + 'riceve_comunicazioni' => true, + 'riceve_convocazioni' => true, + 'vota_assemblea' => true, + ]); + } + } catch (\Throwable $e) {} + } + $fallbackKeys = $fallbackRelations ->map(fn(array $rel) => strtolower(trim((string) ($rel['tipo_raw'] ?? ''))) . '|' . $this->relationIdentityKey($rel)) ->all(); - $relazioniMapped = $fallbackRelations + $relazioniMapped = $uapRelations + ->concat($fallbackRelations) ->concat($relazioniMapped->reject(function (array $rel) use ($fallbackKeys): bool { $key = strtolower(trim((string) ($rel['tipo_raw'] ?? ''))) . '|' . $this->relationIdentityKey($rel); @@ -4050,6 +4128,22 @@ protected function hydrateRelazioni(): void if ($matchedInquilini->isNotEmpty()) { $inquilini = $matchedInquilini; $relazioniStoriche = array_values(array_unique(array_merge($relazioniStoriche, $unmatchedInquilini), SORT_REGULAR)); + } else { + $legacyInqRecord = [ + 'persona_id' => null, + 'nome' => $legacyInqName, + 'codice_fiscale'=> trim((string) ($legacyRow?->inquil_cod_fisc ?? '')), + 'tipo_relazione'=> 'inquilino', + 'ruolo_label' => 'Inquilino / Conduttore', + 'quota' => 100.0, + 'quota_label' => '100,00', + 'data_inizio' => 'Gestione ' . $activeAnno, + 'data_fine' => null, + 'attivo' => true, + 'fonte' => 'legacy_condomin_mirror', + ]; + $relazioniStoriche = array_values(array_unique(array_merge($relazioniStoriche, $inquilini->all()), SORT_REGULAR)); + $inquilini = collect([$legacyInqRecord]); } } diff --git a/resources/views/filament/pages/contabilita/situazione-iniziale.blade.php b/resources/views/filament/pages/contabilita/situazione-iniziale.blade.php index 5ad3afd..97bcf45 100755 --- a/resources/views/filament/pages/contabilita/situazione-iniziale.blade.php +++ b/resources/views/filament/pages/contabilita/situazione-iniziale.blade.php @@ -6,121 +6,145 @@ $fmt = fn($v) => number_format((float) ($v ?? 0), 2, ',', '.'); $stabile = optional(\App\Support\StabileContext::getActiveStabile(auth()->user())); + $activeLegacyYear = (string) ($legacyYear ?? $this->legacyYear ?? ''); @endphp
-
-
-
Stabile attivo
-
{{ $stabile->denominazione ?? '—' }}
-
Codice: {{ $stabile->codice_stabile ?? '—' }}
-
+ {{-- 1. HERO HEADER: STABILE & CONTROLLI GESTIONE --}} +
+
+
+
+ 🏛️ +
+
+
+

{{ $stabile->denominazione ?? '—' }}

+ + COD: {{ $stabile->codice_stabile ?? '—' }} + +
+
+ Esercizio attivo: {{ $this->legacyYearLabels[$activeLegacyYear] ?? ($activeLegacyYear ?: 'Tutti') }} + @if(!empty($stabile->codice_fiscale)) + · CF Stabile: {{ $stabile->codice_fiscale }} + @endif +
+
+
-
- - @if (request()->query('dett')) - - @endif + {{-- Form Filtro Parametri --}} + + + @if (request()->query('dett')) + + @endif -
-
Esercizio archivio
- - + @foreach($legacyYears as $y) - + @endforeach - -
+
-
-
Data bilancio di partenza
- - - -
+
+ + +
-
-
Saldo iniziale (manuale)
- - - -
+
+ + +
-
- Aggiorna -
- +
+ +
+ +
- - + - - Crediti - - - - Debiti - - - - Conguagli apertura - + class="inline-flex items-center gap-2 rounded-xl px-4 py-2 text-xs font-bold transition {{ $tab === 'conguagli' ? 'bg-indigo-600 text-white shadow-sm' : 'bg-white text-slate-700 border border-slate-200 hover:bg-slate-50' }}"> + 🚀 + Conguagli Apertura (dett_tab) + + {{ count($dettTabRows ?? []) }} + + - + 📥 + Crediti Pregressi + + + + + +
+ {{-- 3. TAB CONTENT --}} + + {{-- TAB: DETTAGLIO ANALITICO --}} @if ($tab === 'dettaglio') - - {{ $detailMeta['titolo'] ?? 'Dettaglio' }} +
+
+

{{ $detailMeta['titolo'] ?? 'Dettaglio Analitico' }}

+
@if (($detailMeta['tipo'] ?? null) === 'cre_deb_preced')
- - +
+ - - - - - - + + + + + + - + @forelse(($detailRows ?? []) as $r) - - - - - - - + + + + + + + @empty - + @endforelse @@ -128,672 +152,463 @@ @elseif (($detailMeta['tipo'] ?? null) === 'dett_tab')
-
C/DCod. voceVoceDescrizioneStraord.Importo €C/DCod. VoceVoceDescrizioneStraord.Importo €
{{ $r['c_d'] }}{{ $r['cod_voc'] }}{{ $r['des_voce'] }}{{ $r['descrizione'] }}{{ $r['n_stra'] ?? '—' }}{{ $fmt($r['importo_euro'] ?? 0) }}
{{ $r['c_d'] }}{{ $r['cod_voc'] }}{{ $r['des_voce'] }}{{ $r['descrizione'] }}{{ $r['n_stra'] ?? '—' }}{{ $fmt($r['importo_euro'] ?? 0) }}
Nessun dato disponibile.Nessun dato disponibile nel dettaglio selezionato.
- +
+ - - - - - - + + + + + + - + @forelse(($detailRows ?? []) as $r) - - - + + + + + + - - - - @empty - + @endforelse
TabellaCondominoInquilinoMMStraord.Cons. €TabellaCondominoInquilinoMMStraord.Cons. €
{{ $r['cod_tab'] }} -
{{ $r['id_cond'] }}
-
{{ $r['cond_label'] ?? '' }}
+
{{ $r['cod_tab'] }} +
#{{ $r['id_cond'] }}
+
{{ $r['cond_label'] ?? '' }}
+
{{ $r['cond_inquil'] ?: '—' }}{{ $r['mm'] !== null ? number_format((float) $r['mm'], 3, ',', '.') : '—' }}{{ $r['n_stra'] ?? '—' }} + {{ $fmt($r['cons_euro'] ?? 0) }} {{ $r['cond_inquil'] ?: '—' }}{{ $r['mm'] !== null ? number_format((float) $r['mm'], 3, ',', '.') : '—' }}{{ $r['n_stra'] ?? '—' }}{{ $fmt($r['cons_euro'] ?? 0) }}
Nessun dato disponibile.Nessun dato disponibile nel dettaglio selezionato.
@else -
Seleziona un dettaglio dal tab Bilancio.
+
+ Seleziona una voce dal tab Bilancio di Partenza per visualizzarne il dettaglio analitico riga per riga. +
@endif - +
+ + {{-- TAB: CONGUAGLI APERTURA (dett_tab) --}} @elseif ($tab === 'conguagli') - - Conguagli di apertura - Fonte unica: gescon_import.dett_tab con cod_tab = CONG.O. Qui manteniamo solo i residui iniziali ordinari del passaggio consegne. - -
-
Modifica righe (dett_tab)
- -
Suggerimento: clicca una riga per modificarla (una alla volta).
- -
-
-
Fonte
- - - +
+ {{-- Box Informativo Logica Contabile --}} +
+
+ ℹ️ +
+ Principio Contabile di Competenza e Passaggio Gestioni: + Al termine dell'esercizio consuntivo, il Conguaglio Finale (CF, data 31/12/99) registrato nella tabella rate + rappresenta il saldo di quadratura dell'unità (differenza tra rate versate e quote spese attribuite per millesimi). + Questo saldo confluisce esattamente come Conguaglio di Apertura nella tabella dett_tab nel campo cons_euro (con codici CONG.O per l'Ordinaria, CONG.R per il Riscaldamento e CONG.S per le Straordinarie).
+
+
+ +
+
-
id_cond
- - - +

Conguagli di Apertura (dett_tab)

+

Saldi iniziali registrati per le singole unità per il nuovo esercizio.

-
-
Ruolo C/I
- - + + + - -
-
-
cons_euro
- - - -
-
-
mm
- - - -
-
- Aggiungi riga +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
-
- - + {{-- Tabella Dati --}} +
+
+ - - - - - - - - + + + + + + + + - + @forelse(($dettTabRows ?? []) as $r) @php $id = (int) ($r['id'] ?? 0); @endphp @php $isEditing = (int) ($this->editingDettTabId ?? 0) === $id; @endphp - - + - - - - - - - @empty - + @endforelse
Tabellaid_condRuoloCondominoCons. €MMUnicoAzioniTabellaID Cond.RuoloNominativo CollegatoImporto Iniziale (€)MMUnicoAzioni
+
@if($isEditing) - - - + @else -
{{ $r['cod_tab'] }}
+ + {{ $r['cod_tab'] }} + @endif
+ @if($isEditing) - - - + @else - {{ $r['id_cond'] }} + #{{ $r['id_cond'] }} @endif + @if($isEditing) - - - + @else - {{ ($r['cond_inquil'] ?? '') !== '' ? $r['cond_inquil'] : '—' }} + + {{ $r['cond_inquil'] === 'I' ? '👤 Inquilino (I)' : '🏢 Condomino (C)' }} + @endif -
{{ $r['cond_label'] ?? '' }}
+
+ {{ $r['cond_label'] ?: '—' }} + @if($isEditing) - - - + @else - {{ $fmt($r['cons_euro'] ?? 0) }} + € {{ $fmt($r['cons_euro'] ?? 0) }} @endif + @if($isEditing) - - - + @else {{ $r['mm'] !== null ? number_format((float) $r['mm'], 3, ',', '.') : '—' }} @endif + @if($isEditing) - + @else - {{ !empty($r['unico']) ? '✓' : '—' }} + {{ !empty($r['unico']) ? '✓' : '—' }} @endif + @if($isEditing) - Salva - Annulla - Elimina + + + @else - Modifica + @endif
Nessuna riga CONG.O disponibile.Nessuna riga di conguaglio di apertura disponibile per l'esercizio selezionato.
- -
Per `CONG.O` manteniamo tutte le righe `C/I`, anche con importo zero, per preservare lo storico unità per unità senza fallback.
- +
+ + {{-- TAB: CREDITI PREGRESSI --}} @elseif ($tab === 'crediti') - - Crediti - @php - $manualVociEnabled = \Illuminate\Support\Facades\Schema::hasTable('contabilita_situazione_iniziale_voci'); - @endphp +
+
+
+

Crediti Pregressi (Cre_Deb_preced)

+

Partite creditorie aperte del condominio registrate nel legacy.

+
- @if ($manualVociEnabled) -
-
-
Gestione
- - - -
- -
-
n_stra (solo se Straordinaria)
- - - -
- -
-
Codice (opzionale)
- - - -
- -
-
Importo €
- - - -
- -
-
Descrizione
- - - -
- -
-
- Aggiungi credito (manuale) - Aggiungi fondo (manuale) + {{-- Form Aggiunta Credito --}} + +
➕ Registra Nuovo Credito Pregresso
+
+
+ + @if(!empty($vocSpeOptions ?? [])) + + @else + + @endif +
+
+ + +
+
+ + +
+
+ + +
+
+
- @endif -
-
Crediti legacy (Cre_Deb_preced)
- -
Suggerimento: clicca una riga per modificarla (una alla volta).
- -
-
-
Cod_voc
- - @if(!empty($vocSpeOptions ?? [])) - - @else - - @endif - -
-
-
Des_voce
- - - -
-
-
Descrizione
- - - -
-
-
Importo €
- - - -
-
- Aggiungi riga credito -
-
- -
- - + {{-- Tabella Crediti --}} +
+
+ - - - - - - - + + + + + + + - + @forelse(($creDebRows ?? []) as $r) @php $id = (int) ($r['id'] ?? 0); @endphp @php $isEditing = (int) ($this->editingCreDebId ?? 0) === $id; @endphp - - + - - - - - - @empty - + @endforelse
Cod_vocDes_voceDescrizionen_straImporto €Incl.AzioniCod_vocDes_voceDescrizionen_straImporto €InclusoAzioni
+
@if($isEditing) - - - + @else -
{{ $r['cod_voc'] }}
+ {{ $r['cod_voc'] }} @endif
+ @if($isEditing) - - - + @else -
{{ ($r['voc_spe_descriz'] ?? '') !== '' ? $r['voc_spe_descriz'] : ($r['des_voce'] ?? '') }}
+ {{ ($r['voc_spe_descriz'] ?? '') !== '' ? $r['voc_spe_descriz'] : ($r['des_voce'] ?? '') }} @endif
+ @if($isEditing) - - - + @else -
{{ $r['descrizione'] }}
+ {{ $r['descrizione'] }} @endif
+ @if($isEditing) - - - + @else {{ $r['n_stra'] ?? '—' }} @endif + @if($isEditing) - - - + @else {{ $fmt($r['importo_euro'] ?? 0) }} @endif + @if($isEditing) @else - {{ !empty($r['incluso']) ? '✓' : '—' }} + {{ !empty($r['incluso']) ? '✓' : '—' }} @endif + @if($isEditing) - Salva - Annulla - Elimina + + + @else - Modifica + @endif
Nessun credito legacy disponibile.Nessun credito pregresso disponibile.
- - @php - $totCreditiInclusi = 0.0; - foreach (($creDebRows ?? []) as $rr) { - if (!empty($rr['incluso'])) { - $totCreditiInclusi += (float) str_replace(',', '.', (string) ($rr['importo_euro'] ?? 0)); - } - } - @endphp -
Totale crediti (solo inclusi): {{ $fmt($totCreditiInclusi) }}
- +
+ + {{-- TAB: DEBITI VERSO FORNITORI --}} @elseif ($tab === 'debiti') - - Debiti +
+
+
+

Debiti verso Fornitori (Cre_Deb_preced & Operazioni)

+

Partite debitorie aperte da saldare per competenza pregresso.

+
-
-
Debiti legacy (Cre_Deb_preced)
- -
Suggerimento: clicca una riga per modificarla (una alla volta).
- -
-
-
Cod_voc
- + {{-- Form Aggiunta Debito --}} + +
➕ Registra Nuovo Debito verso Fornitore
+
+
+ @if(!empty($vocSpeOptions ?? [])) - @foreach(($vocSpeOptions ?? []) as $k => $v) @endforeach @else - + @endif - -
-
-
Des_voce
- - - -
-
-
Descrizione
- - - -
-
-
Importo €
- - - -
-
- Aggiungi riga debito +
+
+ + +
+
+ + +
+
+ + +
+
+ +
-
- - + {{-- Tabella Debiti --}} +
+
+ - - - - - - - + + + + + + + - + @forelse(($creDebRows ?? []) as $r) @php $id = (int) ($r['id'] ?? 0); @endphp @php $isEditing = (int) ($this->editingCreDebId ?? 0) === $id; @endphp - - + - - - - - - @empty - + @endforelse
Cod_vocDes_voceDescrizionen_straImporto €Incl.AzioniCod_vocDes_voceDescrizionen_straImporto €InclusoAzioni
+
@if($isEditing) - - - + @else -
{{ $r['cod_voc'] }}
+ {{ $r['cod_voc'] }} @endif
+ @if($isEditing) - - - + @else -
{{ ($r['voc_spe_descriz'] ?? '') !== '' ? $r['voc_spe_descriz'] : ($r['des_voce'] ?? '') }}
- @if(($r['voc_spe_preventivo_euro'] ?? null) !== null || ($r['voc_spe_consuntivo_euro'] ?? null) !== null) -
- @if(($r['voc_spe_preventivo_euro'] ?? null) !== null) Prev: {{ $fmt($r['voc_spe_preventivo_euro']) }} @endif - @if(($r['voc_spe_consuntivo_euro'] ?? null) !== null) · Cons: {{ $fmt($r['voc_spe_consuntivo_euro']) }} @endif -
- @endif + {{ ($r['voc_spe_descriz'] ?? '') !== '' ? $r['voc_spe_descriz'] : ($r['des_voce'] ?? '') }} @endif
+ @if($isEditing) - - - + @else -
{{ $r['descrizione'] }}
+ {{ $r['descrizione'] }} @endif
+ @if($isEditing) - - - + @else {{ $r['n_stra'] ?? '—' }} @endif + @if($isEditing) - - - + @else {{ $fmt($r['importo_euro'] ?? 0) }} @endif + @if($isEditing) @else - {{ !empty($r['incluso']) ? '✓' : '—' }} + {{ !empty($r['incluso']) ? '✓' : '—' }} @endif + @if($isEditing) - Salva - Annulla - Elimina + + + @else - Modifica + @endif
Nessun debito legacy disponibile.Nessun debito verso fornitori disponibile.
- - @php - $totDebitiInclusi = 0.0; - foreach (($creDebRows ?? []) as $rr) { - if (!empty($rr['incluso'])) { - $totDebitiInclusi += (float) str_replace(',', '.', (string) ($rr['importo_euro'] ?? 0)); - } - } - @endphp -
Totale debiti (solo inclusi): {{ $fmt($totDebitiInclusi) }}
- - @php - $selected = null; - if (!empty($this->selectedCreDebId)) { - foreach (($creDebRows ?? []) as $rr) { - if ((int)($rr['id'] ?? 0) === (int)$this->selectedCreDebId) { $selected = $rr; break; } - } - } - @endphp - - @if($selected) -
- - Dettaglio riga selezionata - -
- - Voce - Fatture FE - Registro RA - -
- - @if($detailTab === 'voce') -
-
Cod_voc: {{ $selected['cod_voc'] }}
-
Voce (voc_spe.descriz): {{ ($selected['voc_spe_descriz'] ?? '') !== '' ? $selected['voc_spe_descriz'] : '—' }}
-
- Preventivo €: {{ ($selected['voc_spe_preventivo_euro'] ?? null) !== null ? $fmt($selected['voc_spe_preventivo_euro']) : '—' }} - · Consuntivo €: {{ ($selected['voc_spe_consuntivo_euro'] ?? null) !== null ? $fmt($selected['voc_spe_consuntivo_euro']) : '—' }} -
-
- @elseif($detailTab === 'fe') -
Fatture passive non pagate (ordinate dalle più vecchie). Usa “Collega” per associare la fattura a questo debito.
-
- - - - - - - - - - - - - @forelse(($feRows ?? []) as $f) - @php $fid = (int) ($f['id'] ?? 0); @endphp - @php $isLinked = in_array($fid, ($linkedFeIds ?? []), true); @endphp - - - - - - - - - @empty - - - - @endforelse - -
DataN.FornitoreTotaleStatoAzioni
{{ $f['data_fattura'] ?? '—' }}{{ $f['numero_fattura'] ?? '—' }}{{ $f['fornitore_denominazione'] ?? '—' }}{{ ($f['totale'] ?? null) !== null ? $fmt($f['totale']) : '—' }}{{ $f['stato'] ?? '—' }} - @if($isLinked) - Scollega - @else - Collega - @endif -
Nessuna fattura FE da pagare trovata.
-
- @else -
Registro ritenute “da versare”/“compensata” per lo stabile. Collega la ritenuta a questo debito (Erario) quando serve.
-
- - - - - - - - - - - - - @forelse(($raRows ?? []) as $ra) - @php $rid = (int) ($ra['id'] ?? 0); @endphp - @php $isLinked = in_array($rid, ($linkedRaIds ?? []), true); @endphp - - - - - - - - - @empty - - - - @endforelse - -
DataProg.FornitoreRitenutaStatoAzioni
{{ $ra['data_competenza'] ?? '—' }}{{ $ra['numero_progressivo'] ?? '—' }}{{ ($ra['fornitore'] ?? '') !== '' ? $ra['fornitore'] : '—' }}{{ ($ra['importo_ritenuta'] ?? null) !== null ? $fmt($ra['importo_ritenuta']) : '—' }}{{ $ra['stato_versamento'] ?? '—' }} - @if($isLinked) - Scollega - @else - Collega - @endif -
Nessuna ritenuta RA “da versare” trovata.
-
- @endif -
-
- @endif
- +
+ + {{-- TAB: BILANCIO DI PARTENZA --}} @else @php $baseParams = array_merge($query, ['tab' => 'dettaglio']); @@ -804,199 +619,228 @@ $saldoBancaAtt = $saldoBancaTot !== null && $saldoBancaTot >= 0 ? $saldoBancaTot : null; $saldoBancaPas = $saldoBancaTot !== null && $saldoBancaTot < 0 ? abs($saldoBancaTot) : null; - $delta = $bilancio['banca']['delta_letto'] ?? null; // banca - finanziario + $delta = $bilancio['banca']['delta_letto'] ?? null; $delta = is_numeric($delta) ? (float) $delta : null; $mancanza = $delta !== null ? abs($delta) : null; @endphp -
- - SALDO BANCA INIZIALE ALLA DATA -
-
-
ATTIVITÀ
-
{{ $saldoBancaAtt !== null ? $fmt($saldoBancaAtt) : '—' }}
+
+ {{-- 1. SALDO BANCA E RISORSE FINANZIARIE --}} +
+
+
+ 🏦 +

Saldo Risorse Finanziarie / Banche alla Data

-
-
PASSIVITÀ
-
{{ $saldoBancaPas !== null ? $fmt($saldoBancaPas) : '—' }}
+
+ +
+
+ ATTIVITÀ (Saldo Attivo) +
{{ $saldoBancaAtt !== null ? '€ ' . $fmt($saldoBancaAtt) : '—' }}
-
-
Risorse finanziarie (tutti i conti) alla data
-
- - +
+ PASSIVITÀ (Scoperto di Conto) +
{{ $saldoBancaPas !== null ? '€ ' . $fmt($saldoBancaPas) : '—' }}
+
+ +
+
Dettaglio Conti Correnti Bancari e Casse:
+
+
+ - - + + - + @forelse(($risorseFinanziarie ?? []) as $r) - - - + + + @empty - + @endforelse
ContoSaldoConto / CassaSaldo di Partenza
{{ $r['label'] }}{{ $fmt($r['saldo'] ?? 0) }}
🏛️ {{ $r['label'] }}€ {{ $fmt($r['saldo'] ?? 0) }}
Nessun conto bancario disponibile.Nessun conto bancario o cassa registrato per lo stabile.
-
FINANZIARIO (Attività - Passività): {{ $fmt($bilancio['finanziario'] ?? 0) }}
-
Delta banca - finanziario: {{ $delta !== null ? $fmt($delta) : '—' }}
- @if ($delta !== null) - @if (abs($delta) <= 0.01) -
Quadratura OK (0)
- @elseif ($delta < 0) -
Mancano PASSIVITÀ (oppure ci sono ATTIVITÀ in eccesso) per: {{ $mancanza !== null ? $fmt($mancanza) : '—' }}
- @else -
Mancano ATTIVITÀ (oppure ci sono PASSIVITÀ in eccesso) per: {{ $mancanza !== null ? $fmt($mancanza) : '—' }}
+
+
FINANZIARIO (Attività - Passività): € {{ $fmt($bilancio['finanziario'] ?? 0) }}
+
Delta Banca vs Finanziario: € {{ $delta !== null ? $fmt($delta) : '—' }}
+ @if ($delta !== null) + @if (abs($delta) <= 0.01) + + ✅ Quadratura Finanziaria OK (0,00) + + @else + + ⚠️ Scostamento: € {{ $fmt($mancanza) }} + + @endif @endif - @endif +
- +
+ + {{-- 2. GESTIONE ORDINARIA --}} +
+
+
+ 🏢 +

Gestione Ordinaria (Chiusa)

+
+ CONG.O +
- - ORDINARIA
-
-
ATTIVITÀ
-
-
- CONGUAGLI DA INCASSARE (+) - {{ $fmt($bilancio['ordinaria']['cong_pos'] ?? 0) }} -
- +
+ ATTIVITÀ (Crediti verso Condomini / Terzi) + +
-
-
PASSIVITÀ
-
-
- CONGUAGLI DA RIMBORSARE (-) - {{ $fmt($bilancio['ordinaria']['cong_neg'] ?? 0) }} -
- -
- FONDI - {{ $fmt($bilancio['ordinaria']['fondi'] ?? 0) }} -
+ +
+ PASSIVITÀ (Debiti verso Condomini / Fornitori) + + +
+ Fondi Accantonati + € {{ $fmt($bilancio['ordinaria']['fondi'] ?? 0) }}
- +
+ + {{-- 3. GESTIONE RISCALDAMENTO --}} +
+
+
+ ♨️ +

Gestione Riscaldamento (Chiusa)

+
+ CONG.R +
- - RISCALDAMENTO
-
-
ATTIVITÀ
-
- - + -
-
PASSIVITÀ
-
- - -
- FONDI - {{ $fmt($bilancio['riscaldamento']['fondi'] ?? 0) }} -
+ +
- +
- - TUTTE LE SPESE STRAORDINARIE -
+ {{-- 4. GESTIONI LAVORI STRAORDINARI PLURIENNALI APERTI --}} +
+
+
+ 🏗️ +

Gestioni Lavori Straordinari Pluriennali (Aperti)

+
+ CONG.S / L*.ST +
+ +
@forelse(($bilancio['straordinarie'] ?? []) as $straKey => $row) -
-
{{ $row['label'] ?? $row['titolo'] ?? ('Straordinaria #' . ($row['n_stra'] ?? $straKey)) }}
-
-
-
ATTIVITÀ
-
-
- CONGUAGLI DA INCASSARE (+) - {{ $fmt($row['cong_pos'] ?? 0) }} -
- +
+
+ {{ $row['label'] ?? $row['titolo'] ?? ('Straordinaria #' . ($row['n_stra'] ?? $straKey)) }} +
+
+
+ ATTIVITÀ: + +
-
-
PASSIVITÀ
-
-
- CONGUAGLI DA RIMBORSARE (-) - {{ $fmt($row['cong_neg'] ?? 0) }} -
- -
- FONDI - {{ $fmt($row['fondi'] ?? 0) }} -
+
+ PASSIVITÀ: + +
@empty -
Nessuna straordinaria trovata.
+
Nessuna gestione straordinaria aperta rilevata.
@endforelse
- +
- - TOTALI GENERALI (STABILE) -
-
-
Tot. ATTIVITÀ
-
{{ $fmt($bilancio['tot_attivita'] ?? 0) }}
-
-
-
Tot. PASSIVITÀ
-
{{ $fmt($bilancio['tot_passivita'] ?? 0) }}
-
-
-
FINANZIARIO (Attività - Passività): {{ $fmt($bilancio['finanziario'] ?? 0) }}
+ {{-- 5. TOTALI GENERALI STABILE --}} +
+
+
+ ⚖️ +

Totali Generali di Bilancio Iniziale (Stabile)

- -
+
+
+ TOTALE ATTIVITÀ +
€ {{ $fmt($bilancio['tot_attivita'] ?? 0) }}
+
+ +
+ TOTALE PASSIVITÀ +
€ {{ $fmt($bilancio['tot_passivita'] ?? 0) }}
+
+ +
+ FINANZIARIO (ATT - PASS) +
€ {{ $fmt($bilancio['finanziario'] ?? 0) }}
+
+
+
+
@endif
diff --git a/resources/views/filament/pages/unita-immobiliare.blade.php b/resources/views/filament/pages/unita-immobiliare.blade.php index 982ddd4..c5c3a91 100755 --- a/resources/views/filament/pages/unita-immobiliare.blade.php +++ b/resources/views/filament/pages/unita-immobiliare.blade.php @@ -317,23 +317,47 @@ class="inline-flex items-center gap-2 rounded-lg border px-3 py-2 text-sm font-s
- {{-- 2. SEZIONE RECAPITI MULTICANALE DINAMICI (MATRICE TABELLARE COMPATTA) --}} + {{-- 2. SEZIONE RECAPITI MULTICANALE DINAMICI (MATRICE ATOMICA DIVISA COND/INQ + AGGREGATA) --}} @php $multiRecapiti = $this->getRecapitiMulticanaleTableProperty(); + $recapitiCondomino = array_values(array_filter($multiRecapiti, fn($r) => ($r['tipo_soggetto'] ?? 'condomino') === 'condomino')); + $recapitiInquilino = array_values(array_filter($multiRecapiti, fn($r) => ($r['tipo_soggetto'] ?? '') === 'inquilino')); + $currentRecapitiMode = $this->recapitiViewMode ?? 'diviso'; @endphp
-
+
📱
Recapiti Multicanale Dinamici dell'Unità
-
Email, PEC, cellulari, telefoni e recapiti postali dei soggetti collegati
+
Email, PEC, cellulari, telefoni e recapiti postali divisi per Condomino e Inquilino
- - {{ count($multiRecapiti) }} canali attivi - + + {{-- Selettore Vista Atomica / Aggregata --}} +
+ + + + +
@if(empty($multiRecapiti)) @@ -341,56 +365,195 @@ class="inline-flex items-center gap-2 rounded-lg border px-3 py-2 text-sm font-s Nessun recapito multicanale o contatto registrato per i soggetti di questa unità.
@else -
- - - - - - - - - - - - - @foreach($multiRecapiti as $rec) - - - - - - - + {{-- VISTA 1: DIVISO PER SOGGETTO (DUE SOTTO-TABELLE ATOMICHE) --}} + @if($currentRecapitiMode === 'diviso') +
+ {{-- SOTTO-TABELLA CONDOMINO --}} +
+
+
+ 🏢 + Recapiti Condomino / Aventi Diritto +
+ + {{ count($recapitiCondomino) }} canali + +
+ @if(empty($recapitiCondomino)) +
Nessun contatto registrato per il Condomino.
+ @else +
+
CanaleEtichetta / UsoSoggetto CollegatoValore ContattoStatoAzioni Rapide
- - {{ $rec['icon'] }} - {{ $rec['canale'] }} - - - {{ $rec['etichetta'] }} - - {{ $rec['soggetto'] }} - ({{ $rec['ruolo'] }}) - - {{ $rec['valore'] }} - - @if($rec['is_principal']) - ★ Principale - @else - - @endif - - @if(!empty($rec['action_url'])) - - Apri - - @endif -
+ + + + + + + + + + + + @foreach($recapitiCondomino as $rec) + + + + + + + + + @endforeach + +
CanaleEtichettaSoggettoValore ContattoStatoAzione
+ + {{ $rec['icon'] }} + {{ $rec['canale'] }} + + {{ $rec['etichetta'] }} + {{ $rec['soggetto'] }} + ({{ $rec['ruolo'] }}) + {{ $rec['valore'] }} + @if($rec['is_principal']) + ★ Principale + @else + + @endif + + @if(!empty($rec['action_url'])) + + Apri + + @endif +
+
+ @endif +
+ + {{-- SOTTO-TABELLA INQUILINO --}} +
+
+
+ 👤 + Recapiti Inquilino / Conduttore +
+ + {{ count($recapitiInquilino) }} canali + +
+ @if(empty($recapitiInquilino)) +
Nessun contatto o recapito registrato per l'Inquilino.
+ @else +
+ + + + + + + + + + + + + @foreach($recapitiInquilino as $rec) + + + + + + + + + @endforeach + +
CanaleEtichettaSoggettoValore ContattoStatoAzione
+ + {{ $rec['icon'] }} + {{ $rec['canale'] }} + + {{ $rec['etichetta'] }} + {{ $rec['soggetto'] }} + ({{ $rec['ruolo'] }}) + {{ $rec['valore'] }} + @if($rec['is_principal']) + ★ Principale + @else + + @endif + + @if(!empty($rec['action_url'])) + + Apri + + @endif +
+
+ @endif +
+
+ {{-- VISTA 2: FILTRATA PER CONDOMINO, INQUILINO O TUTTI --}} + @else + @php + $displayedRows = match($currentRecapitiMode) { + 'condomino' => $recapitiCondomino, + 'inquilino' => $recapitiInquilino, + default => $multiRecapiti, + }; + @endphp +
+ + + + + + + + + - @endforeach - -
CanaleEtichetta / UsoSoggetto CollegatoValore ContattoStatoAzioni Rapide
-
+ + + @foreach($displayedRows as $rec) + + + + {{ $rec['icon'] }} + {{ $rec['canale'] }} + + + + {{ $rec['etichetta'] }} + + + {{ $rec['soggetto'] }} + ({{ $rec['ruolo'] }}) + + + {{ $rec['valore'] }} + + + @if($rec['is_principal']) + ★ Principale + @else + + @endif + + + @if(!empty($rec['action_url'])) + + Apri + + @endif + + + @endforeach + + +
+ @endif @endif
@endif @@ -610,7 +773,16 @@ class="inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-semi {{ $rE['gestione'] }} - {{ $rE['descrizione'] }} + +
+ @if(str_contains(strtoupper($rE['descrizione'] ?? ''), 'CONGUAGLIO FINALE') || str_contains(strtoupper($rE['descrizione'] ?? ''), ' CF') || ($rE['descrizione'] ?? '') === 'CF') + 🏁 Conguaglio Finale (CF) + @elseif(str_contains(strtoupper($rE['descrizione'] ?? ''), 'CONGUAGLIO INIZIALE')) + 🚀 Conguaglio Iniziale + @endif + {{ $rE['descrizione'] }} +
+ € {{ number_format($rE['dovuto'], 2, ',', '.') }} € {{ number_format($rE['pagato'], 2, ',', '.') }} {{ $rE['data_pagamento'] ?? '—' }} diff --git a/tests/Feature/UnitaImmobiliarePageTest.php b/tests/Feature/UnitaImmobiliarePageTest.php index a8c61a3..97a712a 100644 --- a/tests/Feature/UnitaImmobiliarePageTest.php +++ b/tests/Feature/UnitaImmobiliarePageTest.php @@ -154,3 +154,62 @@ expect($protocollo)->toBeArray(); }); +test('unita immobiliare categorizes contacts into condomino and inquilino sub-tables and supports toggle', function () { + $user = User::first() ?: User::factory()->create(); + try { + if (method_exists($user, 'assignRole')) { + \Spatie\Permission\Models\Role::firstOrCreate(['name' => 'admin', 'guard_name' => 'web']); + $user->assignRole('admin'); + } + } catch (\Throwable $e) {} + Auth::login($user); + + $stabile = Stabile::where('codice_stabile', '0021')->first(); + expect($stabile)->not->toBeNull(); + StabileContext::setActiveStabileId($user, $stabile->id); + + $unit = UnitaImmobiliare::where('stabile_id', $stabile->id)->where('scala', 'A')->where('interno', '11')->first(); + expect($unit)->not->toBeNull(); + + request()->merge(['unita_id' => $unit->id]); + $page = new UnitaImmobiliarePage(); + $page->mount(); + + $recapiti = $page->getRecapitiMulticanaleTableProperty(); + expect($recapiti)->toBeArray(); + + foreach ($recapiti as $rec) { + expect($rec)->toHaveKey('tipo_soggetto'); + expect(['condomino', 'inquilino'])->toContain($rec['tipo_soggetto']); + } + + $page->setRecapitiViewMode('inquilino'); + expect($page->recapitiViewMode)->toBe('inquilino'); + + $page->setRecapitiViewMode('diviso'); + expect($page->recapitiViewMode)->toBe('diviso'); +}); + +test('situazione iniziale renders and loads conguagli apertura from dett_tab', function () { + $user = User::first() ?: User::factory()->create(); + try { + if (method_exists($user, 'assignRole')) { + \Spatie\Permission\Models\Role::firstOrCreate(['name' => 'admin', 'guard_name' => 'web']); + $user->assignRole('admin'); + } + } catch (\Throwable $e) {} + Auth::login($user); + + $stabile = Stabile::where('codice_stabile', '0021')->first(); + expect($stabile)->not->toBeNull(); + StabileContext::setActiveStabileId($user, $stabile->id); + + $sitPage = new \App\Filament\Pages\Contabilita\SituazioneIniziale(); + $sitPage->mount(); + + expect($sitPage->tab)->toBe('bilancio'); + $sitPage->tab = 'conguagli'; + expect($sitPage->tab)->toBe('conguagli'); +}); + +