fix(legacy-stage): purge 9-stage enum keys from rank tables and stale copy
Some checks failed
Build & Push Docker Images / lint (push) Successful in 2m4s
Build & Push Docker Images / build-and-push (push) Has been cancelled

L-001 hunt landed these:

  - src/lib/services/clients.service.ts — stageRank used pre-refactor
    9-stage names exclusively (`contract_signed`, `deposit_10pct`, …).
    Every modern 7-stage interest fell to rank 0, making client-list
    "most-progressed deal" sort effectively random. Modern values now
    own the canonical ranks; legacy aliases map to their 7-stage
    equivalents so historical audit data still sorts.

  - src/lib/services/berth-recommender.service.ts — STAGE_ORDER had
    the same 9-stage shape. LATE_STAGE_THRESHOLD pointed at the (now
    nonexistent) `deposit_10pct` slot. Reworked to the 7-stage scale;
    threshold now at `deposit_paid` (5).

  - Stale comments referencing `deposit_10pct` in schema (clients,
    financial) and client-archive services updated to current copy.

  - Smart-archive dialog rendered `i.pipelineStage` as raw enum; now
    routes through `stageLabelFor` (the new helper added with A2).

Test fixture updates: berth-recommender.test.ts numeric inputs
re-mapped to the new 7-stage scale (eoi_signed=5 → eoi=3, etc.).
1373/1373 vitest pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-15 01:18:13 +02:00
parent 0d9208a052
commit 98211066a5
10 changed files with 65 additions and 31 deletions

View File

@@ -18,6 +18,7 @@ import { Badge } from '@/components/ui/badge';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Textarea } from '@/components/ui/textarea';
import { apiFetch } from '@/lib/api/client';
import { stageLabelFor } from '@/lib/constants';
import { toastError } from '@/lib/api/toast-error';
interface DossierBerth {
@@ -339,7 +340,7 @@ function SmartArchiveDialogBody({
<span className="font-mono">{i.interestId.slice(0, 8)}</span>
<span className="flex items-center gap-2">
<Badge variant="secondary" className="text-xs">
{i.pipelineStage}
{stageLabelFor(i.pipelineStage)}
</Badge>
{i.hasSignedEoi && <Badge className="text-xs">Signed EOI</Badge>}
</span>
@@ -411,7 +412,9 @@ function SmartArchiveDialogBody({
Releasing will notify the sales rep. Other interests on this berth:{' '}
{b.otherInterests
.slice(0, 3)
.map((o) => `${o.clientName ?? '?'} (${o.pipelineStage})`)
.map(
(o) => `${o.clientName ?? '?'} (${stageLabelFor(o.pipelineStage)})`,
)
.join(', ')}
{b.otherInterests.length > 3 ? ` +${b.otherInterests.length - 3}` : ''}
</p>