@extends('layouts.master') @section('title', 'Account Ledger Report') @push('css') @endpush @section('content') @include('partials.header') @include('partials.sidebar')

Ledger Report

Ledger Filter

@csrf
@isset($data)
@if(count($data) > 0)
{{ $data[0]->Account_Title }}
{{ $data[0]->DatePeriod }}
@endif
@php $balance = floatval($data[0]->OpeningBalance ?? 0); $totalDebit = 0; $totalCredit = 0; @endphp {{-- ✅ New: Opening Balance row --}} {{-- ✅ Existing detail rows --}} @foreach($data as $row) @php $amount = floatval($row->Amount); $balance += $amount; if ($amount > 0) $totalDebit += $amount; if ($amount < 0) $totalCredit += abs($amount); @endphp @endforeach {{-- ✅ Totals row remains unchanged --}}
Voucher Date Remarks Site Other Account Debit Credit Cl. Balance
Opening Balance {{ $balance < 0 ? '(' . number_format(abs($balance), 0) . ')' : number_format($balance, 0) }}
{{ $row->Voucher ?? '' }} {{ \Carbon\Carbon::parse($row->Voucher_Date)->format('d-m-Y') }} {{ $row->Remarks }} {{ $row->Cheque_No }} {{ $row->Other_Account ?? 'N/A' }} {{ $amount > 0 ? number_format($amount, 0) : '' }} {{ $amount < 0 ? number_format(abs($amount), 0) : '' }} {{ $balance < 0 ? '(' . number_format(abs($balance), 0) . ')' : number_format($balance, 0) }}
Totals {{ number_format($totalDebit, 0) }} {{ number_format($totalCredit, 0) }} {{ $balance < 0 ? '(' . number_format(abs($balance), 0) . ')' : number_format($balance, 0) }}
@endisset
@push('js') @endpush @endsection