@extends('layouts.app') @section('title', 'Invoice '.$staffInvoice->invoice_number) @section('breadcrumb')Staff Invoices {{ $staffInvoice->invoice_number }}@endsection @section('content') @php $isAdminOrAccounts = in_array(auth()->user()->role?->name, ['office_admin','accounts']); @endphp
@if(session('success'))
{{ session('success') }}
@endif

{{ $staffInvoice->invoice_number }}

{{ $staffInvoice->period_start->format('d M Y') }} – {{ $staffInvoice->period_end->format('d M Y') }}

@if($staffInvoice->job)
Job: {{ $staffInvoice->job->job_number }} @if($staffInvoice->job->contact) — {{ $staffInvoice->job->contact->first_name }} {{ $staffInvoice->job->contact->last_name }} @endif Trades Invoice
@endif
{{ ucfirst($staffInvoice->status) }}
{{ $staffInvoice->user->initials }}
{{ $staffInvoice->user->name }}
{{ $staffInvoice->user->role?->display_name }}
{{ $staffInvoice->user->email }}
Hourly Rate
${{ number_format($staffInvoice->hourly_rate, 2) }}/hr
Total Hours
{{ number_format($staffInvoice->total_hours, 2) }}h
Rate
${{ number_format($staffInvoice->hourly_rate, 2) }}
Total Amount
${{ number_format($staffInvoice->total_amount, 2) }}
@if($staffInvoice->notes)
{{ $staffInvoice->notes }}
@endif @if($staffInvoice->approval_notes)
{{ ucfirst($staffInvoice->status) }} by {{ $staffInvoice->approver?->name }}: {{ $staffInvoice->approval_notes }}
@endif @if($staffInvoice->status === 'approved')
This approved invoice's labour cost is now reflected in the Gross Profit report @if($staffInvoice->job) for job {{ $staffInvoice->job->job_number }}@endif.
@endif

Time Entry Breakdown

@foreach($staffInvoice->timeEntries as $entry) @endforeach
Date Task Job Duration Amount
{{ $entry->started_at->format('d M H:i') }} {{ $entry->taskType?->name ?? '—' }} {{ $entry->job?->job_number ?? '—' }} {{ $entry->elapsed }} ${{ number_format($entry->duration_hours * $staffInvoice->hourly_rate, 2) }}
Total {{ number_format($staffInvoice->total_hours, 2) }}h ${{ number_format($staffInvoice->total_amount, 2) }}
@if($staffInvoice->job)
This is a trades job invoice for job {{ $staffInvoice->job->job_number }}. @if($staffInvoice->status === 'approved' || $staffInvoice->status === 'paid') The labour cost of ${{ number_format($staffInvoice->total_amount, 2) }} is included in the gross profit calculation for this job. @else Once approved, the labour cost will be included in the gross profit calculation for this job. @endif
@endif
@if($isAdminOrAccounts && $staffInvoice->status === 'pending')

Approval Required

@if($staffInvoice->job)
Trades Job Invoice
Job: {{ $staffInvoice->job->job_number }}
Approving will include this labour cost in the gross profit report for this job.
@endif

Review the time entries above and approve or reject this invoice.

@endif @if($isAdminOrAccounts && $staffInvoice->status === 'approved')

Payment

@csrf
@endif

Invoice Details

Invoice No.{{ $staffInvoice->invoice_number }}
Created{{ $staffInvoice->created_at->format('d M Y') }}
Period{{ $staffInvoice->period_start->format('d M') }} – {{ $staffInvoice->period_end->format('d M Y') }}
@if($staffInvoice->job)
Job{{ $staffInvoice->job->job_number }}
@endif
Entries{{ $staffInvoice->timeEntries->count() }}
@if($staffInvoice->approved_at)
{{ ucfirst($staffInvoice->status) }} At{{ $staffInvoice->approved_at->format('d M Y H:i') }}
@endif
@if($isAdminOrAccounts && $staffInvoice->job && in_array($staffInvoice->status, ['approved', 'paid'])) @endif Back to Invoices
@endsection