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

{{ $vendor['vendor_type'] == 0 ? 'Vendor':'Contractor'}} Detail

@csrf
Good job!
Good job!
{{-- --}} {{-- --}} @if(!empty($dfrom) && !empty($dto)) @endif {{-- --}}
{{ $vendor['vendor_type'] == 0 ? 'Vendor':'Contractor'}}: {{$vendor['vendor_no']}} - {{$vendor['fname']}}Vendor Type: {{$vendor['vtname']}}Contact: {{$vendor['phone1']}}Date From: {{date("d-m-Y", strtotime($dfrom))}} Date To: {{date("d-m-Y", strtotime($dto))}}{{($balance > 0)? 'Payable':'Receiveable'}} Amount: {{number_format(abs($balance))}}Payable Amount: {{number_format($balance)}}
@php $index = 1; $balance = $oBalance; @endphp @if($oBalance != 0) @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 @endforeach @endif @if($cBalance != 0) @endif
Sr. Date Transaction Type Debit Credit Balance Action
{{$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) }}
{{ $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')
@if(isset($item->stock_id)) View @endif @if(isset($item->wage_details) && !empty($item->wage_details) && isset($item->stock_id)) @endif
@else View @endif @elseif(isset($item->return_no)) View @elseif(isset($item->purchase_no)) View @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
{{-- Wages Detail Modals --}} @if($detail->count()) @foreach($detail as $item) @if(isset($item->transaction_type) && $item->transaction_type == 'wages' && isset($item->wage_details)) @endif @endforeach @endif @endsection