wip(qa): preserve package one pending functional acceptance
This commit is contained in:
@@ -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 (
|
||||
<p role="alert">
|
||||
Os dados complementares guardados não têm uma estrutura
|
||||
reconhecida. Foram preservados e não serão substituídos
|
||||
automaticamente.
|
||||
</p>
|
||||
);
|
||||
const a =
|
||||
plan.reportAssumptions ?? newReportAssumptions(plan.periods ?? 12);
|
||||
const update = (patch: Partial<typeof a>) =>
|
||||
onChange({ ...plan, reportAssumptions: { ...a, ...patch } });
|
||||
const numeric = (
|
||||
label: string,
|
||||
value: string,
|
||||
save: (value: string) => void,
|
||||
) => (
|
||||
<label className="grid gap-1 text-sm">
|
||||
{label}
|
||||
<input
|
||||
type="number"
|
||||
min="0"
|
||||
step="0.01"
|
||||
className="min-w-0 rounded border p-2"
|
||||
value={value}
|
||||
onChange={(event) => save(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
return (
|
||||
<details className="my-4 rounded border border-teal-500 p-3">
|
||||
<summary className="font-semibold">
|
||||
Relatório financeiro integral — dados do investimento
|
||||
</summary>
|
||||
<p className="my-2">
|
||||
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.
|
||||
</p>
|
||||
<div className="grid gap-3 sm:grid-cols-2">
|
||||
<label className="grid gap-1 text-sm">
|
||||
Ano inicial
|
||||
<input
|
||||
type="number"
|
||||
min="1900"
|
||||
max="9999"
|
||||
step="1"
|
||||
className="rounded border p-2"
|
||||
value={a.startYear}
|
||||
onChange={(event) =>
|
||||
update({ startYear: event.target.value })
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
{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 }),
|
||||
)}
|
||||
<label className="grid gap-1 text-sm">
|
||||
Tratamento das subvenções
|
||||
<select
|
||||
className="rounded border p-2"
|
||||
value={a.grantsTreatment}
|
||||
onChange={(event) =>
|
||||
update({
|
||||
grantsTreatment: event.target
|
||||
.value as typeof a.grantsTreatment,
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">Por indicar / sem subvenção</option>
|
||||
<option value="capital">Capital</option>
|
||||
<option value="deferred">Passivo diferido</option>
|
||||
</select>
|
||||
</label>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Natureza dos recebimentos manuais
|
||||
<select
|
||||
className="rounded border p-2"
|
||||
value={a.manualCollectionsKind}
|
||||
onChange={(event) =>
|
||||
update({
|
||||
manualCollectionsKind: event.target
|
||||
.value as typeof a.manualCollectionsKind,
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">Por indicar / sem montante</option>
|
||||
<option value="sales">Cobranças de vendas</option>
|
||||
<option value="other_income">
|
||||
Outras receitas reconhecidas e recebidas
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<fieldset className="my-3 space-y-2">
|
||||
<legend>
|
||||
Despesas de arranque — reconhecidas e pagas na abertura
|
||||
</legend>
|
||||
{a.startupExpenses.map((row, index) => (
|
||||
<div className="grid gap-2 sm:grid-cols-3" key={index}>
|
||||
<label className="grid text-sm">
|
||||
Despesa {index + 1}
|
||||
<input
|
||||
className="rounded border p-2"
|
||||
value={row.label}
|
||||
maxLength={160}
|
||||
onChange={(event) =>
|
||||
update({
|
||||
startupExpenses: a.startupExpenses.map(
|
||||
(entry, i) =>
|
||||
i === index
|
||||
? {
|
||||
...entry,
|
||||
label: event.target
|
||||
.value,
|
||||
}
|
||||
: entry,
|
||||
),
|
||||
})
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
{numeric(
|
||||
`Montante de arranque ${index + 1}`,
|
||||
row.amount,
|
||||
(amount) =>
|
||||
update({
|
||||
startupExpenses: a.startupExpenses.map(
|
||||
(entry, i) =>
|
||||
i === index
|
||||
? { ...entry, amount }
|
||||
: entry,
|
||||
),
|
||||
}),
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className="rounded border p-2"
|
||||
onClick={() =>
|
||||
update({
|
||||
startupExpenses: a.startupExpenses.filter(
|
||||
(_, i) => i !== index,
|
||||
),
|
||||
})
|
||||
}
|
||||
>
|
||||
Remover despesa
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
<button
|
||||
type="button"
|
||||
className="rounded border p-2"
|
||||
disabled={a.startupExpenses.length >= 40}
|
||||
onClick={() =>
|
||||
update({
|
||||
startupExpenses: [
|
||||
...a.startupExpenses,
|
||||
{ label: '', amount: '' },
|
||||
],
|
||||
})
|
||||
}
|
||||
>
|
||||
Adicionar despesa de arranque
|
||||
</button>
|
||||
</fieldset>
|
||||
<p className="my-2 text-sm">
|
||||
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.
|
||||
</p>
|
||||
<h5 className="font-semibold">
|
||||
Despesas de arranque (reconhecidas e pagas na abertura)
|
||||
</h5>
|
||||
{a.startupExpenses.map((row, index) => (
|
||||
<div className="my-2 grid gap-2 sm:grid-cols-3" key={index}>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Despesa
|
||||
<input
|
||||
className="min-w-0 rounded border p-2"
|
||||
maxLength={160}
|
||||
value={row.label}
|
||||
onChange={(event) =>
|
||||
update({
|
||||
startupExpenses: a.startupExpenses.map(
|
||||
(entry, i) =>
|
||||
i === index
|
||||
? {
|
||||
...entry,
|
||||
label: event.target.value,
|
||||
}
|
||||
: entry,
|
||||
),
|
||||
})
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
{numeric('Montante de arranque', row.amount, (amount) =>
|
||||
update({
|
||||
startupExpenses: a.startupExpenses.map(
|
||||
(entry, i) =>
|
||||
i === index ? { ...entry, amount } : entry,
|
||||
),
|
||||
}),
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className="rounded border p-2"
|
||||
onClick={() =>
|
||||
update({
|
||||
startupExpenses: a.startupExpenses.filter(
|
||||
(_, i) => i !== index,
|
||||
),
|
||||
})
|
||||
}
|
||||
>
|
||||
Remover despesa
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
<button
|
||||
type="button"
|
||||
className="my-2 rounded border px-3 py-2"
|
||||
disabled={a.startupExpenses.length >= 40}
|
||||
onClick={() =>
|
||||
update({
|
||||
startupExpenses: [
|
||||
...a.startupExpenses,
|
||||
{ label: '', amount: '' },
|
||||
],
|
||||
})
|
||||
}
|
||||
>
|
||||
Adicionar despesa de arranque
|
||||
</button>
|
||||
<p className="text-sm">
|
||||
Sem linhas significa que não declarou despesas de arranque; para
|
||||
confirmar a inexistência, registe uma linha «Sem despesas de
|
||||
arranque» com zero.
|
||||
</p>
|
||||
<label className="my-2 grid gap-1 text-sm">
|
||||
Fonte ou pressuposto dos impostos estimados
|
||||
<input
|
||||
className="rounded border p-2"
|
||||
maxLength={1000}
|
||||
value={a.taxSource}
|
||||
onChange={(event) =>
|
||||
update({ taxSource: event.target.value })
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<details>
|
||||
<summary>Impostos por mês — estimativa e tesouraria</summary>
|
||||
<p className="text-sm">
|
||||
Não activa taxas fiscais nem certifica pagamentos. Preencha
|
||||
cada mês, incluindo zero declarado.
|
||||
</p>
|
||||
{Array.from({ length: plan.periods ?? 12 }, (_, index) => (
|
||||
<div className="my-2 grid gap-2 sm:grid-cols-2" key={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] ??
|
||||
''),
|
||||
),
|
||||
}),
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</details>
|
||||
<InvestmentReportTables
|
||||
tables={buildIntegralFinancialTables(plan)}
|
||||
/>
|
||||
</details>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import {
|
||||
displayReportMoney,
|
||||
type InvestmentReportTable,
|
||||
} from '@/lib/integral-financial-report';
|
||||
|
||||
export function InvestmentReportTables({
|
||||
tables,
|
||||
}: {
|
||||
tables: InvestmentReportTable[];
|
||||
}) {
|
||||
return (
|
||||
<div className="space-y-5">
|
||||
{tables.map((table) => (
|
||||
<section key={table.id} aria-label={table.title}>
|
||||
<h4 className="font-semibold">{table.title}</h4>
|
||||
{table.issues.length > 0 && (
|
||||
<ul className="list-disc pl-5 text-amber-900">
|
||||
{[...new Set(table.issues)].map((issue) => (
|
||||
<li key={issue}>{issue}</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
{table.rows.length > 0 && (
|
||||
<div
|
||||
className="overflow-x-auto"
|
||||
tabIndex={0}
|
||||
role="region"
|
||||
aria-label={`Tabela ${table.title}`}
|
||||
>
|
||||
<table className="w-full border-collapse text-left text-sm">
|
||||
<caption className="sr-only">
|
||||
{table.title}
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
{table.headers.map((header, index) => (
|
||||
<th
|
||||
className="min-w-28 border p-2"
|
||||
key={index}
|
||||
>
|
||||
{header}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{table.rows.map((row, i) => (
|
||||
<tr key={i}>
|
||||
{row.map((cell, j) =>
|
||||
j === 0 ? (
|
||||
<th
|
||||
className="min-w-40 border p-2 font-medium"
|
||||
key={j}
|
||||
>
|
||||
{cell}
|
||||
</th>
|
||||
) : (
|
||||
<td
|
||||
className="border p-2 whitespace-nowrap"
|
||||
key={j}
|
||||
>
|
||||
{displayReportMoney(
|
||||
cell,
|
||||
)}
|
||||
</td>
|
||||
),
|
||||
)}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
{table.notes.map((note, i) => (
|
||||
<p className="mt-1 text-sm" key={i}>
|
||||
{note}
|
||||
</p>
|
||||
))}
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { InvestmentReportTables } from './investment-report-tables';
|
||||
import {
|
||||
createInvestorDossierReport,
|
||||
createInvestorStageReport,
|
||||
@@ -259,6 +260,9 @@ function StageReportPreview({
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
{section.tables && (
|
||||
<InvestmentReportTables tables={section.tables} />
|
||||
)}
|
||||
</section>
|
||||
))}
|
||||
{report.limitations.map((text) => (
|
||||
|
||||
@@ -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({
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<IntegralFinancialPlan plan={plan} onChange={savePlan} />
|
||||
<div className="my-3 flex flex-wrap items-end gap-3 rounded border p-3">
|
||||
<label className="grid gap-1 text-sm">
|
||||
Importar plano financeiro InvestMoz (.json, até 60 KB)
|
||||
|
||||
Reference in New Issue
Block a user