WFDASH-WEBAPP/docs/orders-first-rollout.md
SJCoetz fd1571e294 Add PocketBase collections, APIs & migration docs
Introduce PocketBase workflow support, migration tooling, server APIs and documentation. Adds a set of PocketBase collection JSONs (order_items, order_items_v2, collection_pool, delivery_notes, delivery_note_items, repairs) and a large import manifest for workflow collections; includes docs describing MCP/API layer, migration audit, order-item schema and rollout plans. Adds server-side agent/MCP endpoints and services (api/mcp, api/v1/orders, collection-pool, order-items status, health) plus helper modules (pocketbase-admin, orders-service, order-item-status, agent-auth) and a migration script to create order_items_v2/collection_pool. UI: new pages for collection-pool, delivery-notes, repairs and several updates to orders/quotes pages, sidebar, tooltip and pb helpers/types. Also updates package.json (migration script and related changes) and global styles. Required env vars and suggested migration command are documented (e.g. NEXT_PUBLIC_POCKETBASE_URL, PB_ADMIN_EMAIL, PB_ADMIN_PASSWORD, ORDER_ITEMS_COLLECTION; run npm run pb:migrate:orders-v2).
2026-05-25 18:39:33 +02:00

45 lines
1.3 KiB
Markdown

# Orders-First Rollout Plan
## What was implemented
- `POST /api/v1/orders/from-quote`:
- creates `orders` record from a quote
- copies all `quote_items` into configured order-items collection
- defaults to `order_items`, can target `order_items` using env var
- `GET /api/v1/collection-pool`:
- lists `collection_pool` records for driver/collection operations
- MCP tools added:
- `orders.create_from_quote`
- `collection_pool.list`
## New collection definitions ready for import
- `/D:/NEWBUILD/wfnextjs/docs/pocketbase/order_items.collection.json`
- `/D:/NEWBUILD/wfnextjs/docs/pocketbase/collection_pool.collection.json`
## Create collections automatically
Run:
```bash
npm run pb:migrate:orders-v2
```
Required env vars:
- `NEXT_PUBLIC_POCKETBASE_URL`
- `PB_ADMIN_EMAIL`
- `PB_ADMIN_PASSWORD`
## Switch API writes to the new order-items collection
Set in `.env.local`:
```bash
ORDER_ITEMS_COLLECTION=order_items
```
This immediately makes quote-to-order conversion write to `order_items`.
## Quote alignment checks now covered
- Quote-to-order conversion enforces one path.
- Each copied item gets:
- `item_status=pending`
- `drv_status=unassigned`
- quote link via `quote_item`
- Status patcher accepts `drv_status` and maintains backward compatibility.