fix(catasto-unita): fix inquilino estratto conto role resolution, add rate emesse dovuto vs pagato table, and fix catasto hub defaults for Stabile 0013
This commit is contained in:
parent
5ad6ee6b98
commit
d36c5b9b94
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -655,11 +655,82 @@ class="inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-semi
|
|||
@endif
|
||||
</div>
|
||||
|
||||
{{-- Tabella Rate Emesse (Dovuto vs Pagato) --}}
|
||||
<div class="rounded-xl border border-slate-200 bg-white overflow-hidden shadow-xs">
|
||||
<div class="border-b border-slate-200 bg-slate-50 px-4 py-3 font-semibold text-slate-800 text-sm flex items-center justify-between">
|
||||
<span>📑 Rate Emesse ed Avvisi di Pagamento</span>
|
||||
<span class="text-xs text-slate-500 font-normal">Estratti da rate_emesse / emes_det per {{ $soggetto['nominativo'] }}</span>
|
||||
</div>
|
||||
@if(empty($ecData['rate_emesse']))
|
||||
<div class="p-6 text-center text-slate-500 text-xs">Nessuna rata emessa per questo nominativo / ruolo.</div>
|
||||
@else
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-left text-xs">
|
||||
<thead class="bg-slate-100 text-slate-700 font-semibold border-b border-slate-200">
|
||||
<tr>
|
||||
<th class="px-4 py-2.5">Data Emissione</th>
|
||||
<th class="px-4 py-2.5">Data Scadenza</th>
|
||||
<th class="px-4 py-2.5">Gestione</th>
|
||||
<th class="px-4 py-2.5">Descrizione Rata</th>
|
||||
<th class="px-4 py-2.5 text-right">Dovuto (€)</th>
|
||||
<th class="px-4 py-2.5 text-right">Pagato (€)</th>
|
||||
<th class="px-4 py-2.5 text-right">Residuo (€)</th>
|
||||
<th class="px-4 py-2.5 text-center">Stato</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-100">
|
||||
@foreach($ecData['rate_emesse'] as $rE)
|
||||
<tr class="hover:bg-slate-50 transition">
|
||||
<td class="px-4 py-2 font-mono text-slate-600">{{ $rE['data_emissione'] }}</td>
|
||||
<td class="px-4 py-2 font-mono text-slate-800 font-semibold">{{ $rE['data_scadenza'] }}</td>
|
||||
<td class="px-4 py-2">
|
||||
<span class="inline-flex items-center rounded px-2 py-0.5 text-xs font-semibold bg-indigo-50 text-indigo-700">
|
||||
{{ $rE['gestione'] }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-4 py-2 font-medium text-slate-900">{{ $rE['descrizione'] }}</td>
|
||||
<td class="px-4 py-2 text-right font-mono font-medium text-slate-900">€ {{ number_format($rE['dovuto'], 2, ',', '.') }}</td>
|
||||
<td class="px-4 py-2 text-right font-mono font-medium text-emerald-700">€ {{ number_format($rE['pagato'], 2, ',', '.') }}</td>
|
||||
<td class="px-4 py-2 text-right font-mono font-bold {{ $rE['residuo'] > 0 ? 'text-rose-600' : 'text-slate-500' }}">
|
||||
€ {{ number_format($rE['residuo'], 2, ',', '.') }}
|
||||
</td>
|
||||
<td class="px-4 py-2 text-center">
|
||||
@if($rE['residuo'] <= 0 && $rE['dovuto'] > 0)
|
||||
<span class="inline-flex items-center rounded-full bg-emerald-100 px-2 py-0.5 text-xs font-semibold text-emerald-800">
|
||||
Saldata
|
||||
</span>
|
||||
@elseif($rE['pagato'] > 0)
|
||||
<span class="inline-flex items-center rounded-full bg-amber-100 px-2 py-0.5 text-xs font-semibold text-amber-800">
|
||||
Parziale
|
||||
</span>
|
||||
@else
|
||||
<span class="inline-flex items-center rounded-full bg-rose-100 px-2 py-0.5 text-xs font-semibold text-rose-800">
|
||||
Da Pagare
|
||||
</span>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot class="bg-slate-50 font-bold border-t border-slate-200">
|
||||
<tr>
|
||||
<td colspan="4" class="px-4 py-2.5 text-right text-slate-700">Totali Rate Emesse:</td>
|
||||
<td class="px-4 py-2.5 text-right font-mono text-slate-900">€ {{ number_format($ecData['totale_dovuto_rate'], 2, ',', '.') }}</td>
|
||||
<td class="px-4 py-2.5 text-right font-mono text-emerald-700">€ {{ number_format($ecData['totale_pagato_rate'], 2, ',', '.') }}</td>
|
||||
<td class="px-4 py-2.5 text-right font-mono text-rose-700">€ {{ number_format($ecData['totale_residuo_rate'], 2, ',', '.') }}</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
{{-- Tabella Incassi Registrati --}}
|
||||
<div class="rounded-xl border border-slate-200 bg-white overflow-hidden shadow-xs">
|
||||
<div class="border-b border-slate-200 bg-slate-50 px-4 py-3 font-semibold text-slate-800 text-sm flex items-center justify-between">
|
||||
<span>💵 Rate ed Incassi Effettuati</span>
|
||||
<span class="text-xs text-slate-500 font-normal">Estratti da incassi / inc_da_ec</span>
|
||||
<span>💵 Incassi Effettuati e Ricevute</span>
|
||||
<span class="text-xs text-slate-500 font-normal">Estratti da incassi / in_da_ec</span>
|
||||
</div>
|
||||
@if(empty($ecData['incassi']))
|
||||
<div class="p-6 text-center text-slate-500 text-xs">Nessun incasso registrato per questo nominativo.</div>
|
||||
|
|
@ -686,6 +757,12 @@ class="inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-semi
|
|||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot class="bg-slate-50 font-bold border-t border-slate-200">
|
||||
<tr>
|
||||
<td colspan="4" class="px-4 py-2.5 text-right text-slate-700">Totale Incassato:</td>
|
||||
<td class="px-4 py-2.5 text-right font-mono text-emerald-700">€ {{ number_format($ecData['totale_incassato'], 2, ',', '.') }}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
@endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user