@php // Show only the actions that the current user can perform. $canCreateSaleReturn = \App\Support\AdminAccess::canAction('sale_returns', 'create'); $canDeleteSaleReturn = \App\Support\AdminAccess::canAction('sale_returns', 'delete'); @endphp

{{ __('Sale Returns') }}

@error('customer_id') {{ $message }} @enderror
@php $invoiceOptions = $invoices->map(fn ($invoice) => [ 'id' => (string) $invoice->id, 'label' => $invoice->invoice_number . ' | ' . \Carbon\Carbon::parse($invoice->created_at)->format('d-m-Y h:i A') . ' | Rs.' . number_format((float) $invoice->paid_amount, 2), ])->values()->all(); @endphp
{{ __('No invoices found.') }}
@error('invoice_id') {{ $message }} @enderror
@forelse($items as $index => $item) @empty @endforelse
{{ __('Product') }} {{ __('Sold Qty') }} {{ __('Return Qty') }} {{ __('Unit Price') }} {{ __('Total Refund') }}
{{ $item['product_name'] }}
@if($item['already_returned_qty'] > 0) {{ __('Already Returned:') }} {{ number_format((float) $item['already_returned_qty'], 2) }} @endif
{{ number_format((float) $item['sold_qty'], 2) }} Rs. {{ number_format((float) $item['unit_price'], 2) }} Rs. {{ number_format((float) (($item['return_qty'] ?: 0) * $item['unit_price']), 2) }}
{{ __('After selecting an invoice, the products sold in that invoice will be displayed here.') }}
@error('items') {{ $message }} @enderror
@error('note') {{ $message }} @enderror
{{ __('Total Refund:') }} Rs.{{ number_format((float) $totalRefund, 2) }}
@error('refund_account_id') {{ $message }} @enderror
@if($canCreateSaleReturn)
@endif
{{ __('All Sale Returns') }}
@forelse($saleReturns as $return) @empty @endforelse
{{ __('Invoice') }} {{ __('Return Date') }} {{ __('Note') }} {{ __('Total') }} {{ __('Action') }}
{{ $return->invoice?->invoice_number ?? __('N/A') }} {{ \Carbon\Carbon::parse($return->return_date)->format('Y-m-d') }} {{ $return->note ?: __('N/A') }} Rs.{{ number_format((float) $return->total_amount, 2) }} @if($canDeleteSaleReturn) @endif
{{ __('No sale returns found yet.') }}
@if($saleReturns->hasPages())
{{ $saleReturns->links() }}
@endif