# Flow — Assigned Work-Order → Fixed (Technician)

> Persona: **Suresh Kale** (TECH), Maintenance team, Game Zone Ahmedabad-1, reports to **Mahesh Patil (Maintenance TL)**. Source: `CHANGE_LIST_v1.1.md` CL-2 + `FOUNDATION_SPEC §4a`. Screens: `TECH-WO-TODAY` → `TECH-WO-DETAIL` → `TECH-WO-DONE`. Sheets: `bottom-sheets/photo-capture.html`, `bottom-sheets/confirm-done.html`.

---

## Preconditions
- Suresh is logged in (`/me` resolved role = TECH).
- A Staff Court Monitor flagged an **A-item** on an inspection checklist; the operations TL **routed** it to maintenance (WO → `ROUTED`, parent checklist → `HELD`); the **Maintenance TL (Mahesh) assigned** the WO to Suresh (WO → `ASSIGNED`, `assignedToId = Suresh`). It is visible on `TECH-WO-TODAY` and as a `SENT/assigned` push notification.

## Steps

1. **Open the work-order.** Suresh taps **WO-1039 · Harness clip stiff** on `TECH-WO-TODAY`.
   → App `GET /work-orders/:id`; opens `TECH-WO-DETAIL` showing the **source checklist** (ZipZag Opening), the **A-item** text, the **issue photos** from inspection, the Maintenance TL's instructions, and the WorkOrder timeline (Routed → Assigned → *your turn*).

2. **Start work.** Suresh taps **Start work** → `PATCH /work-orders/:id/start` (`If-Match: <version>`) → WO state `ASSIGNED → IN_PROGRESS`, `startedAt` stamped, a `WorkOrderEvent` row written. The card now reads **In progress** everywhere.

3. **Do the physical fix** on the floor. When done, Suresh opens `TECH-WO-DONE`, optionally types a short **fix note** ("Cleaned and re-greased the clip mechanism; tested latch 10×").

4. **Attach the mandatory fix photo.** The **fix-photo tile** (or the orange **camera FAB**) opens the **photo-capture sheet** (`photo-capture.html`, Camera / Gallery). Suresh shoots proof of the completed fix → `POST /uploads/photos` (`kind=COMPLETION`, `workOrderId`) → multipart → **local disk on the VPS** → a `WorkOrderPhoto` row (uploader, timestamp, device). The thumbnail appears.
   - **Gate:** until ≥1 fix photo exists, the **Mark Done** button stays disabled ("add a fix photo first"). This mirrors the §4a photo gate.

5. **Confirm Done.** With the photo present, **Mark Done** enables. Tapping it opens the **confirm-done sheet** (`confirm-done.html`) summarising the fix photo + the "closes at maintenance level" rule. Suresh confirms → `PATCH /work-orders/:id/done` (`If-Match`, ≥1 `WorkOrderPhoto`) → WO state `IN_PROGRESS → DONE`, `closedAt` stamped, `WorkOrderEvent` written.

6. **The action closes — at the maintenance level.** A `DONE` WO does **not** go to the Store Manager (locked rule, CL-2). If this was the **last open WO** for the source checklist, the parent instance releases from `HELD` and resumes its approval cascade (`HELD → TL_APPROVED → …`). The Maintenance TL sees it as closed on `MTL-WO-REVIEW`.

## Rules enforced in this flow
- **Done is photo-gated** — no fix photo, no Done (UI **and** server `422`, mirrors §4a/L7).
- **Internally-fixed actions close here** — only `OUTSOURCED` WOs ever reach the Store Manager.
- **Scope:** Suresh can only open / start / done WOs **assigned to him** in his Game Zone; any other id → `403` (`states/forbidden.html`).
- **Online-only:** Done uploads a photo, so it needs a connection — offline shows the online-only retry state (`states/offline.html`); the fix note + staged photo are held on device and re-sent on retry.
- **Concurrency:** every transition carries `If-Match: <version>` → `409` if stale (e.g. the TL reassigned it meanwhile).

## Result
- WO-1039 is `DONE` with a fix photo + audit trail; the action is closed at maintenance; the source checklist resumes toward Done if no other A-items remain open.
