diff --git a/src/lib/server/order-quote-link-service.test.ts b/src/lib/server/order-quote-link-service.test.ts index 76de895..254658a 100644 --- a/src/lib/server/order-quote-link-service.test.ts +++ b/src/lib/server/order-quote-link-service.test.ts @@ -170,6 +170,8 @@ describe("suggestQuoteForOrder", () => { const opts = quotesGetList.mock.calls[0][2] as { filter: string; fields?: string }; expect(opts.filter).toContain('created >= "2026-05-31T10:00:00.000Z"'); expect(opts.filter).toContain('company = "co1"'); + // A different contact at the same company must still be a candidate. + expect(opts.filter).not.toContain("customer"); // `quotes` also carries email_body / ai_insights / migration_meta — // this query must not pull those to read five scalars. expect(opts.fields).toBe("id,quote_number,company,customer,created"); diff --git a/src/lib/server/order-quote-link-service.ts b/src/lib/server/order-quote-link-service.ts index e1a6bb8..1b7ce24 100644 --- a/src/lib/server/order-quote-link-service.ts +++ b/src/lib/server/order-quote-link-service.ts @@ -210,9 +210,9 @@ async function fuzzyPass( "is_template != true", ]; if (order.company) filters.push(`company = "${esc(order.company)}"`); - if (order.customer) { - filters.push(`(customer = "${esc(order.customer)}" || customer = "")`); - } + // No customer filter: one company has many contacts, and the person who + // asked for the quote is often not the person who placed the order + // (M24 nylock, 2026-10-28). The scorer still rewards a customer match. const candidates = await pb .collection(QUOTE_COLLECTION)