diff --git a/resources/js/components/integral-financial-plan.tsx b/resources/js/components/integral-financial-plan.tsx new file mode 100644 index 00000000..6757ffa0 --- /dev/null +++ b/resources/js/components/integral-financial-plan.tsx @@ -0,0 +1,327 @@ +import type { BusinessFinancialPlanInput } from '@/lib/business-financial-plan'; +import { + buildIntegralFinancialTables, + newReportAssumptions, + isReportAssumptions, +} from '@/lib/integral-financial-report'; +import { InvestmentReportTables } from './investment-report-tables'; + +export function IntegralFinancialPlan({ + plan, + onChange, +}: { + plan: BusinessFinancialPlanInput; + onChange: (plan: BusinessFinancialPlanInput) => void; +}) { + 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. Não + utiliza o cenário sintético. 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. +

+
+ + {numeric( + 'Activos fixos anteriores (valor líquido)', + a.openingFixedAssets, + (openingFixedAssets) => update({ openingFixedAssets }), + )} + {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. +

+
+ Despesas de arranque (reconhecidas e pagas na abertura) +
+ {a.startupExpenses.map((row, index) => ( +
+ + {numeric('Montante de arranque', row.amount, (amount) => + update({ + startupExpenses: a.startupExpenses.map( + (entry, i) => + i === index ? { ...entry, amount } : entry, + ), + }), + )} + +
+ ))} + +

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

+ +
+ Impostos por mês — estimativa e tesouraria +

+ Não activa taxas fiscais nem certifica pagamentos. Preencha + cada mês, incluindo zero declarado. +

+ {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] ?? + ''), + ), + }), + )} +
+ ))} +
+ +
+ ); +} diff --git a/resources/js/components/investment-report-tables.tsx b/resources/js/components/investment-report-tables.tsx new file mode 100644 index 00000000..4f6265ff --- /dev/null +++ b/resources/js/components/investment-report-tables.tsx @@ -0,0 +1,83 @@ +import { + displayReportMoney, + type InvestmentReportTable, +} from '@/lib/integral-financial-report'; + +export function InvestmentReportTables({ + tables, +}: { + tables: InvestmentReportTable[]; +}) { + return ( +
+ {tables.map((table) => ( +
+

{table.title}

+ {table.issues.length > 0 && ( +
    + {[...new Set(table.issues)].map((issue) => ( +
  • {issue}
  • + ))} +
+ )} + {table.rows.length > 0 && ( +
+ + + + + {table.headers.map((header, index) => ( + + ))} + + + + {table.rows.map((row, i) => ( + + {row.map((cell, j) => + j === 0 ? ( + + ) : ( + + ), + )} + + ))} + +
+ {table.title} +
+ {header} +
+ {cell} + + {displayReportMoney( + cell, + )} +
+
+ )} + {table.notes.map((note, i) => ( +

+ {note} +

+ ))} +
+ ))} +
+ ); +} diff --git a/resources/js/components/investor-dossier-reports.tsx b/resources/js/components/investor-dossier-reports.tsx index 9d1245cb..67d6699c 100644 --- a/resources/js/components/investor-dossier-reports.tsx +++ b/resources/js/components/investor-dossier-reports.tsx @@ -1,4 +1,5 @@ import { useEffect, useState } from 'react'; +import { InvestmentReportTables } from './investment-report-tables'; import { createInvestorDossierReport, createInvestorStageReport, @@ -259,6 +260,9 @@ function StageReportPreview({ ))} + {section.tables && ( + + )} ))} {report.limitations.map((text) => ( diff --git a/resources/js/components/simulation-business-plan.tsx b/resources/js/components/simulation-business-plan.tsx index dd2f240d..49235c27 100644 --- a/resources/js/components/simulation-business-plan.tsx +++ b/resources/js/components/simulation-business-plan.tsx @@ -20,6 +20,7 @@ import { import { buildFinancialFiscalBridge } from '@/lib/financial-fiscal-bridge'; import { BusinessPlanWarnings } from '@/components/business-plan-warnings'; import { SimulationAnnualExample } from '@/components/simulation-annual-example'; +import { IntegralFinancialPlan } from '@/components/integral-financial-plan'; const emptyPlan: BusinessFinancialPlanInput = { currency: '', @@ -938,6 +939,7 @@ export function SimulationBusinessPlan({ } /> )} +