@extends('layouts.app') @section('title', 'General Ledger') @section('body-class', 'page-general-ledger') @section('breadcrumb') @endsection @push('styles') @include('partials.report-datepicker-assets') @endpush @section('content') @php $companyId = auth()->user()->company_id; $fmt = fn($amount) => abs((float) $amount) < 0.005 ? '—' : \App\Helpers\NumberHelper::formatAmount((float) abs($amount), $companyId); $ledgerData = $ledger ?? null; $isAllLedger = $ledgerData && ($ledgerData['mode'] ?? 'single') === 'all'; $selectedAccount = $ledgerData['account'] ?? null; $entries = $ledgerData['entries'] ?? collect(); $groups = $ledgerData['groups'] ?? []; $totals = $ledgerData['totals'] ?? [ 'opening_debit' => 0, 'opening_credit' => 0, 'period_debit' => 0, 'period_credit' => 0, 'closing_debit' => 0, 'closing_credit' => 0, ]; $companyName = auth()->user()->company?->name ?? config('app.name'); $periodLabel = \Carbon\Carbon::parse($dateFrom)->format('d M Y') . ' to ' . \Carbon\Carbon::parse($dateTo)->format('d M Y'); $accountLabel = $selectedAccountsLabel ?? 'Select account(s)'; $allLedger = $allLedger ?? false; $selectedAccountIds = $selectedAccountIds ?? []; $hasReport = (bool) $ledgerData; $exportQuery = $exportQuery ?? request()->query(); $hasGroups = $isAllLedger && !empty($groups); @endphp
{{ $companyName }}

General Ledger

{{ $periodLabel }}
@if($hasReport)
Export
@endif
@include('reports.general-ledger._account-picker', [ 'accountTree' => $filterOptions['accountTree'] ?? [], 'selectedAccountIds' => $selectedAccountIds, 'allLedger' => $allLedger, 'selectedAccountsLabel' => $selectedAccountsLabel ?? 'Select account(s)', ])
@include('reports.profit-loss._multi-filter-picker', [ 'pickerId' => 'glAccountTypePicker', 'emptyLabel' => 'All account types', 'searchPlaceholder' => 'Search account types...', 'inputName' => 'account_sections[]', 'selectedValues' => $filters['account_sections'] ?? [], 'options' => $filterOptions['accountTypes'], 'toggleLabel' => $selectedAccountTypesLabel ?? 'All account types', ])
@include('reports.profit-loss._multi-filter-picker', [ 'pickerId' => 'glVoucherTypePicker', 'emptyLabel' => 'All voucher types', 'searchPlaceholder' => 'Search voucher types...', 'inputName' => 'voucher_types[]', 'selectedValues' => $filters['voucher_types'] ?? [], 'options' => $filterOptions['voucherTypes'], 'toggleLabel' => $selectedVoucherTypesLabel ?? 'All voucher types', ])
@include('reports.profit-loss._dimension-picker', [ 'pickerId' => 'glDimensionPicker', 'dimensionTree' => $filterOptions['dimensionTree'] ?? [], 'selectedIds' => $filters['dimension_value_ids'] ?? [], 'emptyLabel' => 'All dimensions', 'toggleLabel' => $selectedDimensionsLabel ?? 'All dimensions', ])
@if(!$hasReport)

Select All Ledger or one or more accounts, then apply your date range.

@else
Account
{{ $accountLabel }}
@if($hasReport) @endif @if(!$isAllLedger)
Closing Balance
{{ $totals['closing_debit'] > 0 ? $fmt($totals['closing_debit']) . ' Dr' : ($totals['closing_credit'] > 0 ? $fmt($totals['closing_credit']) . ' Cr' : '—') }}
@elseif($hasGroups)
Accounts Shown
{{ count($groups) }}
@endif
@if($hasGroups) @forelse($groups as $group) @include('reports.general-ledger._account-group', [ 'group' => $group, 'fmt' => $fmt, 'dateFrom' => $dateFrom, ]) @empty @endforelse @else @if(!$isAllLedger) @endif @forelse($entries as $entry) @include('reports.general-ledger._entry-row', ['entry' => $entry, 'fmt' => $fmt]) @empty @endforelse @endif @if($hasReport) @endif
Date Voucher Reference / Narration Name Dimension Split Accounts Debit Credit Balance
No ledger movement found for the selected filters.
{{ \Carbon\Carbon::parse($dateFrom)->subDay()->format('d M Y') }} Opening Balance {{ $fmt($totals['opening_debit']) }} {{ $fmt($totals['opening_credit']) }} {{ $totals['opening_debit'] > 0 ? $fmt($totals['opening_debit']) . ' Dr' : ($totals['opening_credit'] > 0 ? $fmt($totals['opening_credit']) . ' Cr' : '—') }}
No ledger movement found for the selected period.
Current Period Total {{ $fmt($totals['period_debit']) }} {{ $fmt($totals['period_credit']) }}
@endif
@endsection @push('modals') @if($hasReport ?? false) @php $emailFormat = old('format', 'pdf'); $defaultPaperSize = old('paper_size', 'a4'); $defaultLayout = old('layout', 'landscape'); $paperSizeOptions = ['a4' => 'A4', 'letter' => 'Letter', 'legal' => 'Legal']; $layoutOptions = ['portrait' => 'Portrait', 'landscape' => 'Landscape']; @endphp @endif @endpush @push('scripts') @include('partials.report-datepicker-init') @include('reports.general-ledger._account-picker-scripts') @include('reports.general-ledger._filter-scripts') @endpush