@php $type = class_basename($task->projectable_type ?? ''); @endphp @php use Carbon\Carbon; $durationText = ''; if ( $type === "Contract" ) { $start = Carbon::parse($task->projectable->start_date); $end = Carbon::parse($task->projectable->end_date); $diff = $start->diff($end); $totalDays = $start->diffInDays($end); $totalWeeks = floor($totalDays / 7); $totalMonths = $diff->m + ($diff->y * 12); if ($diff->y >= 1 && $diff->m == 0 && $diff->d == 0) { // Case 1: Exact year(s) $durationText = $diff->y . ' year' . ($diff->y > 1 ? 's' : ''); } elseif ($totalMonths >= 1 && $totalMonths < 12) { // Case 2: Show in months $durationText = $totalMonths . ' month' . ($totalMonths > 1 ? 's' : ''); } else { // Case 3: Less than 1 month OR non-exact year(s) → show in weeks $durationText = $totalWeeks . ' week' . ($totalWeeks > 1 ? 's' : ''); } } @endphp @if($task->featured_image)
image
@endif @switch($type) @case('Invoice')
{{-- Contract & Company --}}
{{ $task->projectable->contract->subject ?? '—' }}

{{ $task->projectable->company->name ?? '—' }}

{{-- Tags --}} @if($task->tags()->exists())
@foreach($task->tagsTranslated('en')->get()->pluck('name_translated') as $tag) {{ $tag }} @endforeach
@endif
{{-- Invoice ID --}}

Invoice ID:

Claim Number:

{{ $task->projectable->getFormatedId() ?? '—' }}

{{ $task->projectable->claim_number ?? '—' }}


{{-- Financial Summary --}}

Total

Paid

Unpaid

@cMoney($task->projectable->total_invoiced, $task->projectable->currency, true)

@cMoney($task->projectable->paid_amount, $task->projectable->currency, true)

@cMoney($task->projectable->remaining_unpaid, $task->projectable->currency, true)

@break @case('Contract')
Duration {{ $start->format('d M Y') }} — {{ $end->format('d M Y') }} ({{ $durationText }})

Contract

Invoiced

Paid

Advance Payment

{{ money($task->projectable->value, $task->projectable->currency, true) }}

{{ money($task->projectable->total_invoiced, $task->projectable->currency, true) }}

{{ money($task->projectable->total_paid, $task->projectable->currency, true) }}

{{ money($task->projectable->advance_payment ?? 0, $task->projectable->currency, true) }}

@break @case('Project')

Project: {{ $task->projectable->name ?? '-' }}
Description: {{ $task->projectable->description ?? '-' }}

@break @case('StudioRequest')
Job Name: {{ $task->projectable->job_name ?? '—' }}
Description: {{ $task->projectable->job_description ?? '—' }}
Requested By: {{ $task->projectable->requester->full_name ?? '—' }}
Sector: {{ $task->projectable->sector->name ?? '—' }}
Department: {{ $task->projectable->department->name ?? '—' }}
{{-- Related Job --}} @if ($task->projectable?->parent)
Related Job: STU#{{ $task->projectable->parent->id ?? '—' }}
@endif
@break @default

Type: {{ $type }}

{{ $task->projectable->description ?? '-' }}

@endswitch