@include('styles.pdfs') @includeIf('reports.letterhead') @foreach($sales as $sale)
{{ __('sale.invoice.header')}} {{ $sale->code }}
Invoice date: {{ $sale->created_at->toDayDateTimeString() }}
Cashier : {{ $sale->cashier ? $sale->cashier->name : '' }}
Service : {{ $sale->service ? $sale->service->name : '' }}
Customer : {{ $sale->customer ? $sale->customer->name : '' }}

@foreach($sale->items as $item) @endforeach
{{ __('sale.report.label.ref') }} {{ __('sale.invoice.label.item') }} {{ __('sale.invoice.label.quantity') }} {{ __('sale.invoice.label.rate') }} {{ __('sale.invoice.label.amount') }}
{{ $loop->index + 1 }} {{ $item->item->name }} - {{ $item->item->description }} {{ $item->quantity }} {{ number_format($item->unit_price) }} {{ number_format($item->unit_price * $item->quantity) }}
Summary
@php $subtotal = array_sum(array_map(function ($itm) {return $itm['unit_price'] * $itm['quantity'];}, $sale->items->toArray())); @endphp
{{ __('sale.invoice.label.subtotal') }} {{ number_format($subtotal) }}
{{ __('sale.invoice.label.discount') }} {{ number_format($sale->discount) }}
{{ __('sale.report.label.paid') }} {{ number_format($sale->paid) }}
{{ __('sale.invoice.label.total') }} {{ number_format($subtotal - $sale->discount) }}
@endforeach