Simulador: os campos numéricos aceitam «25.000», «1 500» e «1500,50»
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
O campo numérico do navegador segue a língua do navegador: «25.000» era lido como 25 e a vírgula decimal podia ser recusada, pelo que o investidor via o valor mudar ou não conseguia escrever. Os campos de montantes do simulador, do plano de negócio e do orçamento inicial passam a usar um campo de texto decimal que lê os números como se escrevem em Moçambique, mostra «Lido como …» quando reinterpreta e deixa o texto inválido chegar à validação, que o explica. Os campos inteiros (horizonte, prazo de entrega, vida útil, mês económico) deixam de saltar para 1 quando se apaga para reescrever; se o valor escrito não for aceite, ao sair do campo volta o valor em vigor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MzJmxFy3izprXr5dSq91jM
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
import {
|
||||
useEffect,
|
||||
useId,
|
||||
useRef,
|
||||
useState,
|
||||
type InputHTMLAttributes,
|
||||
} from 'react';
|
||||
import { normalizeDecimalInput, presentDecimal } from '@/lib/decimal-input';
|
||||
|
||||
type Props = Omit<
|
||||
InputHTMLAttributes<HTMLInputElement>,
|
||||
'type' | 'value' | 'onChange' | 'min' | 'max' | 'step'
|
||||
> & {
|
||||
value: string | number | null | undefined;
|
||||
/** Receives the stored format ("1500.50"), or the raw text when it is not a number, so validation can explain it. */
|
||||
onValueChange: (value: string) => void;
|
||||
min?: string | number;
|
||||
max?: string | number;
|
||||
step?: string | number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Number field that reads «25.000», «1 500» and «1500,50» as written in
|
||||
* Mozambique, instead of the browser's number input, which follows the
|
||||
* browser locale (25.000 → 25; a comma may be refused).
|
||||
*/
|
||||
export function DecimalInput({
|
||||
value: rawValue,
|
||||
onValueChange,
|
||||
min: _min,
|
||||
max: _max,
|
||||
step: _step,
|
||||
onBlur,
|
||||
...rest
|
||||
}: Props) {
|
||||
const value =
|
||||
rawValue === null || rawValue === undefined ? '' : String(rawValue);
|
||||
const hintId = useId();
|
||||
const [text, setText] = useState(value);
|
||||
const emitted = useRef(value);
|
||||
useEffect(() => {
|
||||
// A value set elsewhere (draft recovery, another field) replaces the text.
|
||||
if (normalizeDecimalInput(text) !== value) setText(value);
|
||||
emitted.current = value;
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [value]);
|
||||
const read = normalizeDecimalInput(text);
|
||||
const reinterpreted =
|
||||
read !== null && read !== '' && read !== text.trim() ? read : null;
|
||||
return (
|
||||
<>
|
||||
<input
|
||||
{...rest}
|
||||
type="text"
|
||||
inputMode="decimal"
|
||||
autoComplete="off"
|
||||
value={text}
|
||||
onBlur={(event) => {
|
||||
// A field the plan did not accept (an emptied horizon, a
|
||||
// fraction of a month) shows again the value still in force.
|
||||
if (emitted.current !== value) {
|
||||
setText(value);
|
||||
emitted.current = value;
|
||||
}
|
||||
onBlur?.(event);
|
||||
}}
|
||||
aria-describedby={
|
||||
[rest['aria-describedby'], reinterpreted ? hintId : null]
|
||||
.filter(Boolean)
|
||||
.join(' ') || undefined
|
||||
}
|
||||
onChange={(event) => {
|
||||
setText(event.target.value);
|
||||
const normalized = normalizeDecimalInput(
|
||||
event.target.value,
|
||||
);
|
||||
emitted.current =
|
||||
normalized === null ? event.target.value : normalized;
|
||||
onValueChange(emitted.current);
|
||||
}}
|
||||
/>
|
||||
{reinterpreted && (
|
||||
<span id={hintId} className="mt-1 block text-xs text-slate-600">
|
||||
Lido como {presentDecimal(reinterpreted)}
|
||||
</span>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DecimalInput } from '@/components/decimal-input';
|
||||
import {
|
||||
forecastBusinessPlan,
|
||||
type BusinessFinancialPlanInput,
|
||||
@@ -198,15 +199,15 @@ export function FinancialDayTerms({
|
||||
))}
|
||||
<label className="grid gap-1">
|
||||
Mês económico
|
||||
<input
|
||||
<DecimalInput
|
||||
className="w-full min-w-0 rounded border p-2"
|
||||
type="number"
|
||||
min="1"
|
||||
max={plan.periods}
|
||||
value={o.month}
|
||||
onChange={(e) =>
|
||||
onValueChange={(value) =>
|
||||
/^\d+$/.test(value) &&
|
||||
update(index, {
|
||||
month: Number(e.target.value),
|
||||
month: Number(value),
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DecimalInput } from '@/components/decimal-input';
|
||||
import type { BusinessFinancialPlanInput } from '@/lib/business-financial-plan';
|
||||
/** Optional declarations share the existing plan snapshot; no independent storage. */
|
||||
export function FinancialPlanDetails({
|
||||
@@ -10,13 +11,12 @@ export function FinancialPlanDetails({
|
||||
const input = (label: string, value: string, save: (s: string) => void) => (
|
||||
<label className="grid gap-1 text-sm">
|
||||
{label}
|
||||
<input
|
||||
<DecimalInput
|
||||
className="min-w-0 rounded border p-2"
|
||||
type="number"
|
||||
min="0"
|
||||
step="0.01"
|
||||
value={value}
|
||||
onChange={(e) => save(e.target.value)}
|
||||
onValueChange={(value) => save(value)}
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
@@ -27,15 +27,14 @@ export function FinancialPlanDetails({
|
||||
</summary>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Prazo de recebimento a crédito (dias, quando conhecido)
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="0"
|
||||
max="365"
|
||||
step="1"
|
||||
className="min-w-0 rounded border p-2"
|
||||
value={plan.creditTermDays ?? ''}
|
||||
onChange={(e) =>
|
||||
onChange({ ...plan, creditTermDays: e.target.value })
|
||||
onValueChange={(value) =>
|
||||
onChange({ ...plan, creditTermDays: value })
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DecimalInput } from '@/components/decimal-input';
|
||||
import type { BusinessFinancialPlanInput } from '@/lib/business-financial-plan';
|
||||
import { buildFinancialRatiosTable } from '@/lib/financial-ratios-report';
|
||||
import { InvestmentReportTables } from './investment-report-tables';
|
||||
@@ -68,14 +69,13 @@ export function FinancialRatiosPlan({
|
||||
? 'Activo corrente'
|
||||
: 'Passivo corrente'}{' '}
|
||||
— mês {i + 1}
|
||||
<input
|
||||
<DecimalInput
|
||||
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)
|
||||
onValueChange={(value) =>
|
||||
save(key, i, value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DecimalInput } from '@/components/decimal-input';
|
||||
import type { BusinessFinancialPlanInput } from '@/lib/business-financial-plan';
|
||||
import {
|
||||
buildIntegralFinancialTables,
|
||||
@@ -49,13 +50,12 @@ export function IntegralFinancialPlan({
|
||||
) => (
|
||||
<label className="grid gap-1 text-sm">
|
||||
{label}
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="0"
|
||||
step="0.01"
|
||||
className="min-w-0 rounded border p-2"
|
||||
value={value}
|
||||
onChange={(event) => save(event.target.value)}
|
||||
onValueChange={(value) => save(value)}
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
@@ -78,16 +78,13 @@ export function IntegralFinancialPlan({
|
||||
<div className="grid gap-3 sm:grid-cols-2">
|
||||
<label className="grid gap-1 text-sm">
|
||||
Ano inicial
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="1900"
|
||||
max="9999"
|
||||
step="1"
|
||||
className="rounded border p-2"
|
||||
value={a.startYear}
|
||||
onChange={(event) =>
|
||||
update({ startYear: event.target.value })
|
||||
}
|
||||
onValueChange={(value) => update({ startYear: value })}
|
||||
/>
|
||||
</label>
|
||||
{!plan.startupAssetRequirements &&
|
||||
@@ -319,8 +316,8 @@ function TaxScenario({
|
||||
<h4 className="font-semibold">Cenário fiscal</h4>
|
||||
<p className="text-sm">
|
||||
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.
|
||||
partir do lucro antes de impostos, para ver o lucro líquido e a
|
||||
viabilidade. Pode depois ajustar mês a mês.
|
||||
</p>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Cenário
|
||||
@@ -331,13 +328,11 @@ function TaxScenario({
|
||||
setScenario(event.target.value as IrpcPlanScenario)
|
||||
}
|
||||
>
|
||||
{Object.entries(irpcPlanScenarios).map(
|
||||
([key, option]) => (
|
||||
<option key={key} value={key}>
|
||||
{option.label}
|
||||
</option>
|
||||
),
|
||||
)}
|
||||
{Object.entries(irpcPlanScenarios).map(([key, option]) => (
|
||||
<option key={key} value={key}>
|
||||
{option.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<button
|
||||
@@ -345,10 +340,7 @@ function TaxScenario({
|
||||
className="rounded bg-emerald-800 px-3 py-2 text-white"
|
||||
onClick={() => {
|
||||
try {
|
||||
const result = irpcScenarioSchedule(
|
||||
plan,
|
||||
scenario,
|
||||
);
|
||||
const result = irpcScenarioSchedule(plan, scenario);
|
||||
setScenarioError('');
|
||||
onApply(result);
|
||||
} catch (cause) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DecimalInput } from '@/components/decimal-input';
|
||||
import CurrencySelect from './currency-select';
|
||||
|
||||
/** A planning interval is not the amount used in a financial calculation. */
|
||||
@@ -30,15 +31,14 @@ export default function InvestmentBudgetRange({
|
||||
).map((field, index) => (
|
||||
<label key={field} className="grid gap-1">
|
||||
{index === 0 ? 'Desde' : 'Até'}
|
||||
<input
|
||||
<DecimalInput
|
||||
className="min-w-0 rounded border p-2"
|
||||
disabled={disabled}
|
||||
type="number"
|
||||
min="0"
|
||||
step="any"
|
||||
value={values[field] ?? ''}
|
||||
onChange={(event) =>
|
||||
onChange(field, event.target.value)
|
||||
onValueChange={(value) =>
|
||||
onChange(field, value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DecimalInput } from '@/components/decimal-input';
|
||||
import { useState } from 'react';
|
||||
import { sumFinancialAmounts } from '@/lib/financial-calculators';
|
||||
type Row = { label: string; amount: string };
|
||||
@@ -82,19 +83,18 @@ export default function InvestmentInitialBudget({
|
||||
</label>
|
||||
<label>
|
||||
Montante {currency}
|
||||
<input
|
||||
<DecimalInput
|
||||
className="block w-full rounded border p-2"
|
||||
type="number"
|
||||
min="0"
|
||||
step="0.01"
|
||||
value={row.amount}
|
||||
onChange={(e) =>
|
||||
onValueChange={(value) =>
|
||||
save(
|
||||
rows.map((item, i) =>
|
||||
i === index
|
||||
? {
|
||||
...item,
|
||||
amount: e.target.value,
|
||||
amount: value,
|
||||
}
|
||||
: item,
|
||||
),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DecimalInput } from '@/components/decimal-input';
|
||||
import { useState } from 'react';
|
||||
import {
|
||||
estimateOperatingCosts,
|
||||
@@ -32,13 +33,12 @@ export default function InvestmentOperatingAssistance({
|
||||
) => (
|
||||
<label className="block">
|
||||
{label}
|
||||
<input
|
||||
<DecimalInput
|
||||
className="block w-full rounded border p-2"
|
||||
type="number"
|
||||
min="0"
|
||||
step="0.01"
|
||||
value={data[key]}
|
||||
onChange={(e) => save({ ...data, [key]: e.target.value })}
|
||||
onValueChange={(value) => save({ ...data, [key]: value })}
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
@@ -195,13 +195,12 @@ export default function InvestmentOperatingAssistance({
|
||||
</label>
|
||||
<label>
|
||||
Estimativa anual
|
||||
<input
|
||||
<DecimalInput
|
||||
className="block w-full rounded border p-2"
|
||||
type="number"
|
||||
min="0"
|
||||
step="0.01"
|
||||
value={row.annual}
|
||||
onChange={(e) =>
|
||||
onValueChange={(value) =>
|
||||
save({
|
||||
...data,
|
||||
costs: data.costs.map(
|
||||
@@ -209,9 +208,7 @@ export default function InvestmentOperatingAssistance({
|
||||
i === index
|
||||
? {
|
||||
...item,
|
||||
annual: e
|
||||
.target
|
||||
.value,
|
||||
annual: value,
|
||||
}
|
||||
: item,
|
||||
),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DecimalInput } from '@/components/decimal-input';
|
||||
import {
|
||||
readRows,
|
||||
type ProjectMilestone,
|
||||
@@ -231,19 +232,18 @@ export function ProjectTeamPlanner({
|
||||
</label>
|
||||
<label className="text-sm">
|
||||
Custo estimado (moeda do projecto)
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="0"
|
||||
step="0.01"
|
||||
className="mt-1 w-full rounded border p-2"
|
||||
value={row.estimated_cost}
|
||||
onChange={(e) =>
|
||||
onValueChange={(value) =>
|
||||
persist(
|
||||
update(
|
||||
rows,
|
||||
index,
|
||||
'estimated_cost',
|
||||
e.target.value,
|
||||
value,
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -424,19 +424,18 @@ export function ProjectMilestonePlanner({
|
||||
</label>
|
||||
<label className="text-sm">
|
||||
Montante planeado
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="0"
|
||||
step="0.01"
|
||||
className="mt-1 w-full rounded border p-2"
|
||||
value={row.planned_amount}
|
||||
onChange={(e) =>
|
||||
onValueChange={(value) =>
|
||||
persist(
|
||||
update(
|
||||
rows,
|
||||
index,
|
||||
'planned_amount',
|
||||
e.target.value,
|
||||
value,
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -444,20 +443,14 @@ export function ProjectMilestonePlanner({
|
||||
</label>
|
||||
<label className="text-sm">
|
||||
Montante realizado
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="0"
|
||||
step="0.01"
|
||||
className="mt-1 w-full rounded border p-2"
|
||||
value={row.actual_amount}
|
||||
onChange={(e) =>
|
||||
onValueChange={(value) =>
|
||||
persist(
|
||||
update(
|
||||
rows,
|
||||
index,
|
||||
'actual_amount',
|
||||
e.target.value,
|
||||
),
|
||||
update(rows, index, 'actual_amount', value),
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DecimalInput } from '@/components/decimal-input';
|
||||
import { BusinessPlanWarnings } from './business-plan-warnings';
|
||||
import {
|
||||
getProjectReadiness,
|
||||
@@ -262,16 +263,14 @@ export function ProjectReadiness({
|
||||
</label>
|
||||
<label className="grid gap-1 text-sm font-medium">
|
||||
Custo previsto ({currency})
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="0"
|
||||
step="0.01"
|
||||
className="rounded border p-2"
|
||||
value={response.estimated_cost}
|
||||
onChange={(event) =>
|
||||
onValueChange={(value) =>
|
||||
updateResponse(item.id, {
|
||||
estimated_cost:
|
||||
event.target.value,
|
||||
estimated_cost: value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DecimalInput } from '@/components/decimal-input';
|
||||
import {
|
||||
calculateAnnualReferencePlan,
|
||||
newAnnualReferencePlan,
|
||||
@@ -43,14 +44,13 @@ function ExampleNumber({
|
||||
return (
|
||||
<label className="grid gap-1 text-sm">
|
||||
{label}
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="0"
|
||||
step="0.01"
|
||||
className="min-w-0 rounded border p-2"
|
||||
value={value}
|
||||
aria-invalid={!!error}
|
||||
onChange={(event) => onChange(event.target.value)}
|
||||
onValueChange={(value) => onChange(value)}
|
||||
/>
|
||||
{error && (
|
||||
<span role="alert" className="text-red-800">
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DecimalInput } from '@/components/decimal-input';
|
||||
import { WarningLimitsEditor } from './warning-limits-editor';
|
||||
import { SupplierAdvancesEditor } from '@/components/supplier-advances';
|
||||
import { PeriodInvestmentsEditor } from '@/components/period-investments';
|
||||
@@ -110,14 +111,13 @@ function MoneyInput({
|
||||
return (
|
||||
<label className="block text-sm font-medium">
|
||||
{label}
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min={allowNegative ? undefined : '0'}
|
||||
step={step}
|
||||
value={value}
|
||||
onChange={(event) => {
|
||||
onValueChange={(next) => {
|
||||
setTouched(true);
|
||||
onChange(event.target.value);
|
||||
onChange(next);
|
||||
}}
|
||||
onBlur={() => setTouched(true)}
|
||||
aria-invalid={!!error}
|
||||
@@ -1038,13 +1038,12 @@ export function SimulationBusinessPlan({
|
||||
<label className="block text-sm font-medium">
|
||||
Taxa indicativa ({plan.presentationCurrency} por
|
||||
1 {currency})
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="0.00000001"
|
||||
step="0.00000001"
|
||||
value={plan.fxRate ?? ''}
|
||||
onChange={(event) =>
|
||||
update('fxRate', event.target.value)
|
||||
onValueChange={(value) =>
|
||||
update('fxRate', value)
|
||||
}
|
||||
className="mt-1 w-full rounded border p-2"
|
||||
aria-required="true"
|
||||
@@ -1092,14 +1091,13 @@ export function SimulationBusinessPlan({
|
||||
)}
|
||||
<label className="block text-sm font-medium">
|
||||
Horizonte (meses)
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="1"
|
||||
max="60"
|
||||
step="1"
|
||||
value={String(plan.periods ?? 12)}
|
||||
onChange={(event) =>
|
||||
updatePeriods(Number(event.target.value))
|
||||
onValueChange={(value) =>
|
||||
/^\d+$/.test(value) && updatePeriods(Number(value))
|
||||
}
|
||||
className="mt-1 w-full rounded border p-2"
|
||||
/>
|
||||
@@ -1350,26 +1348,23 @@ export function SimulationBusinessPlan({
|
||||
</label>
|
||||
<label>
|
||||
Percentagem
|
||||
<input
|
||||
<DecimalInput
|
||||
className="mt-1 w-full rounded border p-2"
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
step="0.01"
|
||||
value={
|
||||
part.percent
|
||||
}
|
||||
onChange={(
|
||||
event,
|
||||
onValueChange={(
|
||||
value,
|
||||
) =>
|
||||
updateProductPaymentInstallment(
|
||||
index,
|
||||
month,
|
||||
partIndex,
|
||||
'percent',
|
||||
event
|
||||
.target
|
||||
.value,
|
||||
value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
@@ -1446,17 +1441,16 @@ export function SimulationBusinessPlan({
|
||||
className="block text-sm"
|
||||
>
|
||||
Unidades - mes {month + 1}
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="0"
|
||||
step="0.001"
|
||||
value={units}
|
||||
onChange={(event) =>
|
||||
onValueChange={(value) =>
|
||||
updateProductSchedule(
|
||||
index,
|
||||
'monthlyUnitsByPeriod',
|
||||
month,
|
||||
event.target.value,
|
||||
value,
|
||||
)
|
||||
}
|
||||
className="mt-1 w-full rounded border p-2"
|
||||
@@ -1872,8 +1866,7 @@ export function SimulationBusinessPlan({
|
||||
/>
|
||||
<label className="block text-sm font-medium">
|
||||
Prazo de entrega das compras (meses)
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="0"
|
||||
max="12"
|
||||
step="1"
|
||||
@@ -1881,10 +1874,11 @@ export function SimulationBusinessPlan({
|
||||
plan.inventoryPurchaseLeadMonths ??
|
||||
0,
|
||||
)}
|
||||
onChange={(event) =>
|
||||
onValueChange={(value) =>
|
||||
/^\d+$/.test(value) &&
|
||||
update(
|
||||
'inventoryPurchaseLeadMonths',
|
||||
Number(event.target.value),
|
||||
Number(value),
|
||||
)
|
||||
}
|
||||
className="mt-1 w-full rounded border p-2"
|
||||
@@ -2282,16 +2276,13 @@ export function SimulationBusinessPlan({
|
||||
/>
|
||||
<label className="block text-sm">
|
||||
Vida útil (meses)
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="1"
|
||||
max="600"
|
||||
value={plan.depreciationLifeMonths}
|
||||
onChange={(event) =>
|
||||
update(
|
||||
'depreciationLifeMonths',
|
||||
Number(event.target.value),
|
||||
)
|
||||
onValueChange={(value) =>
|
||||
/^\d+$/.test(value) &&
|
||||
update('depreciationLifeMonths', Number(value))
|
||||
}
|
||||
className="mt-1 w-full rounded border p-2"
|
||||
/>
|
||||
@@ -2370,19 +2361,14 @@ export function SimulationBusinessPlan({
|
||||
).map(([key, label]) => (
|
||||
<label key={key} className="block text-sm">
|
||||
{label}
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="-100"
|
||||
step="0.01"
|
||||
value={
|
||||
scenarioAdjustments[scenario][key]
|
||||
}
|
||||
onChange={(event) =>
|
||||
updateScenario(
|
||||
scenario,
|
||||
key,
|
||||
event.target.value,
|
||||
)
|
||||
onValueChange={(value) =>
|
||||
updateScenario(scenario, key, value)
|
||||
}
|
||||
className="mt-1 w-full rounded border p-2"
|
||||
/>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DecimalInput } from '@/components/decimal-input';
|
||||
import CurrencySelect from '@/components/currency-select';
|
||||
import { useEffect, useState } from 'react';
|
||||
import {
|
||||
@@ -223,13 +224,12 @@ export function SimulationCashflowPlanner({
|
||||
{taxMode === 'fixed' ? (
|
||||
<label className="block max-w-xs text-sm font-medium">
|
||||
Imposto manual do cenário personalizado por mês
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="0"
|
||||
step="0.01"
|
||||
value={inputs.monthlyTaxAssessed}
|
||||
onChange={(event) =>
|
||||
set('monthlyTaxAssessed', event.target.value)
|
||||
onValueChange={(value) =>
|
||||
set('monthlyTaxAssessed', value)
|
||||
}
|
||||
className="mt-1 w-full rounded border p-2"
|
||||
/>
|
||||
@@ -243,19 +243,18 @@ export function SimulationCashflowPlanner({
|
||||
<label key={index} className="text-sm font-medium">
|
||||
Imposto manual do cenário personalizado — mês{' '}
|
||||
{index + 1}
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="0"
|
||||
step="0.01"
|
||||
value={value}
|
||||
onChange={(event) =>
|
||||
onValueChange={(value) =>
|
||||
update({
|
||||
...inputs,
|
||||
monthlyTaxSchedule:
|
||||
inputs.monthlyTaxSchedule.map(
|
||||
(amount, month) =>
|
||||
month === index
|
||||
? event.target.value
|
||||
? value
|
||||
: amount,
|
||||
),
|
||||
})
|
||||
@@ -301,8 +300,7 @@ export function SimulationCashflowPlanner({
|
||||
).map(([key, label]) => (
|
||||
<label key={key} className="text-sm font-medium">
|
||||
{label}
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min={key === 'vatRefundExpectedMonth' ? '1' : '0'}
|
||||
max={
|
||||
key === 'vatRefundExpectedMonth'
|
||||
@@ -313,7 +311,7 @@ export function SimulationCashflowPlanner({
|
||||
key === 'vatRefundExpectedMonth' ? '1' : '0.01'
|
||||
}
|
||||
value={inputs[key]}
|
||||
onChange={(event) => set(key, event.target.value)}
|
||||
onValueChange={(value) => set(key, value)}
|
||||
className="mt-1 w-full rounded border p-2"
|
||||
/>
|
||||
</label>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DecimalInput } from '@/components/decimal-input';
|
||||
import CurrencySelect from '@/components/currency-select';
|
||||
import {
|
||||
fundingDifferences,
|
||||
@@ -29,12 +30,11 @@ function Field({
|
||||
return (
|
||||
<label className="block text-sm font-medium">
|
||||
{label}
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="0"
|
||||
step={step}
|
||||
value={value}
|
||||
onChange={(event) => onChange(event.target.value)}
|
||||
onValueChange={(value) => onChange(value)}
|
||||
className="mt-1 w-full rounded border p-2"
|
||||
/>
|
||||
</label>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DecimalInput } from '@/components/decimal-input';
|
||||
import { focusCorrectionId } from '@/lib/field-corrections';
|
||||
import FiscalOperationPicker from './fiscal-operation-picker';
|
||||
import { SimulationIrpcAnnual } from '@/components/simulation-irpc-annual';
|
||||
@@ -298,7 +299,8 @@ const fieldGuidance: Record<
|
||||
why: 'As chaves para o sucesso são os poucos factores de que o negócio depende para resultar.',
|
||||
example:
|
||||
'Exemplo ilustrativo: qualidade do serviço, boas relações com os clientes, equipa com experiência complementar.',
|
||||
clarify: 'Indique três a cinco factores, separados por vírgulas ou por linhas.',
|
||||
clarify:
|
||||
'Indique três a cinco factores, separados por vírgulas ou por linhas.',
|
||||
},
|
||||
project_problem: {
|
||||
why: 'Uma necessidade concreta ajuda a explicar a razão do projecto.',
|
||||
@@ -3808,23 +3810,35 @@ export function SimulationForm() {
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<input
|
||||
) : (field.type ??
|
||||
(isArea ? 'number' : 'text')) ===
|
||||
'number' ? (
|
||||
<DecimalInput
|
||||
id={`field-${field.key}`}
|
||||
type={
|
||||
field.type ??
|
||||
(isArea ? 'number' : 'text')
|
||||
}
|
||||
min={
|
||||
field.type === 'number'
|
||||
? '0'
|
||||
: undefined
|
||||
}
|
||||
step={
|
||||
field.type === 'number'
|
||||
? 'any'
|
||||
className="w-full rounded-lg border border-slate-300 p-3 focus-visible:outline-2 focus-visible:outline-emerald-700"
|
||||
value={String(draft[field.key] ?? '')}
|
||||
onValueChange={(value) =>
|
||||
change(field.key, value)
|
||||
}
|
||||
aria-invalid={Boolean(fieldError)}
|
||||
aria-required={
|
||||
fieldRequired || undefined
|
||||
}
|
||||
aria-describedby={
|
||||
fieldError
|
||||
? `error-${field.key}`
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<input
|
||||
id={`field-${field.key}`}
|
||||
type={field.type ?? 'text'}
|
||||
className="w-full rounded-lg border border-slate-300 p-3 focus-visible:outline-2 focus-visible:outline-emerald-700"
|
||||
value={String(draft[field.key] ?? '')}
|
||||
onChange={(e) =>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { DecimalInput } from '@/components/decimal-input';
|
||||
import type { BusinessFinancialPlanInput } from '@/lib/business-financial-plan';
|
||||
import {
|
||||
calculateStartupAssetRequirements,
|
||||
@@ -33,13 +34,12 @@ export function StartupAssetRequirements({
|
||||
const field = (label: string, value: string, save: (s: string) => void) => (
|
||||
<label className="grid gap-1 text-sm">
|
||||
{label}
|
||||
<input
|
||||
type="number"
|
||||
<DecimalInput
|
||||
min="0"
|
||||
step="0.01"
|
||||
className="min-w-0 rounded border p-2"
|
||||
value={value}
|
||||
onChange={(e) => save(e.target.value)}
|
||||
onValueChange={(value) => save(value)}
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user