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
@@ -95,11 +95,29 @@ void test('approved formulas are presented from the same monthly and annual stat
assert.equal(get(t, 'Crescimento das vendas')[2], '0,00%');
assert.equal(get(t, 'Crescimento das vendas').at(-1), 'Por determinar');
});
void test('inconsistent balance blocks only dependent indicators; missing liquidity does not invent maturity', () => {
void test('inconsistent balance blocks only dependent indicators; without classification liquidity comes from the balance', () => {
const { plan, source } = fixture();
delete plan.ratioCurrentBalances;
let t = buildFinancialRatiosTable(plan, source);
assert.equal(get(t, 'Liquidez corrente')[1], 'Por determinar');
// Mapa de erros, plano de negócio: ratios are calculated from the balance;
// loans are read as long-term and the rule is stated in the notes.
const balance = source.find((b) => b.id === 'balance');
const value = (label) =>
Number(balance.rows.find((r) => r[0] === label)[1]);
const expected =
(value('Total do activo') - value('Activos fixos líquidos')) /
(value('Total do passivo') -
value('Empréstimos e suprimentos por reembolsar'));
assert.equal(
get(t, 'Liquidez corrente')[1],
expected.toFixed(2).replace('.', ',') + '×',
);
assert.ok(
t.notes.some((n) =>
n.startsWith('Activo e passivo correntes calculados a partir do balanço'),
),
);
assert.ok(!t.issues.some((i) => i.includes('Activo corrente — mês')));
assert.equal(get(t, 'Margem líquida')[1], '26,00%');
assert.equal(get(t, 'Retorno do capital')[1], '14,77%');
source
@@ -10,6 +10,7 @@ import { financialReportFixture } from './fixtures/integral-financial-plan.mjs';
import * as report from '../../resources/js/lib/integral-financial-report.ts';
import * as warnings from '../../resources/js/lib/financial-plan-warnings.ts';
import * as annual from '../../resources/js/lib/annual-example-report.ts';
import * as irpcScenario from '../../resources/js/lib/irpc-plan-scenario.ts';
import {
serializeBusinessPlanSnapshot,
restoreBusinessPlanSnapshot,
@@ -36,6 +37,8 @@ void test('one startup editor retains all rows and persists an edit without dupl
(name) =>
name === '@/lib/integral-financial-report'
? report
: name === '@/lib/irpc-plan-scenario'
? irpcScenario
: name === './investment-report-tables'
? { InvestmentReportTables: () => null }
: name === '@/lib/financial-plan-warnings'
@@ -0,0 +1,135 @@
import assert from "node:assert/strict";
import test from "node:test";
import { financialReportFixture } from "./fixtures/integral-financial-plan.mjs";
import {
forecastBusinessPlan,
serializeBusinessPlanSnapshot,
} from "../../resources/js/lib/business-financial-plan.ts";
import { buildIntegralFinancialTables } from "../../resources/js/lib/integral-financial-report.ts";
import { irpcScenarioSchedule } from "../../resources/js/lib/irpc-plan-scenario.ts";
import {
createInvestorDecisionReport,
createProjectDossierPrintHtml,
} from "../../resources/js/lib/project-dossier-report.ts";
const toCents = (value) => {
const [whole, fraction = "00"] = String(value).replace("-", "").split(".");
const amount = BigInt(whole) * 100n + BigInt(fraction.padEnd(2, "0"));
return String(value).startsWith("-") ? -amount : amount;
};
void test("the fiscal scenario applies the documented 32% IRPC to each year profit, never to a loss (Criar Hotel)", () => {
const plan = financialReportFixture(36);
const rows = forecastBusinessPlan(plan).rows;
const result = irpcScenarioSchedule(plan, "general");
assert.equal(result.expense.length, 36);
assert.deepEqual(result.payment, result.expense);
for (let year = 0; year < 3; year++) {
const profit = rows
.slice(year * 12, year * 12 + 12)
.reduce((t, r) => t + toCents(r.profitBeforeTax), 0n);
const expected = profit > 0n ? (profit * 32n * 2n + 100n) / 200n : 0n;
assert.equal(toCents(result.expense[year * 12 + 11]), expected);
for (let m = 0; m < 11; m++)
assert.equal(result.expense[year * 12 + m], "0.00");
}
assert.match(result.source, /artigo 61\.º, n\.º 1/);
assert.match(result.source, /não é liquidação/);
// The calculated schedule is accepted by the report as declared taxes.
plan.reportAssumptions = {
...plan.reportAssumptions,
taxExpenseByMonth: result.expense,
taxPaymentByMonth: result.payment,
taxSource: result.source,
};
const pl = buildIntegralFinancialTables(plan).find(
(t) => t.id === "profit-loss",
);
assert.deepEqual(pl.issues, []);
});
void test("the simulation result is a business plan in the model order, without audit columns (Criar Hotel)", async () => {
const plan = financialReportFixture(36);
const draft = {
project_title: "Hotel QA sintético",
project_summary: "Hotel de praia.",
plan_objectives: "Lucro no segundo ano.",
plan_mission: "Servir bem.",
plan_success_keys: "Qualidade, localização.",
business_plan_snapshot: serializeBusinessPlanSnapshot(plan),
};
const report = createInvestorDecisionReport(draft, {
generatedAt: "2026-12-04T12:00:00Z",
});
assert.equal(report.title, "Hotel QA sintético");
assert.deepEqual(
report.sections.map((s) => s.title),
[
"1. Resumo Executivo",
"2. Resumo da Startup",
"4. Análise de Mercado",
"5. Estratégia e Implementação",
"6. Resumo da Gestão",
"7. Plano Financeiro",
"Anexo — detalhe mensal do primeiro ano",
],
);
assert.ok(report.sections.every((s) => s.rows.length === 0));
// Chapters carry the yearly columns only; the annex carries 12 months.
const pl = report.sections[5].tables.find((t) => t.id === "profit-loss");
assert.ok(pl.headers.slice(1).every((h) => /^\d{4}( \(parcial\))?$/.test(h)));
assert.equal(pl.headers.length, 4);
const annex = report.sections[6].tables.find((t) => t.id === "profit-loss");
assert.equal(annex.headers.length, 13);
assert.ok(annex.headers.slice(1).every((h) => /^\d{4}-\d{2}$/.test(h)));
assert.deepEqual(report.sections[0].paragraphs, [
"Hotel de praia.",
"Objectivos: Lucro no segundo ano.",
"Missão: Servir bem.",
"Chaves para o sucesso: Qualidade, localização.",
]);
const ids = report.sections.slice(0, -1).flatMap((s) =>
(s.tables ?? []).map((t) => t.id),
);
assert.deepEqual(
ids.filter((id) =>
[
"startup",
"sales",
"funding",
"break-even",
"profit-loss",
"cashflow",
"balance",
].includes(id),
),
[
"startup",
"sales",
"funding",
"break-even",
"profit-loss",
"cashflow",
"balance",
],
);
assert.ok(!report.missing.some((gap) => gap.field));
const html = await createProjectDossierPrintHtml(report, [], false);
assert.match(html, /<h1>InvesteMoz<br>Plano de negócio<\/h1>/);
assert.doesNotMatch(html, /Classificação \/ origem/);
});
void test("missing executive summary fields are listed with the field to open (Criar Hotel)", () => {
const report = createInvestorDecisionReport({ project_title: "Hotel" });
const fields = report.missing.filter((g) => g.field).map((g) => g.field);
assert.deepEqual(fields, [
"project_summary",
"plan_objectives",
"plan_mission",
"plan_success_keys",
]);
assert.match(
report.missing[0].message,
/Preencha este campo para continuar/,
);
});
+2
View File
@@ -12,6 +12,7 @@ import * as startup from '../../resources/js/lib/startup-asset-requirements.ts';
import * as presentation from '../../resources/js/lib/financial-issue-presentation.ts';
import * as annual from '../../resources/js/lib/annual-example-report.ts';
import * as warnings from '../../resources/js/lib/financial-plan-warnings.ts';
import * as irpcScenario from '../../resources/js/lib/irpc-plan-scenario.ts';
import { financialReportFixture } from './fixtures/integral-financial-plan.mjs';
const require = createRequire(import.meta.url);
@@ -22,6 +23,7 @@ const modules = {
'@/lib/financial-issue-presentation': presentation,
'@/lib/annual-example-report': annual,
'@/lib/financial-plan-warnings': warnings,
'@/lib/irpc-plan-scenario': irpcScenario,
'./business-plan-warnings': { BusinessPlanWarnings: () => null },
};
function component(name) {