From d9f0925d8372db805acfd5b833af31f3cdbf82f9 Mon Sep 17 00:00:00 2001 From: Dave Date: Sun, 30 Aug 2026 22:26:05 +0200 Subject: [PATCH] refactor(orders): rename runQuoteMatch to runPostCreateMatchers, update stale comments --- src/lib/server/orders-service.test.ts | 4 ++-- src/lib/server/orders-service.ts | 23 +++++++++++------------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/lib/server/orders-service.test.ts b/src/lib/server/orders-service.test.ts index 3146072..bfb4059 100644 --- a/src/lib/server/orders-service.test.ts +++ b/src/lib/server/orders-service.test.ts @@ -2962,13 +2962,13 @@ describe("createOrder quote auto-detection", () => { expect(r.order.id).toBeDefined(); // Proves the catch fired AND ran the inline fallback — without // the call assertion the test would pass on the spy alone even - // if `void runQuoteMatch()` was deleted. + // if `void runPostCreateMatchers()` was deleted. expect(suggestQuoteForOrder).toHaveBeenCalledWith(r.order.id); // The fallback logs its engagement so a silent switch to // fire-and-forget is impossible to miss in production logs. expect(consoleErrorSpy).toHaveBeenCalledWith( expect.stringContaining( - "[createOrder] after() unavailable, running quote match inline", + "[createOrder] after() unavailable, running post-create matchers inline", ), expect.anything(), ); diff --git a/src/lib/server/orders-service.ts b/src/lib/server/orders-service.ts index d8bbdf8..70dfa3b 100644 --- a/src/lib/server/orders-service.ts +++ b/src/lib/server/orders-service.ts @@ -2254,16 +2254,15 @@ export async function createOrder(input: CreateOrderInput): Promise { + // Writes only soft suggestions (quote, delivery-note, order-number + // duplicate, order-item duplicate). Promoting any of them to a + // hard link stays a deliberate human click. + const runPostCreateMatchers = async () => { try { await suggestQuoteForOrder(order.id); } catch (err) { @@ -2298,7 +2297,7 @@ export async function createOrder(input: CreateOrderInput): Promise