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).
1.7 KiB
1.7 KiB
Order Workflow Rules
Quote to Order
- A quote remains in
quotes. - Quote items remain in
quote_items. - Creating an order from a quote creates one new
ordersrecord. - The new order links back to the quote through
orders.quote. - Each quote item is copied into
order_items. - Each copied order item links back to its source quote item through
order_items.quote_item. - Creating an order from the same quote twice returns the existing order instead of duplicating it.
- Quote status is not changed by order creation.
Order Items as Source of Truth
order_items is the operational source of truth after an order is created.
Order items move through:
- supplier ordering / purchase order
- driver list / collection pool
- collected
- office received
- invoicing
- picked
- loaded
- delivered
Driver/collection fields use drv_* naming where possible, for example drv_status and drv_id.
Driver List and Collection Pool
The old Django driver_list workflow is represented by the new collection_pool concept.
collection_pool tracks assignment and collection work, while order_items keeps the item lifecycle state.
Future Stock Collection
Later we will add a dedicated stock collection.
Stock is used when:
- more items are collected than the order requires
- stock is ordered and arrives at the office
- collected items should be booked into stock instead of moving to invoicing
Until that collection exists, stock-related operational movement stays on order_items.
Delivery Notes
Delivery notes should be generated from order items that are ready, loaded, or delivered.
Repairs
Repairs will be rebuilt only where they connect to the practical order/quote/repair flow.