@props([ 'sale' => null, 'saleId' => null, 'show' => false, 'closeAction' => 'closeReceiptModal', ]) @php if (!$sale && !empty($saleId)) { $sale = \App\Models\Sale::with(['customer', 'items.productVariant.product', 'user', 'location', 'receivable.payments'])->find($saleId); } if ($sale) { $sale->loadMissing(['customer', 'items.productVariant.product', 'user', 'location', 'receivable.payments']); } @endphp @if($show && $sale) @php $isCredit = $sale->isCredit(); $isQuote = $sale->isQuote(); $itemsSum = (float) $sale->items->sum(fn ($i) => (float) $i->subtotal_price_usdt); $totalUsdBcv = $itemsSum > 0 ? $itemsSum : (float) ($sale->usd_bcv_total ?? $sale->total_amount_usdt); $invoiceSettings = \App\Services\InvoiceSettingsService::getSettings(); // Obtener tasa oficial BCV actual real y evitar sobreescritura con 1.00 de ventas en divisas $rateService = app(\App\Services\ExchangeRateIngestionService::class); $bcvRates = $rateService->getAllCurrentRates(); $officialBcvRate = (float) ($bcvRates['VES_BCV'] ?? 70.0); if ($officialBcvRate <= 0) { $officialBcvRate = (float) (\App\Models\ExchangeRate::where('currency_code', 'VES')->where('rate_type', 'bcv')->latest('created_at')->value('rate') ?? 70.0); } $historicalRate = (float) ($sale->exchange_rate_applied ?? 0); $rateApplied = ($historicalRate > 1.0) ? $historicalRate : $officialBcvRate; $totalBs = $totalUsdBcv * $rateApplied; $docTitle = $isQuote ? 'PRESUPUESTO / COTIZACIÓN' : ($isCredit ? 'FACTURA DE VENTA A CRÉDITO' : 'Factura / Comprobante de Venta Fiscal'); $receivable = $sale->receivable; $paidAmount = $receivable ? (float)$receivable->paid_amount_usdt : ($isCredit ? 0.0 : $totalUsdBcv); $pendingBalance = $receivable ? (float)$receivable->remaining_balance_usdt : ($isCredit ? $totalUsdBcv : 0.0); @endphp
R.I.F. {{ $invoiceSettings['rif'] }} • {{ $invoiceSettings['tax_condition'] }}
{{ $invoiceSettings['fiscal_address'] }} • Tel: {{ $invoiceSettings['phone'] }}
{{ $sale->customer?->name ?: 'Cliente Ocasional / Vitrina' }}
C.I. / RIF: {{ $sale->customer?->identification_number ?: 'V-No Registrado' }}
@if($sale->customer?->phone)Tel / WhatsApp: {{ $sale->customer->phone }}
@endifSucursal / Almacén: {{ $sale->location?->name ?: 'Depósito Central Caracas' }}
Atendido por: {{ $sale->user?->name ?: 'Personal de Tienda' }}
@if($sale->delivery_address)Despacho: {{ $sale->delivery_address }}
@endif| Cant. | Descripción de la Prenda / SKU | P. Unitario | Total ($ BCV) |
|---|---|---|---|
| {{ (int)$item->quantity }}x | {{ $item->variant?->display_name ?: ($item->variant?->name ?: 'Prenda Kairos') }} SKU: {{ $item->variant?->sku ?: 'SKU-'.$item->id }} | ${{ number_format($unitPrice, 2) }} | ${{ number_format($subtotalItem, 2) }} |
| Sin prendas en la factura. | |||
* Los abonos se registrarán en Bolívares a la tasa oficial del BCV del día en que se efectúe el pago, o en divisas acordadas.
Nota / Referencia: {{ $sale->payment_notes }}
@endif