@extends('layouts.app') @section('content')

General Ledger

Period: {{ \Carbon\Carbon::parse($fromDate)->format('d M Y') }} to {{ \Carbon\Carbon::parse($toDate)->format('d M Y') }} | Accounts with Activity: {{ $accounts->count() }}
@forelse($accounts as $account)
{{ $account->code }} - {{ $account->name }} {{ $account->type }}
Opening: @if($account->opening >= 0) {{ number_format($account->opening, 2) }} Dr @else {{ number_format(abs($account->opening), 2) }} Cr @endif
@php $balance = $account->opening; @endphp @foreach($account->transactions as $txn) @php $balance += $txn->debit - $txn->credit; @endphp @endforeach
Date Particulars Debit Credit Balance
{{ $txn->date->format('d-M-Y') }} @if($txn->transactionable) @php $ref = $txn->transactionable; @endphp @if($ref instanceof \App\Models\Purchase) Purchase: {{ $ref->bill_no }} @elseif($ref instanceof \App\Models\Sale) Sale: {{ $ref->bill_no }} @elseif($ref instanceof \App\Models\Voucher) {{ $ref->type }}: {{ $ref->voucher_no }} @else {{ class_basename($ref) }} @endif @else Transaction @endif {{ $txn->debit > 0 ? number_format($txn->debit, 2) : '-' }} {{ $txn->credit > 0 ? number_format($txn->credit, 2) : '-' }} @if($balance >= 0) {{ number_format($balance, 2) }} Dr @else {{ number_format(abs($balance), 2) }} Cr @endif
Closing Balance: {{ number_format($account->transactions->sum('debit'), 2) }} {{ number_format($account->transactions->sum('credit'), 2) }} @if($account->closing >= 0) {{ number_format($account->closing, 2) }} Dr @else {{ number_format(abs($account->closing), 2) }} Cr @endif
@empty
No accounts with transactions found for the selected period.
@endforelse
@endsection