@extends('layouts.app')
@section('title', __('Payments & Receipts'))
@section('content')
<div class="row g-3"><div class="col-lg-6"><div class="card h-100"><div class="card-body p-4"><h6><i class="fa-solid fa-arrow-down text-success me-2"></i>{{ __('Receive from Customer') }}</h6><p class="text-muted small">{{ __('Record money received against a customer sale.') }}</p><form method="POST" action="{{ route('payments.receive') }}">@csrf<label class="form-label">{{ __('Unpaid Invoice') }}</label><select name="invoice_id" class="form-select" required><option value="">{{ __('Select invoice') }}</option>@foreach($customerInvoices as $invoice)<option value="{{ $invoice->id }}">{{ $invoice->invoice_number }} — {{ $invoice->customer?->name ?? __('Walk-in Customer') }} — {{ number_format($invoice->due_amount,2) }} {{ $invoice->currency_code }}</option>@endforeach</select><div class="row g-2 mt-1"><div class="col-6"><label class="form-label">{{ __('Amount') }}</label><input name="amount" type="number" min="0.01" step="0.01" class="form-control" required></div><div class="col-6"><label class="form-label">{{ __('Date') }}</label><input name="payment_date" type="date" class="form-control" value="{{ now()->toDateString() }}"></div></div><label class="form-label mt-3">{{ __('Method') }}</label><select name="method" class="form-select"><option value="cash">{{ __('Cash') }}</option><option value="bank">{{ __('Bank') }}</option><option value="mobile">{{ __('Mobile Money') }}</option><option value="other">{{ __('Other') }}</option></select><input name="reference" class="form-control mt-3" placeholder="{{ __('Reference number') }}"><button class="btn btn-success w-100 mt-3"><i class="fa-solid fa-circle-down me-1"></i>{{ __('Receive Payment') }}</button></form></div></div></div><div class="col-lg-6"><div class="card h-100"><div class="card-body p-4"><h6><i class="fa-solid fa-arrow-up text-danger me-2"></i>{{ __('Pay Supplier') }}</h6><p class="text-muted small">{{ __('Record money paid against a supplier purchase.') }}</p><form method="POST" action="{{ route('payments.supplier') }}">@csrf<label class="form-label">{{ __('Unpaid Purchase') }}</label><select name="purchase_id" class="form-select" required><option value="">{{ __('Select purchase') }}</option>@foreach($supplierPurchases as $purchase)<option value="{{ $purchase->id }}">{{ $purchase->purchase_number }} — {{ $purchase->supplier?->name ?? '—' }} — {{ number_format($purchase->due_amount,2) }} {{ $purchase->currency_code }}</option>@endforeach</select><div class="row g-2 mt-1"><div class="col-6"><label class="form-label">{{ __('Amount') }}</label><input name="amount" type="number" min="0.01" step="0.01" class="form-control" required></div><div class="col-6"><label class="form-label">{{ __('Date') }}</label><input name="payment_date" type="date" class="form-control" value="{{ now()->toDateString() }}"></div></div><label class="form-label mt-3">{{ __('Method') }}</label><select name="method" class="form-select"><option value="cash">{{ __('Cash') }}</option><option value="bank">{{ __('Bank') }}</option><option value="mobile">{{ __('Mobile Money') }}</option><option value="other">{{ __('Other') }}</option></select><input name="reference" class="form-control mt-3" placeholder="{{ __('Reference number') }}"><button class="btn btn-danger w-100 mt-3"><i class="fa-solid fa-circle-up me-1"></i>{{ __('Pay Supplier') }}</button></form></div></div></div></div>
<div class="row g-3 mt-1"><div class="col-lg-6"><div class="card"><div class="card-body"><h6>{{ __('Recent Customer Receipts') }}</h6><table class="table table-sm"><thead><tr><th>{{ __('Date') }}</th><th>{{ __('Customer') }}</th><th>{{ __('Amount') }}</th></tr></thead><tbody>@forelse($receipts as $receipt)<tr><td>{{ $receipt->payment_date->format('d M') }}</td><td>{{ $receipt->customer?->name ?? __('Walk-in Customer') }}<small class="d-block">{{ $receipt->invoice?->invoice_number }}</small></td><td class="text-success">{{ number_format($receipt->amount,2) }} {{ $receipt->currency_code }}</td></tr>@empty<tr><td colspan="3" class="text-muted text-center">{{ __('No receipts yet.') }}</td></tr>@endforelse</tbody></table></div></div></div><div class="col-lg-6"><div class="card"><div class="card-body"><h6>{{ __('Recent Supplier Payments') }}</h6><table class="table table-sm"><thead><tr><th>{{ __('Date') }}</th><th>{{ __('Supplier') }}</th><th>{{ __('Amount') }}</th></tr></thead><tbody>@forelse($supplierPayments as $payment)<tr><td>{{ $payment->payment_date->format('d M') }}</td><td>{{ $payment->supplier?->name }}<small class="d-block">{{ $payment->purchase?->purchase_number }}</small></td><td class="text-danger">{{ number_format($payment->amount,2) }} {{ $payment->currency_code }}</td></tr>@empty<tr><td colspan="3" class="text-muted text-center">{{ __('No supplier payments yet.') }}</td></tr>@endforelse</tbody></table></div></div></div></div>
<div class="row g-3 mt-1"><div class="col-lg-6"><div class="card"><div class="card-body p-4"><h6><i class="fa-solid fa-circle-plus text-success me-2"></i>{{ __('General Receipt') }}</h6><form method="POST" action="{{ route('payments.general') }}">@csrf<input type="hidden" name="type" value="receipt"><div class="row g-2"><div class="col-6"><input name="party_name" class="form-control" placeholder="{{ __('From / Party') }}"></div><div class="col-6"><input name="category" class="form-control" placeholder="{{ __('Category') }}" required></div><div class="col-6"><input name="amount" type="number" min="0.01" step="0.01" class="form-control" placeholder="{{ __('Amount') }}" required></div><div class="col-6"><select name="currency_code" class="form-select">@foreach($currencies as $currency)<option value="{{ $currency->code }}" @selected($currency->is_default)>{{ $currency->code }}</option>@endforeach</select></div><div class="col-6"><input name="transaction_date" type="date" class="form-control" value="{{ now()->toDateString() }}"></div><div class="col-6"><select name="method" class="form-select"><option value="cash">{{ __('Cash') }}</option><option value="bank">{{ __('Bank') }}</option><option value="mobile">{{ __('Mobile Money') }}</option></select></div></div><input name="reference" class="form-control mt-2" placeholder="{{ __('Reference number') }}"><textarea name="notes" class="form-control mt-2" rows="2" placeholder="{{ __('Notes') }}"></textarea><button class="btn btn-success w-100 mt-3">{{ __('Save General Receipt') }}</button></form></div></div></div><div class="col-lg-6"><div class="card"><div class="card-body p-4"><h6><i class="fa-solid fa-circle-minus text-danger me-2"></i>{{ __('General Payment') }}</h6><form method="POST" action="{{ route('payments.general') }}">@csrf<input type="hidden" name="type" value="payment"><div class="row g-2"><div class="col-6"><input name="party_name" class="form-control" placeholder="{{ __('To / Party') }}"></div><div class="col-6"><input name="category" class="form-control" placeholder="{{ __('Category') }}" required></div><div class="col-6"><input name="amount" type="number" min="0.01" step="0.01" class="form-control" placeholder="{{ __('Amount') }}" required></div><div class="col-6"><select name="currency_code" class="form-select">@foreach($currencies as $currency)<option value="{{ $currency->code }}" @selected($currency->is_default)>{{ $currency->code }}</option>@endforeach</select></div><div class="col-6"><input name="transaction_date" type="date" class="form-control" value="{{ now()->toDateString() }}"></div><div class="col-6"><select name="method" class="form-select"><option value="cash">{{ __('Cash') }}</option><option value="bank">{{ __('Bank') }}</option><option value="mobile">{{ __('Mobile Money') }}</option></select></div></div><input name="reference" class="form-control mt-2" placeholder="{{ __('Reference number') }}"><textarea name="notes" class="form-control mt-2" rows="2" placeholder="{{ __('Notes') }}"></textarea><button class="btn btn-danger w-100 mt-3">{{ __('Save General Payment') }}</button></form></div></div></div></div>
<div class="card mt-3"><div class="card-body"><h6>{{ __('General Transactions') }}</h6><table class="table table-sm"><thead><tr><th>{{ __('Date') }}</th><th>{{ __('Type') }}</th><th>{{ __('Party') }}</th><th>{{ __('Category') }}</th><th>{{ __('Amount') }}</th></tr></thead><tbody>@forelse($generalTransactions as $transaction)<tr><td>{{ $transaction->transaction_date->format('d M Y') }}</td><td><span class="badge {{ $transaction->type==='receipt'?'badge-soft':'badge-danger' }}">{{ ucfirst($transaction->type) }}</span></td><td>{{ $transaction->party_name }}</td><td>{{ $transaction->category }}</td><td class="{{ $transaction->type==='receipt'?'text-success':'text-danger' }}">{{ number_format($transaction->amount,2) }} {{ $transaction->currency_code }}</td></tr>@empty<tr><td colspan="5" class="text-muted text-center">{{ __('No general transactions yet.') }}</td></tr>@endforelse</tbody></table></div></div>
@endsection
