@extends('admin.layout.print') @section('content')
{{-- Header (Shop Info) --}}

{{ $admin->name ?? 'Shop Name' }}

{{ $admin->address ?? '' }}

Phone: {{ $admin->contact ?? 'N/A' }}

{{-- Title --}}

Supplier Ledger Report

Generated on: {{ now()->format('d/m/Y H:i') }}
{{-- Supplier Details --}}

Supplier Details

Name: {{ $supplier->name ?? '-' }}
CNIC: {{ $supplier->cnic ?? '-' }}
WhatsApp: {{ $supplier->whatsapp ?? '-' }}
Address: {{ $supplier->address ?? '-' }}
Opening Balance: Rs. {{ number_format($openingBalance) }}
Current Balance: Rs. {{ number_format($currentBalance) }}
{{-- Summary Boxes --}}
Total Debit (Purchases) Rs. {{ number_format($totalDebit) }}
Total Credit (Payments) Rs. {{ number_format($totalCredit) }}
Balance Due Rs. {{ number_format($currentBalance) }}
{{-- Transaction History --}}
Transaction History
@php $balance = $openingBalance; $sr = 1; $totalDebitRow = 0; $totalCreditRow = 0; @endphp {{-- Opening Balance Row --}} @foreach($purchases as $purchase) @php $debit = $purchase->total ?? 0; $balance += $debit; $totalDebitRow += $debit; @endphp {{-- Purchase Paid Credit --}} @if(($purchase->paid ?? 0) > 0) @php $credit = $purchase->paid ?? 0; $balance -= $credit; $totalCreditRow += $credit; @endphp @endif @endforeach {{-- Payments (Credit) --}} @foreach($wallets as $wallet) @php $credit = $wallet->amount ?? 0; $balance -= $credit; $totalCreditRow += $credit; $paymentType = $wallet->payment_type ?? $wallet->method ?? 'Payment'; @endphp @endforeach {{-- Totals Row --}}
# Date Item Qty Price Payment Debit Credit Balance
- - Opening Balance - - - - - Rs. {{ number_format($balance) }}
{{ $sr++ }} {{ \Carbon\Carbon::parse($purchase->date)->format('d/m/Y') }} {{ $purchase->item_name ?? 'Purchase' }} {{ $purchase->quantity ?? '-' }} {{ number_format($purchase->total ?? 0) }} {{ ucfirst($purchase->mop ?? '-') }} Rs. {{ number_format($debit) }} - Rs. {{ number_format($balance) }}
{{ $sr++ }} {{ \Carbon\Carbon::parse($purchase->date)->format('d/m/Y') }} Payment (Purchase) - - {{ ucfirst($purchase->type ?? 'Cash') }} - Rs. {{ number_format($credit) }} Rs. {{ number_format($balance) }}
{{ $sr++ }} {{ \Carbon\Carbon::parse($wallet->date)->format('d/m/Y') }} Payment - - {{ ucfirst($paymentType) }} - Rs. {{ number_format($credit) }} Rs. {{ number_format($balance) }}
Totals: Rs. {{ number_format($totalDebitRow) }} Rs. {{ number_format($totalCreditRow) }} Rs. {{ number_format($balance) }}
@endsection