@php use App\Services\Targets\SalesForecastService; $canvasId = $canvasId ?? 'team-forecast-chart-canvas'; $deferChartInit = (bool) ($deferChartInit ?? false); $teamForecastChart = $teamForecastChart ?? []; $teamForecastChartOptions = $teamForecastChartOptions ?? []; $teamForecastChartCode = (string) ($teamForecastChartCode ?? 'final_score'); $chartSummary = $teamForecastChart['summary'] ?? []; $chartHasTarget = ($teamForecastChart['has_target'] ?? false) === true; $chartPaceStatus = (string) ($chartSummary['pace_status'] ?? SalesForecastService::PACE_NO_TARGET); $chartPaceBadge = $forecastPaceBadgeClasses[$chartPaceStatus] ?? $forecastPaceBadgeClasses[SalesForecastService::PACE_NO_TARGET]; $chartPaceLabel = $forecastPaceLabels[$chartPaceStatus] ?? ucfirst(str_replace('_', ' ', $chartPaceStatus)); $chartValueType = (string) ($teamForecastChart['value_type'] ?? 'score'); $teamForecastChartSelectOptions = collect($teamForecastChartOptions)->map(fn (array $option) => [ 'value' => (string) ($option['metric_code'] ?? ''), 'label' => (string) ($option['label'] ?? ''), ])->all(); $formatTeamChartSummaryValue = function (string $field) use ($chartSummary, $chartValueType): string { $value = (float) ($chartSummary[$field] ?? 0); if ($chartValueType === 'money') { return format_rand($value); } if ($chartValueType === 'score') { return number_format($value, 1, '.', ','); } return number_format($value, 0, '.', ','); }; @endphp

Team forecast trend

Aggregated target pace, actual progress, and projected run-rate for the sales team (monthly).

@if (! $chartHasTarget)
No team target data is available for this metric this month, so chart lines cannot be drawn.
@else

Target

{{ $formatTeamChartSummaryValue('target') }}

Actual to date

{{ $formatTeamChartSummaryValue('actual_to_date') }}

Projected end

{{ $formatTeamChartSummaryValue('projected_end') }}

Projected %

{{ number_format((float) ($chartSummary['projected_percent'] ?? 0), 1) }}%

Pace

{{ $chartPaceLabel }}

Targets are dealership targets. Actuals are total dealer sales for the month.

@unless ($deferChartInit) @endunless @endif