@extends('print.layout') @section('title', 'Purchase_Ledger_' . ($dfrom ?? 'All') . '_to_' . ($dto ?? 'Current')) @section('content')
Purchase Ledger
{{-- Report Information --}}
Report Type: Purchase Ledger
Report Period: {{ $dfrom ?? 'All Time' }} to {{ $dto ?? 'Current' }}
Opening Balance: {{ number_format($oBalance ?? 0, 2) }}
{{-- Ledger Transactions Table --}} @if(isset($detail) && $detail->count() > 0)

Transaction History

@php $index = 1; $runningBalance = $oBalance ?? 0; $totalDebit = 0; $totalCredit = 0; @endphp @if($oBalance != 0) @endif @foreach($detail as $transaction) @php $debit = $transaction->debit ?? 0; $credit = $transaction->credit ?? 0; $totalDebit += $debit; $totalCredit += $credit; $runningBalance += $debit - $credit; // Determine reference number and description $refNo = '-'; $description = 'Transaction'; if(isset($transaction->purchase_no)) { $refNo = $transaction->purchase_no; $description = 'Purchase'; } elseif(isset($transaction->return_no)) { $refNo = $transaction->return_no; $description = 'Return'; } elseif(isset($transaction->transaction_id)) { $refNo = 'TXN-' . date('Y') . '-' . str_pad($transaction->transaction_id, 4, '0', STR_PAD_LEFT); $description = $transaction->description ?? 'Vendor Payment'; } @endphp @endforeach
@else

No purchase ledger records found for the selected period.

@endif @endsection