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,58 @@
|
||||
import {
|
||||
forecastBusinessPlan,
|
||||
type BusinessFinancialPlanInput,
|
||||
} from "./business-financial-plan.ts";
|
||||
|
||||
/**
|
||||
* Fiscal scenario for the investor's business plan: the yearly IRPC is the
|
||||
* documented rate applied to each year's profit before tax. It guides the
|
||||
* viability reading; it is not a tax assessment.
|
||||
*/
|
||||
export const irpcPlanScenarios = {
|
||||
general: {
|
||||
label: "Regime geral do IRPC — taxa de 32%",
|
||||
rate: 32,
|
||||
source: "Cenário fiscal: IRPC à taxa geral de 32% (Código do IRPC, artigo 61.º, n.º 1) sobre o lucro antes de impostos de cada ano.",
|
||||
},
|
||||
} as const;
|
||||
|
||||
export type IrpcPlanScenario = keyof typeof irpcPlanScenarios;
|
||||
|
||||
const SIMPLIFICATIONS =
|
||||
" Estimativa para avaliar a viabilidade, não é liquidação: o imposto de cada ano é registado no último mês desse ano; um ano com prejuízo tem imposto zero; não inclui reporte de prejuízos, benefícios fiscais, pagamentos por conta nem o calendário de pagamento da Autoridade Tributária.";
|
||||
|
||||
function cents(value: string): bigint {
|
||||
const match = /^(-?)(\d+)\.(\d{2})$/.exec(value);
|
||||
if (!match) throw new Error("Resultado mensal com formato inesperado.");
|
||||
const amount = BigInt(match[2]) * 100n + BigInt(match[3]);
|
||||
return match[1] ? -amount : amount;
|
||||
}
|
||||
|
||||
function money(value: bigint): string {
|
||||
return `${value / 100n}.${String(value % 100n).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
/** Yearly tax on 12-month blocks, rounded half-up to the cent. */
|
||||
export function irpcScenarioSchedule(
|
||||
plan: BusinessFinancialPlanInput,
|
||||
scenario: IrpcPlanScenario,
|
||||
): { expense: string[]; payment: string[]; source: string } {
|
||||
const { rate, source } = irpcPlanScenarios[scenario];
|
||||
const rows = forecastBusinessPlan(plan).rows;
|
||||
const expense = rows.map(() => "0.00");
|
||||
for (let start = 0; start < rows.length; start += 12) {
|
||||
const block = rows.slice(start, start + 12);
|
||||
const profit = block.reduce(
|
||||
(total, row) => total + cents(String(row.profitBeforeTax)),
|
||||
0n,
|
||||
);
|
||||
if (profit <= 0n) continue;
|
||||
const tax = (profit * BigInt(rate) * 2n + 100n) / 200n;
|
||||
expense[start + block.length - 1] = money(tax);
|
||||
}
|
||||
return {
|
||||
expense,
|
||||
payment: [...expense],
|
||||
source: source + SIMPLIFICATIONS,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user