@extends('layouts.app') @section('title', 'Suppliers') @section('content')

Supplier ledger

Creditor balances, supplier invoices and payment history. Supplier records are maintained in the inventory module.
Manage suppliers
@include('finance._nav') @php $openInvoices = \Illuminate\Support\Facades\DB::table('supplier_invoices') ->join('suppliers', 'suppliers.id', '=', 'supplier_invoices.supplier_id') ->select('supplier_invoices.*', 'suppliers.name as supplier_name') ->whereRaw('supplier_invoices.total > supplier_invoices.paid_amount') ->orderByDesc('supplier_invoices.id')->get(); $balances = \Illuminate\Support\Facades\DB::table('supplier_invoices') ->select('supplier_id', \Illuminate\Support\Facades\DB::raw('SUM(total - paid_amount) as balance')) ->groupBy('supplier_id')->pluck('balance', 'supplier_id'); $paidTotal = \Illuminate\Support\Facades\DB::table('supplier_payments')->where('status', 'Active')->sum('amount'); @endphp

Supplier balances

Aggregated from supplier invoices.
@forelse($suppliers as $supplier) @empty @endforelse
SupplierContactPhoneOutstandingStatusAction
{{ $supplier->name }}
{{ $supplier->kra_pin ? 'PIN '.$supplier->kra_pin : ($supplier->email ?: '—') }}
{{ $supplier->contact_name ?: '—' }} {{ $supplier->contact_phone ?: ($supplier->phone ?: '—') }} {{ money($balances[$supplier->id] ?? 0) }}

Open invoices

Ready for payment
@forelse($openInvoices as $invoice)
{{ $invoice->supplier_name }}
{{ $invoice->ref_no }}
{{ money($invoice->total - $invoice->paid_amount) }}
of {{ money($invoice->total) }}
@empty @endforelse

Recent supplier payments

{{ num($payments->count()) }} latest entries
@forelse($payments as $payment) @empty @endforelse
DateSupplierMethodReferenceAmountStatusAction
{{ \Carbon\Carbon::parse($payment->paid_on)->format('d M Y') }} {{ $payment->supplier_name }} {{ $payment->method }} {{ $payment->reference ?: '—' }} {{ money($payment->amount) }} @if($payment->status !== 'Void')
@csrf
@endif
@csrf
@foreach($suppliers as $supplier)
@csrf
@endforeach @endsection