@extends('layouts.app')
@section('title', __('Bank & Sarafi'))
@section('content')<div class="row g-3"><div class="col-lg-5"><div class="card"><div class="card-body p-4"><h6>{{ __('Add Financial Account') }}</h6><form method="POST" action="{{ route('finance.accounts.store') }}">@csrf<input name="name" class="form-control mb-2" placeholder="{{ __('Account Name') }}" required><div class="row g-2"><div class="col-6"><select name="type" class="form-select"><option value="cash">{{ __('Cash') }}</option><option value="bank">{{ __('Bank') }}</option><option value="sarafi">{{ __('Sarafi') }}</option></select></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><input name="opening_balance" type="number" step="0.01" class="form-control mt-2" placeholder="{{ __('Opening Balance') }}"><input name="account_number" class="form-control mt-2" placeholder="{{ __('Account / Phone Number') }}"><input name="contact_person" class="form-control mt-2" placeholder="{{ __('Contact Person') }}"><button class="btn btn-success w-100 mt-3">{{ __('Save Account') }}</button></form><hr><h6>{{ __('Accounts') }}</h6>@foreach($accounts as $account)<div class="border-top py-2 d-flex justify-content-between"><span><strong>{{ $account->name }}</strong><small class="d-block">{{ ucfirst($account->type) }} · {{ $account->currency_code }}</small></span><span>{{ number_format($account->opening_balance,2) }}</span></div>@endforeach</div></div></div><div class="col-lg-7"><div class="card"><div class="card-body p-4"><h6>{{ __('Sarafi Exchange Transaction') }}</h6><form method="POST" action="{{ route('finance.exchange') }}">@csrf<div class="row g-2"><div class="col-md-6"><label class="form-label">{{ __('From Account') }}</label><select name="from_account_id" class="form-select">@foreach($accounts as $account)<option value="{{ $account->id }}">{{ $account->name }} ({{ $account->currency_code }})</option>@endforeach</select></div><div class="col-md-6"><label class="form-label">{{ __('To Account') }}</label><select name="to_account_id" class="form-select">@foreach($accounts as $account)<option value="{{ $account->id }}">{{ $account->name }} ({{ $account->currency_code }})</option>@endforeach</select></div><div class="col-md-6"><label class="form-label">{{ __('From Amount') }}</label><input name="from_amount" type="number" step="0.01" class="form-control" required></div><div class="col-md-6"><label class="form-label">{{ __('To Amount') }}</label><input name="to_amount" type="number" step="0.01" class="form-control" required></div><div class="col-md-6"><input name="transaction_date" type="date" class="form-control" value="{{ now()->toDateString() }}"></div><div class="col-md-6"><input name="reference" class="form-control" placeholder="{{ __('Reference') }}"></div></div><button class="btn btn-success mt-3">{{ __('Record Exchange') }}</button></form><hr><h6>{{ __('Recent Exchanges') }}</h6><table class="table table-sm"><thead><tr><th>{{ __('Date') }}</th><th>{{ __('From') }}</th><th>{{ __('To') }}</th><th>{{ __('Rate') }}</th></tr></thead><tbody>@foreach($exchanges as $exchange)<tr><td>{{ $exchange->transaction_date->format('d M') }}</td><td>{{ $exchange->fromAccount?->name }} {{ $exchange->from_amount }}</td><td>{{ $exchange->toAccount?->name }} {{ $exchange->to_amount }}</td><td>{{ $exchange->exchange_rate }}</td></tr>@endforeach</tbody></table></div></div></div></div>@endsection
