152 lines
5.7 KiB
TypeScript
152 lines
5.7 KiB
TypeScript
import {SimulationIrpcPecCorrection} from './simulation-irpc-pec-correction';
|
|
import {SimulationIrpcPecPlan} from './simulation-irpc-pec-plan';
|
|
import {
|
|
newPecObligation,
|
|
calculatePecObligation,
|
|
type PecObligation,
|
|
} from '@/lib/irpc-pec-obligation';
|
|
import { fractionPresentation } from '@/lib/fiscal-rational';
|
|
import type { AnnualBook } from '@/lib/irpc-annual-settlement';
|
|
export function SimulationIrpcPecObligation({
|
|
book,
|
|
onChange,
|
|
}: {
|
|
book: AnnualBook;
|
|
onChange: (p: PecObligation) => void;
|
|
}) {
|
|
const p = book.pecObligation;
|
|
if (!p)
|
|
return (
|
|
<section className="rounded border p-3">
|
|
<h5>Estimativa PEC</h5>
|
|
<p>
|
|
Preparar o total e os meses previstos conserva os
|
|
comprovativos pagos em separado.
|
|
</p>
|
|
<button
|
|
type="button"
|
|
onClick={() =>
|
|
onChange(newPecObligation(book.subjectNuit, book.year))
|
|
}
|
|
>
|
|
Simular PEC
|
|
</button>
|
|
</section>
|
|
);
|
|
const m = calculatePecObligation(
|
|
p,
|
|
book.subjectNuit,
|
|
book.year,
|
|
book.assessment,
|
|
),
|
|
patch = (changes: Partial<PecObligation>) =>
|
|
onChange({ ...p, ...changes });
|
|
const field = (
|
|
key: Exclude<keyof PecObligation, 'version' | 'scope' | 'plan' | 'correction'>,
|
|
label: string,
|
|
) => (
|
|
<label className="block">
|
|
{label}
|
|
<input
|
|
aria-label={label}
|
|
value={p[key]}
|
|
onChange={(e) => patch({ [key]: e.target.value })}
|
|
/>
|
|
</label>
|
|
);
|
|
return (
|
|
<section
|
|
aria-label="Preparação da estimativa PEC"
|
|
className="rounded border p-3"
|
|
>
|
|
<h5>Estimativa PEC — preparação</h5>
|
|
<label className="block">
|
|
Enquadramento PEC
|
|
<select
|
|
aria-label="Enquadramento PEC"
|
|
value={p.scope}
|
|
onChange={(e) =>
|
|
patch({
|
|
scope: e.target.value as PecObligation['scope'],
|
|
})
|
|
}
|
|
>
|
|
<option value="">Por confirmar</option>
|
|
<option value="ordinary_resident">
|
|
Residente geral — comercial,industrial ou agrícola,ano
|
|
civil
|
|
</option>
|
|
<option value="other">
|
|
Outro enquadramento — separado
|
|
</option>
|
|
</select>
|
|
</label>
|
|
{p.scope === 'ordinary_resident' && (
|
|
<>
|
|
{field('subjectNuit', 'NUIT — estimativa PEC')}
|
|
{field('year', 'Exercício — estimativa PEC')}
|
|
{field(
|
|
'activityStartYear',
|
|
'Ano de início efectivo da actividade — PEC',
|
|
)}
|
|
{field(
|
|
'activityReference',
|
|
'Fonte do início de actividade — PEC',
|
|
)}
|
|
{p.activityStartYear !== book.year && (
|
|
<>
|
|
{field('previousYear', 'Exercício anterior — PEC')}
|
|
{field(
|
|
'previousTurnover',
|
|
'Volume de negócios anterior — MZN',
|
|
)}
|
|
{field(
|
|
'turnoverReference',
|
|
'Fonte do volume de negócios — PEC',
|
|
)}
|
|
<SimulationIrpcPecCorrection value={p.correction} original={p.previousTurnover} subjectNuit={p.subjectNuit} onChange={correction=>patch({correction})}/>
|
|
{field(
|
|
'previousPpcPaid',
|
|
'PPC efectivamente pagos no ano anterior — MZN',
|
|
)}
|
|
{field(
|
|
'ppcReference',
|
|
'Fonte dos PPC anteriores — PEC',
|
|
)}
|
|
</>
|
|
)}
|
|
</>
|
|
)}
|
|
{m.pending.length ? (
|
|
<p role="status">{m.pending.join(' ')}</p>
|
|
) : m.notApplicable ? (
|
|
<p>Não aplicável no ano de início da actividade29(4).</p>
|
|
) : (
|
|
<>
|
|
<p>
|
|
Total estimado:{' '}
|
|
{fractionPresentation(m.total!).decimal} MZN.
|
|
</p>
|
|
<ul>
|
|
{m.months.map((month) => (
|
|
<li key={month}>{month}</li>
|
|
))}
|
|
</ul>
|
|
|
|
</>
|
|
)}
|
|
<SimulationIrpcPecPlan plan={p.plan} total={m.total} notApplicable={m.notApplicable} year={book.year} onChange={plan=>patch({plan})}/>
|
|
<p>
|
|
Guardar o rascunho conserva esta preparação. Calcular o fecho
|
|
anual inclui-a no relatório. Não regista pagamentos,cria
|
|
deduções ou executa guias. Os comprovativos efectivos permanecem
|
|
no detalhe PEC existente.
|
|
</p>
|
|
<details>
|
|
<summary>Fonte e limites PEC</summary>
|
|
<p>{m.source}</p>
|
|
</details>
|
|
</section>
|
|
);
|
|
}
|