feat: persist investor warning limits and preserve financial snapshots in QA
This commit is contained in:
@@ -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 &&
|
||||
|
||||
Reference in New Issue
Block a user