@extends('layouts.app') @section('title', 'View Provider Name') @section('content')
Profile Provider
{{ $provider->name }}

@if($provider->website) {{ $provider->website }} @else No website @endif

Status: {{ ucfirst($provider->status) }}
Contact Person: {{ $provider->contact_person ?? 'N/A' }}
Email: {{ $provider->contact_email ?? 'N/A' }}
Phone: {{ $provider->contact_phone ?? 'N/A' }}
Created Date: {{ $provider->created_at->format('d M Y') }}
Quick Stats
Days Active: {{ $provider->created_at->diffInDays(now()) }} days
Last Updated: {{ $provider->updated_at->format('d M Y') }}
@php $overviewInvoices = $provider->purchaseInvoices; $totalInvoices = $overviewInvoices->count(); $totalInvoiceAmount = $overviewInvoices->sum('bill_amount'); $totalPaid = $overviewInvoices->sum('paid_amount'); $totalDue = $overviewInvoices->sum('due_amount'); // Calculate unused credits: amount - used_amount for all advances $allAdvances = $provider->purchaseAdvancePayments()->get(); $unusedCredits = $allAdvances->sum(function($adv) { return ($adv->amount ?? 0) - ($adv->used_amount ?? 0); }); // Invoice vs Payment Analysis - Last 6 Months for this provider $months = []; $invoiceData = []; $paymentData = []; for ($i = 5; $i >= 0; $i--) { $date = now()->subMonths($i); $monthKey = $date->format('Y-m'); $monthLabel = $date->format('M Y'); // Get invoice amounts for this month for this provider (based on bill_date) $monthInvoices = $overviewInvoices->filter(function($inv) use ($monthKey) { return $inv->bill_date && \Carbon\Carbon::parse($inv->bill_date)->format('Y-m') === $monthKey; }); $invoiceAmount = $monthInvoices->sum('bill_amount'); // Get payment amounts for this month from purchase_invoice_transections for this provider $monthPayments = \App\Models\PurchaseInvoiceTransection::whereHas('purchaseInvoice', function($query) use ($provider) { $query->where('provider_id', $provider->id); }) ->where('transaction_type', 'payment') ->whereYear('transaction_date', $date->year) ->whereMonth('transaction_date', $date->month) ->sum('amount'); $months[] = $monthLabel; $invoiceData[] = $invoiceAmount; $paymentData[] = $monthPayments; } @endphp
Client Overview
BDT - Bangladeshi Taka
BDT {{ number_format($totalDue, 2) }}
BDT {{ number_format($unusedCredits, 2) }}
Invoice vs Payment Analysis
Monthly Invoice vs Payment Comparison (Last 6 Months)
Payment Distribution
Payment Summary
Total Invoice Amount: BDT {{ number_format($totalInvoiceAmount, 2) }}
Total Paid Amount: BDT {{ number_format($totalPaid, 2) }}
Due Amount: BDT {{ number_format($totalDue, 2) }}
Advance Amount: BDT {{ number_format($unusedCredits, 2) }}
Payment Ratio: {{ $totalInvoiceAmount > 0 ? number_format(($totalPaid / $totalInvoiceAmount) * 100, 2) : 0 }}%
Due Ratio: {{ $totalInvoiceAmount > 0 ? number_format(($totalDue / $totalInvoiceAmount) * 100, 2) : 0 }}%
Total Invoices

{{ $totalInvoices }}

Total Invoices Amount
BDT {{ number_format($totalInvoiceAmount, 2) }}
Total Paid
BDT {{ number_format($totalPaid, 2) }}
Due Amount
BDT {{ number_format($totalDue, 2) }}
Bills or Invoices
+ Invoice
@if(request()->has(['from_date','to_date']) && (request('from_date') || request('to_date')))
Clear
@endif
@php $serial = ($invoices->currentPage() - 1) * $invoices->perPage(); @endphp @forelse($invoices as $inv) @empty @endforelse
# Invoice # Bill Date Amount Paid Due Status Actions
{{ ++$serial }} {{ $inv->bill_no ?? $inv->id }} {{ $inv->bill_date ? $inv->bill_date->format('d M Y') : 'N/A' }} BDT {{ number_format($inv->bill_amount ?? 0, 2) }} BDT {{ number_format($inv->paid_amount ?? 0, 2) }} BDT {{ number_format($inv->due_amount ?? 0, 2) }} @if(($inv->status ?? '') === 'paid') Paid @elseif(($inv->status ?? '') === 'partial') Partial @else Unpaid @endif @if(($inv->due_amount ?? 0) > 0) @else - @endif
No invoices found
@if($invoices->hasPages()) @endif
@foreach($invoices as $inv) @if(($inv->due_amount ?? 0) > 0) @endif @endforeach
@if(request()->filled('from_date') || request()->filled('to_date'))
Clear
@endif

