# 🔧 DEBUGGING GUIDE - Why £50 Shows Every Time

## Issue: Always Showing £50 (25 miles × £2 = £50)

If you're seeing £50 for every route, it means the distance calculation is defaulting to 25 miles.

---

## 🔍 HOW TO DEBUG IN BROWSER

### Step 1: Open Browser Console
1. Go to: https://3000-ibnwdfw71auepqpe8f3p3-b9b802c4.sandbox.novita.ai/quotation.html
2. Press **F12** (or right-click → Inspect)
3. Click the **Console** tab

### Step 2: Fill Out the Form
1. **Pickup Type:** Select "Service Area (Select from list)"
2. **Pickup Location:** Choose "Wigan"
3. **Dropoff Type:** Select "UK Airport"
4. **Dropoff Location:** Choose "Manchester Airport (MAN)"
5. Select date, time, passengers, vehicle
6. Click **"Calculate Fare"**

### Step 3: Check Console Output
You should see debug logs like:
```
=== Distance Calculation Debug ===
Pickup Type: service-area
Pickup Value: wigan
Dropoff Type: airport  
Dropoff Value: manchester-airport
Looking up distance in matrix...
[getDistance] Looking up: "wigan" -> "manchester-airport"
[getDistance] ✅ Found in key1: 24 miles
Distance from matrix: 24
Final distance: 24 miles
```

---

## 🚨 COMMON PROBLEMS

### Problem 1: Wrong Pickup Value
**Console shows:** `Pickup Value: undefined` or `Pickup Value: null`

**Cause:** The form field isn't being read correctly

**Fix:** Check that you selected "Service Area" FIRST, then chose a location

### Problem 2: Key Not Found
**Console shows:** `❌ Not found in matrix, fallback to 25 miles`

**This means:** The route combination isn't in the distance matrix

**Example:**
```
[getDistance] Looking up: "bolton" -> "liverpool"
[getDistance] ❌ Not found
```

This route (Bolton → Liverpool) is missing! Report it to me.

### Problem 3: Airport Value Wrong
**Console shows:** `Dropoff Value: manchester-airport-man`

**Cause:** The dropdown value doesn't match the matrix keys

**Matrix expects:** `manchester-airport`  
**But form sends:** `manchester-airport-man`

**Fix:** Check the HTML option values match the matrix keys

---

## 🧪 QUICK TEST WITH DEBUG PAGE

I've created a debug calculator:

**URL:** https://3000-ibnwdfw71auepqpe8f3p3-b9b802c4.sandbox.novita.ai/debug-calculator.html

This shows EXACTLY what's happening:
- What values are being looked up
- Whether they're found in the matrix
- The calculated distance and price

**Test these routes:**
1. Bolton → Wigan = should show **10 miles, £20**
2. Manchester → Manchester Airport = should show **10 miles, £20**
3. Wigan → Manchester Airport = should show **24 miles, £48**

---

## 📋 REPORTING THE ISSUE

If you still see £50 everywhere, please provide:

1. **Your browser:** (Chrome/Firefox/Safari/Edge)
2. **Route tested:** (e.g., "Bolton to Manchester Airport")
3. **Console output:** (copy/paste the logs)
4. **Screenshot:** (if possible)

Send to: info@ashtransfer.com

---

## 🔧 TEMPORARY WORKAROUND

If the quote calculator isn't working:
1. Call: **+44 7860 261578**
2. We'll calculate your quote manually
3. We'll fix the calculator issue ASAP

---

## ✅ EXPECTED PRICES

For reference, here's what different routes SHOULD show:

| Route | Distance | Price (Saloon) |
|-------|----------|----------------|
| Manchester → Airport | 10 mi | £20.00 |
| Wigan → Airport | 24 mi | £48.00 |
| Bolton → Airport | 20 mi | £40.00 |
| Bolton → Wigan | 10 mi | £20.00 |
| Bury → Oldham | 8 mi | £16.00 |
| Wigan → Liverpool | 20 mi | £40.00 |

If you're seeing £50 for ALL of these, the calculator is broken.

---

## 🛠️ DEVELOPER NOTES

If you're debugging the code:

1. **Check:** `pickupValue` and `dropoffValue` are correct strings
2. **Check:** DISTANCE_MATRIX is properly defined before getDistance()
3. **Check:** No JavaScript errors in console
4. **Check:** Form field values match matrix keys exactly

**Matrix key format:** `'bolton->manchester-airport': 20`  
**Form must send:** `bolton` and `manchester-airport` (no quotes, lowercase, hyphens)

---

**Contact:** info@ashtransfer.com | +44 7860 261578 | 24/7 Service
