@php $errorBag = $errors ?? new \Illuminate\Support\ViewErrorBag(); $errors = $errorBag; $documentType = $type === 'invoice' ? 'Invoice' : 'Quotation'; $statusOptions = $type === 'invoice' ? ['draft' => 'Draft', 'sent' => 'Sent', 'paid' => 'Paid'] : ['draft' => 'Draft', 'sent' => 'Sent']; if ($type === 'invoice' && ! auth()->user()?->can('mark-invoices-paid')) { if (($document->status ?? null) === 'paid') { $statusOptions = ['paid' => 'Paid']; } else { unset($statusOptions['paid']); } } $dateFieldTwo = $type === 'invoice' ? 'due_date' : 'valid_until'; $dateFieldTwoLabel = $type === 'invoice' ? 'Due date' : 'Valid until'; $items = old('items', isset($document) && $document->items ? $document->items->map(fn ($item) => $item->only(['description', 'quantity', 'unit_price']))->all() : [['description' => '', 'quantity' => 1, 'unit_price' => 0]]); $submitLabel = $submitLabel ?? 'Save'; $notesLabel = $type === 'invoice' ? 'Notes' : 'Notes'; $fieldClass = function (string $field, string $baseClass) use ($errorBag): string { return $errorBag->has($field) ? $baseClass.' '.$baseClass.'-invalid' : $baseClass; }; $hasItemErrors = $errorBag->has('items') || collect($errorBag->keys())->contains(fn ($key) => str_starts_with($key, 'items.')); $initialSubtotal = collect($items)->sum(fn ($item) => (float) ($item['quantity'] ?? 0) * (float) ($item['unit_price'] ?? 0)); $initialTaxRate = (float) old('tax_rate', $document->tax_rate ?? 15); $initialTax = $initialSubtotal * ($initialTaxRate / 100); $initialGrandTotal = $initialSubtotal + $initialTax; @endphp @csrf
Complete the highlighted fields.
Select client and status.
{{ $message }}
@enderrorLinks to client records.
{{ $message }}
@enderrorChoose the current status.
Set dates. VAT uses Company Settings.
{{ $message }}
@enderror{{ $message }}
@enderror{{ $message }}
@enderrorAdd short client notes.
{{ $message }}
@enderrorShown on the client document.
Add products or services.
{{ $message }}
@enderror{{ $message }}
@enderror{{ $message }}
@enderrorKeep line items clear.
Use one row per item.
{{ $message }}
@enderror