@php $cfg = is_array($empresa->configuracoes ?? null) ? $empresa->configuracoes : []; $contextoFatura = $contextoFatura ?? []; $isMedicaoFatura = (bool) ($contextoFatura['is_medicao'] ?? false); $itensFatura = collect($contextoFatura['itens'] ?? []); $parcelas = collect($contextoFatura['parcelas'] ?? []); $primeiroVencimento = optional($parcelas->sortBy('numero_parcela')->first())->data_vencimento ?? $faturamento->data_vencimento; $formatarData = static fn($data) => !empty($data) ? \Illuminate\Support\Carbon::parse((string) $data)->format('d/m/Y') : '-'; $periodoFaturaRotulo = $contextoFatura['periodo_rotulo'] ?? ( optional($faturamento->locacao->data_inicio)->format('d/m/Y') . ' até ' . optional($faturamento->locacao->data_fim)->format('d/m/Y') ); $diasPeriodoFatura = $contextoFatura['dias_periodo'] ?? null; $logoSrc = \App\Helpers\PdfAssetHelper::resolveCompanyConfigImage($empresa, 'logo_url', true); @endphp
@if($logoSrc) Logo @endif @if($empresa)

{{ $empresa->razao_social ?? $empresa->nome_fantasia ?? 'Empresa' }}

@if($empresa->cnpj)

CNPJ: {{ $empresa->cnpj }}

@endif @if($empresa->endereco)

{{ $empresa->endereco }}@if($empresa->cidade), {{ $empresa->cidade }}@endif @if($empresa->uf)- {{ $empresa->uf }}@endif

@endif @if($empresa->telefone)

Tel: {{ $empresa->telefone }}

@endif @endif

{{ $isMedicaoFatura ? 'FATURA DE MEDIÇÃO' : 'FATURA DE LOCAÇÃO' }} Nº {{ str_pad($faturamento->id_faturamento_locacao, 6, '0', STR_PAD_LEFT) }}

Data: {{ $faturamento->data_faturamento->format('d/m/Y') }}

DADOS DO CLIENTE
@if($faturamento->locacao->cliente)
Nome/Razão Social: {{ $faturamento->locacao->cliente->nome ?? $faturamento->locacao->cliente->razao_social ?? '-' }}
@if($faturamento->locacao->cliente->cpf ?? $faturamento->locacao->cliente->cnpj ?? null)
CPF/CNPJ: {{ $faturamento->locacao->cliente->cpf ?? $faturamento->locacao->cliente->cnpj ?? '-' }}
@endif @if($faturamento->locacao->cliente->endereco ?? null)
Endereço: {{ $faturamento->locacao->cliente->endereco }}
@endif @if($faturamento->locacao->cliente->telefone ?? null)
Telefone: {{ $faturamento->locacao->cliente->telefone }}
@endif @endif
DADOS DA LOCAÇÃO
Contrato: #{{ $faturamento->locacao->numero_contrato ?? $faturamento->locacao->id_locacao }}
Período: {{ $periodoFaturaRotulo }}
@if($isMedicaoFatura)
Tipo de Fatura: Medição @if($diasPeriodoFatura) ({{ $diasPeriodoFatura }} dia(s)) @endif
@endif @if($faturamento->locacao->local_evento ?? null)
Local do Evento: {{ $faturamento->locacao->local_evento }}
@endif
@if($itensFatura->count() > 0)
ITENS DA LOCAÇÃO - PRODUTOS
@if($isMedicaoFatura) @endif @foreach($itensFatura as $item) @if($isMedicaoFatura) @endif @endforeach
Qtd ProdutoDiasValor Unit. Subtotal
{{ $item['quantidade'] ?? 1 }} {{ $item['produto'] ?? 'Produto' }}{{ $item['dias'] ?? '-' }}R$ {{ number_format((float) ($item['valor_unitario'] ?? 0), 2, ',', '.') }} R$ {{ number_format((float) ($item['subtotal'] ?? 0), 2, ',', '.') }}
@endif @if($faturamento->locacao->servicos && $faturamento->locacao->servicos->count() > 0)
SERVIÇOS ADICIONAIS
@foreach($faturamento->locacao->servicos as $servico) @endforeach
Qtd Serviço Valor Unit. Subtotal
{{ $servico->quantidade ?? 1 }} {{ $servico->descricao ?? 'Serviço' }} R$ {{ number_format($servico->valor ?? 0, 2, ',', '.') }} R$ {{ number_format(($servico->quantidade ?? 1) * ($servico->valor ?? 0), 2, ',', '.') }}
@endif
@if($faturamento->locacao->valor_desconto ?? 0 > 0) @endif @if($faturamento->locacao->valor_acrescimo ?? 0 > 0) @endif @if($faturamento->locacao->valor_frete ?? 0 > 0) @endif
Desconto: - R$ {{ number_format($faturamento->locacao->valor_desconto, 2, ',', '.') }}
Acréscimo: R$ {{ number_format($faturamento->locacao->valor_acrescimo, 2, ',', '.') }}
Frete: R$ {{ number_format($faturamento->locacao->valor_frete, 2, ',', '.') }}
VALOR TOTAL: R$ {{ number_format($faturamento->valor_total, 2, ',', '.') }}
INFORMAÇÕES DE PAGAMENTO
{{ $parcelas->count() > 1 ? '1º Vencimento:' : 'Vencimento:' }} {{ $formatarData($primeiroVencimento) }}
Status: @php $status = $faturamento->contaReceber->status ?? 'pendente'; $statusClass = $status === 'pago' ? 'status-pago' : 'status-pendente'; $statusLabel = $status === 'pago' ? 'PAGO' : 'PENDENTE'; @endphp {{ $statusLabel }}
@if($faturamento->locacao->forma_pagamento ?? null)
Forma de Pagamento: {{ $faturamento->locacao->forma_pagamento }}
@endif
@if($parcelas->count() > 0)
VENCIMENTOS DAS CONTAS
@foreach($parcelas as $parcela) @endforeach
Parcela Documento/Referência Vencimento Valor
{{ $parcela->numero_parcela ?? 1 }}/{{ $parcela->total_parcelas ?? 1 }} {{ $parcela->documento ?? '-' }} {{ $formatarData($parcela->data_vencimento ?? null) }} R$ {{ number_format((float) ($parcela->valor_total ?? 0), 2, ',', '.') }}
Total das Parcelas: R$ {{ number_format($parcelas->sum('valor_total'), 2, ',', '.') }}
@if($parcelas->count() > 1)

* Esta fatura foi parcelada em {{ $parcelas->count() }} vezes. Cada parcela possui data de vencimento própria conforme tabela acima.

@endif
@endif @if($faturamento->observacoes || $faturamento->locacao->observacoes)
OBSERVAÇÕES

{{ $faturamento->observacoes ?? $faturamento->locacao->observacoes }}

@endif