@php
$total_consumido = 0;
$total_abonos = 0;
// Calculamos automáticamente los positivos y los negativos
foreach($order->details as $detail) {
$line_total = $detail->quantity * $detail->price;
if($line_total > 0) {
$total_consumido += $line_total;
} else {
$total_abonos += abs($line_total); // Guardamos el valor en positivo para mostrarlo bonito
}
}
@endphp
TOTAL CONSUMIDO:
{{ $settings['currency_symbol'] ?? 'S/' }} {{ number_format($total_consumido, 2) }}
@if($total_abonos > 0)
ABONOS PREVIOS:
- {{ $settings['currency_symbol'] ?? 'S/' }} {{ number_format($total_abonos, 2) }}
@endif
@if($order->discount > 0)
Descuento:
-{{ number_format($order->discount, 2) }}
@endif
@if($order->tip > 0)
Propina:
{{ number_format($order->tip, 2) }}
@endif
SALDO A PAGAR:
{{ $settings['currency_symbol'] ?? 'S/' }} {{ number_format($order->total, 2) }}
F. PAGO: {{ strtoupper($order->payment_method) }}
RECIBIDO: {{ number_format($order->received_amount, 2) }}
VUELTO: {{ number_format($order->change_amount, 2) }}