---
name: stater-bros-grocery-sync
description: Sync Stater Bros grocery orders from the last 30 days into the canonical purchase tracker ledger and yearly merchant CSV files using the authenticated user browser profile.
---

# Stater Bros Grocery Sync

1. Step 0: Confirm `user` browser profile/session is active before navigation.
2. Open Stater Bros order history.
3. Capture page snapshots at each major step (history loaded, date filter set, details expanded, final extraction).
4. Collect orders from the last 30 days; capture `order_date`, `order_id`, `fulfillment_type`, `order_total`, detail URL.
5. Detect whether pagination exists before assuming it; if present, iterate until all qualifying orders are collected.
6. For each detail page, run expand + repeated bottom scroll + load-more until no new rows appear.
7. Explicitly detect and click `Show all`/`View all items` controls before extraction.
8. Extract all visible line items and adjustment lines separately.
9. Run sanity-check: compare extracted item + adjustment totals against order total and flag when delta exceeds 5%.
10. Write normalized payload via `scripts/sync_to_grocery_db.py` using canonical DB/classification/log paths.
11. Merge yearly CSV exports with `scripts/merge_grocery_csv.py`.
12. Stop and report blocker on login failure, CAPTCHA, or unrecoverable page-design breakage.

## References
- Shared schema: `../grocery-shared/references/schema.md`
- Merchant notes: `references/extraction-notes.md`
