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:
@@ -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/,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user