@extends('index') @section('content')

Expense Table

{{-- Filter Form --}}
@csrf
@if(!empty($dfrom) || !empty($dto) || !empty($head_id)) Clear @endif
@if(!empty($dfrom) || !empty($dto) || !empty($head_id))
Filtered Results: @if(!empty($dfrom) && !empty($dto)) Showing expenses from {{ date("d-m-Y", strtotime($dfrom)) }} to {{ date("d-m-Y", strtotime($dto)) }} @endif @if(!empty($head_id)) @php $selectedHead = $heads->firstWhere('head_id', $head_id); @endphp @if($selectedHead) for expense head: {{ $selectedHead->name }} @endif @endif
@endif
@php $totalDebit = 0; $totalCredit = 0; $balance = 0; @endphp @if($transaction->count()) @foreach($transaction as $item) @php $debit = $item->debit ?? 0; $credit = $item->credit ?? 0; $totalDebit += $debit; $totalCredit += $credit; // Balance calculation: Balance = Previous Balance + Debit - Credit $balance += $credit - $debit; @endphp @endforeach @endif
Sr. Date Voucher No Description Debit Credit Balance Action
{{$loop->index + 1}} {{\Carbon\Carbon::parse($item->transaction_date)->format('d-m-Y')}} SLE-{{ date('Y') }}-{{ str_pad($item->transaction_id, 4, '0', STR_PAD_LEFT) }} {{$item->name}} {{ $credit > 0 ? number_format($credit, 2) : '-' }} {{ $debit > 0 ? number_format($debit, 2) : '-' }} {{ number_format($balance, 2) }} View Edit
Total: {{ number_format($totalCredit, 2) }} {{ number_format($totalDebit, 2) }} {{ number_format($balance, 2) }}
@endsection