{{-- Supplier --}}
{{-- Transaction Type --}}
{{-- Reference Number --}}
{{-- Claim Month --}}
{{-- Transaction Date From --}}
{{-- Transaction Date To --}}
@php static $supplierBalances = []; static $suppliersShown = []; $hasDateFilter = request('filter.transaction_date_from'); @endphp {{-- Total Opening Balance Row (only show if there's an opening balance) --}} @if (($totalOpeningBalance ?? 0) != 0) Total Opening Balance: {{ number_format($totalOpeningBalance, 2) }} - - {{ number_format($totalOpeningBalance, 2) }} @endif @foreach ($claims as $index => $claim) @php $supplierId = $claim->supplier_id; // Initialize supplier balance with opening balance if not yet done if (!isset($supplierBalances[$supplierId])) { $supplierBalances[$supplierId] = $openingBalances[$supplierId] ?? 0; } $debit = (float) $claim->debit; $credit = (float) $claim->credit; // Opening balance is the balance BEFORE this transaction $transactionOpeningBalance = $supplierBalances[$supplierId]; // Apply transaction to get closing balance $supplierBalances[$supplierId] += $debit - $credit; $closingBalance = $supplierBalances[$supplierId]; @endphp {{ $claims->firstItem() + $index }} {{ $claim->transaction_date->format('d-m-Y') }} {{ $claim->supplier?->short_name ?? '-' }} {{ $claim->reference_number ?? '-' }} {{ $claim->description ?? '-' }} {{ $claim->claim_month ?? '-' }} {{ number_format($transactionOpeningBalance, 2) }} {{ $debit > 0 ? number_format($debit, 2) : '-' }} {{ $credit > 0 ? number_format($credit, 2) : '-' }} {{ number_format($closingBalance, 2) }}
@if (!$claim->isPosted()) @can('claim-register-edit') @endcan @role('super-admin')
@csrf @method('DELETE')
@endrole @endif
@endforeach