@php $cfg = is_array($empresa->configuracoes ?? null) ? $empresa->configuracoes : []; $contextosFatura = is_array($contextosFatura ?? null) ? $contextosFatura : []; $contextoFaturaPrincipal = $contextosFatura[$faturamentos->first()->id_faturamento_locacao] ?? []; $parcelas = collect($contextoFaturaPrincipal['parcelas'] ?? []); $primeiroVencimento = optional($parcelas->sortBy('numero_parcela')->first())->data_vencimento ?? $faturamentos->first()->data_vencimento; $formatarData = static fn($data) => !empty($data) ? \Illuminate\Support\Carbon::parse((string) $data)->format('d/m/Y') : '-'; $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

FATURA EM LOTE Nº {{ str_pad($faturamentos->first()->id_faturamento_locacao, 6, '0', STR_PAD_LEFT) }}

{{ $faturamentos->count() }} LOCAÇÕES

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

DADOS DO CLIENTE
@if($faturamentos->first()->locacao->cliente)
Nome/Razão Social: {{ $faturamentos->first()->locacao->cliente->nome ?? $faturamentos->first()->locacao->cliente->razao_social ?? '-' }}
@if($faturamentos->first()->locacao->cliente->cpf ?? $faturamentos->first()->locacao->cliente->cnpj ?? null)
CPF/CNPJ: {{ $faturamentos->first()->locacao->cliente->cpf ?? $faturamentos->first()->locacao->cliente->cnpj ?? '-' }}
@endif @if($faturamentos->first()->locacao->cliente->endereco ?? null)
Endereço: {{ $faturamentos->first()->locacao->cliente->endereco }}
@endif @if($faturamentos->first()->locacao->cliente->telefone ?? null)
Telefone: {{ $faturamentos->first()->locacao->cliente->telefone }}
@endif @endif
DETALHAMENTO DAS LOCAÇÕES
@foreach($faturamentos as $index => $faturamento) @php $contexto = $contextosFatura[$faturamento->id_faturamento_locacao] ?? []; $isMedicaoFatura = (bool) ($contexto['is_medicao'] ?? false); $itensFatura = collect($contexto['itens'] ?? []); $periodoFaturaRotulo = $contexto['periodo_rotulo'] ?? ( optional($faturamento->locacao->data_inicio)->format('d/m/Y') . ' até ' . optional($faturamento->locacao->data_fim)->format('d/m/Y') ); $diasPeriodoFatura = $contexto['dias_periodo'] ?? null; @endphp
Locação {{ $index + 1 }} de {{ $faturamentos->count() }} - 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($faturamento->descricao ?? null)
Descrição: {{ $faturamento->descricao }}
@endif @if($itensFatura->count() > 0)
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 @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)
Desconto: - R$ {{ number_format($faturamento->locacao->valor_desconto, 2, ',', '.') }}
@endif @if($faturamento->locacao->valor_acrescimo ?? 0 > 0)
Acréscimo: + R$ {{ number_format($faturamento->locacao->valor_acrescimo, 2, ',', '.') }}
@endif @if($faturamento->locacao->valor_frete ?? 0 > 0)
Frete: + R$ {{ number_format($faturamento->locacao->valor_frete, 2, ',', '.') }}
@endif
Subtotal desta Locação: R$ {{ number_format($faturamento->valor_total, 2, ',', '.') }}
@if($faturamento->observacoes)
Observações: {{ $faturamento->observacoes }}
@endif
@endforeach
@php $totalGeral = $faturamentos->sum('valor_total'); @endphp
Quantidade de Locações: {{ $faturamentos->count() }}
VALOR TOTAL DO LOTE: R$ {{ number_format($totalGeral, 2, ',', '.') }}
INFORMAÇÕES DE PAGAMENTO
{{ $parcelas->count() > 1 ? '1º Vencimento:' : 'Vencimento:' }} {{ $formatarData($primeiroVencimento) }}
Status: @php $contaReceber = $faturamentos->first()->contaReceber; $status = $contaReceber->status ?? 'pendente'; $statusClass = $status === 'pago' ? 'status-pago' : 'status-pendente'; $statusLabel = $status === 'pago' ? 'PAGO' : 'PENDENTE'; @endphp {{ $statusLabel }}
@if($faturamentos->first()->locacao->forma_pagamento ?? null)
Forma de Pagamento: {{ $faturamentos->first()->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)

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

@endif
@endif