<?php $__env->startSection('title',$sale->invoice_no); ?>
<?php $__env->startSection('content'); ?>
<div class="page-head"><div><div class="d-flex align-items-center gap-2"><h1><?php echo e($sale->invoice_no); ?></h1><span class="badge status-<?php echo e($sale->status); ?>"><?php echo e(strtoupper($sale->status)); ?></span></div><p><?php echo e($sale->invoice_date->format('d F Y')); ?> · <?php echo e(str_replace('_',' ',ucfirst($sale->invoice_type))); ?></p></div><div class="d-flex flex-wrap gap-2"><?php if($sale->status==='draft'): ?><form method="POST" action="<?php echo e(route('sales.finalize',$sale)); ?>"><?php echo csrf_field(); ?><button class="btn btn-primary btn-dense"><i class="bi bi-check2-circle me-1"></i>Finalize</button></form><?php else: ?><a target="_blank" class="btn btn-light border btn-dense" href="<?php echo e(route('sales.thermal',$sale)); ?>"><i class="bi bi-printer me-1"></i>Thermal</a><a target="_blank" class="btn btn-dark btn-dense" href="<?php echo e(route('sales.print',$sale)); ?>"><i class="bi bi-printer me-1"></i>A4 Print</a><a class="btn btn-light border btn-dense" href="<?php echo e(route('sales.pdf',$sale)); ?>"><i class="bi bi-file-pdf me-1"></i>PDF</a><a class="btn btn-outline-danger btn-dense" href="<?php echo e(route('sales-returns.create',$sale)); ?>"><i class="bi bi-arrow-return-left me-1"></i>Create return</a><?php endif; ?></div></div>
<div class="row g-2"><div class="col-lg-8"><div class="card-erp"><div class="card-erp-header"><span>Invoice items</span><small class="text-muted"><?php echo e($sale->items->count()); ?> line(s)</small></div><div class="table-responsive"><table class="table table-dense"><thead><tr><th>#</th><th>Description / الوصف</th><th>Unit</th><th class="text-end">Qty</th><th class="text-end">Price</th><th class="text-end"><?php echo e($sale->invoice_type==='non_tax_invoice'?'Amount':'Taxable'); ?></th><?php if($sale->invoice_type!=='non_tax_invoice'): ?><th class="text-end">VAT</th><?php endif; ?><th class="text-end">Total</th></tr></thead><tbody><?php $__currentLoopData = $sale->items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i=>$item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><tr><td><?php echo e($i+1); ?></td><td><strong><?php echo e($item->product_name_en_snapshot); ?></strong><small class="d-block text-muted" dir="rtl"><?php echo e($item->product_name_ar_snapshot); ?></small></td><td><?php echo e($item->unit_snapshot); ?></td><td class="text-end"><?php echo e(number_format((float)$item->quantity,4)); ?></td><td class="text-end"><?php echo e(number_format((float)$item->unit_price,2)); ?></td><td class="text-end"><?php echo e(number_format((float)$item->taxable_amount,2)); ?></td><?php if($sale->invoice_type!=='non_tax_invoice'): ?><td class="text-end"><?php echo e(number_format((float)$item->vat_amount,2)); ?></td><?php endif; ?><td class="text-end fw-bold"><?php echo e(number_format((float)$item->line_total,2)); ?></td></tr><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></tbody></table></div></div></div>
<div class="col-lg-4"><div class="card-erp"><div class="card-erp-header">Customer</div><div class="card-erp-body"><strong><?php echo e($sale->customer->name_en); ?></strong><div dir="rtl"><?php echo e($sale->customer->name_ar); ?></div><div class="text-muted mt-2"><?php echo e($sale->customer->customer_code); ?><?php if($sale->invoice_type!=='non_tax_invoice'): ?> · VAT <?php echo e($sale->customer->vat_number?:'Not registered'); ?><?php endif; ?></div><div class="text-muted"><?php echo e($sale->warehouse->code); ?> · <?php echo e($sale->warehouse->name_en); ?></div></div></div><div class="card-erp"><div class="card-erp-body"><div class="d-flex justify-content-between py-1"><span>Gross</span><strong><?php echo e(number_format((float)$sale->gross_total,2)); ?></strong></div><div class="d-flex justify-content-between py-1"><span>Discount</span><strong><?php echo e(number_format((float)$sale->discount_total,2)); ?></strong></div><div class="d-flex justify-content-between py-1"><span><?php echo e($sale->invoice_type==='non_tax_invoice'?'Subtotal':'Taxable'); ?></span><strong><?php echo e(number_format((float)$sale->taxable_total,2)); ?></strong></div><?php if($sale->invoice_type!=='non_tax_invoice'): ?><div class="d-flex justify-content-between py-1"><span>VAT</span><strong><?php echo e(number_format((float)$sale->vat_total,2)); ?></strong></div><?php endif; ?><hr><div class="d-flex justify-content-between align-items-end"><span>Grand total</span><strong class="fs-4 text-accent">SAR <?php echo e(number_format((float)$sale->grand_total,2)); ?></strong></div><div class="d-flex justify-content-between mt-2"><span>Paid</span><strong><?php echo e(number_format((float)$sale->paid_total,2)); ?></strong></div><div class="d-flex justify-content-between"><span>Balance</span><strong class="<?php echo e($sale->balance_total>0?'text-danger':''); ?>"><?php echo e(number_format((float)$sale->balance_total,2)); ?></strong></div><?php if(auth()->user()->hasPermission('sales.view_profit')): ?><div class="d-flex justify-content-between border-top mt-2 pt-2"><span>Gross profit</span><strong><?php echo e(number_format((float)$sale->profit_total,2)); ?></strong></div><?php endif; ?></div></div><?php if($sale->payments->count()): ?><div class="card-erp"><div class="card-erp-header">Payments</div><div class="card-erp-body"><?php $__currentLoopData = $sale->payments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $payment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><div class="d-flex justify-content-between py-1"><span><?php echo e(ucfirst($payment->payment_method)); ?></span><strong><?php echo e(number_format((float)$payment->amount,2)); ?></strong></div><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></div></div><?php endif; ?></div></div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\saudi\resources\views\sales\show.blade.php ENDPATH**/ ?>