Invoice Transactions
@php $itSerial = ($invoiceTransactions->currentPage() - 1) * $invoiceTransactions->perPage(); @endphp @forelse($invoiceTransactions as $tx) @empty @endforelse
# Trans Date Invoice # Type Amount Method Ref
{{ ++$itSerial }} {{ $tx->transaction_date ? \Carbon\Carbon::parse($tx->transaction_date)->format('d M Y') : 'N/A' }} {{ optional($tx->purchaseInvoice)->bill_no ?? optional($tx->purchaseInvoice)->id ?? '—' }} {{ ucfirst($tx->transaction_type ?? '—') }} BDT {{ number_format($tx->amount ?? 0, 2) }} {{ $tx->payment_method ?? '—' }} {{ $tx->reference ?? '—' }}
No invoice transactions found
@if($invoiceTransactions->hasPages())
{{ $invoiceTransactions->withQueryString()->fragment('payment-bills')->links() }}
@endif

Advance Payments
@php $apSerial = ($advancePayments->currentPage() - 1) * $advancePayments->perPage(); @endphp @forelse($advancePayments as $ap) @php $remaining = ($ap->amount ?? 0) - ($ap->used_amount ?? 0); @endphp @empty @endforelse
# Trans Date Invoice # Amount Used Amount Remaining Status
{{ ++$apSerial }} {{ $ap->transaction_date ? \Carbon\Carbon::parse($ap->transaction_date)->format('d M Y') : 'N/A' }} {{ $ap->purchase_invoices_id ?? '—' }} BDT {{ number_format($ap->amount ?? 0, 2) }} BDT {{ number_format($ap->used_amount ?? 0, 2) }} BDT {{ number_format($remaining, 2) }} {{ ucfirst($ap->status ?? '—') }}
No advance payments found
@if($advancePayments->hasPages())
{{ $advancePayments->withQueryString()->fragment('payment-bills')->links() }}
@endif
Cheque Issues
@if(request()->filled('from_date') || request()->filled('to_date'))
Clear
@endif
@php $ciSerial = ($chequeIssues->currentPage() - 1) * $chequeIssues->perPage(); @endphp @forelse($chequeIssues as $cheque) @empty @endforelse
# Cheque Number Bank Account Issue Date Payee Date Amount Purpose Clearing Status Actions
{{ ++$ciSerial }} {{ $cheque->chequeLeaf->cheque_number ?? 'N/A' }} {{ $cheque->chequeLeaf->chequeBook->bankAccount->bank_name ?? 'N/A' }}
{{ $cheque->chequeLeaf->chequeBook->bankAccount->account_number ?? 'N/A' }}
{{ $cheque->issue_date ? $cheque->issue_date->format('d M Y') : 'N/A' }} {{ $cheque->payee_date ? $cheque->payee_date->format('d M Y') : 'N/A' }} BDT {{ number_format($cheque->amount ?? 0, 2) }} {{ $cheque->purpose ?? 'N/A' }} @if($cheque->clearing_status == 'pending') Pending @elseif($cheque->clearing_status == 'cleared') Cleared @elseif($cheque->clearing_status == 'bounced') Bounced @else {{ ucfirst($cheque->clearing_status) }} @endif @if($cheque->clearing_status == 'cleared') @else @endif
No cheque issues found
@if($chequeIssues->hasPages()) @endif
@foreach($chequeIssues as $cheque) @endforeach
Statement
@php $defaultFrom = $stmtFrom ?? now()->startOfMonth()->toDateString(); $defaultTo = $stmtTo ?? now()->endOfMonth()->toDateString(); @endphp
@if(request()->filled('stmt_from') || request()->filled('stmt_to'))
Clear
@endif
@forelse($statementEntries as $row) @empty @endforelse
Date Source Reference Description Debit Credit
{{ \Carbon\Carbon::parse($row['date'])->format('d M Y') }} {{ $row['source'] }} {{ $row['ref'] ?? '—' }} {{ $row['description'] }} {{ $row['debit'] > 0 ? ('BDT ' . number_format($row['debit'], 2)) : '' }} {{ $row['credit'] > 0 ? ('BDT ' . number_format($row['credit'], 2)) : '' }}
No statement data found for selected period
@endsection