@extends('layouts.enterprise') @section('title', 'Listado de facturas') @section('content')

Listado de facturas

Gestión de facturas para carga de comprobantes y cambio a pagada.

@if(session('ok'))
{{ session('ok') }}
@endif @if($errors->any())
@endif @php $hasActiveFilters = (($filters['q'] ?? '') !== '') || (($filters['status'] ?? 'all') !== 'all') || (($filters['from'] ?? '') !== '') || (($filters['to'] ?? '') !== ''); @endphp
Filtros @if($hasActiveFilters) Activos @endif
Limpiar
@forelse($invoices as $invoice) @php $proof = $invoice->files->first(); $isRejected = $invoice->status === \App\Models\Invoice::STATUS_REJECTED; $providerMatch = (array) data_get($invoice->pipefy_payload, 'provider_match', []); $providerTrackableTotal = (int) ($providerMatch['provider_trackable_items_total'] ?? 0); $providerCoveredAfter = (int) ($providerMatch['provider_items_covered_after'] ?? 0); $providerPendingAfter = (int) ($providerMatch['provider_items_pending_after'] ?? max($providerTrackableTotal - $providerCoveredAfter, 0)); $isPartialForProvider = $providerTrackableTotal > 0 ? (bool) ($providerMatch['is_partial_for_provider'] ?? false) : null; $providerFinancialKey = ($invoice->pipefy_request_id && $invoice->pipefy_request_provider_id) ? ((int) $invoice->pipefy_request_id.'|'.(int) $invoice->pipefy_request_provider_id) : null; $providerAmounts = $providerFinancialKey ? ($providerFinancials[$providerFinancialKey] ?? null) : null; $pendingAmount = $providerAmounts['pending_total_sale'] ?? null; $coveredAmount = $providerAmounts['invoiced_total'] ?? null; $canManagePayment = in_array($invoice->status, [ \App\Models\Invoice::STATUS_APPROVED, \App\Models\Invoice::STATUS_SCHEDULED, \App\Models\Invoice::STATUS_PAID, ], true); $canUploadPaymentProof = $canManagePayment && !$proof; $stepOneLabel = 'Paso 1: Selecciona el comprobante'; $stepTwoLabel = 'Paso 2: Subir comprobante y marcar pagada'; @endphp @empty @endforelse
ID Proveedor RC JN Estatus Monto facturado Monto pendiente Fecha pago Comprobante Acciones
{{ $invoice->id }} {{ $invoice->company?->legal_name }} {{ $invoice->rc_number }} {{ $invoice->pipefyRequest?->title ?: ($invoice->jn_number ?: '-') }} @if($invoice->pipefyRequest?->project_name)
{{ $invoice->pipefyRequest->project_name }} @endif
{{ $invoice->status }} @if($isPartialForProvider !== null) @if($isPartialForProvider) Parcial (pendientes {{ $providerPendingAfter }}) @else Completa ({{ $providerCoveredAfter }}/{{ $providerTrackableTotal }}) @endif @endif ${{ number_format((float) $invoice->total, 2) }} @if($pendingAmount !== null) ${{ number_format((float) $pendingAmount, 2) }} @if($coveredAmount !== null) Acumulado: ${{ number_format((float) $coveredAmount, 2) }} @endif @else - @endif {{ $isRejected ? '-' : optional($invoice->payment_date)->format('Y-m-d') }} @if($isRejected) - @elseif($proof) Ver comprobante @else Sin comprobante @endif @if($isRejected) - @elseif($canManagePayment)
@if($canUploadPaymentProof)
@csrf
Ningún archivo seleccionado
@else Comprobante ya cargado @endif
@else Disponible al aprobar @endif
No hay facturas registradas.
{{ $invoices->onEachSide(1)->links('vendor.pagination.enterprise') }}
@endsection @push('scripts') @endpush @push('styles') @endpush