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

Account Ledger

@if($selectedAccount) @endif
@if($account)
{{ $account->code }} - {{ $account->name }} | Type: {{ $account->type }} | Sub-Type: {{ $account->sub_type }}
@php $runningBalance = $openingBalance; @endphp @forelse($entries as $entry) @php $runningBalance += $entry->debit - $entry->credit; @endphp @empty @endforelse
Date Particulars Debit Credit Balance
{{ \Carbon\Carbon::parse($fromDate)->format('d-M-Y') }} Opening Balance - - @if($openingBalance >= 0) {{ number_format($openingBalance, 2) }} Dr @else {{ number_format(abs($openingBalance), 2) }} Cr @endif
{{ $entry->date->format('d-M-Y') }} @if($entry->transactionable) @php $ref = $entry->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 {{ $entry->description ?? 'Transaction' }} @endif {{ $entry->debit > 0 ? number_format($entry->debit, 2) : '-' }} {{ $entry->credit > 0 ? number_format($entry->credit, 2) : '-' }} @if($runningBalance >= 0) {{ number_format($runningBalance, 2) }} Dr @else {{ number_format(abs($runningBalance), 2) }} Cr @endif
No transactions found
Period Total: {{ number_format($entries->sum('debit'), 2) }} {{ number_format($entries->sum('credit'), 2) }} @if($runningBalance >= 0) {{ number_format($runningBalance, 2) }} Dr @else {{ number_format(abs($runningBalance), 2) }} Cr @endif
@else
Please select an account to view its ledger.
@endif
@endsection