@extends('index')
@section('content')
Employee: {{$employee['employee_no']}} - {{$employee['name']}}
@if(!empty($dfrom) && !empty($dto))
Date From: {{date("d-m-Y", strtotime($dfrom))}}
Date To: {{date("d-m-Y", strtotime($dto))}}
@endif
{{-- Department: {{$employee['dname']}} --}}
{{-- Contact: {{$employee['phone']}} --}}
{{($balance > 0)? 'Payable':'Receivable'}} Amount: {{number_format(abs($balance))}}
{{-- Receivable Amount: {{number_format($balance)}} --}}
@php $index = 1; $balance = $oBalance; @endphp
@if($oBalance != 0)
Sr.
Date
Transaction Type
Debit
Credit
Balance
Action
@endif
@if($detail->count())
@foreach($detail as $item)
@php
// 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
$debit = $item->debit ?? 0;
$credit = $item->credit ?? 0;
if($item->transaction_type != 'salary'){
$balance += $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
{{$index++}}
{{\Carbon\Carbon::parse($dfrom)->format('d-m-Y')}}
Opening Balance
{{ $oBalance > 0 ? number_format(abs($oBalance)) : '' }}
{{ $oBalance < 0 ? number_format(abs($oBalance)) : '' }}
{{ number_format($oBalance) }}
@endforeach
@endif
@if($cBalance != 0)
{{ $loop->index + 1 }}
{{ isset($item->purchase_date) ? \Carbon\Carbon::parse($item->purchase_date)->format('d-m-Y') : (isset($item->transaction_date) ? \Carbon\Carbon::parse($item->transaction_date)->format('d-m-Y') : '') }}
@if(isset($item->transaction_type))
@switch($item->transaction_type)
@case('advance')
Give Loan
@break
@case('receiveAdvance')
Receive Loan Repayment
@break
@case('salaryAdvance')
Salary Advance
@break
@case('salary')
Monthly Salary
@if(isset($item->description))
{{ $item->description }}
@endif
@break
@default
{{ ucfirst($item->transaction_type) }}
@endswitch
@else
Purchase Order
@endif
{{ $displayDebit > 0 ? number_format($displayDebit) : '' }}
{{ $displayCredit > 0 ? number_format($displayCredit) : '' }}
{{number_format($balance)}}
@if($item->transaction_type == 'openingBalance')
View
@elseif($item->transaction_type == 'wages')
@endif
{{$index++}}
{{\Carbon\Carbon::parse($dto)->format('d-m-Y')}}
Closing Balance
{{ $cBalance < 0 ? number_format(abs($cBalance)) : '' }}
{{ $cBalance > 0 ? number_format(abs($cBalance)) : '' }}
{{ $balance ? number_format($balance += $cBalance) : number_format($oBalance + $cBalance) }}
Sr.
Date
Transaction Type
Debit
Credit
Balance
Action