@extends('index')
@section('content')
{{ $vendor['vendor_type'] == 0 ? 'Vendor':'Contractor'}}: {{$vendor['vendor_no']}} - {{$vendor['fname']}}
{{-- Vendor Type: {{$vendor['vtname']}} --}}
{{-- Contact: {{$vendor['phone1']}} --}}
@if(!empty($dfrom) && !empty($dto))
Date From: {{date("d-m-Y", strtotime($dfrom))}}
Date To: {{date("d-m-Y", strtotime($dto))}}
@endif
{{($balance > 0)? 'Payable':'Receiveable'}} Amount: {{number_format(abs($balance))}}
{{-- Payable 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 vendor/contractor ledger (liability account):
// DB debit (displayed as Credit) = purchases/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;
$balance += $debit - $credit;
// For vendor/contractor 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->return_date) ? \Carbon\Carbon::parse($item->return_date)->format('d-m-Y') : (isset($item->purchase_date) ? \Carbon\Carbon::parse($item->purchase_date)->format('d-m-Y') : (isset($item->transaction_date) ? $item->transaction_date : '')) }}
@if(isset($item->transaction_type)) {{ucfirst($item->transaction_type)}}
@elseif(isset($item->return_no)) Return - ({{$item->return_no}})
@elseif(isset($item->purchase_no)) Purchase - ({{$item->purchase_no}})
@else Unknown Type @endif
{{ $displayDebit > 0 ? number_format($displayDebit) : '' }}
{{ $displayCredit > 0 ? number_format($displayCredit) : '' }}
{{number_format($balance)}}
@if(isset($item->transaction_type))
@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