# Job Data Extraction Rules (job_sieve.md)

**Purpose:** Guide for calendar entry format to ensure Python script can extract billing data correctly.

## Calendar Event Title Format

**✅ REQUIRED for export:**
- Use `✅` or `✅✅` in title for completed/successful jobs
- Example: `✅✅ Smith, John — Converted FWN 5G 100`

**🚫 EXCLUDED from export:**
- Use `💩` in title for failed/cancelled jobs
- Example: `💩 Jones, Mary — Unable to install, signal below requirements`

## Event Notes Format

Place data on **separate lines** in this order:

```
Customer Name
Phone/Contact info
Job description
Equipment tier (5G 25/5, 5G 100/10, etc.)
O5SGS260902041          ← FWN Serial (if used)
854V6DB262005174        ← XWR Serial (if used)
1700947                 ← Account # (5-7 digits)
38044984                ← Case # (8 digits, starts with 3)
Additional info (coordinates, signal, etc.)
```

### Critical Rules:

1. **Account # MUST appear on line immediately before Case #**
   - Script finds Case # first, then looks at previous line for Account #

2. **FWN Serial Pattern:** `O5SGS` + exactly 9 digits
   - Example: `O5SGS260902041`

3. **XWR Serial Pattern:** `854V6DB` OR `854V6D8` + exactly 9 digits
   - Example: `854V6DB262005174` or `854V6D8262000890`

4. **Case # Pattern:** Starts with `3`, total 8 digits
   - Example: `38044984`

5. **Account # Pattern:** 5-7 digits
   - Example: `1700947` (7), `243058` (6), `12345` (5)
   - ⚠️ Less than 5 or more than 7 digits will be flagged

## Equipment Usage

Jobs may have:
- **Both FWN + XWR** (CPE + Router) - most common
- **FWN only** (CPE only) - 1 serial
- **XWR only** (Router only) - 1 serial
- **No equipment** (service call: repoint, adjust, etc.) - no serials

All are valid and billable.

## Billing Reference

- **FWN Conversion:** $150.00
- **XWR:** $15.00
- **Service Call:** $100.00 (with or without equipment)
- **Default when uncertain:** $150.00

## Real-World Example (Actual Calendar Entry)

**Title:** `✅✅Stepanik-Keber, Gail — Conversion FWN`

**Notes:** _(Location/Date/Time fields are managed separately - billing script only reads the Notes field below)_
```
(780) 239-3417 — Phone

Conversion FWN
5G 50/5 unlimited
O5SGS260902041
854V6DB262005174
1700947
38044984
53.5390, -114.2496
7dB -83dBm
302131
0008DB
78
3E6B3C002 302131
```

**What gets extracted:**
- Customer: Stepanik-Keber, Gail ✓
- FWN Serial: O5SGS260902041 ✓
- XWR Serial: 854V6DB262005174 ✓
- Account #: 1700947 (line before case #) ✓
- Case #: 38044984 ✓
- Extra data (coordinates, signal, IDs) is fine - script ignores it ✓

**Result:** Perfect entry - all billing data extracted correctly ✓

## Example Failed Job (Not Exported)

**Title:** `💩 Michaelsen, Kayla — Unable to install, signal below requirements`

**Result:** Skipped entirely (not billable) ✓

---

**Quality Control Process:**
1. Claude.ai creates calendar entries (first pass)
2. Python script extracts/validates data (second pass - the sieve)
3. Human review during billing (final pass)
