@extends('layouts.master') @section('title', 'Client Invoice - ') @section('content') @php $PermissionsAdd = Auth::check() ? Auth::user()->hasFeaturePermission('client-invoices', 'add') : false; $PermissionsEdit = Auth::check() ? Auth::user()->hasFeaturePermission('client-invoices', 'edit') : false; $PermissionsDelete = Auth::check() ? Auth::user()->hasFeaturePermission('client-invoices', 'delete') : false; $PermissionsPrint = Auth::check() ? Auth::user()->hasFeaturePermission('client-invoices', 'print') : false; @endphp

Client Invoice Management

Process Invoice
@if (session('success'))
{{ session('success') }}
@endif @if ($errors->any())
@foreach ($errors->all() as $error)
{{ $error }}
@endforeach
@endif
@csrf
@php $oldClientId = old('client_id'); $oldClientName = ''; if ($oldClientId) { $matchedClient = $clients->firstWhere('id', (int) $oldClientId); $oldClientName = $matchedClient ? ($matchedClient->full_name ?? ($matchedClient->client_name ?? trim(($matchedClient->first_name ?? '') . ' ' . ($matchedClient->last_name ?? '')))) : ''; } @endphp
Start typing to search and select a client.
{{ $homeCurrency?->currency?->currency_name ?? 'Home Currency' }} {{ $homeCurrency?->currency?->currency_code ?? '' }} {{ $homeCurrency?->currency?->symbol ? '• '.$homeCurrency?->currency?->symbol : '' }}

Add multiple tariffs (hourly uses minutes; fixed/per case uses quantity; percentage uses base amount).

Add multiple disbursements (e.g., Court filing fees, Travel, Photocopying, Courier, etc.)

Allocate totals across multiple GL accounts (optional).

Add multiple taxes (e.g., VAT, Withholding Tax, etc.) - Total tax will be calculated as combined percentage


Client Transactions
@if($PermissionsAdd) Process @endif Back to Client
Filter
@foreach ($clientTransactions as $transaction) @php $amountPaid = (float) ($transaction->amount_paid ?? 0); $totalAmount = (float) ($transaction->total ?? 0); $balanceAmount = isset($transaction->balance_due) ? (float) $transaction->balance_due : max($totalAmount - $amountPaid, 0); if ($totalAmount > 0 && $balanceAmount <= 0) { $invoiceStatusKey = 'fully_paid'; } elseif ($amountPaid > 0) { $invoiceStatusKey = 'partially_paid'; } else { $invoiceStatusKey = 'unpaid'; } $invoiceData = [ 'id' => $transaction->id, 'client_id' => $transaction->client_id, 'invoice_number' => $transaction->invoice_number, 'invoice_date' => optional($transaction->invoice_date)->format('Y-m-d'), 'due_date' => optional($transaction->due_date)->format('Y-m-d'), 'status' => $transaction->status, 'matter_id' => $transaction->matter_id, 'case_id' => $transaction->case_id, 'case_reference' => $transaction->case_reference, 'description' => $transaction->description, 'responsible_lawyer' => $transaction->responsible_lawyer, 'narration' => $transaction->narration, 'gl_account' => $transaction->gl_account, 'discount' => ($transaction->subtotal - $transaction->disbursement_total) > 0 ? round(($transaction->discount_total / max(($transaction->subtotal - $transaction->disbursement_total), 1)) * 100, 2) : 0, 'currency_id' => $transaction->currency_id, 'billing_period_from' => optional($transaction->billing_period_from)->format('Y-m-d'), 'billing_period_to' => optional($transaction->billing_period_to)->format('Y-m-d'), ]; $tariffLines = $transaction->lines->map(fn($line) => [ 'tariff_id' => $line->tariff_id, 'minutes_used' => $line->total_raw_minutes ?? 0, 'quantity' => $line->quantity, 'base_amount' => $line->base_amount, ])->values(); $taxLines = $transaction->taxesList->map(fn($line) => [ 'tax_id' => $line->tax_id, 'tax_rate' => $line->tax_rate, ])->values(); $disbursementLines = $transaction->disbursementsList->map(fn($line) => [ 'description' => $line->description, 'amount' => $line->amount, 'gl_account_id' => $line->gl_account_id ?? null, ])->values(); $glSplits = $transaction->glAccounts->map(fn($line) => [ 'gl_account_id' => $line->gl_account_id ?? null, 'gl_account_code' => $line->gl_account_code ?? null, 'amount' => $line->amount ?? 0, 'line_type' => $line->line_type ?? null, 'description' => $line->description ?? null, ])->values(); @endphp @endforeach
Entry Date Description Matter Tariff Total Disbursements Discount % Tax Total Total Status Actions
{{ $transaction->created_at->format('Y-m-d') }} {{ $transaction->description }} {{ $transaction->case_reference }} {{ number_format($transaction->subtotal, 2) }} {{ number_format($transaction->disbursement_total, 2) }} {{ number_format($transaction->discount_total, 2) }} {{ number_format($transaction->tax_total, 2) }} {{ number_format($transaction->total, 2) }} {{ ucfirst((string) $transaction->status) }} @if($PermissionsEdit) Edit @endif @if($PermissionsAdd) Process @endif @if($PermissionsPrint) Print @endif @if($PermissionsDelete) Delete @endif
Invoice Summary

Tariff Subtotal: 0.00

Disbursements: 0.00

Discount: 0.00

Tax Total: 0.00

Net Total: 0.00

@endsection