fix: complete InvesteMoz validation and error corrections

This commit is contained in:
2026-10-29 21:47:33 +02:00
parent 63147312e2
commit daf8623441
718 changed files with 127308 additions and 20959 deletions
@@ -1,19 +1,45 @@
export type LandPreparation = { need: 'yes' | 'no' | 'unknown'; reason: string };
import { inputText } from './input-text.ts';
export type LandPreparation = {
need: 'yes' | 'no' | 'unknown';
reason: string;
};
/** Preparation decision from the same saved dossier, never evidence of a land right. */
export function investmentLandPreparation(raw: unknown): LandPreparation {
try {
const snapshot = JSON.parse(String(raw ?? ''));
const snapshot = JSON.parse(inputText(raw ?? ''));
if (snapshot.version !== 1) return { need: 'unknown', reason: '' };
const decision = snapshot.land_preparation;
if (decision && ['yes', 'no', 'unknown'].includes(decision.need))
return { need: decision.need, reason: typeof decision.reason === 'string' ? decision.reason : '' };
return {
need: decision.need,
reason:
typeof decision.reason === 'string' ? decision.reason : '',
};
// Existing snapshots already carry S10 applicability; no reimport is required.
const step = Array.isArray(snapshot.path?.steps) ? snapshot.path.steps.find((row: { code?: string } | null) => row?.code === 'S10') : null;
return { need: step?.applicability === 'not_needed_for_preparation' ? 'no' : step?.applicability === 'applicable' ? 'yes' : 'unknown', reason: typeof step?.reason === 'string' ? step.reason : '' };
} catch { return { need: 'unknown', reason: '' }; }
const step = Array.isArray(snapshot.path?.steps)
? snapshot.path.steps.find(
(row: { code?: string } | null) => row?.code === 'S10',
)
: null;
return {
need:
step?.applicability === 'not_needed_for_preparation'
? 'no'
: step?.applicability === 'applicable'
? 'yes'
: 'unknown',
reason: typeof step?.reason === 'string' ? step.reason : '',
};
} catch {
return { need: 'unknown', reason: '' };
}
}
export function landStatusVisible(draft: Record<string, unknown>): boolean {
return !draft.context_applicability_snapshot || investmentLandPreparation(draft.context_applicability_snapshot).need === 'yes';
return (
!draft.context_applicability_snapshot ||
investmentLandPreparation(draft.context_applicability_snapshot).need ===
'yes'
);
}