@extends('layouts.master') @section('title', 'Client Statement') @section('styles') @endsection @section('content') @php $companyDetails = $company ?? \App\Models\CompanySettings::query()->first(); $selectedCurrency = null; if (!empty($currency)) { $selectedCurrency = ($currencies ?? collect())->firstWhere('currency_id', $currency); } $currencySymbol = $selectedCurrency->symbol ?? '$'; @endphp

{{ $companyDetails->company_name ?? config('app.name', 'Law Firm') }}

@if(!empty($companyDetails?->address)) {{ $companyDetails->address }} @else {{ $companyDetails?->company_code ?? 'Law Firm Information' }} @endif @if(!empty($companyDetails?->contact_phone))  |  {{ $companyDetails->contact_phone }} @endif @if(!empty($companyDetails?->contact_email))  |  {{ $companyDetails->contact_email }} @endif

Refresh @if($selectedClient) Download PDF @endif Back
@if($selectedClient)

{{ $selectedClient->full_name }}

{{ $selectedClient->email ?? 'N/A' }} {{ $selectedClient->phone_primary ?? 'N/A' }}

{{ trim(implode(', ', array_filter([ $selectedClient->street_address ?? null, $selectedClient->city ?? null, $selectedClient->state_province ?? null, $selectedClient->country ?? null, ]))) ?: '—' }}

Statement period: {{ $dateFrom ?? 'N/A' }} to {{ $dateTo ?? 'N/A' }}
Opening Balance
{{ $currencySymbol }}{{ number_format((float)($openingBalance ?? 0), 2) }}
as of period start
Total Invoices
{{ $currencySymbol }}{{ number_format((float)($metrics['totalInvoices'] ?? 0), 2) }}
billed this period
Total Receipts
{{ $currencySymbol }}{{ number_format((float)($metrics['totalReceipts'] ?? 0), 2) }}
payments received
Current Balance
{{ $currencySymbol }}{{ number_format((float)($metrics['balance'] ?? 0), 2) }}
outstanding amount
Overdue
{{ (int)($metrics['overdueInvoices'] ?? 0) }}
invoices past due
Paid Invoices
{{ (int)($metrics['paidInvoices'] ?? 0) }}
fully settled
Invoice Activity & Receipts
@forelse(($transactions ?? collect()) as $txn) @php $type = strtolower((string)($txn['type'] ?? '')); $signed = (float)($txn['debit'] ?? 0) - (float)($txn['credit'] ?? 0); $status = strtolower((string)($txn['status'] ?? '')); $badge = 'badge-status'; if ($type === 'invoice' && $status === 'paid') $badge = 'badge-status badge-paid'; elseif ($type === 'invoice' && $status === 'overdue') $badge = 'badge-status badge-overdue'; elseif ($type === 'invoice' && in_array($status, ['unpaid', 'sent', 'pending'], true)) $badge = 'badge-status badge-unpaid'; elseif ($type === 'receipt') $badge = 'badge-status badge-paid'; @endphp @empty @endforelse @if(($transactions ?? collect())->count() > 0) @php $netPeriod = (float)($metrics['totalInvoices'] ?? 0) - (float)($metrics['totalReceipts'] ?? 0); $opening = (float)($openingBalance ?? 0); $closing = (float)($metrics['balance'] ?? 0); $fmtSigned = function ($v) use ($currencySymbol) { $v = (float)$v; return ($v < 0 ? '-' : '') . $currencySymbol . number_format(abs($v), 2); }; @endphp @endif
Date Type Description / Matter Reference Amount ({{ $currencySymbol }}) Status
{{ !empty($txn['date']) ? \Carbon\Carbon::parse($txn['date'])->format('Y-m-d') : '' }} {{ $type === 'receipt' ? 'Receipt' : 'Invoice' }} {{ $txn['description'] ?? '' }} {{ $txn['reference'] ?? '' }} {{ $signed < 0 ? '-' : '' }}{{ $currencySymbol }}{{ number_format(abs($signed), 2) }} {{ $type === 'receipt' ? 'Received' : ($txn['status'] ?? 'N/A') }}
No transactions for the selected period. Adjust date range or generate report.
Net period activity {{ $fmtSigned($netPeriod) }}
Opening balance (carried) {{ $fmtSigned($opening) }}
Closing balance {{ $fmtSigned($closing) }}
@else

Select a client

Please choose a client and generate the statement.

{{ $dateFrom ?? date('Y-m-01') }} to {{ $dateTo ?? date('Y-m-d') }}
@endif
@endsection