@extends('adminlte::page') @section('title', 'Historial de Precios - ' . $producto->codigo_producto) @section('content_header')

Historial de Precios: {{ $producto->codigo_producto }}

@stop @section('content')
Información del Producto

Código: {{ $producto->codigo_producto }}
Descripción: {{ $producto->descripcion }}
Precio Base Actual: S/ {{ number_format($producto->precio_base, 2) }}
Precio Venta: S/ {{ number_format($producto->precio_venta, 2) }}
Resumen del Historial

Total de Cambios: {{ $historial->total() }}
Último Cambio: @if($historial->count() > 0) {{ $historial->first()->created_at->format('d/m/Y H:i') }} @else Sin cambios registrados @endif

Historial de Cambios de Precio Base
@if($historial->count() > 0)
@foreach($historial as $index => $item) @endforeach
# Fecha y Hora Usuario Precio Anterior Precio Nuevo Diferencia Cotización Observaciones
{{ $historial->firstItem() + $index }} {{ $item->created_at->format('d/m/Y H:i:s') }} {{ $item->usuario->name ?? 'N/A' }} S/ {{ number_format($item->precio_base_anterior, 2) }} S/ {{ number_format($item->precio_base_nuevo, 2) }} @php $diferencia = $item->precio_base_nuevo - $item->precio_base_anterior; $porcentaje = $item->precio_base_anterior > 0 ? (($diferencia / $item->precio_base_anterior) * 100) : 0; @endphp {{ $diferencia >= 0 ? '+' : '' }}S/ {{ number_format($diferencia, 2) }} ({{ $diferencia >= 0 ? '+' : '' }}{{ number_format($porcentaje, 2) }}%) @if($item->cotizacion) {{ $item->cotizacion->numero_cotizacion }} @else - @endif {{ $item->observaciones ?? '-' }}
{{ $historial->links() }}
@else
No se han registrado cambios en el precio base de este producto.
@endif
@stop @section('css') @stop @section('js') @stop