@php /** @var \App\Models\Owner $owner */ /** @var \Illuminate\Support\Carbon $from */ /** @var \Illuminate\Support\Carbon $to */ /** @var \Illuminate\Support\Collection $entries */ /** @var array $totals */ /** @var string $statementId */ /** @var int $payoutAmountCents */ /** @var \Illuminate\Support\Collection|\Illuminate\Support\Collection[]|array $vehicles */ /** @var array|null $previewTotals */ /** @var \Illuminate\Support\Carbon|null $previewPayoutDate */ /** @var \Illuminate\Support\Collection|null $previewJobs */ // Normalise preview variables so the view never explodes $previewTotals = $previewTotals ?? ['owner_total_cents' => 0, 'month_label' => null, 'per_vehicle_cents' => []]; $previewPayoutDate = $previewPayoutDate ?? now()->copy()->day(10); $previewJobs = $previewJobs ?? collect(); $earnings = $totals['earnings_cents'] ?? 0; $costs = $totals['costs_cents'] ?? 0; $payouts = $totals['payouts_cents'] ?? 0; $adjustments = $totals['adjustments_cents'] ?? 0; $balance = $totals['balance_cents'] ?? 0; $fmt = fn (int $cents) => '$' . number_format($cents / 100, 2); $today = now(); $payoutReference = $owner->bank_reference ?: ('DD-' . $statementId); // Per-vehicle breakdown for the current statement period $vehicleSummary = []; foreach ($entries as $entry) { $name = $entry->vehicle->name ?? 'Unassigned'; $typeEnum = $entry->type; $type = $typeEnum instanceof \BackedEnum ? $typeEnum->value : (string) $typeEnum; $rawCents = (int) $entry->amount_cents; $ownerPercent = $entry->vehicle?->owner_share_percent; $ownerCents = $rawCents; if ($type === 'earning' && $ownerPercent !== null) { $ownerCents = (int) round($rawCents * ($ownerPercent / 100)); } elseif (in_array($type, ['cost', 'payout'], true)) { $ownerCents = $rawCents; } if (! isset($vehicleSummary[$name])) { $vehicleSummary[$name] = [ 'gross_cents' => 0, 'owner_cents' => 0, ]; } if ($type === 'earning') { $vehicleSummary[$name]['gross_cents'] += $rawCents; $vehicleSummary[$name]['owner_cents'] += $ownerCents; } } // Preview totals (next payout) $previewOwnerTotal = $previewTotals['owner_total_cents'] ?? 0; $previewMonthLabel = $previewTotals['month_label'] ?? $previewPayoutDate->format('F Y'); $previewPerVehicle = $previewTotals['per_vehicle_cents'] ?? []; @endphp Owner Statement

Owner Statement

Wilberforce Offroad Ltd T/A Dream Drives
Company GST {{ \App\Models\Owner::COMPANY_GST_NUMBER }} Owner {{ $owner->legal_name ?? $owner->name }}
Owner GST {{ $owner->gst_registered ? ($owner->gst_number ?: '—') : 'Not registered' }} Period {{ $from->toDateString() }} – {{ $to->toDateString() }}
Generated {{ $today->toDateTimeString() }} Statement ID {{ $statementId }}

Amounts shown are inclusive of GST where applicable. @if ($owner->gst_registered) This statement can be used to support your GST records. @else This statement is not a tax invoice. @endif

Payment
Payout for this statement {{ $fmt($payoutAmountCents) }}
Paid on {{ $today->toDateString() }}
Paid to {{ $owner->bank_account_name ?: ($owner->legal_name ?? $owner->name) }} @if ($owner->bank_account_number) · {{ $owner->bank_account_number }} @endif
Bank reference {{ $payoutReference }}
@if(!empty($vehicleSummary))

Vehicle summary

@foreach ($vehicleSummary as $vehicleName => $row) @endforeach
Vehicle Gross earnings Owner share
{{ $vehicleName }} {{ $fmt($row['gross_cents']) }} {{ $fmt($row['owner_cents']) }}
@endif

Summary

Earnings (your share) {{ $fmt($earnings) }}
Adjustments {{ $fmt($adjustments) }}
Costs {{ $fmt($costs) }}
Payouts {{ $fmt($payouts) }}
Balance for this period {{ $fmt($balance) }}
@if ($previewOwnerTotal > 0)

Future earnings (next payout)

Estimated owner share for bookings ending in {{ $previewMonthLabel }}. These will be paid on {{ $previewPayoutDate->toDateString() }} according to our payout schedule (10th of each month for the previous month’s completed bookings).

@foreach ($previewPerVehicle as $vehicleName => $ownerCents) @endforeach
Vehicle Estimated owner share
{{ $vehicleName }} {{ $fmt($ownerCents) }}
Total estimated owner share {{ $fmt($previewOwnerTotal) }}
@endif @if ($previewJobs->isNotEmpty())

Upcoming bookings

@foreach ($previewJobs as $job) @php $ownerPercent = $job->vehicle?->owner_share_percent ?? 100; $gross = (int) ($job->charge_amount_cents ?? $job->total_price_cents ?? 0); $ownerCents = (int) round($gross * ($ownerPercent / 100)); @endphp @endforeach
Vehicle Start End Est. owner share
{{ $job->vehicle?->name }} {{ \Illuminate\Support\Carbon::parse($job->start_at)->toDateString() }} {{ \Illuminate\Support\Carbon::parse($job->end_at)->toDateString() }} {{ $fmt($ownerCents) }}
@endif

Ledger entries

@forelse ($entries as $entry) @php $typeEnum = $entry->type; $type = $typeEnum instanceof \BackedEnum ? $typeEnum->value : (string) $typeEnum; $rawCents = (int) $entry->amount_cents; $ownerPercent = $entry->vehicle?->owner_share_percent; $ownerCents = $rawCents; if ($type === 'earning' && $ownerPercent !== null) { $ownerCents = (int) round($rawCents * ($ownerPercent / 100)); } elseif (in_array($type, ['cost', 'payout'], true)) { $ownerCents = $rawCents; } $date = $entry->occurred_at ? \Illuminate\Support\Carbon::parse($entry->occurred_at)->format('Y-m-d H:i') : ''; @endphp @empty @endforelse
Date Type Raw amount Owner % Owner amount Vehicle Booking Description
{{ $date }} {{ ucfirst($type) }} {{ $fmt($rawCents) }} @if ($type === 'earning' && $ownerPercent !== null) {{ $ownerPercent }}% @elseif (in_array($type, ['cost', 'payout'], true)) 100% @else — @endif {{ $fmt($ownerCents) }} {{ $entry->vehicle?->name }} {{ $entry->job?->booking_reference }} {{ $entry->description }}
No entries for this period.

If anything in this statement doesn’t look right, please contact us as soon as possible.