@extends('layouts.page') @section('head') @include('elements.seo', ['title'=>'Ordenes' ]) @endsection @section('content')

Orden #{{$order->id}}

Cliente: {{$order->user->name}}
Fecha: {{$order->created_at->subHour(5)->format('Y-m-d H:i')}}
Estado:
Productos: {{$order->products->count()}}
Unidades: {{$order->products->sum('quantity')}}
@foreach ($order->products as $product) @endforeach @php $totalTax = 0; $subtotalBeforeTax = 0; foreach ($order->products as $orderProduct) { $productPrice = $orderProduct->product->price; $discount = $orderProduct->product->discount; $quantity = $orderProduct->quantity; // Calculate discounted price per item $discountedPrice = $productPrice * ((100 - $discount) / 100); $lineSubtotal = $discountedPrice * $quantity; $subtotalBeforeTax += $lineSubtotal; // Calculate tax for this line item $taxRate = $orderProduct->product->tax ? $orderProduct->product->tax->tax : 0; $lineTax = $lineSubtotal * ($taxRate / 100); $totalTax += $lineTax; } @endphp
Producto Precio Cantidad Descuento Total
{{ $product->product->name }}
${{ number_format($product->product->price, 2) }} {{$product->quantity}} ${{ number_format($product->product->price*$product->product->discount/100 * $product->quantity, 2) }} ${{ number_format($product->product->price*((100-$product->product->discount)/100)*$product->quantity, 2) }}
Subtotal ${{ number_format($subtotalBeforeTax, 2) }}
Impuestos ${{ number_format($totalTax, 2) }}
Total ${{ number_format($order->total, 2) }}
@if($order->bonifications->count())

Bonificaciones

@foreach ($order->bonifications as $bonification) @endforeach
Producto Bonificación Cantidad
{{ $bonification->product->name }} {{ $bonification->bonification->name }} {{ $bonification->quantity }}
@endif
@endsection @section('scripts') @endsection