@extends('admin.master') @section('title', 'Supplier Ledger: ' . $supplier->name) @section('content')
Ledger Summary

{{ $supplier->name }}

Company: {{ $supplier->company_name ?? 'N/A' }}
Mobile: {{ $supplier->mobile }}
Email: {{ $supplier->email ?? 'N/A' }}
Address: {{ $supplier->address ?? 'N/A' }}
@if($supplier->customer_id) @endif
Total Purchases: ৳ {{ number_format($total_purchases, 2) }} Total Paid: ৳ {{ number_format($total_paid, 2) }}
Total Sales: ৳ {{ number_format($total_sales, 2) }} Total Received: ৳ {{ number_format($total_received, 2) }}
{{ $net_due >= 0 ? 'Total Payable (Company owes Supplier)' : 'Total Receivable (Supplier owes Company)' }} ৳ {{ number_format(abs($net_due), 2) }}
Transaction History (Combined)
@php $running_balance = 0; @endphp @if(count($transactions) > 0) @foreach($transactions as $txn) @php $payable = 0; $paid = 0; /* Calculate running balance */ if($txn->type == 'Purchase' || $txn->type == 'Payment Received') { $payable = $txn->amount; $running_balance += $payable; } elseif($txn->type == 'Payment Given' || $txn->type == 'Sale') { $paid = $txn->amount; $running_balance -= $paid; } @endphp @endforeach @else @endif
Date Ref No. / Invoice Transaction Type Payable (Dr) Paid (Cr) Balance
{{ date('d-M-Y', strtotime($txn->date)) }} {{ $txn->ref_no }} @if($txn->type == 'Purchase') Purchase @elseif($txn->type == 'Payment Given') Payment Given @elseif($txn->type == 'Sale') Sale (Customer) @elseif($txn->type == 'Payment Received') Payment Rcv @endif {{ $payable > 0 ? '৳ '.number_format($payable, 2) : '-' }} {{ $paid > 0 ? '৳ '.number_format($paid, 2) : '-' }} ৳ {{ number_format(abs($running_balance), 2) }} ({{ $running_balance >= 0 ? 'Cr' : 'Dr' }})
No transactions found for this supplier.
Grand Total: ৳ {{ number_format(($total_purchases + $total_received), 2) }} ৳ {{ number_format(($total_paid + $total_sales), 2) }} ৳ {{ number_format(abs($running_balance), 2) }} ({{ $running_balance >= 0 ? 'Cr' : 'Dr' }})
@endsection