# Task 010 — Opportunities Pipeline

## Objective

Implement sales opportunities with pipeline stages, kanban view, and lead conversion.

## Scope

- Opportunities API including `/api/opportunities/pipeline`
- Kanban UI at `/pipeline`
- Convert lead endpoint
- Default stages from `docs/07-leads-pipeline.md`
- Weighted value calculation on pipeline summary

**Out of scope:** Custom stage editor (partial in Task 022).

## Requirements

1. Opportunity requires `companyId`.
2. Stage drag-and-drop updates via PATCH.
3. `lost` stage requires reason.
4. Activity logged on stage change.

## Files to create or modify

| Path | Action |
|------|--------|
| `src/app/pipeline/**` | Create |
| `src/app/api/opportunities/**` | Create |
| `src/services/opportunity.service.ts` | Create |
| `docs/07-leads-pipeline.md` | Sync |
| `docs/04-ui-pages.md` | Pipeline page |
| `docs/16-changelog.md` | Entry |

## Acceptance criteria

- [ ] Kanban shows stages with cards
- [ ] Lead convert creates opportunity in discovery
- [ ] Pipeline API returns aggregates by stage

## Documentation updates required

- `docs/07-leads-pipeline.md`
- `docs/03-api-specification.md`
- `docs/16-changelog.md`
