@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) }}
Monthly Invoice vs Payment Comparison (Last 6 Months)
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) }}
| # |
Invoice # |
Bill Date |
Amount |
Paid |
Due |
Status |
Actions |
@php
$serial = ($invoices->currentPage() - 1) * $invoices->perPage();
@endphp
@forelse($invoices as $inv)
| {{ ++$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
|
@empty
| No invoices found |
@endforelse
@if($invoices->hasPages())
@endif
@foreach($invoices as $inv)
@if(($inv->due_amount ?? 0) > 0)
@endif
@endforeach
Invoice Transactions
| # |
Trans Date |
Invoice # |
Type |
Amount |
Method |
Ref |
@php $itSerial = ($invoiceTransactions->currentPage() - 1) * $invoiceTransactions->perPage(); @endphp
@forelse($invoiceTransactions as $tx)
| {{ ++$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 ?? '—' }} |
@empty
| No invoice transactions found |
@endforelse
@if($invoiceTransactions->hasPages())
{{ $invoiceTransactions->withQueryString()->fragment('payment-bills')->links() }}
@endif
Advance Payments
| # |
Trans Date |
Invoice # |
Amount |
Used Amount |
Remaining |
Status |
@php $apSerial = ($advancePayments->currentPage() - 1) * $advancePayments->perPage(); @endphp
@forelse($advancePayments as $ap)
@php $remaining = ($ap->amount ?? 0) - ($ap->used_amount ?? 0); @endphp
| {{ ++$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 ?? '—') }} |
@empty
| No advance payments found |
@endforelse
@if($advancePayments->hasPages())
{{ $advancePayments->withQueryString()->fragment('payment-bills')->links() }}
@endif
| # |
Cheque Number |
Bank Account |
Issue Date |
Payee Date |
Amount |
Purpose |
Clearing Status |
Actions |
@php
$ciSerial = ($chequeIssues->currentPage() - 1) * $chequeIssues->perPage();
@endphp
@forelse($chequeIssues as $cheque)
| {{ ++$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
|
@empty
| No cheque issues found |
@endforelse
@if($chequeIssues->hasPages())
@endif
@foreach($chequeIssues as $cheque)
@endforeach
| Date |
Source |
Reference |
Description |
Debit |
Credit |
@forelse($statementEntries as $row)
| {{ \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)) : '' }} |
@empty
| No statement data found for selected period |
@endforelse