# PHASE 10: OPERATIONS DASHBOARD AND REPORTS

Read `docs/06-DATA-MODEL.md` section 4 and decision D-09 and D-21.

## Scope

One dashboard page that answers "what do I need to do today" and "what did we sell". Nothing more.

**Do not replace WooCommerce Analytics.** It already covers sales reporting. Build only what improves operations.

## Build

1. A top-level admin page, Store Dashboard, reading exclusively from `bc_order_stats` and `bc_order_stat_items`, never from a live join over order meta. Both tables carry what this page needs: `fulfilment_status` and `units` on the parent, `category_id` and `qty` on the items table.
2. Action counters, each a link into the filtered order list: Pending Verification, To Fulfil, Ready for Courier, Shipped, Delivered Today, RTO This Month, Cancelled This Month. These are the numbers the owner acts on.
3. Sales: today, this week, this month. Orders count, gross, discounts, shipping, net, **average order value**, and **return rate** (RTO plus returned, over delivered), both required by brief section 31. Delivered-only revenue, plus a separate line for orders in flight, so the two are never confused.
4. COD position: collected and unsettled, settled this month, and the ageing figure from phase 9.
5. Products: top ten by units sold this month (from `bc_order_stat_items`), sales by category (brief section 31, same table), out-of-stock products, and low-stock products below the `low_stock_threshold` setting.
6. One simple chart, orders per day for the last 30 days. Inline SVG or a tiny canvas, no charting library.
7. A daily operating checklist panel, static text, listing the twice-daily verification routine so the owner has the procedure in front of them.
8. All queries wrapped in a 10 minute transient, purged on order status change.

### Customers

Brief section 24, and it has no home anywhere else in the build.

A Customers submenu listing one row per distinct phone in `bc_order_stats`: name from the most recent order, phone, city, total orders, total spent (delivered only), cancelled count, RTO count. Sortable by total spent and by RTO count. Searchable by phone or name.

Clicking through gives a customer detail view: their addresses as used, and their full order history with status. No editing, this is a read view over order data. It shares the same query the verification panel uses, so it costs little beyond the screen itself.

## Explicitly deferred

CAC, ROAS and contribution margin (decision D-21). The cost data is not in the system and building the shell now guarantees it is wrong. Do not build placeholder cards for them.

## Acceptance criteria

- [ ] Every counter links to the correctly filtered order list
- [ ] Dashboard numbers match WooCommerce Analytics for the same day, verified by hand
- [ ] Delivered revenue and in-flight revenue are separate and clearly labelled
- [ ] The page loads in under 1.5 seconds with 5,000 seeded orders
- [ ] No query in the page joins over `wc_orders_meta`
- [ ] No charting library is loaded
- [ ] The Customers list loads in under 2 seconds with 5,000 seeded orders and its totals match a hand-checked phone number
- [ ] Average order value and return rate are present and correct
- [ ] Sales by category renders
- [ ] Low stock uses the configured threshold
- [ ] A Shop Manager can see the page, a Subscriber cannot
- [ ] Transients invalidate correctly on a status change

## Stop

No emails, no notifications. Next phase.
