@extends('layouts.app') @section('title', 'Facturas de Venta') @section('content')
Gestión y seguimiento de facturas de venta
| N° Factura | Cliente | Vendedor | Fecha | Vencimiento | Monto a Cobrar | Pagado | Pendiente | Estado | Acciones |
|---|---|---|---|---|---|---|---|---|---|
| {{ $invoice->invoice_number }} |
@if($invoice->client)
{{ Str::limit($invoice->client->business_name, 30) }}
@if($invoice->client->legal_name)
{{ Str::limit($invoice->client->legal_name, 25) }}
@endif
|
@if($invoice->salesman) {{ $invoice->salesman->first_name }} {{ $invoice->salesman->last_name }} @else N/A @endif | {{ $invoice->invoice_date ? $invoice->invoice_date->format('d/m/Y') : 'N/A' }} | @if($invoice->due_date) {{ $invoice->due_date->format('d/m/Y') }} @else N/A @endif | @php // Monto a cobrar: total_legal (USD) si existe, sino total_amount_usd, sino total_amount $amountToCollect = $invoice->total_legal ?? $invoice->total_amount_usd ?? $invoice->total_amount; @endphp ${{ number_format($amountToCollect, 2) }} | @php // Pagado: convertir a USD si es necesario $paidUSD = $invoice->amount_paid; if ($invoice->currency !== 'USD' && $invoice->total_legal > 0 && $invoice->total_amount > 0) { $rate = $invoice->total_amount / $invoice->total_legal; $paidUSD = $invoice->amount_paid / $rate; } @endphp ${{ number_format($paidUSD, 2) }} | @php // Pendiente: monto a cobrar - pagado $pending = $amountToCollect - $paidUSD; @endphp ${{ number_format(max(0, $pending), 2) }} | @php $statusConfig = [ 'draft' => ['class' => 'secondary', 'icon' => 'edit', 'label' => 'Borrador'], 'sent' => ['class' => 'primary', 'icon' => 'paper-plane', 'label' => 'Procesada'], 'paid' => ['class' => 'success', 'icon' => 'check-circle', 'label' => 'Pagada'], 'overdue' => ['class' => 'danger', 'icon' => 'exclamation-triangle', 'label' => 'Vencida'] // Las facturas no se cancelan, se devuelven mediante notas de crédito ]; $status = $statusConfig[$invoice->status] ?? ['class' => 'secondary', 'icon' => 'circle', 'label' => ucfirst($invoice->status)]; @endphp {{ $status['label'] }} | |