fix(orders): quote shortlist no longer requires the same customer contact
The AI order assistant's shortlist filtered candidate quotes to the order's customer (or blank). A different contact at the same company is common, so the right quote was dropped and the AI was never asked (M24 nylock order 74288 vs Q202610684). The scorer still rewards a customer match. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
16743f87ed
commit
66f23a34e9
2 changed files with 5 additions and 3 deletions
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue