diff --git a/src/app/(app)/orders/page.tsx b/src/app/(app)/orders/page.tsx index 38d83f4..44b6fe0 100644 --- a/src/app/(app)/orders/page.tsx +++ b/src/app/(app)/orders/page.tsx @@ -733,6 +733,28 @@ function OrderCard({ Suggested )} + {/* Repeat-order pill — set by suggestDeliveryNoteForOrder + when this order's items exactly match a past + delivery note for the same company. Reads the + denormalized number field (no `expand` needed, see + orders-service.ts:253). Blue, distinct from the + quote pills' amber/teal — a different kind of fact + (a repeat-order observation, not a provenance link). */} + {order.potential_delivery_note_number && ( + + + {order.potential_delivery_note_number} + + )} {complete && } · diff --git a/src/lib/types.ts b/src/lib/types.ts index 495e249..c2639f3 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -655,6 +655,20 @@ export interface Order extends BaseRecord { quote_match_confidence: number; potential_quote: string; potential_quote_confidence: number; + /** + * Repeat-order detection — relation to a past delivery note whose + * items exactly matched this order's. Set by + * suggestDeliveryNoteForOrder at intake (see + * order-delivery-note-link-service.ts). Visibility only — a wrong + * flag costs nothing; the operator just ignores the pill. + */ + potential_delivery_note?: string; + /** Denormalized copy of the matched DN's delivery_note_number. + * Written alongside potential_delivery_note so the list pill can + * render the number without a second `expand` (see + * orders-service.ts:253). delivery_note_number is immutable once + * assigned, so copying carries no staleness risk. */ + potential_delivery_note_number?: string; is_repair_order: boolean; /** * Sales rep handling this order. Free-text — auto-populated from the