@php $bill = $record->bill; $transactions = $bill?->bodies ?? collect(); $client = $record->client; $clientInvoices = \App\Models\InvoicesHeaderModel::with('bill')->where('client_id', $client->id_client)->get(); $total = $clientInvoices->sum('total_rd'); $pagado = $clientInvoices->sum(fn($invoice) => $invoice->bill?->paid_rd ?? 0); $deuda = $total - $pagado; @endphp
{{-- Tabla de Factura --}}
Factura Total RD$ Total USD$ Pagado RD$ Pagado USD$ Pendiente de pago RD$ Pendiente de pago USD$
{{ $record->invoice_number }} {{ number_format($record->total_rd, 2) }} {{ number_format($record->total_usd, 2) }} {{ number_format($bill?->paid_rd ?? 0, 2) }} {{ number_format($bill?->paid_usd ?? 0, 2) }} {{ number_format($bill?->bill_rd ?? 0, 2) }} {{ number_format($bill?->bill_usd ?? 0, 2) }}
{{-- Tabla de Transacciones --}}
@if ($transactions->isEmpty())

— Sin transacciones —

@else @foreach ($transactions as $transaction) @switch($transaction->status) @case('paid_cash') @break @case('paid_transfer') @break @default @endswitch @endforeach
Pago RD$ Pago USD$ Tasa Meotodo de pago Fecha de pago
{{ number_format($transaction->paid_rd, 2) }} {{ number_format($transaction->paid_usd, 2) }} {{ $transaction->change_rate }}EfectivoTransferencia {{ \Carbon\Carbon::parse($transaction->created_at)->format('d-m-Y h:i') }}
@endif