Skip to content

fix(sales): an unqualified lead imports with its Disqualification Reason (#2780) - #2781

Merged
sunhaolin merged 3 commits into
mainfrom
claude/jolly-poincare-2431c8
Nov 25, 2026
Merged

sunhaolin merged 3 commits into
mainfrom
claude/jolly-poincare-2431c8

Conversation

@sunhaolin

@sunhaolin sunhaolin commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #2780

What was wrong

crm_lead_import maps Lead Status = Disqualified / Closed - Not Converted (and Unqualified) to unqualified, but no column wrote disqualification_reason, so crm_lead.disqualification_reason_required refused every such row, and a saved mapping gave the user no way to repair the file.

While pinning this I found the same shape for Qualified: qualified_needs_qualification needs need_type + estimated_amount, and the mapping had neither column. Measured through the real import on a fresh DB before the fix: assets/import-templates/leads.csv imported 42/50, and the 8 Qualified rows were refused.

Direction: (a), add the companion columns

The repo's facts argue for importing the reason, not for dropping the rows. The reason is a plain select with ordinary options (not_a_fit, no_budget, wrong_persona, unreachable, competitor, other, duplicate). The rule exists so a dropped lead records why, and a migration from another CRM carries exactly that information. Dropping the synonyms would lose history the user has.

  • New columns: Disqualification Reason (value map: Bad Fit / Poor Fit → not_a_fit, Not Interested → other (the prospect's answer, not a fit judgement), Budget → no_budget, Wrong Contact / Not a Decision Maker → wrong_persona, No Response / Unresponsive → unreachable, Lost to Competitor → competitor; option labels/codes still match case-insensitively), Need Type, Estimated Amount.
  • Blank reason stays refused. It is never defaulted to other, and the row fails with the lead's own message.
  • Still refused by design and pinned: reason Duplicate (needs a surviving record, which duplicate_disqualification_requires_survivor requires and a file can't name) and status Converted (converted_only_by_conversion).
  • Template: Qualified rows now carry Need Type + Estimated Amount; three rows show Unqualified / Disqualified / Closed - Not Converted with a reason.
  • Docs: import guide in en / zh-Hans / zh-Hant, plus the in-app admin doc (en + zh).

Tests: test/import-values-accepted.test.ts, all through POST /data/<object>/import

  • accounts / contacts / leads templates import whole (no refusals).
  • Unqualified + reason, in all three status spellings → stored unqualified with the reason. 12 reason spellings land on their option.
  • No reason → refused with disqualification_reason_required's message, nothing stored. An unknown reason, or Duplicate, → refused.
  • Qualified with both companions → stored. Missing either → refused. Converted → refused.
  • Generic guard over all five mappings (account, contact, lead, invoice, payment): every value-map spelling yields a row the target object accepts, given only columns of the same mapping. A COMPANIONS table names the values that need a second cell.

Audit of the other mappings

No other mapping has this shape: every translated value of account, contact, invoice and payment is accepted. Unrelated note: the one-row invoices.csv / payments.csv templates fail on an empty DB only with reference_not_found, because they reference example records. That is a column guide, not this defect, so it is left as is.

The _record: prefix in the wizard's error text is platform, already filed as objectstack-ai/objectstack#36980, and not touched here.

Verification

  • pnpm verify: passed (333 files, 6420 tests).
  • Browser, own dev server on :4013 (not 4001), Leads → Import, saved mapping "线索导入(CSV)" auto-selected. The mapping step lists Disqualification Reason, and the preview shows the 未通过原因 column. I uploaded 2 rows: Disqualified + Budget, and Closed - Not Converted with a blank reason. Result: 新建 1 条, 已跳过 1 条. Row 2 was refused with "线索标记为不合格时必须填写取消资格原因". The stored row reads status=unqualified, disqualification_reason=no_budget.

Metadata-impact: reviewer

…son (#2780)

The lead import mapping produced status Unqualified (from Disqualified /
Closed - Not Converted) and Qualified with no column for the companion
fields the lead's own rules require, so such rows were always refused.
Add Disqualification Reason (with synonyms), Need Type and Estimated
Amount columns; the shipped leads template now imports whole.

Fixes #2780
@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
hotcrm Ignored Ignored Nov 25, 2026 2:20am UTC

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation ci/cd CI plumbing and the verification pipeline labels Nov 25, 2026
@sunhaolin

Copy link
Copy Markdown
Collaborator Author

Seat record · 独立评审 · head 9a9a96ee · 2026-11-25

结论:通过(有 nit)。类别:reviewer。 正文写的 Metadata-impact: none 不是 AGENTS.md 允许的取值(只有 reviewer 或 maintainer — <kind>),按规则未声明即视为 maintainer,直到评审裁定。本次裁定为 reviewer:lead.object.ts 未改,不涉及权限、删除/改名、校验收紧或 hook。请把这一行改成 Metadata-impact: reviewer。

  • 改了什么:线索导入映射 crm_lead_import 新增三列:Disqualification Reason(带同义词表)、Need Type、Estimated Amount,让「未通过」和「已确认」状态的行能带着对象规则要求的字段一起导入。导入模板 leads.csv、三语导入指南、管理员文档同步更新。不改任何对象、字段、校验或权限。
  • 为什么改、谁提的:线索导入:映射把 Disqualified / Closed - Not Converted 导成「不合格」,却没有取消资格原因列,这些行永远被拒 #2780,UI 测试发现。映射把 Disqualified / Closed - Not Converted 转成「未通过」,却没有原因列,这些行必然被 disqualification_reason_required 拒绝。修复中又发现模板里 8 行 Qualified 同样会被 qualified_needs_qualification 拒绝。
  • 最坏情况与能否回退:最坏是某个外部系统的原因词被归到不太贴切的选项(如 Not Interested 记成「需求不匹配」)。空单元格按「未提供」处理,再次导入更新时不会清空已有值。改动全是增量元数据,回退本 PR 即可完全恢复。
  • 评审没有验证的:没有亲自在浏览器里走导入向导(作者称已在 :4013 验证),也没有在托管环境做导入。

评审实际做过的检查

  • 新测试文件加 import-mappings.test.ts:95/95 通过。
  • 把映射和 _shared.ts 还原成 main 后再跑新测试:31 条里 19 条失败,说明测试确实锁住了这次修复。
  • 去掉 COMPANIONS 表那一条:通用检查恰好在 Disqualified、Closed - Not Converted 两行失败,说明它没有掩盖问题。
  • 新旧 leads.csv 逐格比对:仍是 LF、无 BOM、50 行数据。变化只有三处:新增三列;8 行 Qualified 补上 Need Type 和 Estimated Amount;第 38、44、50 行从 New 改成三种不合格状态,各带合法原因。
  • 本地 pnpm verify:6419 通过,1 条失败,是无关的 escalation-task-subject.test.ts 在本地负载下 5s 超时;CI 全绿。

Findings

  1. low · PR 正文 Metadata-impact: none:取值不合规,见上文。
  2. nit · src/sales/mappings/lead_import.mapping.ts:35:注释说重复是在线索上用「(Mark as Duplicate)」标记,但 src/ 里没有这个动作,实际是填 Duplicate Of / Duplicate Status 字段。用户文档的写法(「之后在线索上标记」)是准确的。
  3. nit · src/sales/mappings/_shared.ts:101:'Not Interested': 'not_a_fit' 可商榷。「不合适」是我方判断,「不感兴趣」是对方答复,归到 other 或许更诚实。现在的写法也有效。
  4. nit · test/import-values-accepted.test.ts:166-222:通用检查只遍历 valueMap 里的写法,原样透传的状态值(Qualified、Converted)不在其中,所以它单独抓不到 Qualified 那一半问题;专门测试 :140-163 覆盖了。文档注释略夸大了它的覆盖面。
  5. nit · test/import-values-accepted.test.ts:119-123:「未知原因」只断言没建记录,没有断言错误码或消息。
  6. nit · zh-Hans 指南 :207、zh-Hant 指南 :212、src/docs/crm_admin_data_import.zh.md:58:「以 Duplicate 失格」读起来别扭。建议对齐应用里的校验文案,写成「被判为重复而取消资格的线索」。

与其他 PR:未发现与在途 PR 冲突。_shared.ts 只是新增导出,客户、联系人映射不受影响。

…2780)

- Not Interested files as Other: it is the prospect's answer, not a fit judgement.
- The mapping comment names how a duplicate is really marked (Duplicate Of + Duplicate Status), not a nonexistent action.
- The generic-guard test comment says it walks valueMap spellings only.
- The unknown-reason test asserts the refusal's field and message.
- zh docs: 被判为重复而取消资格的线索 / 被判為重複而取消資格的線索.
@sunhaolin
sunhaolin marked this pull request as ready for review November 25, 2026 02:28
@sunhaolin
sunhaolin added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit b1ea6fc Nov 25, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/cd CI plumbing and the verification pipeline documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

线索导入:映射把 Disqualified / Closed - Not Converted 导成「不合格」,却没有取消资格原因列,这些行永远被拒

1 participant