@extends('layouts.dashboard') @section('title', $pageTitle ?? (isset($sale) ? 'Edit Sale' : 'Create Sale')) @section('page_header') @endsection @section('page_content') @if (session('status'))
{{ session('status') }}
@endif @if ($errors->any())
{{ $errors->first() }}
@endif
@php $isEdit = isset($sale); $oldItems = old('product_id'); $items = $isEdit ? $sale->items : collect(); $defaultAccount = old('account_id', ''); $allocated = $isEdit ? $sale->allocations->sum('amount') : 0; $outstanding = $isEdit ? max($sale->amount - $allocated, 0) : 0; @endphp
@csrf @if ($isEdit) @method('PUT') @endif
Applied only when an agent is selected.

Items
@if (is_array($oldItems)) @foreach ($oldItems as $index => $oldProduct) @endforeach @elseif ($items->isNotEmpty()) @foreach ($items as $item) @endforeach @else @endif
Product Quantity Price Total
Grand Total
@if (!$isEdit)
@endif
Cancel
@if ($isEdit)
Add Payment
Outstanding: {{ number_format((float) $outstanding, 2) }}
@csrf
@endif @endsection @push('styles') @endpush @push('scripts') @endpush