# Pipeline analytics — apply

    cp -R pipeline-analytics/app/*       ./app/
    cp -R pipeline-analytics/config/*    ./config/
    cp -R pipeline-analytics/resources/* ./resources/
    cp -R pipeline-analytics/tests/*     ./tests/

## 1. Sync the extra timestamp fields
Add to config/pipeline.php 'lead_fields':
    'Call_1_Time_Stamp__c', 'Nurture_Time_Stamp__c', 'Wait_List_Time_Stamp__c',
    'Follow_Up_Time_Stamp__c',
then re-run the Lead sync.

## 2. Route — inside the auth group:
    Route::get('/portfolio/pipeline-analytics', [\App\Http\Controllers\PipelineAnalyticsController::class, 'index'])->name('portfolio.pipeline-analytics');

## 3. Link it from the Pipeline tab (or add its own tab).

## 4. Test + build
    php artisan test --filter=PipelineAnalytics
    node node_modules/vite/bin/vite.js build

## What it computes
- TREND: monthly/weekly series for leads, scheduled tours, completed tours, leases
  signed — plus paid/organic splits of each. Switchable 3/6/12/24 months.
- CONVERSION FUNNEL: lead→scheduled, scheduled→completed, completed→signed,
  end-to-end, and "recovered" (signed despite having been lost or nurtured).
- LEAD VELOCITY: median hours new→first touch, new→tour completed,
  tour completed→signed, and how many leads are still untouched.
- PROJECTION: baseline = median leads of recent complete months, walked forward by the
  prior year's month-over-month change (seasonality, clamped 0.4–2.5×), then trailing
  conversion rates applied for tours and signings.
- PAID vs ORG: per-bucket averages, the paid:organic ratio, and per-source averages.

Each stage is counted in the period its own timestamp falls in — so a lead created in
January but toured in March counts toward March's tours.
