fix(migration): modernize stale NocoDB→CRM pipeline stage map to current 7 stages

The 2026-05-03 migration pipeline (src/lib/dedup/*) predates the 9→7
pipeline-stage refactor; its STAGE_MAP emitted invalid stages
(open/details_sent/eoi_sent/…) that would write bad pipeline_stage values
on --apply. Remap to the current PIPELINE_STAGES (enquiry/qualified/
nurturing/eoi/reservation/deposit_paid/contract) + a deposit-received →
deposit_paid override. Frozen-fixture test expectations updated (17/17 pass).

Validated: live --dry-run = 239 clients / 255 interests / 41 EOI docs
(matches independent snapshot analysis; pipeline is more conservative and
flags 3 borderline pairs for review).

Adds the migration design spec (source map, scope lock to Port Nimara +
Expenses bases, EOI coverage 48/48, in-flight Documenso state, remaining
gaps: interest eoiStatus, expenses, doc-blob backfill).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-01 19:03:32 +02:00
parent 31ba72f344
commit 7dba1a47bb
3 changed files with 235 additions and 13 deletions

View File

@@ -183,10 +183,10 @@ describe('transformSnapshot - fixture regression', () => {
it('maps the legacy 8-stage enum to new pipeline stages', () => {
const plan = transformSnapshot(FIXTURE);
const stagesById = new Map(plan.interests.map((i) => [i.sourceId, i.pipelineStage]));
expect(stagesById.get(681)).toBe('open'); // General Qualified Interest
expect(stagesById.get(682)).toBe('details_sent'); // Specific Qualified Interest
expect(stagesById.get(336)).toBe('contract_signed'); // Contract Signed
expect(stagesById.get(585)).toBe('eoi_signed'); // Signed EOI and NDA
expect(stagesById.get(681)).toBe('qualified'); // General Qualified Interest
expect(stagesById.get(682)).toBe('nurturing'); // Specific Qualified Interest
expect(stagesById.get(336)).toBe('contract'); // Contract Signed
expect(stagesById.get(585)).toBe('eoi'); // Signed EOI and NDA
});
it('attaches different yachts to one merged Constanzo client', () => {