@extends('layouts.app')
@section('title','General Ledger')
@section('content')
<div class="page-head"><div><h1>General ledger</h1><p>Posted journal activity with running account balance.</p></div></div><div class="card-erp"><div class="card-erp-body"><form class="row g-2 align-items-end"><div class="col-md-5"><label class="form-label">Account</label><select name="account_id" class="form-select">@foreach($accounts as $a)<option value="{{ $a->id }}" @selected($selected?->id===$a->id)>{{ $a->code }} · {{ $a->name_en }}</option>@endforeach</select></div><div class="col-md-2"><label class="form-label">From</label><input type="date" class="form-control" name="date_from" value="{{ request('date_from') }}"></div><div class="col-md-2"><label class="form-label">To</label><input type="date" class="form-control" name="date_to" value="{{ request('date_to') }}"></div><div class="col-md-3"><button class="btn btn-dark w-100">Run ledger</button></div></form></div><div class="table-responsive"><table class="table table-dense"><thead><tr><th>Date</th><th>Journal</th><th>Reference</th><th>Description</th><th class="text-end">Debit</th><th class="text-end">Credit</th><th class="text-end">Balance</th></tr></thead><tbody>@php $running=0; @endphp @forelse($lines as $line) @php $running+=(float)$line->debit-(float)$line->credit; @endphp <tr><td>{{ $line->journalEntry->entry_date->format('d M Y') }}</td><td>{{ $line->journalEntry->journal_no }}</td><td>{{ $line->journalEntry->reference_number }}</td><td>{{ $line->description }}</td><td class="text-end">{{ number_format((float)$line->debit,2) }}</td><td class="text-end">{{ number_format((float)$line->credit,2) }}</td><td class="text-end fw-bold">{{ number_format($running,2) }}</td></tr>@empty<tr><td colspan="7" class="text-center text-muted py-5">No posted activity for this account.</td></tr>@endforelse</tbody></table></div></div>
@endsection
