@extends('layouts.app') @section('title', 'Edit Invoice ' . $sale->invoice_number) @section('content')

{{ $sale->payment_status == 'paid' ? 'Mark as Record Only' : 'Edit Invoice' }}

{{ $sale->invoice_number }}

@if($sale->payment_status == 'paid') {{-- Simplified form for paid invoices - only record_only toggle --}}
@csrf @method('PUT')

Paid Invoice

This invoice is marked as Paid. You can only mark it as "Record Only" to restore stock. Other details cannot be edited.

{{-- Invoice Summary (read-only) --}}

Invoice Summary

Customer
{{ $customers->firstWhere('id', $sale->customer_id)->name ?? 'N/A' }}
Invoice Date
{{ \Carbon\Carbon::parse($sale->invoice_date)->format('d M Y') }}
Total
RM {{ number_format($sale->total, 2) }}
Items
{{ $items->count() }} items ({{ $items->sum('quantity') }} units)
{{-- Record Only Toggle --}}

Check this box if this sale was already processed in Dashboard/Marketing. This will restore {{ $items->sum('quantity') }} units back to inventory.

Cancel
@else {{-- Full edit form for unpaid/partial invoices --}}
@csrf @method('PUT')

Invoice Details

@error('customer_id')

{{ $message }}

@enderror
@error('invoice_date')

{{ $message }}

@enderror

Items

Product Qty Price Total
Subtotal: RM 0.00
Discount: - RM 0.00
Total: RM 0.00
record_only ? 'checked disabled' : '' }} class="h-4 w-4 text-amber-600 focus:ring-amber-500 border-gray-300 rounded">
@if($sale->record_only)

This sale is already marked as Record Only. @if($sale->stock_restored) Stock was restored on {{ \Carbon\Carbon::parse($sale->stock_restored_at)->format('d M Y H:i') }}. @endif

@else

Check this if this sale was already processed in Dashboard/Marketing. This will restore the stock that was deducted.

@endif
@if(!$sale->record_only)

Enter the Dashboard/Marketing order number for reference.

@endif
Cancel
@endif @endsection