oportunidades 4
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-10 07:03:59 +02:00
parent e662230df7
commit 6ddafc95ba
179 changed files with 22750 additions and 933 deletions
+70
View File
@@ -0,0 +1,70 @@
import {
calculateBreakEven,
calculateFundingGap,
restoreFinancialToolsSnapshot,
} from './financial-calculators.ts';
export const pathStates: Record<string, string> = {
not_started: 'Por iniciar',
preparing: 'Em preparação',
ready_to_submit: 'Pronto para submeter',
submitted: 'Submetido',
reviewing: 'Validação interna',
correction_required: 'Correcção pedida',
waiting_external: 'Aguarda informação externa',
approved: 'Acto externo favorável documentado',
rejected: 'Acto externo desfavorável documentado',
dispensed: 'Preparação dispensada pelo promotor',
completed: 'Concluído',
expired: 'Acto externo expirado',
};
export type PathResult = {
id: string;
financial_snapshot: string;
currency: string | null;
draft_id: string;
draft_version: number;
engine: string;
recorded_at: string;
};
export function recoverPathResult(result: PathResult) {
if (result.engine !== 'financial-calculators:v1')
throw new Error(
'Versão do cálculo indisponível; as entradas foram preservadas.',
);
const snapshot = restoreFinancialToolsSnapshot(result.financial_snapshot);
if (!snapshot)
throw new Error(
'Entradas incompatíveis; a evidência original foi preservada.',
);
const independent = <T>(
run: () => T,
): { value: T | null; error: string | null } => {
try {
return { value: run(), error: null };
} catch (error) {
return {
value: null,
error:
error instanceof Error
? error.message
: 'Cálculo indeterminado',
};
}
};
return {
breakEven: independent(() =>
calculateBreakEven(
snapshot.breakEven.fixed,
snapshot.breakEven.price,
snapshot.breakEven.variable,
),
),
funding: independent(() =>
calculateFundingGap(
snapshot.funding.total,
snapshot.funding.secured,
),
),
};
}
+2
View File
@@ -72,6 +72,7 @@ export type Filters = {
};
export type InterestFormData = {
declared_origin_country_code?: string;
name: string;
email: string;
phone: string;
@@ -195,6 +196,7 @@ export function newSubmissionKey(): string {
export function fieldErrors(error: PortalApiError): FormErrors {
const result: FormErrors = {};
const fields: (keyof InterestFormData)[] = [
'declared_origin_country_code',
'name',
'email',
'phone',