import type { BusinessFinancialPlanInput } from '@/lib/business-financial-plan'; import { buildIntegralFinancialTables, newReportAssumptions, isReportAssumptions, } from '@/lib/integral-financial-report'; import { InvestmentReportTables } from './investment-report-tables'; import { BusinessPlanWarnings } from './business-plan-warnings'; import { financialPlanWarnings } from '@/lib/financial-plan-warnings'; import { StartupAssetRequirements } from './startup-asset-requirements'; import { irpcPlanScenarios, irpcScenarioSchedule, type IrpcPlanScenario, } from '@/lib/irpc-plan-scenario'; import { useState } from 'react'; export function IntegralFinancialPlan({ plan, onChange, }: { plan: BusinessFinancialPlanInput; onChange: (plan: BusinessFinancialPlanInput) => void; }) { if (plan.reportSource === 'annual_example') { return (

Seleccione o plano do investidor para consultar o relatório financeiro.

); } if (plan.reportAssumptions && !isReportAssumptions(plan.reportAssumptions)) return (

Os dados complementares guardados não têm uma estrutura reconhecida. Foram preservados e não serão substituídos automaticamente.

); const a = plan.reportAssumptions ?? newReportAssumptions(plan.periods ?? 12); const update = (patch: Partial) => onChange({ ...plan, reportAssumptions: { ...a, ...patch } }); const numeric = ( label: string, value: string, save: (value: string) => void, ) => ( ); return (
Relatório financeiro integral — dados do investimento

Utiliza as vendas, custos e agendas do plano financeiro. Todos os montantes são projecções declaradas em{' '} {plan.currency || 'moeda por seleccionar'}. Campos em falta permanecem por determinar; indique zero apenas quando aplicável.

{!plan.startupAssetRequirements && numeric( 'Activos fixos anteriores (valor líquido)', a.openingFixedAssets, (openingFixedAssets) => update({ openingFixedAssets }), )} {!plan.startupAssetRequirements && numeric( 'Outros activos anteriores', a.openingOtherAssets, (openingOtherAssets) => update({ openingOtherAssets }), )} {numeric( 'Capital e resultados anteriores', a.openingEquity, (openingEquity) => update({ openingEquity }), )}
Despesas de arranque — reconhecidas e pagas na abertura {a.startupExpenses.map((row, index) => (
{numeric( `Montante de arranque ${index + 1}`, row.amount, (amount) => update({ startupExpenses: a.startupExpenses.map( (entry, i) => i === index ? { ...entry, amount } : entry, ), }), )}
))}

Os saldos anteriores têm de reconciliar entre si. Não inclua os novos activos no saldo anterior, nem os novos capitais nos resultados anteriores.

Sem linhas significa que não declarou despesas de arranque; para confirmar a inexistência, registe uma linha «Sem despesas de arranque» com zero.

update({ taxExpenseByMonth: result.expense, taxPaymentByMonth: result.payment, taxSource: result.source, }) } />
Impostos por mês — estimativa e tesouraria

Preenchidos pelo cenário fiscal ou por si. Não certifica pagamentos; um mês sem imposto fica com zero.

{Array.from({ length: plan.periods ?? 12 }, (_, index) => (
{numeric( `Imposto reconhecido — mês ${index + 1}`, a.taxExpenseByMonth[index] ?? '', (value) => update({ taxExpenseByMonth: Array.from( { length: plan.periods ?? 12 }, (_, i) => i === index ? value : (a.taxExpenseByMonth[i] ?? ''), ), }), )} {numeric( `Pagamento fiscal previsto — mês ${index + 1}`, a.taxPaymentByMonth[index] ?? '', (value) => update({ taxPaymentByMonth: Array.from( { length: plan.periods ?? 12 }, (_, i) => i === index ? value : (a.taxPaymentByMonth[i] ?? ''), ), }), )}
))}
); } /** Own component so its state never runs when the plan editor is used as a plain function. */ function TaxScenario({ plan, onApply, }: { plan: BusinessFinancialPlanInput; onApply: (result: ReturnType) => void; }) { const [scenario, setScenario] = useState('general'); const [scenarioError, setScenarioError] = useState(''); return (

Cenário fiscal

Escolha o cenário e o simulador calcula o IRPC de cada ano a partir do lucro antes de impostos, para ver o lucro líquido e a viabilidade. Pode depois ajustar mês a mês.

{scenarioError && (

{scenarioError}

)}
); }