feat(qa): integrate financial ratios with accounting consistency guards
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
import type { BusinessFinancialPlanInput } from '@/lib/business-financial-plan';
|
||||
import { buildFinancialRatiosTable } from '@/lib/financial-ratios-report';
|
||||
import { InvestmentReportTables } from './investment-report-tables';
|
||||
export function FinancialRatiosPlan({
|
||||
plan,
|
||||
onChange,
|
||||
}: {
|
||||
plan: BusinessFinancialPlanInput;
|
||||
onChange: (p: BusinessFinancialPlanInput) => void;
|
||||
}) {
|
||||
const periods = plan.periods ?? 12,
|
||||
s = plan.ratioCurrentBalances;
|
||||
if (
|
||||
s &&
|
||||
(!Array.isArray(s.assetsByMonth) ||
|
||||
!Array.isArray(s.liabilitiesByMonth) ||
|
||||
s.assetsByMonth.some((x) => typeof x !== 'string') ||
|
||||
s.liabilitiesByMonth.some((x) => typeof x !== 'string'))
|
||||
)
|
||||
return (
|
||||
<p role="alert">
|
||||
A classificação corrente guardada tem uma estrutura
|
||||
desconhecida. O original foi preservado.
|
||||
</p>
|
||||
);
|
||||
const save = (
|
||||
key: 'assetsByMonth' | 'liabilitiesByMonth',
|
||||
index: number,
|
||||
value: string,
|
||||
) =>
|
||||
onChange({
|
||||
...plan,
|
||||
ratioCurrentBalances: {
|
||||
assetsByMonth: s?.assetsByMonth ?? Array(periods).fill(''),
|
||||
liabilitiesByMonth:
|
||||
s?.liabilitiesByMonth ?? Array(periods).fill(''),
|
||||
[key]: Array.from(
|
||||
{ length: Math.max(periods, s?.[key].length ?? 0) },
|
||||
(_, i) => (i === index ? value : (s?.[key][i] ?? '')),
|
||||
),
|
||||
},
|
||||
});
|
||||
return (
|
||||
<details className="my-4 rounded border p-3">
|
||||
<summary>Rácios financeiros e classificação corrente</summary>
|
||||
<p className="my-2 text-sm">
|
||||
Para a liquidez, declare os totais classificados como activo e
|
||||
passivo correntes no fecho de cada mês, segundo os vencimentos
|
||||
aplicáveis. Não alteram o balanço. Vazio permanece por
|
||||
determinar; zero só quando aplicável. Os restantes rácios
|
||||
utilizam as demonstrações já guardadas.
|
||||
</p>
|
||||
<details>
|
||||
<summary>Classificar saldos correntes para liquidez</summary>
|
||||
{Array.from({ length: periods }, (_, i) => (
|
||||
<fieldset
|
||||
key={i}
|
||||
className="my-2 grid gap-2 rounded border p-2 sm:grid-cols-2"
|
||||
>
|
||||
<legend>Mês {i + 1}</legend>
|
||||
{(['assetsByMonth', 'liabilitiesByMonth'] as const).map(
|
||||
(key) => (
|
||||
<label
|
||||
key={key}
|
||||
className="grid min-w-0 gap-1 text-sm"
|
||||
>
|
||||
{key === 'assetsByMonth'
|
||||
? 'Activo corrente'
|
||||
: 'Passivo corrente'}{' '}
|
||||
— mês {i + 1}
|
||||
<input
|
||||
className="min-w-0 rounded border p-2"
|
||||
type="number"
|
||||
min="0"
|
||||
step="0.01"
|
||||
value={s?.[key][i] ?? ''}
|
||||
onChange={(e) =>
|
||||
save(key, i, e.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
),
|
||||
)}
|
||||
</fieldset>
|
||||
))}
|
||||
</details>
|
||||
<InvestmentReportTables
|
||||
tables={[buildFinancialRatiosTable(plan)]}
|
||||
/>
|
||||
</details>
|
||||
);
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import { BusinessPlanWarnings } from '@/components/business-plan-warnings';
|
||||
import { SimulationAnnualExample } from '@/components/simulation-annual-example';
|
||||
import { IntegralFinancialPlan } from '@/components/integral-financial-plan';
|
||||
import { MarketAnalysisPlan } from '@/components/market-analysis-plan';
|
||||
import { FinancialRatiosPlan } from '@/components/financial-ratios-plan';
|
||||
|
||||
const emptyPlan: BusinessFinancialPlanInput = {
|
||||
currency: '',
|
||||
@@ -942,6 +943,7 @@ export function SimulationBusinessPlan({
|
||||
)}
|
||||
<IntegralFinancialPlan plan={plan} onChange={savePlan} />
|
||||
<MarketAnalysisPlan plan={plan} onChange={savePlan} />
|
||||
<FinancialRatiosPlan 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