diff --git a/app/Filament/Pages/Condomini/CatastoHub.php b/app/Filament/Pages/Condomini/CatastoHub.php index 7e7361e..3078489 100644 --- a/app/Filament/Pages/Condomini/CatastoHub.php +++ b/app/Filament/Pages/Condomini/CatastoHub.php @@ -461,14 +461,14 @@ public function loadUnitaList(): void } if (empty($uFoglio) || $uFoglio === '-' || $uFoglio === '0') { - $uFoglio = $this->stabileAttivo?->foglio_catasto ?? $this->stabileAttivo?->foglio ?? '405'; + $uFoglio = $this->stabileAttivo?->foglio ?? $this->stabileAttivo?->foglio_catasto ?? '403'; } if (empty($uParticella) || $uParticella === '-' || $uParticella === '0') { if ($this->stabileAttivo && ($this->stabileAttivo->id == 4 || $this->stabileAttivo->codice_stabile === '0021')) { $scalaUpper = strtoupper(trim($u->scala ?: '')); $uParticella = ($scalaUpper === 'D') ? '253' : '256'; } else { - $uParticella = $this->stabileAttivo?->particella_catasto ?? $this->stabileAttivo?->mappale ?? '256'; + $uParticella = $this->stabileAttivo?->particella_catasto ?? $this->stabileAttivo?->mappale ?? '60'; } } @@ -476,6 +476,17 @@ public function loadUnitaList(): void $jsonFilename = "risultato_immobile_" . (string)$uFoglio . "_" . (string)$uParticella . "{$subLabel}.json"; $jsonRelativePath = "{$dirPath}/{$jsonFilename}"; + if (! Storage::disk('public')->exists($jsonRelativePath) && ! empty($uSubalterno)) { + $subPattern = "_sub{$uSubalterno}.json"; + $allFiles = Storage::disk('public')->files($dirPath); + foreach ($allFiles as $f) { + if (str_contains($f, $subPattern)) { + $jsonRelativePath = $f; + break; + } + } + } + if (Storage::disk('public')->exists($jsonRelativePath)) { try { $sisterContent = json_decode(Storage::disk('public')->get($jsonRelativePath), true); @@ -630,7 +641,7 @@ public function selectUnita(int $unitaId): void } if (empty($uFoglio) || $uFoglio === '-' || $uFoglio === '0') { - $uFoglio = $this->stabileAttivo?->foglio_catasto ?? $this->stabileAttivo?->foglio ?? '405'; + $uFoglio = $this->stabileAttivo?->foglio ?? $this->stabileAttivo?->foglio_catasto ?? '403'; } if ($this->stabileAttivo && ($this->stabileAttivo->id == 4 || $this->stabileAttivo->codice_stabile === '0021')) { $scalaUpper = strtoupper(trim($u->scala ?: '')); @@ -642,7 +653,7 @@ public function selectUnita(int $unitaId): void } } else { if (empty($uParticella) || $uParticella === '-' || $uParticella === '0') { - $uParticella = $this->stabileAttivo?->particella_catasto ?? $this->stabileAttivo?->mappale ?? '256'; + $uParticella = $this->stabileAttivo?->particella_catasto ?? $this->stabileAttivo?->mappale ?? '60'; } } @@ -701,6 +712,17 @@ public function selectUnita(int $unitaId): void $jsonFilename = "risultato_immobile_" . (string)$uFoglio . "_" . (string)$uParticella . "{$subLabel}.json"; $jsonRelativePath = "{$dirPath}/{$jsonFilename}"; + if (! Storage::disk('public')->exists($jsonRelativePath) && ! empty($uSubalterno)) { + $subPattern = "_sub{$uSubalterno}.json"; + $allFiles = Storage::disk('public')->files($dirPath); + foreach ($allFiles as $f) { + if (str_contains($f, $subPattern)) { + $jsonRelativePath = $f; + break; + } + } + } + if (Storage::disk('public')->exists($jsonRelativePath)) { try { $sisterContent = json_decode(Storage::disk('public')->get($jsonRelativePath), true); diff --git a/app/Filament/Pages/UnitaImmobiliarePage.php b/app/Filament/Pages/UnitaImmobiliarePage.php index 4037639..a5b2ddb 100755 --- a/app/Filament/Pages/UnitaImmobiliarePage.php +++ b/app/Filament/Pages/UnitaImmobiliarePage.php @@ -792,8 +792,8 @@ public function getEstrattoContoNominativoDettaglioProperty(): array } } - if (! $selectedItem) { - $roleTarget = $this->condInquilActive === 'I' ? 'Inquilino' : 'Condomino / Proprietario'; + $roleTarget = $this->condInquilActive === 'I' ? 'Inquilino' : 'Condomino / Proprietario'; + if (! $selectedItem || (($selectedItem['ruolo'] ?? '') !== $roleTarget)) { foreach ($timeline as $t) { if (($t['ruolo'] ?? '') === $roleTarget) { $selectedItem = $t; @@ -953,15 +953,53 @@ public function getEstrattoContoNominativoDettaglioProperty(): array } } + if (empty($this->estrattoCompattoRateRows)) { + $this->initEstrattoContoCompattoData(); + } + + $rateList = $this->condInquilActive === 'I' + ? $this->estrattoRateRowsInquilino + : $this->estrattoRateRowsProprietario; + + $rateEmesseRows = []; + $totaleDovutoRate = 0.0; + $totalePagatoRate = 0.0; + + foreach ($rateList as $r) { + $dovuto = (float) ($r['dovuto'] ?? 0); + $pagato = (float) ($r['pagato'] ?? 0); + $residuo = (float) ($r['residuo'] ?? ($dovuto - $pagato)); + + $rateEmesseRows[] = [ + 'id' => $r['id'] ?? null, + 'data_emissione' => $r['data_emissione'] ?? '—', + 'data_scadenza' => $r['data_scadenza'] ?? '—', + 'data_pagamento' => $r['data_pagamento'] ?? '—', + 'avviso' => $r['avviso'] ?? '—', + 'gestione' => $r['gestione'] ?? '—', + 'descrizione' => $r['descrizione'] ?? '—', + 'dovuto' => $dovuto, + 'pagato' => $pagato, + 'residuo' => $residuo, + ]; + + $totaleDovutoRate += $dovuto; + $totalePagatoRate += $pagato; + } + return [ - 'soggetto' => $selectedItem, - 'addebiti' => $dettaglioAddebiti, - 'incassi' => $dettaglioIncassi, - 'totale_preventivo' => $totalePreventivo, - 'totale_consuntivo' => $totaleConsuntivo, - 'totale_conguaglio' => $totaleConguaglio, - 'totale_incassato' => $totaleIncassato, - 'saldo_finale' => $totaleIncassato - $totaleConsuntivo, + 'soggetto' => $selectedItem, + 'addebiti' => $dettaglioAddebiti, + 'incassi' => $dettaglioIncassi, + 'rate_emesse' => $rateEmesseRows, + 'totale_preventivo' => $totalePreventivo, + 'totale_consuntivo' => $totaleConsuntivo, + 'totale_conguaglio' => $totaleConguaglio, + 'totale_incassato' => $totaleIncassato, + 'totale_dovuto_rate' => $totaleDovutoRate, + 'totale_pagato_rate' => $totalePagatoRate, + 'totale_residuo_rate' => $totaleDovutoRate - $totalePagatoRate, + 'saldo_finale' => $totaleIncassato - $totaleConsuntivo, ]; } diff --git a/resources/views/filament/pages/unita-immobiliare.blade.php b/resources/views/filament/pages/unita-immobiliare.blade.php index b166cd2..5587be3 100755 --- a/resources/views/filament/pages/unita-immobiliare.blade.php +++ b/resources/views/filament/pages/unita-immobiliare.blade.php @@ -655,11 +655,82 @@ class="inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-semi @endif + {{-- Tabella Rate Emesse (Dovuto vs Pagato) --}} +
+
+ 📑 Rate Emesse ed Avvisi di Pagamento + Estratti da rate_emesse / emes_det per {{ $soggetto['nominativo'] }} +
+ @if(empty($ecData['rate_emesse'])) +
Nessuna rata emessa per questo nominativo / ruolo.
+ @else +
+ + + + + + + + + + + + + + + @foreach($ecData['rate_emesse'] as $rE) + + + + + + + + + + + @endforeach + + + + + + + + + + +
Data EmissioneData ScadenzaGestioneDescrizione RataDovuto (€)Pagato (€)Residuo (€)Stato
{{ $rE['data_emissione'] }}{{ $rE['data_scadenza'] }} + + {{ $rE['gestione'] }} + + {{ $rE['descrizione'] }}€ {{ number_format($rE['dovuto'], 2, ',', '.') }}€ {{ number_format($rE['pagato'], 2, ',', '.') }} + € {{ number_format($rE['residuo'], 2, ',', '.') }} + + @if($rE['residuo'] <= 0 && $rE['dovuto'] > 0) + + Saldata + + @elseif($rE['pagato'] > 0) + + Parziale + + @else + + Da Pagare + + @endif +
Totali Rate Emesse:€ {{ number_format($ecData['totale_dovuto_rate'], 2, ',', '.') }}€ {{ number_format($ecData['totale_pagato_rate'], 2, ',', '.') }}€ {{ number_format($ecData['totale_residuo_rate'], 2, ',', '.') }}
+
+ @endif +
+ {{-- Tabella Incassi Registrati --}}
- 💵 Rate ed Incassi Effettuati - Estratti da incassi / inc_da_ec + 💵 Incassi Effettuati e Ricevute + Estratti da incassi / in_da_ec
@if(empty($ecData['incassi']))
Nessun incasso registrato per questo nominativo.
@@ -686,6 +757,12 @@ class="inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-semi @endforeach + + + Totale Incassato: + € {{ number_format($ecData['totale_incassato'], 2, ',', '.') }} + +
@endif