@extends('print.layout') @section('title', 'Employee_Ledger_' . ($employee['employee_no'] ?? 'N/A') . '_' . ($dfrom ?? 'All') . '_to_' . ($dto ?? 'Current')) @section('content')
Employee Ledger
{{-- Employee Information --}}
Employee No: {{ $employee['employee_no'] ?? 'N/A' }}
Employee Name: {{ $employee['name'] ?? 'N/A' }}
Department: {{ $employee['dname'] ?? 'N/A' }}
Employee Type: {{ $employee['etname'] ?? 'N/A' }}
Report Period: {{ $dfrom ?? 'All Time' }} to {{ $dto ?? 'Current' }}
Opening Balance: {{ number_format($oBalance ?? 0, 2) }}
Phone: {{ $employee['phone'] ?? 'N/A' }}
CNIC: {{ $employee['cnic'] ?? 'N/A' }}
{{-- Ledger Transactions Table --}} @if(isset($detail) && $detail->count() > 0)

Transaction History

@php $runningBalance = $oBalance ?? 0; @endphp @if($oBalance != 0) @endif @foreach($detail as $transaction) @php $debit = $transaction->debit ?? 0; $credit = $transaction->credit ?? 0; // For employee ledger (liability account): // DB debit (displayed as Credit) = work done, increases liability = ADD to balance // DB credit (displayed as Debit) = payments made, decreases liability = SUBTRACT from balance // Include ALL transaction types - no filtering $runningBalance += $debit - $credit; // For employee ledger, reverse the display (DB debit shown in credit column, DB credit shown in debit column) $displayDebit = $credit; $displayCredit = $debit; @endphp @endforeach
@endif {{-- Summary Section --}}
Total Wages Earned: {{ number_format($detail->sum('debit') ?? 0, 2) }}
Total Payments Received: {{ number_format($detail->sum('credit') ?? 0, 2) }}
Current Balance: {{ number_format($balance ?? 0, 2) }}
{{-- Balance Status --}}

Account Status

@if($balance > 0) Credit Balance: Company owes employee {{ number_format(abs($balance), 2) }} @elseif($balance < 0) Debit Balance: Employee owes company {{ number_format(abs($balance), 2) }} @else Balanced Account: No outstanding amount @endif
@endsection