@php $runningBalance = $netOpening; $totalDr = max($netOpening, 0); $totalCr = max(-$netOpening, 0); $formatBal = function($amount) { if ($amount == 0) return '-'; $suffix = $amount >= 0 ? ' Dr' : ' Cr'; return indian_number(abs($amount), 2) . $suffix; }; @endphp @foreach($ledger as $entry) @php $runningBalance += ($entry['debit'] - $entry['credit']); $totalDr += $entry['debit']; $totalCr += $entry['credit']; @endphp @endforeach
Date Type Particulars Ref No. Debit Credit Balance
{{ \Carbon\Carbon::parse($startDate)->format('d-M-Y') }} OPENING Balance Brought Forward - {{ $netOpening > 0 ? indian_number(abs($netOpening), 2) : '-' }} {{ $netOpening < 0 ? indian_number(abs($netOpening), 2) : '-' }} {{ $formatBal($runningBalance) }}
{{ \Carbon\Carbon::parse($entry['date'])->format('d-M-Y') }} {{ $entry['type'] }} {{ $entry['desc'] }} {{ $entry['ref'] ?: '-' }} {{ $entry['debit'] > 0 ? indian_number($entry['debit'], 2) : '-' }} {{ $entry['credit'] > 0 ? indian_number($entry['credit'], 2) : '-' }} {{ $formatBal($runningBalance) }}
Period Totals: {{ indian_number($totalDr, 2) }} {{ indian_number($totalCr, 2) }} {{ $formatBal($runningBalance) }}
Closing Balance: @if($runningBalance >= 0) {{ indian_number(abs($runningBalance), 2) }} Dr (Party owes you) @else {{ indian_number(abs($runningBalance), 2) }} Cr (You owe party) @endif {{ $formatBal($runningBalance) }}