fix: retain editable investment plans and record partial QA continuity evidence
This commit is contained in:
@@ -3,6 +3,10 @@ import { landStatusVisible } from './investment-land-preparation.ts';
|
||||
import { csvCell } from './csv.js';
|
||||
import { fiscalQaRows } from './fiscal-qa-preview.ts';
|
||||
import { isApiSimulationResultSnapshotV1 } from './simulation-contract.ts';
|
||||
import {
|
||||
forecastBusinessPlan,
|
||||
restoreBusinessPlanSnapshot,
|
||||
} from './business-financial-plan.ts';
|
||||
|
||||
export type SimulationDraft = Record<string, string | string[]>;
|
||||
export const projectQuestionnaireVersion =
|
||||
@@ -1801,6 +1805,26 @@ export function validateSimulationDraft(
|
||||
errors.total_investment =
|
||||
'A soma do capital, dívida e subvenções deve corresponder ao investimento total.';
|
||||
}
|
||||
if (
|
||||
sectionId === 'financial' &&
|
||||
typeof draft.business_plan_snapshot === 'string' &&
|
||||
draft.business_plan_snapshot
|
||||
) {
|
||||
const plan = restoreBusinessPlanSnapshot(draft.business_plan_snapshot);
|
||||
if (!plan)
|
||||
errors.business_plan_snapshot =
|
||||
'Não foi possível recuperar o plano financeiro. Reveja os dados guardados.';
|
||||
else {
|
||||
try {
|
||||
forecastBusinessPlan(plan);
|
||||
} catch (cause) {
|
||||
errors.business_plan_snapshot =
|
||||
cause instanceof Error
|
||||
? cause.message
|
||||
: 'Reveja os dados do plano financeiro antes de continuar.';
|
||||
}
|
||||
}
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user