@extends('layouts.app') @section('title', 'Inicio') @section('content') {{-- ===== AI WIDGET ===== --}}
IA Activa
Asistente de Facturación IA
Describe en lenguaje natural la factura que quieres crear y la IA la generará automáticamente.
@if (session('ia_error'))
{{ session('ia_error') }}
@endif
@csrf
@if (session('ia_estado') === 'requiere_confirmacion') @php $iaPropuesta = session('ia_propuesta', []); $iaLineas = $iaPropuesta['lineas'] ?? []; $iaClientes = (array) session('ia_clientes', []); $iaSeries = (array) session('ia_series', []); $baseTotal = 0; $ivaTotal = 0; $totalTotal = 0; foreach ($iaLineas as $l) { $base = (float)($l['cantidad'] ?? 0) * (float)($l['precio_unitario'] ?? 0); $iva = $base * ((float)($l['iva_porcentaje'] ?? 0) / 100); $baseTotal += $base; $ivaTotal += $iva; $totalTotal += $base + $iva; } @endphp
{{-- Header de propuesta --}}
Propuesta generada por IA
Revisa los datos y confirma para emitir la factura
{{-- Cliente detectado --}}
Cliente detectado
{{ session('ia_cliente_detectado') }}
{{-- Tabla de líneas --}} @if (count($iaLineas) > 0)
Líneas de factura
@foreach ($iaLineas as $l) @php $lBase = (float)($l['cantidad'] ?? 0) * (float)($l['precio_unitario'] ?? 0); $lIva = $lBase * ((float)($l['iva_porcentaje'] ?? 0) / 100); @endphp @endforeach
Concepto Cant. P. Unit. IVA Total
{{ $l['concepto'] ?? '—' }} {{ $l['cantidad'] ?? 0 }} {{ number_format((float)($l['precio_unitario'] ?? 0), 2, ',', '.') }} € {{ (int)($l['iva_porcentaje'] ?? 0) }}% {{ number_format($lBase + $lIva, 2, ',', '.') }} €
{{-- Resumen de totales --}}
Base imponible {{ number_format($baseTotal, 2, ',', '.') }} €
IVA {{ number_format($ivaTotal, 2, ',', '.') }} €
TOTAL {{ number_format($totalTotal, 2, ',', '.') }} €
@endif {{-- Formulario de confirmación (sin botones dentro) --}}
@csrf @if ($errors->any())
{{ $errors->first() }}
@endif
@php $iaClienteSugeridoId = session('ia_cliente_sugerido_id'); @endphp
@php $iaSerieSugeridaId = session('ia_serie_sugerida_id') ?? ($iaSeries[0]['id'] ?? null); @endphp
{{-- Form de cancelar separado + botón de confirmar vinculado por form= --}}
@elseif (session('ia_estado') === 'requiere_confirmacion_presupuesto') @php $iaPropuesta = session('ia_presupuesto_propuesta', []); $iaLineas = $iaPropuesta['lineas'] ?? []; $iaClientes = (array) session('ia_clientes', []); $baseTotal = 0; $ivaTotal = 0; $totalTotal = 0; foreach ($iaLineas as $l) { $base = (float)($l['cantidad'] ?? 0) * (float)($l['precio_unitario'] ?? 0); $iva = $base * ((float)($l['iva_porcentaje'] ?? 0) / 100); $baseTotal += $base; $ivaTotal += $iva; $totalTotal += $base + $iva; } @endphp
{{-- Header de propuesta --}}
Propuesta generada por IA
Revisa los datos y confirma para crear el presupuesto
{{-- Cliente detectado --}}
Cliente detectado
{{ session('ia_cliente_detectado') }}
{{-- Tabla de líneas --}} @if (count($iaLineas) > 0)
Líneas de presupuesto
@foreach ($iaLineas as $l) @php $lBase = (float)($l['cantidad'] ?? 0) * (float)($l['precio_unitario'] ?? 0); $lIva = $lBase * ((float)($l['iva_porcentaje'] ?? 0) / 100); @endphp @endforeach
Concepto Cant. P. Unit. IVA Total
{{ $l['concepto'] ?? '—' }} {{ $l['cantidad'] ?? 0 }} {{ number_format((float)($l['precio_unitario'] ?? 0), 2, ',', '.') }} € {{ (int)($l['iva_porcentaje'] ?? 0) }}% {{ number_format($lBase + $lIva, 2, ',', '.') }} €
{{-- Resumen de totales --}}
Base imponible {{ number_format($baseTotal, 2, ',', '.') }} €
IVA {{ number_format($ivaTotal, 2, ',', '.') }} €
TOTAL {{ number_format($totalTotal, 2, ',', '.') }} €
@endif {{-- Formulario de confirmación --}}
@csrf @if ($errors->any())
{{ $errors->first() }}
@endif
@php $iaClienteSugeridoId = session('ia_cliente_sugerido_id'); @endphp
@elseif (session('ia_estado') === 'requiere_confirmacion_cliente') @php $iaCliente = session('ia_cliente_propuesta', []); @endphp
{{-- Header de propuesta --}}
Propuesta de Nuevo Cliente (IA)
Revisa y completa los datos antes de guardarlo
@csrf @if ($errors->any())
{{ $errors->first() }}
@endif
@endif
{{-- ===== KPI CARDS ===== --}}
{{-- Este mes --}}
Este mes — Total
{{ number_format($mes->total ?? 0, 2, ',', '.') }} €
Base {{ number_format($mes->base ?? 0, 2, ',', '.') }} € · IVA {{ number_format($mes->iva ?? 0, 2, ',', '.') }} €
{{-- Este trimestre --}}
Este trimestre — Total
{{ number_format($trimestre->total ?? 0, 2, ',', '.') }} €
Base {{ number_format($trimestre->base ?? 0, 2, ',', '.') }} € · IVA {{ number_format($trimestre->iva ?? 0, 2, ',', '.') }} €
{{-- Estado --}}
Facturas emitidas
{{ $emitidas }}
{{ $borradores }} borradores pendientes
{{-- Acciones rápidas --}}

Acciones rápidas

Nueva factura Ver facturas Facturas recurrentes Configurar empresa
{{-- ===== ÚLTIMAS FACTURAS ===== --}}
Últimas facturas emitidas Ver todas
@forelse ($ultimas as $f) @empty @endforelse
Número Cliente Fecha Total
{{ $f->serie->codigo }}-{{ $f->numero }} {{ $f->cliente->nombre_fiscal }} {{ \Carbon\Carbon::parse($f->fecha_emision)->format('d/m/Y') }} {{ number_format($f->total, 2, ',', '.') }} €

Aún no hay facturas emitidas.

{{-- ===== ÚLTIMOS PRESUPUESTOS ===== --}} @php $estadoColor = [ 'borrador' => 'badge-gray', 'enviado' => 'badge-primary', 'aceptado' => 'badge-success', 'rechazado' => 'badge-warning', 'facturado' => 'badge-success', ]; @endphp
Últimos presupuestos Ver todos
@forelse ($ultimosPresupuestos as $p) @empty @endforelse
Número Cliente Fecha Estado Total
{{ $p->numero_formateado }} {{ $p->cliente->nombre_fiscal }} {{ \Carbon\Carbon::parse($p->fecha_emision)->format('d/m/Y') }} {{ ucfirst($p->estado) }} {{ number_format($p->total, 2, ',', '.') }} €

Aún no hay presupuestos.

@endsection