feat: apply owner warning decisions and add editable annual planning example
This commit is contained in:
@@ -18,6 +18,8 @@ import {
|
||||
simulationCurrencyOptions,
|
||||
} from '@/lib/simulation-contract';
|
||||
import { buildFinancialFiscalBridge } from '@/lib/financial-fiscal-bridge';
|
||||
import { BusinessPlanWarnings } from '@/components/business-plan-warnings';
|
||||
import { SimulationAnnualExample } from '@/components/simulation-annual-example';
|
||||
|
||||
const emptyPlan: BusinessFinancialPlanInput = {
|
||||
currency: '',
|
||||
@@ -76,18 +78,21 @@ function MoneyInput({
|
||||
onChange,
|
||||
allowNegative = false,
|
||||
step = '0.01',
|
||||
optional = false,
|
||||
}: {
|
||||
label: string;
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
allowNegative?: boolean;
|
||||
step?: string;
|
||||
optional?: boolean;
|
||||
}) {
|
||||
const errorId = useId();
|
||||
const [touched, setTouched] = useState(false);
|
||||
const error = touched
|
||||
? businessPlanNumberError(value, { allowNegative })
|
||||
: '';
|
||||
const error =
|
||||
touched && (!optional || value.trim() !== '')
|
||||
? businessPlanNumberError(value, { allowNegative })
|
||||
: '';
|
||||
return (
|
||||
<label className="block text-sm font-medium">
|
||||
{label}
|
||||
@@ -139,6 +144,7 @@ export function SimulationBusinessPlan({
|
||||
);
|
||||
const [workingPlan, setWorkingPlan] =
|
||||
useState<BusinessFinancialPlanInput | null>(null);
|
||||
const [showExample, setShowExample] = useState(false);
|
||||
useEffect(() => setWorkingPlan(null), [snapshot]);
|
||||
if (hasOversizedStoredSnapshot) {
|
||||
return (
|
||||
@@ -914,6 +920,16 @@ export function SimulationBusinessPlan({
|
||||
separados. Não calcula impostos, não converte moedas e não
|
||||
substitui um plano contabilístico validado.
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
className="rounded border px-3 py-2 text-sm"
|
||||
onClick={() => setShowExample((previous) => !previous)}
|
||||
>
|
||||
{showExample
|
||||
? 'Fechar cenário de exemplo'
|
||||
: 'Carregar cenário anual de exemplo'}
|
||||
</button>
|
||||
{showExample && <SimulationAnnualExample currency={currency} />}
|
||||
<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)
|
||||
@@ -957,6 +973,17 @@ export function SimulationBusinessPlan({
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<MoneyInput
|
||||
optional
|
||||
label="Crescimento anual pretendido (%)"
|
||||
value={plan.annualGrowthPercent ?? ''}
|
||||
onChange={(value) => update('annualGrowthPercent', value)}
|
||||
/>
|
||||
<p className="text-sm">
|
||||
A meta de crescimento pode exceder 100%, com aviso. É uma
|
||||
hipótese declarada; as agendas de vendas introduzidas mantêm
|
||||
os seus valores.
|
||||
</p>
|
||||
|
||||
<p className="text-sm text-slate-700">
|
||||
O plano financeiro aceita moedas ISO suportadas com duas
|
||||
@@ -2498,24 +2525,29 @@ export function SimulationBusinessPlan({
|
||||
>
|
||||
Exportar plano em CSV
|
||||
</button>
|
||||
<p
|
||||
role={
|
||||
result.fundingStatus === 'balanced'
|
||||
? 'status'
|
||||
: 'alert'
|
||||
}
|
||||
className={
|
||||
result.fundingStatus === 'balanced'
|
||||
? 'rounded bg-emerald-50 p-3 text-sm'
|
||||
: 'rounded bg-amber-50 p-3 text-sm'
|
||||
}
|
||||
>
|
||||
{result.fundingStatus === 'balanced'
|
||||
? 'As fontes de financiamento reconciliam com os usos iniciais.'
|
||||
: result.fundingStatus === 'shortfall'
|
||||
? `Falta financiar ${result.fundingGap} ${currency} dos usos iniciais.`
|
||||
: `As fontes excedem os usos iniciais em ${result.fundingGap.replace('-', '')} ${currency}.`}
|
||||
</p>
|
||||
<BusinessPlanWarnings
|
||||
metrics={{
|
||||
currency,
|
||||
fundingGap: Number(result.fundingGap),
|
||||
growthPercent: plan.annualGrowthPercent?.trim()
|
||||
? Number(plan.annualGrowthPercent)
|
||||
: undefined,
|
||||
}}
|
||||
/>
|
||||
{result.fundingStatus !== 'shortfall' && (
|
||||
<p
|
||||
role="status"
|
||||
className={
|
||||
result.fundingStatus === 'balanced'
|
||||
? 'rounded bg-emerald-50 p-3 text-sm'
|
||||
: 'rounded bg-amber-50 p-3 text-sm'
|
||||
}
|
||||
>
|
||||
{result.fundingStatus === 'balanced'
|
||||
? 'As fontes de financiamento reconciliam com os usos iniciais.'
|
||||
: `As fontes excedem os usos iniciais em ${result.fundingGap.replace('-', '')} ${currency}.`}
|
||||
</p>
|
||||
)}
|
||||
<dl className="grid gap-2 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{[
|
||||
['Fundo de maneio líquido', result.workingCapital],
|
||||
|
||||
Reference in New Issue
Block a user