Fattura
{{ $fattura->numero_fattura }}
Data
{{ optional($fattura->data_fattura)->format('d/m/Y') }}
Scadenza
{{ optional($fattura->data_scadenza)->format('d/m/Y') ?: '—' }}
Stato
{{ $fattura->stato }}
@php $modalitaLabel = $this->getPagamentoModalitaXsdLabel(); @endphp @if(is_string($fattura->pagamento_modalita) && trim($fattura->pagamento_modalita) !== '')
Modalità pagamento
{{ trim($fattura->pagamento_modalita) }}
@if($modalitaLabel)
{{ $modalitaLabel }}
@endif @if(auth()->user()?->hasRole('super-admin')) @endif
@endif @if(!empty($fattura->consumo_valore) || (is_string($fattura->consumo_riferimento) && trim($fattura->consumo_riferimento) !== ''))
Consumo (acqua)
{{ $fattura->consumo_valore !== null ? number_format((float) $fattura->consumo_valore, 3, ',', '.') : '—' }} {{ $fattura->consumo_unita ?: 'mc' }}
@if(is_string($fattura->consumo_riferimento) && trim($fattura->consumo_riferimento) !== '')
{{ trim($fattura->consumo_riferimento) }}
@endif
@endif
Fornitore (da XML)
{{ $fattura->fornitore_denominazione }}
P.IVA
{{ $fattura->fornitore_piva ?: '—' }}
C.F.
{{ $fattura->fornitore_cf ?: '—' }}
Fornitore agganciato
{{ $this->getFornitoreAgganciatoLabel() ?: '—' }}
@php $xmlOk = is_string($fattura->xml_content ?? null) ? trim((string) $fattura->xml_content) !== '' : false; $pdfOk = (is_string($fattura->allegato_pdf_path ?? null) && trim((string) $fattura->allegato_pdf_path) !== '') || (is_string($fattura->allegato_pdf_hash ?? null) && trim((string) $fattura->allegato_pdf_hash) !== '') || (isset($this->documento) && $this->documento); @endphp
@if($pdfOk) Scarica PDF @endif @if($xmlOk) Scarica FE XML @endif
Importi
Imponibile
€ {{ number_format((float) $fattura->imponibile, 2, ',', '.') }}
IVA
€ {{ number_format((float) $fattura->iva, 2, ',', '.') }}
Totale
€ {{ number_format((float) $fattura->totale, 2, ',', '.') }}
@php $ritenuta = is_array($xmlDetails['ritenuta'] ?? null) ? $xmlDetails['ritenuta'] : []; $ritenutaImporto = (float) ($ritenuta['importo'] ?? 0); $ritenutaAliquota = $ritenuta['aliquota'] ?? null; $ritenutaTipo = $ritenuta['tipo'] ?? null; $ritenutaCausale = $ritenuta['causale'] ?? null; $nettoDaPagare = round(((float) $fattura->totale) - $ritenutaImporto, 2); $scadenzaVersamento = null; if ($ritenutaImporto > 0 && $fattura->data_fattura) { $scadenzaVersamento = optional($fattura->data_fattura)->copy()->addMonthNoOverflow()->day(16); } @endphp @if($ritenutaImporto > 0)
Ritenuta d'acconto
Importo
€ {{ number_format($ritenutaImporto, 2, ',', '.') }}
Aliquota
{{ $ritenutaAliquota !== null ? number_format((float) $ritenutaAliquota, 2, ',', '.') . '%' : '—' }}
Tipo
{{ $ritenutaTipo ?: '—' }}
Causale
{{ $ritenutaCausale ?: '—' }}
Netto da pagare
€ {{ number_format($nettoDaPagare, 2, ',', '.') }}
Versamento (indicativo)
{{ $scadenzaVersamento ? $scadenzaVersamento->format('d/m/Y') : '—' }}
@endif
Documento
PDF allegato (se presente) oppure prospetto generato
@if($this->documento)
Protocollo: {{ $this->documentoProtocolloConAnno ?: $this->documento->numero_protocollo }} ·
@php $ocr = is_string($this->documento->contenuto_ocr ?? null) ? trim((string) $this->documento->contenuto_ocr) : ''; @endphp @if($ocr !== '')
Testo PDF estratto: presente ({{ number_format(mb_strlen($ocr), 0, ',', '.') }} caratteri)
@endif @else
Nessun Documento collegato
@endif
@php $pdfPath = is_string($fattura->allegato_pdf_path) ? trim($fattura->allegato_pdf_path) : ''; $pdfHash = is_string($fattura->allegato_pdf_hash ?? null) ? trim((string) $fattura->allegato_pdf_hash) : ''; $hasXml = is_string($fattura->xml_content ?? null) ? trim((string) $fattura->xml_content) !== '' : false; $docPdfPath = ''; if ($this->documento) { $docPdfPath = is_string($this->documento->percorso_file) ? trim($this->documento->percorso_file) : ''; if ($docPdfPath === '') { $docPdfPath = is_string($this->documento->path_file) ? trim($this->documento->path_file) : ''; } } // Se abbiamo un riferimento (path/hash) o l'XML, proviamo comunque a mostrare l'iframe: // l'endpoint download-pdf fa auto-repair/rigenerazione se lo storage è stato pulito. // Evita di mostrare l'iframe quando non c'è alcun PDF agganciato: in quel caso la rotta scarica-pdf andrà in 404. $pdfOk = ($pdfPath !== '' || $docPdfPath !== '' || $pdfHash !== ''); $righe = is_array($xmlDetails['righe'] ?? null) ? $xmlDetails['righe'] : []; $escludiRigheFe = (bool) ($fattura->fornitore?->escludi_righe_fe ?? false); @endphp @if($pdfOk)
@else
PDF non disponibile (mancante o non ancora spostato nel percorso corretto). Usa “Completa” per riparare/aggiornare.
@endif @if($this->documento)
Documento protocollato (PDF)
@endif
Fornitore
{{ $fattura->fornitore_denominazione }}
P.IVA {{ $fattura->fornitore_piva ?: '—' }} · CF {{ $fattura->fornitore_cf ?: '—' }}
Fattura
{{ $fattura->numero_fattura }}
{{ optional($fattura->data_fattura)->format('d/m/Y') }}
@if($escludiRigheFe)
Righe FE non visualizzate: il fornitore ha attiva l'opzione “Escludi righe FE”.
@elseif(count($righe) > 0)
@foreach($righe as $r) @endforeach
Riga Descrizione Q.tà Totale IVA% RA
{{ $r['numero_linea'] ?? '—' }} {{ $r['descrizione'] ?? '—' }} {{ isset($r['quantita']) ? number_format((float) $r['quantita'], 2, ',', '.') : '—' }} € {{ isset($r['prezzo_totale']) ? number_format((float) $r['prezzo_totale'], 2, ',', '.') : '—' }} {{ isset($r['aliquota_iva']) ? number_format((float) $r['aliquota_iva'], 2, ',', '.') : '—' }} {{ ($r['ritenuta'] ?? false) ? 'SI' : '—' }}
@endif
Totale documento
€ {{ number_format((float) $fattura->totale, 2, ',', '.') }}
Dati destinatario
Da XML (DatiTrasmissione / CessionarioCommittente) + riferimenti stabile
@php $cfStabileNorm = strtoupper(str_replace(' ', '', (string) ($fattura->stabile?->codice_fiscale ?? ''))); $cfDestNorm = strtoupper(str_replace(' ', '', (string) ($fattura->destinatario_cf ?? ''))); $cfOk = ($cfStabileNorm !== '' && $cfDestNorm !== '' && $cfStabileNorm === $cfDestNorm); @endphp
@if($cfOk) Filtro CF stabile: OK. Questa FE e coerente con lo stabile attivo. @else Filtro CF stabile: non allineato. La lettura guidata PDF acqua viene bloccata finche CF stabile e CF destinatario FE non coincidono. @endif
Stabile
{{ $fattura->stabile?->codice_stabile ? ($fattura->stabile->codice_stabile . ' - ' . $fattura->stabile->denominazione) : '—' }}
CF stabile
{{ $fattura->stabile?->codice_fiscale ?: '—' }}
CF destinatario
{{ $fattura->destinatario_cf ?: '—' }}
Destinatario
{{ $fattura->destinatario_denominazione ?: '—' }}
Codice destinatario
{{ $fattura->codice_destinatario ?: '—' }}
PEC destinatario
{{ $fattura->pec_destinatario ?: '—' }}
SDI stabile
{{ $fattura->stabile?->codice_destinatario_sdi ?: '—' }}
PEC stabile
{{ $fattura->stabile?->pec_condominio ?: ($fattura->stabile?->pec_amministratore ?: '—') }}
@php $tx = is_array($xmlDetails['trasmissione'] ?? null) ? $xmlDetails['trasmissione'] : []; $idPaese = $tx['id_paese'] ?? null; $idCodice = $tx['id_codice'] ?? null; $progressivo = $tx['progressivo_invio'] ?? null; $formato = $tx['formato_trasmissione'] ?? null; @endphp
IdTrasmittente
{{ ($idPaese && $idCodice) ? ($idPaese . $idCodice) : '—' }}
Progressivo invio
{{ $progressivo ?: '—' }}
Formato trasmissione
{{ $formato ?: '—' }}
@if(!empty($fattura->xml_content))
XML importato
{{ $fattura->xml_content }}
@endif @php $preview = is_array($acquaPdfPreview ?? null) ? $acquaPdfPreview : []; $rawText = is_string($preview['raw_text'] ?? null) ? $preview['raw_text'] : ''; $parsed = is_array($preview['parsed'] ?? null) ? $preview['parsed'] : []; @endphp @if($preview !== [])
Lettura PDF Acqua (Guidata)
Anteprima dati estratti dalla FE #{{ $preview['fattura_id'] ?? $fattura->id }} del {{ $preview['generated_at'] ?? '—' }}
CF stabile: {{ $preview['stabile_cf'] ?? '—' }} · CF destinatario FE: {{ $preview['destinatario_cf'] ?? '—' }}
JSON parser acqua (ordinato)
{{ json_encode($parsed, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) }}
Testo OCR PDF estratto (completo anteprima)
Caratteri: {{ number_format((int) ($preview['chars'] ?? 0), 0, ',', '.') }} @if(($preview['truncated'] ?? false) === true) · mostrati i primi {{ number_format(mb_strlen($rawText), 0, ',', '.') }} @endif
{{ $rawText }}
@endif