@extends('layouts.app')
@section('title','Transfer Funds')
@section('content')
<x-ui.form-shell title="Transfer Funds" description="Move money between business financial accounts without changing total company funds or profit." :breadcrumbs="[['label'=>'Dashboard','url'=>route('dashboard')],['label'=>'Financial Accounts','url'=>route('accounts.index')],['label'=>'Transfer Funds']]" narrow>
<form method="POST" action="{{ route('account-transfers.store') }}" class="mf-form">@csrf
<x-ui.form-section title="Transfer Details" description="Source and destination balances are locked and updated together in one database transaction."><x-ui.form-grid>
<div class="mf-col-6"><label class="mf-field-label">From account</label><select class="mf-input" name="source_account_id" required><option value="">Select source</option>@foreach($accounts as $account)<option value="{{ $account->id }}" @selected((int)old('source_account_id',request('source'))===$account->id)>{{ $account->name }} · {{ $account->branch->name }} · {{ number_format((float)$account->current_balance,2) }}</option>@endforeach</select>@error('source_account_id')<p class="mf-field-error">{{ $message }}</p>@enderror</div>
<div class="mf-col-6"><label class="mf-field-label">To account</label><select class="mf-input" name="destination_account_id" required><option value="">Select destination</option>@foreach($accounts as $account)<option value="{{ $account->id }}" @selected((int)old('destination_account_id')===$account->id)>{{ $account->name }} · {{ $account->branch->name }} · {{ number_format((float)$account->current_balance,2) }}</option>@endforeach</select>@error('destination_account_id')<p class="mf-field-error">{{ $message }}</p>@enderror</div>
<div class="mf-col-3"><label class="mf-field-label">Amount</label><input type="number" min="0.01" step="0.01" class="mf-input" name="amount" value="{{ old('amount') }}" required>@error('amount')<p class="mf-field-error">{{ $message }}</p>@enderror</div>
<div class="mf-col-3"><label class="mf-field-label">Date</label><input type="date" class="mf-input" name="date" value="{{ old('date',now()->format('Y-m-d')) }}" required></div>
<div class="mf-col-3"><label class="mf-field-label">Reference</label><input class="mf-input" name="reference" value="{{ old('reference') }}" placeholder="Optional external reference"></div>
<div class="mf-col-3"><label class="mf-field-label">Notes</label><input class="mf-input" name="notes" value="{{ old('notes') }}" placeholder="Optional transfer note"></div>
</x-ui.form-grid></x-ui.form-section>
<x-ui.form-actions><a class="mf-btn" href="{{ route('accounts.index') }}">Cancel</a><button class="mf-btn mf-btn-primary">Post Transfer</button></x-ui.form-actions>
</form></x-ui.form-shell>
@endsection
