feat: persist investor warning limits and preserve financial snapshots in QA

This commit is contained in:
2026-11-21 20:55:34 +02:00
parent c144425e77
commit a4ecc8a5a9
26 changed files with 1239 additions and 48 deletions
+20 -1
View File
@@ -12,6 +12,23 @@ export const defaultPlanWarningLimits: PlanWarningLimits = {
creditDays: 90,
debtAssetsPercent: 70,
};
export function isPlanWarningLimits(
value: unknown,
): value is PlanWarningLimits {
if (!value || typeof value !== 'object' || Array.isArray(value))
return false;
const limits = value as Record<string, unknown>;
return (
Object.keys(limits).length === 5 &&
Object.keys(defaultPlanWarningLimits).every(
(key) =>
typeof limits[key] === 'number' &&
Number.isFinite(limits[key]) &&
(!['cashExpenseMonths', 'creditDays'].includes(key) ||
Number(limits[key]) >= 0),
)
);
}
export type PlanWarning = { id: string; message: string };
export type PlanWarningMetrics = {
optionalTexts?: { label: string; value: string }[];
@@ -81,7 +98,9 @@ export function businessPlanWarnings(
)
add(
'cash',
'A caixa disponível cobre menos de um mês de despesas. Considere reforçar o financiamento.',
limits.cashExpenseMonths === 1
? 'A caixa disponível cobre menos de um mês de despesas. Considere reforçar o financiamento.'
: `A caixa disponível cobre menos de ${limits.cashExpenseMonths.toLocaleString('pt-MZ')} meses de despesas. Considere reforçar o financiamento.`,
);
if (
metrics.growthPercent !== undefined &&