Plano de negócio como resultado da simulação

O relatório do investidor segue o modelo: resumo executivo (com objectivos,
missão e chaves para o sucesso), startup, mercado, vendas e marcos, pessoal
e plano financeiro, com as tabelas anuais nos capítulos e o detalhe mensal
do primeiro ano em anexo, sem colunas técnicas. Antes de exportar aparece
«Falta preencher» com ligação aos campos.

O cenário fiscal calcula o IRPC de cada ano à taxa geral de 32% sobre o
lucro antes de impostos, em vez de 72 campos mensais. Os rácios passam a
ser calculados a partir do balanço quando o investidor não classifica o
activo e o passivo correntes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzJmxFy3izprXr5dSq91jM
This commit is contained in:
Claude
2026-12-04 21:11:45 +02:00
committed by nala
parent a082c2542a
commit a3f2d2d7ca
14 changed files with 622 additions and 17 deletions
+171
View File
@@ -12,6 +12,7 @@ import { restoreBusinessPlanSnapshot } from './business-financial-plan.ts';
import { fiscalQaRows } from './fiscal-qa-preview.ts';
import { financialPlanWarnings } from './financial-plan-warnings.ts';
import { pathStates } from './investor-path.ts';
import { financialIssuesForDisplay } from './financial-issue-presentation.ts';
import {
buildProjectDossierRows,
type ProjectDossierRow,
@@ -46,6 +47,7 @@ export const dossierReportSections = [
export type DossierReportSectionId =
| (typeof dossierReportSections)[number]['id']
| 'financial-report'
| 'investor-report'
| 'supply';
export type DossierReference = {
version: number;
@@ -982,6 +984,175 @@ export function createIntegralFinancialReport(
};
}
/** Investor decision report: the business-plan chapters the simulation must deliver.
* The tables are the same eleven integral tables (one source, one calculation);
* only the order, the narrative and the plain presentation change. */
export const investorReportFields = {
objectives: 'plan_objectives',
mission: 'plan_mission',
successKeys: 'plan_success_keys',
} as const;
export type InvestorReportGap = { message: string; field?: string };
export function createInvestorDecisionReport(
draft: Record<string, string | string[]>,
options: Omit<
Parameters<typeof createProjectDossierReport>[1],
'selectedSections'
> = {},
): DossierReportModel & { missing: InvestorReportGap[] } {
const integral = createIntegralFinancialReport(draft, options);
const tables = integral.sections.flatMap((s) => s.tables ?? []);
// As in the model: chapters show the yearly columns; the first year's
// months go to the closing annex. Same cells, no recalculation.
const columns = (
table: InvestmentReportTable,
keep: (header: string, index: number) => boolean,
): InvestmentReportTable => {
const kept = table.headers
.map((header, index) => (index === 0 || keep(header, index) ? index : -1))
.filter((index) => index >= 0);
return {
...table,
headers: kept.map((index) => table.headers[index]),
rows: table.rows.map((row) => kept.map((index) => row[index] ?? '')),
};
};
const yearly = (table: InvestmentReportTable) =>
table.headers.some((h) => /^\d{4}( \(parcial\))?$/.test(h))
? columns(table, (h) => /^\d{4}( \(parcial\))?$/.test(h))
: table;
const firstYearMonths = (table: InvestmentReportTable) =>
columns(table, (h, index) => /^\d{4}-\d{2}$/.test(h) && index <= 12);
const pick = (...ids: string[]) =>
ids.flatMap((id) => tables.filter((t) => t.id === id).map(yearly));
const said = (key: string) => text(draft, key);
const labelled = (label: string, key: string) =>
said(key) ? [`${label}: ${said(key)}`] : [];
const missing: InvestorReportGap[] = [];
for (const [label, key] of [
['Resumo executivo', 'project_summary'],
['Objectivos', investorReportFields.objectives],
['Missão', investorReportFields.mission],
['Chaves para o sucesso', investorReportFields.successKeys],
] as const)
if (!said(key))
missing.push({
message: `${label}: Preencha este campo para continuar.`,
field: key,
});
const expected = integralFinancialTableIds.filter(
(id) => !tables.some((t) => t.id === id),
);
if (expected.length)
missing.push({
message: `Tabelas ainda sem dados suficientes: ${expected.length} de ${integralFinancialTableIds.length}.`,
});
for (const issue of financialIssuesForDisplay(tables))
missing.push({
message: `${issue.message} (${issue.tables.join('; ')})`,
});
const chapter = (
title: string,
paragraphs: string[],
chapterTables: InvestmentReportTable[] = [],
): DossierReportSection => ({
id: 'investor-report',
title,
private: true,
paragraphs,
rows: [],
tables: chapterTables,
});
const optional = (title: string, paragraphs: string[]) =>
paragraphs.length ? [chapter(title, paragraphs)] : [];
const sections: DossierReportSection[] = [
chapter('1. Resumo Executivo', [
...(said('project_summary') ? [said('project_summary')] : []),
...labelled('Objectivos', investorReportFields.objectives),
...labelled('Missão', investorReportFields.mission),
...labelled('Chaves para o sucesso', investorReportFields.successKeys),
]),
chapter(
'2. Resumo da Startup',
['Despesas e activos iniciais e o financiamento total requerido.'],
pick('startup'),
),
...optional('3. Produtos e Serviços', [
...(said('products_services') ? [said('products_services')] : []),
...labelled('Proposta de valor', 'value_proposition'),
]),
chapter(
'4. Análise de Mercado',
[
...labelled('Clientes', 'target_customers'),
...labelled('Hipótese de mercado', 'market_assumption'),
...labelled('Concorrência', 'competitor_assumption'),
],
pick('market-analysis'),
),
chapter(
'5. Estratégia e Implementação',
[
...labelled('Vendas', 'sales_channel_assumption'),
...labelled('Marketing', 'marketing_approach'),
...labelled('Presença digital', 'web_plan'),
],
pick('sales', 'milestones'),
),
chapter(
'6. Resumo da Gestão',
labelled('Organização e gestão', 'management_summary'),
pick('personnel'),
),
chapter(
'7. Plano Financeiro',
[
'Projecções calculadas a partir dos mesmos dados das tabelas anteriores; não são contas realizadas nem confirmação de financiamento.',
],
pick(
'funding',
'break-even',
'profit-loss',
'cashflow',
'balance',
'ratios',
),
),
];
const monthly = ['sales', 'profit-loss', 'cashflow', 'balance'].flatMap(
(id) =>
tables
.filter(
(t) =>
t.id === id &&
t.headers.some((h) => /^\d{4}-\d{2}$/.test(h)),
)
.map((t) => ({
...firstYearMonths(t),
title: `${t.title} — mês a mês, primeiro ano`,
issues: [],
})),
);
if (monthly.length)
sections.push(
chapter(
'Anexo — detalhe mensal do primeiro ano',
['Os mesmos valores das tabelas anuais, por mês.'],
monthly,
),
);
return {
...integral,
sections,
missing,
limitations: [
'Projecções preparadas pelo investidor no InvesteMoz; não constituem aprovação, garantia de financiamento nem resultado oficial.',
],
};
}
export function classifyDossierAttachment(
file: Pick<File, 'name' | 'type' | 'size'>,
): DossierAttachmentKind {