@extends('layouts.dashboard') @section('title', $pageTitle ?? (isset($salesReturn) ? 'Edit Sales Return' : 'Create Sales Return')) @section('page_header') @endsection @section('page_content') @if (session('status'))
{{ session('status') }}
@endif @if ($errors->any())
{{ $errors->first() }}
@endif
@php $isEdit = isset($salesReturn); $oldItems = old('product_id'); $items = $isEdit ? $salesReturn->items : collect(); $allocated = $isEdit ? $salesReturn->returnAllocations->sum('amount') : 0; $outstanding = $isEdit ? max($salesReturn->amount - $allocated, 0) : 0; $defaultAccount = old('account_id', ''); $currentSaleId = (string) ($selectedSaleId ?? ''); $selectedSaleProducts = collect($saleProductsMap[$currentSaleId] ?? []); @endphp
@csrf @if ($isEdit) @method('PUT') @endif

Return 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 Refund
Pending Refund: {{ number_format((float) $outstanding, 2) }}
@csrf
@endif @endsection @push('styles') @endpush @push('scripts') @endpush