Files
Investidor-V2/resources/js/components/simulation-irpc-pec-correction.tsx
2026-11-11 10:55:53 +02:00

86 lines
3.0 KiB
TypeScript

import {
newPecCorrection,
type PecCorrection,
} from '@/lib/irpc-pec-correction';
export function SimulationIrpcPecCorrection({
value,
original,
subjectNuit,
onChange,
}: {
value?: PecCorrection;
original: string;
subjectNuit: string;
onChange: (c: PecCorrection) => void;
}) {
if (!value)
return (
<button
type="button"
onClick={() =>
onChange(newPecCorrection(original, subjectNuit))
}
>
Rectificar volume na simulação PEC
</button>
);
const patch = (c: Partial<PecCorrection>) => onChange({ ...value, ...c }),
field = (
key: Exclude<keyof PecCorrection, 'version' | 'apply'>,
label: string,
) => (
<label className="block">
{label}
<input
aria-label={label}
value={value[key]}
onChange={(e) => patch({ [key]: e.target.value })}
/>
</label>
);
return (
<section
aria-label="Rectificação da estimativa PEC"
className="rounded border p-3"
>
<h6>Volume de negócios corrigido</h6>
<p>
O volume original permanece {original || 'por indicar'} MZN. A
nova fonte fundamenta a correcção da simulação2026; não submete
declaração fiscal.
</p>
<label className="block">
Aplicar rectificação PEC
<select
aria-label="Aplicar rectificação PEC"
value={value.apply}
onChange={(e) =>
patch({
apply: e.target.value as PecCorrection['apply'],
})
}
>
<option value="">Por decidir</option>
<option value="yes">
Usar volume corrigido na estimativa
</option>
<option value="no">Conservar volume original</option>
</select>
</label>
<details open={value.apply !== 'no'}>
<summary>Alterar rectificação PEC</summary>
{field('originalTurnover', 'Volume original analisado — PEC')}
{field('revisedTurnover', 'Volume corrigido — PEC')}
{field('subjectNuit', 'NUIT da rectificação PEC')}
{field('turnoverYear', 'Ano do volume corrigido — PEC')}
{field('reference', 'Fonte e fundamento da rectificação PEC')}
</details>
<p>
Trocar a opção conserva os dois valores. Uma alteração da base
original exige nova conferência; recalcule o fecho e a hipótese
de tesouraria para reflectir a estimativa corrigida.
</p>
</section>
);
}