Integrate authorised editorial package with current homologation changes
This commit is contained in:
@@ -22,6 +22,7 @@ export type QuantitativeMapContext = {
|
||||
source_reference?: string | null;
|
||||
source_date?: string | null;
|
||||
knowledge: string;
|
||||
measure_kind?: 'unknown' | 'observed' | 'planned' | 'projected';
|
||||
missing_metadata: string[];
|
||||
}[];
|
||||
zones_consulted?: number;
|
||||
@@ -47,6 +48,17 @@ const metadataLabels: Record<string, string> = {
|
||||
source_date: 'data da fonte',
|
||||
};
|
||||
const text = (value?: string | null) => value?.trim() || 'Não indicado';
|
||||
const measureKinds: Record<string, string> = {
|
||||
unknown: 'Por confirmar',
|
||||
observed: 'Observado / efectivo',
|
||||
planned: 'Planeado / meta',
|
||||
projected: 'Projectado / estimado',
|
||||
};
|
||||
const measureKind = (row: QuantitativeMapContext['records'][number]) =>
|
||||
row.measure_kind &&
|
||||
['observed', 'planned', 'projected'].includes(row.measure_kind)
|
||||
? row.measure_kind
|
||||
: 'unknown';
|
||||
const completeDate = (value?: string | null) =>
|
||||
Boolean(
|
||||
value &&
|
||||
@@ -55,6 +67,286 @@ const completeDate = (value?: string | null) =>
|
||||
new Date(value).toISOString().slice(0, 10) === value,
|
||||
);
|
||||
|
||||
type MapObservation = QuantitativeMapContext['records'][number];
|
||||
// Calendar metadata only: inclusive source dates, never a rate or annualisation.
|
||||
function periodDays(row: MapObservation): number | null {
|
||||
if (
|
||||
!completeDate(row.period_start) ||
|
||||
!completeDate(row.period_end) ||
|
||||
row.period_start! > row.period_end!
|
||||
)
|
||||
return null;
|
||||
return (
|
||||
(Date.parse(row.period_end!) - Date.parse(row.period_start!)) /
|
||||
86_400_000 +
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
const observationKey = (row: MapObservation) =>
|
||||
JSON.stringify([row.zone_id, row.id, row.zone_version]);
|
||||
|
||||
export function compareMapObservations(
|
||||
first: MapObservation,
|
||||
second: MapObservation,
|
||||
) {
|
||||
const issues: string[] = [];
|
||||
if (observationKey(first) === observationKey(second))
|
||||
issues.push('Escolha duas observações distintas.');
|
||||
if (first.zone_id !== second.zone_id)
|
||||
issues.push(
|
||||
'Territórios distintos: os valores não representam uma série do mesmo local.',
|
||||
);
|
||||
for (const [label, row] of [
|
||||
['Primeira', first],
|
||||
['Segunda', second],
|
||||
] as const) {
|
||||
if (measureKind(row) === 'unknown')
|
||||
issues.push(
|
||||
`${label} observação: natureza do valor por confirmar na fonte.`,
|
||||
);
|
||||
if (row.knowledge !== 'documented')
|
||||
issues.push(
|
||||
`${label} observação: informação desconhecida ou em divergência.`,
|
||||
);
|
||||
if (
|
||||
row.value === null ||
|
||||
!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(row.value)
|
||||
)
|
||||
issues.push(
|
||||
`${label} observação: valor quantitativo por confirmar.`,
|
||||
);
|
||||
const comparisonMetadata: Record<string, string> = {
|
||||
...metadataLabels,
|
||||
description: 'descrição/natureza da grandeza',
|
||||
};
|
||||
const missing = Object.keys(comparisonMetadata).filter(
|
||||
(field) => !row[field as keyof MapObservation]?.toString().trim(),
|
||||
);
|
||||
if (missing.length)
|
||||
issues.push(
|
||||
`${label} observação sem ${missing.map((field) => comparisonMetadata[field]).join(', ')}.`,
|
||||
);
|
||||
if (
|
||||
!completeDate(row.period_start) ||
|
||||
!completeDate(row.period_end) ||
|
||||
(row.period_start ?? '') > (row.period_end ?? '')
|
||||
)
|
||||
issues.push(`${label} observação: período incompleto ou inválido.`);
|
||||
if (!completeDate(row.source_date))
|
||||
issues.push(
|
||||
`${label} observação: data da fonte incompleta ou inválida.`,
|
||||
);
|
||||
}
|
||||
const firstDays = periodDays(first);
|
||||
const secondDays = periodDays(second);
|
||||
if (firstDays !== null && secondDays !== null) {
|
||||
if (firstDays !== secondDays)
|
||||
issues.push(
|
||||
'Duração dos períodos diferente; não trate os valores como bases temporais equivalentes.',
|
||||
);
|
||||
if (
|
||||
(first.period_start !== second.period_start ||
|
||||
first.period_end !== second.period_end) &&
|
||||
first.period_start! <= second.period_end! &&
|
||||
second.period_start! <= first.period_end!
|
||||
)
|
||||
issues.push(
|
||||
'Os períodos sobrepõem-se; as observações podem abranger os mesmos dias.',
|
||||
);
|
||||
}
|
||||
if (measureKind(first) !== measureKind(second))
|
||||
issues.push(
|
||||
'Natureza do valor diferente: observado, planeado e projectado não são equivalentes.',
|
||||
);
|
||||
for (const [field, label] of Object.entries({
|
||||
indicator: 'Indicador',
|
||||
unit: 'Unidade',
|
||||
scope: 'Âmbito',
|
||||
population: 'População/base',
|
||||
methodology: 'Metodologia',
|
||||
})) {
|
||||
if (
|
||||
(first[field as keyof MapObservation] ?? '').toString().trim() !==
|
||||
(second[field as keyof MapObservation] ?? '').toString().trim()
|
||||
)
|
||||
issues.push(`${label} diferente entre as observações.`);
|
||||
}
|
||||
return {
|
||||
state: issues.length ? 'review_required' : 'metadata_aligned',
|
||||
issues,
|
||||
};
|
||||
}
|
||||
|
||||
export function MapObservationComparison({
|
||||
first,
|
||||
second,
|
||||
}: {
|
||||
first?: MapObservation;
|
||||
second?: MapObservation;
|
||||
}) {
|
||||
if (!first || !second)
|
||||
return (
|
||||
<p role="status">
|
||||
Seleccione duas observações disponíveis nos filtros actuais.
|
||||
</p>
|
||||
);
|
||||
const assessment = compareMapObservations(first, second);
|
||||
const fields: [string, (row: MapObservation) => string][] = [
|
||||
['Território', (row) => row.zone_name],
|
||||
['Observação', (row) => text(row.label)],
|
||||
['Descrição e natureza da grandeza', (row) => text(row.description)],
|
||||
['Natureza do valor', (row) => measureKinds[measureKind(row)]],
|
||||
['Indicador', (row) => labels[row.indicator] ?? row.indicator],
|
||||
[
|
||||
'Valor original',
|
||||
(row) => (row.value === null ? 'Por confirmar' : row.value),
|
||||
],
|
||||
['Unidade', (row) => text(row.unit)],
|
||||
[
|
||||
'Período',
|
||||
(row) => `${text(row.period_start)} — ${text(row.period_end)}`,
|
||||
],
|
||||
[
|
||||
'Duração do período (dias, limites incluídos)',
|
||||
(row) => {
|
||||
const days = periodDays(row);
|
||||
return days === null ? 'Por confirmar' : String(days);
|
||||
},
|
||||
],
|
||||
['Âmbito', (row) => text(row.scope)],
|
||||
['População/base', (row) => text(row.population)],
|
||||
['Metodologia', (row) => text(row.methodology)],
|
||||
[
|
||||
'Situação da informação',
|
||||
(row) =>
|
||||
row.knowledge === 'documented'
|
||||
? 'Documentada'
|
||||
: row.knowledge === 'disputed'
|
||||
? 'Em divergência'
|
||||
: 'Por confirmar',
|
||||
],
|
||||
['Fonte', (row) => text(row.source_reference)],
|
||||
['Data da fonte', (row) => text(row.source_date)],
|
||||
['Versão da ficha territorial', (row) => String(row.zone_version)],
|
||||
];
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<p role="status">
|
||||
{assessment.state === 'metadata_aligned'
|
||||
? 'Metadados alinhados; confirme nas fontes se os valores podem ser comparados.'
|
||||
: 'Há diferenças ou lacunas a conferir antes de comparar os valores.'}
|
||||
</p>
|
||||
{!!assessment.issues.length && (
|
||||
<ul className="list-disc pl-5">
|
||||
{assessment.issues.map((issue) => (
|
||||
<li key={issue}>{issue}</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
<p>
|
||||
Períodos distintos ou sobrepostos exigem conferência da duração
|
||||
e da base na fonte. Esta apresentação não calcula evolução,
|
||||
soma, conversão, pontuação ou estimativa regional. A natureza
|
||||
declarada deve ser conferida com a descrição e a fonte.
|
||||
</p>
|
||||
<div className="overflow-x-auto">
|
||||
<table className="w-full text-left text-sm">
|
||||
<caption className="sr-only">
|
||||
Conferência de duas observações quantitativas
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th className="p-2">Campo</th>
|
||||
<th className="p-2">Primeira observação</th>
|
||||
<th className="p-2">Segunda observação</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{fields.map(([label, value]) => (
|
||||
<tr key={label} className="border-t">
|
||||
<th className="p-2" scope="row">
|
||||
{label}
|
||||
</th>
|
||||
<td className="p-2 break-words">
|
||||
{value(first)}
|
||||
</td>
|
||||
<td className="p-2 break-words">
|
||||
{value(second)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function MapObservationComparisonPicker({ rows }: { rows: MapObservation[] }) {
|
||||
const id = useId();
|
||||
const [firstKey, setFirst] = useState('');
|
||||
const [secondKey, setSecond] = useState('');
|
||||
const first = rows.find((row) => observationKey(row) === firstKey);
|
||||
const second = rows.find((row) => observationKey(row) === secondKey);
|
||||
return (
|
||||
<details className="space-y-3 rounded border p-3">
|
||||
<summary>Comparar duas observações</summary>
|
||||
<p>
|
||||
Confronte os dados e as fontes antes de os usar na decisão.
|
||||
Selecções fora dos filtros deixam de ser comparadas; uma versão
|
||||
nova exige nova selecção.
|
||||
</p>
|
||||
<div className="grid gap-3 sm:grid-cols-2">
|
||||
{(['Primeira', 'Segunda'] as const).map((label, index) => (
|
||||
<label
|
||||
className="grid gap-1"
|
||||
key={label}
|
||||
htmlFor={`${id}-${index}`}
|
||||
>
|
||||
{label} observação
|
||||
<select
|
||||
className="w-full min-w-0 rounded border p-2"
|
||||
id={`${id}-${index}`}
|
||||
value={
|
||||
index === 0
|
||||
? first
|
||||
? firstKey
|
||||
: ''
|
||||
: second
|
||||
? secondKey
|
||||
: ''
|
||||
}
|
||||
onChange={(event) =>
|
||||
(index === 0 ? setFirst : setSecond)(
|
||||
event.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Seleccionar observação</option>
|
||||
{rows.map((row) => (
|
||||
<option
|
||||
key={observationKey(row)}
|
||||
value={observationKey(row)}
|
||||
>
|
||||
{row.zone_name} —{' '}
|
||||
{row.label ||
|
||||
labels[row.indicator] ||
|
||||
row.indicator}{' '}
|
||||
— {row.period_start || '?'} /{' '}
|
||||
{row.period_end || '?'} — v
|
||||
{row.zone_version}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
<MapObservationComparison first={first} second={second} />
|
||||
</details>
|
||||
);
|
||||
}
|
||||
|
||||
export function filterMapIndicators(
|
||||
records: QuantitativeMapContext['records'],
|
||||
indicator: string,
|
||||
@@ -114,9 +406,9 @@ export default function InvestmentMapIndicators({
|
||||
contexto territorial, independentes das evidências das
|
||||
oportunidades. Emprego não mede trabalhadores disponíveis;
|
||||
investimento, produção e exportações não constituem um índice de
|
||||
potencial ou garantia de retorno. A natureza prevista ou
|
||||
efectiva de cada valor depende da descrição da fonte, não é
|
||||
determinada automaticamente.
|
||||
potencial ou garantia de retorno. A natureza do valor é
|
||||
declarada segundo a fonte; sem essa indicação permanece por
|
||||
confirmar.
|
||||
</p>
|
||||
{!context ? (
|
||||
<p role="status">A carregar indicadores quantitativos…</p>
|
||||
@@ -242,6 +534,9 @@ export default function InvestmentMapIndicators({
|
||||
observações. Refine a localização.
|
||||
</p>
|
||||
)}
|
||||
{rows.length > 1 && (
|
||||
<MapObservationComparisonPicker rows={rows} />
|
||||
)}
|
||||
{rows.length === 0 ? (
|
||||
<p>
|
||||
{filtered
|
||||
@@ -308,6 +603,14 @@ export default function InvestmentMapIndicators({
|
||||
'Por determinar'}{' '}
|
||||
· {text(row.unit)}
|
||||
</p>
|
||||
<p>
|
||||
Natureza:{' '}
|
||||
{
|
||||
measureKinds[
|
||||
measureKind(row)
|
||||
]
|
||||
}
|
||||
</p>
|
||||
<p>
|
||||
{row.knowledge ===
|
||||
'documented'
|
||||
|
||||
@@ -60,7 +60,8 @@ const labels: Record<string, string> = {
|
||||
geometry_id: 'Geometria já associada ao parque',
|
||||
zone_link_id: 'Relação económica já associada ao parque',
|
||||
indicator: 'Indicador',
|
||||
value: 'Valor observado',
|
||||
measure_kind: 'Natureza do valor segundo a fonte',
|
||||
value: 'Valor indicado na fonte',
|
||||
unit: 'Unidade de medida',
|
||||
period_start: 'Início do período',
|
||||
period_end: 'Fim do período',
|
||||
@@ -86,6 +87,7 @@ const extras: Record<Group, string[]> = {
|
||||
],
|
||||
observations: [
|
||||
'indicator',
|
||||
'measure_kind',
|
||||
'value',
|
||||
'unit',
|
||||
'period_start',
|
||||
@@ -105,6 +107,12 @@ const extras: Record<Group, string[]> = {
|
||||
],
|
||||
};
|
||||
const choices: Record<string, Record<string, string>> = {
|
||||
measure_kind: {
|
||||
unknown: 'Por confirmar',
|
||||
observed: 'Observado / efectivo',
|
||||
planned: 'Planeado / meta',
|
||||
projected: 'Projectado / estimado',
|
||||
},
|
||||
knowledge: {
|
||||
unknown: 'Não informado',
|
||||
documented: 'Documentado pela fonte',
|
||||
@@ -248,7 +256,11 @@ export default function ParkIntegralEditor({
|
||||
})
|
||||
}
|
||||
>
|
||||
<option value="">Não informado / sem associação</option>
|
||||
<option value="">
|
||||
{key === 'measure_kind'
|
||||
? 'Por confirmar na fonte'
|
||||
: 'Não informado / sem associação'}
|
||||
</option>
|
||||
{Object.entries(options).map(([k, v]) => (
|
||||
<option key={k} value={k}>
|
||||
{v}
|
||||
@@ -541,7 +553,9 @@ export function ParkIntegralPublic({ value }: { value?: ParkIntegral }) {
|
||||
)
|
||||
: item[k] == null ||
|
||||
item[k] === ''
|
||||
? 'Não informado'
|
||||
? k === 'measure_kind'
|
||||
? 'Por confirmar'
|
||||
: 'Não informado'
|
||||
: k === 'expansion'
|
||||
? item[k]
|
||||
? 'Sim, segundo a fonte'
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { AdvanceFiscalPeriod } from '@/lib/irpc-ppc-obligation';
|
||||
import {SimulationIrpcPecObligation} from './simulation-irpc-pec-obligation';
|
||||
import { SimulationIrpcPpcObligation } from './simulation-irpc-ppc-obligation';
|
||||
import { SimulationIrpcInvestment } from './simulation-irpc-investment';
|
||||
@@ -8,6 +9,9 @@ import { SimulationIrpcInternational } from './simulation-irpc-international';
|
||||
import { SimulationIrpcPec } from './simulation-irpc-pec';
|
||||
import { useState } from 'react';
|
||||
import {
|
||||
advanceCashflowAmount,
|
||||
annualAdvanceCashflow,
|
||||
annualAdvancePeriod,
|
||||
annualBook,
|
||||
newAnnualBook,
|
||||
saveAnnualBook,
|
||||
@@ -77,6 +81,7 @@ export function SimulationIrpcAnnual({ draft, onChange }: Props) {
|
||||
);
|
||||
const patch = (p: Partial<AnnualBook>) => save({ ...b, ...p }),
|
||||
a = annualAssessment(draft),
|
||||
advancePeriod = annualAdvancePeriod(draft),
|
||||
options = annualWithholdingOptions(draft);
|
||||
const field = (
|
||||
key: 'subjectNuit' | 'year' | 'reference' | 'assessmentReference',
|
||||
@@ -341,10 +346,14 @@ export function SimulationIrpcAnnual({ draft, onChange }: Props) {
|
||||
})}
|
||||
</fieldset>
|
||||
<fieldset className="space-y-2 rounded border p-3">
|
||||
<legend>PPC efectivamente pagos</legend>
|
||||
<legend>Estimativas PPC e PEC para a viabilidade</legend>
|
||||
<p>Simulação fiscal para avaliar a viabilidade do negócio e as necessidades de tesouraria. Os valores e meses previstos são estimativas; o portal não executa pagamentos nem submete declarações fiscais.</p>
|
||||
<SimulationIrpcPecObligation book={b} onChange={pecObligation=>patch({pecObligation})}/>
|
||||
<SimulationIrpcPpcObligation book={b} onChange={ppcObligation=>patch({ppcObligation})}/>
|
||||
<SimulationIrpcPecObligation book={b} period={advancePeriod} onChange={pecObligation=>patch({pecObligation})}/>
|
||||
<SimulationIrpcPpcObligation book={b} period={advancePeriod} onChange={ppcObligation=>patch({ppcObligation})}/>
|
||||
<SimulationIrpcAdvanceCashflow book={b} period={advancePeriod}/>
|
||||
</fieldset>
|
||||
<fieldset className="space-y-2 rounded border p-3">
|
||||
<legend>PPC documentados como pagos</legend>
|
||||
{group('ppc', 'PPC efectuados')}
|
||||
<p>
|
||||
Regista comprovativos de pagamentos por conta; não
|
||||
@@ -613,3 +622,24 @@ export function SimulationIrpcAnnual({ draft, onChange }: Props) {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function SimulationIrpcAdvanceCashflow({book,period}: {book: AnnualBook;period?: AdvanceFiscalPeriod}) {
|
||||
if (!book.ppcObligation && !book.pecObligation) return null;
|
||||
const m = annualAdvanceCashflow(book,period);
|
||||
const show = advanceCashflowAmount;
|
||||
return <section className="space-y-3 rounded border p-3" aria-label="Projecção conjunta PPC e PEC">
|
||||
<h5 className="font-semibold">Saídas previstas PPC/PEC por mês</h5>
|
||||
{period && <p>Período preparado em L6: {period.from || 'por confirmar'} — {period.to || 'por confirmar'}.</p>}
|
||||
<p>Reúne as estimativas PPC e a hipótese de tesouraria PEC. Os comprovativos pagos e o fecho anual permanecem separados; esta vista não acrescenta outra saída ao fluxo financeiro do negócio.</p>
|
||||
<p role="status">{m.total ? 'Total da projecção: '+show(m.total) : 'Projecção parcial — total por determinar.'}</p>
|
||||
{!!m.pending.length && <ul className="list-disc pl-5">{m.pending.map(p=><li key={p}>{p}</li>)}</ul>}
|
||||
{!!m.rows.length && <div className="overflow-x-auto"><table className="w-full text-left text-sm">
|
||||
<caption className="sr-only">Projecção mensal das estimativas PPC e PEC</caption>
|
||||
<thead><tr><th className="p-2">Mês</th><th className="p-2">PPC</th><th className="p-2">PEC</th><th className="p-2">{m.total ? 'Total previsto' : 'Subtotal conhecido'}</th></tr></thead>
|
||||
<tbody>{m.rows.map(r=><tr key={r.month} className="border-t"><th scope="row" className="p-2">{r.month}</th><td className="p-2">{m.ppcKnown ? show(r.ppc) : 'Por determinar'}</td><td className="p-2">{m.pecKnown ? show(r.pec) : 'Por determinar'}</td><td className="p-2">{show(r.knownSubtotal)}</td></tr>)}</tbody>
|
||||
</table></div>}
|
||||
{!m.rows.length && m.total && <p>Sem saída PPC/PEC estimada neste recorte.</p>}
|
||||
<p>Meses e montantes dependem das fontes e opções preparadas acima. A opção PEC concentrada conserva o mês escolhido; esta apresentação não certifica o prazo legal.</p>
|
||||
</section>;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {SimulationIrpcPecCorrection} from './simulation-irpc-pec-correction';
|
||||
import {SimulationIrpcPecPlan} from './simulation-irpc-pec-plan';
|
||||
import type { AdvanceFiscalPeriod } from '@/lib/irpc-ppc-obligation';
|
||||
import { SimulationIrpcPecCorrection } from './simulation-irpc-pec-correction';
|
||||
import { SimulationIrpcPecPlan } from './simulation-irpc-pec-plan';
|
||||
import {
|
||||
newPecObligation,
|
||||
calculatePecObligation,
|
||||
@@ -9,9 +10,11 @@ import { fractionPresentation } from '@/lib/fiscal-rational';
|
||||
import type { AnnualBook } from '@/lib/irpc-annual-settlement';
|
||||
export function SimulationIrpcPecObligation({
|
||||
book,
|
||||
period,
|
||||
onChange,
|
||||
}: {
|
||||
book: AnnualBook;
|
||||
period?: AdvanceFiscalPeriod;
|
||||
onChange: (p: PecObligation) => void;
|
||||
}) {
|
||||
const p = book.pecObligation;
|
||||
@@ -38,16 +41,21 @@ export function SimulationIrpcPecObligation({
|
||||
book.subjectNuit,
|
||||
book.year,
|
||||
book.assessment,
|
||||
period,
|
||||
),
|
||||
patch = (changes: Partial<PecObligation>) =>
|
||||
onChange({ ...p, ...changes });
|
||||
const field = (
|
||||
key: Exclude<keyof PecObligation, 'version' | 'scope' | 'plan' | 'correction'>,
|
||||
key: Exclude<
|
||||
keyof PecObligation,
|
||||
'version' | 'scope' | 'plan' | 'correction' | 'lastAmount'
|
||||
>,
|
||||
label: string,
|
||||
) => (
|
||||
<label className="block">
|
||||
{label}
|
||||
<input
|
||||
className="mt-1 block w-full rounded border px-3 py-2"
|
||||
aria-label={label}
|
||||
value={p[key]}
|
||||
onChange={(e) => patch({ [key]: e.target.value })}
|
||||
@@ -63,6 +71,7 @@ export function SimulationIrpcPecObligation({
|
||||
<label className="block">
|
||||
Enquadramento PEC
|
||||
<select
|
||||
className="mt-1 block w-full rounded border px-3 py-2"
|
||||
aria-label="Enquadramento PEC"
|
||||
value={p.scope}
|
||||
onChange={(e) =>
|
||||
@@ -104,7 +113,131 @@ export function SimulationIrpcPecObligation({
|
||||
'turnoverReference',
|
||||
'Fonte do volume de negócios — PEC',
|
||||
)}
|
||||
<SimulationIrpcPecCorrection value={p.correction} original={p.previousTurnover} subjectNuit={p.subjectNuit} onChange={correction=>patch({correction})}/>
|
||||
<SimulationIrpcPecCorrection
|
||||
value={p.correction}
|
||||
original={p.previousTurnover}
|
||||
subjectNuit={p.subjectNuit}
|
||||
onChange={(correction) => patch({ correction })}
|
||||
/>
|
||||
{(m.requiresLastAmount || p.lastAmount) && (
|
||||
<details className="rounded border p-3">
|
||||
<summary>
|
||||
Sem volume anterior — referência PEC dos
|
||||
anos anteriores
|
||||
</summary>
|
||||
<p>
|
||||
Indique o último montante PEC já
|
||||
determinado, com suporte do mesmo
|
||||
titular, ano civil e MZN. Não introduza
|
||||
volume de negócios ou somatório de
|
||||
pagamentos. A hipótese conserva o valor
|
||||
documental sem nova percentagem ou
|
||||
segunda dedução de PPC.
|
||||
</p>
|
||||
{!p.lastAmount ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() =>
|
||||
patch({
|
||||
lastAmount: {
|
||||
version: 1,
|
||||
subjectNuit:
|
||||
p.subjectNuit,
|
||||
year: '',
|
||||
amount: '',
|
||||
reference: '',
|
||||
confirmed: '',
|
||||
},
|
||||
})
|
||||
}
|
||||
>
|
||||
Acrescentar referência PEC anterior
|
||||
</button>
|
||||
) : (
|
||||
<>
|
||||
{(
|
||||
[
|
||||
'subjectNuit',
|
||||
'year',
|
||||
'amount',
|
||||
'reference',
|
||||
] as const
|
||||
).map((key) => {
|
||||
const names = {
|
||||
subjectNuit:
|
||||
'NUIT do montante PEC anterior',
|
||||
year: 'Exercício do último montante PEC',
|
||||
amount: 'Último montante PEC já determinado — MZN',
|
||||
reference:
|
||||
'Fonte e fundamento do último montante PEC',
|
||||
};
|
||||
return (
|
||||
<label
|
||||
className="block"
|
||||
key={key}
|
||||
>
|
||||
{names[key]}
|
||||
<input
|
||||
className="mt-1 block w-full rounded border px-3 py-2"
|
||||
aria-label={
|
||||
names[key]
|
||||
}
|
||||
value={
|
||||
p.lastAmount![
|
||||
key
|
||||
]
|
||||
}
|
||||
onChange={(e) =>
|
||||
patch({
|
||||
lastAmount:
|
||||
{
|
||||
...p.lastAmount!,
|
||||
[key]: e
|
||||
.target
|
||||
.value,
|
||||
confirmed:
|
||||
'',
|
||||
},
|
||||
})
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
})}
|
||||
<label className="block">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={
|
||||
p.lastAmount
|
||||
.confirmed === 'yes'
|
||||
}
|
||||
onChange={(e) =>
|
||||
patch({
|
||||
lastAmount: {
|
||||
...p.lastAmount!,
|
||||
confirmed: e
|
||||
.target
|
||||
.checked
|
||||
? 'yes'
|
||||
: '',
|
||||
},
|
||||
})
|
||||
}
|
||||
/>
|
||||
Conferi no suporte que é o
|
||||
último montante PEC aplicável a
|
||||
esta hipótese
|
||||
</label>
|
||||
<p>
|
||||
Alterar a referência exige nova
|
||||
conferência. Guardar conserva o
|
||||
original e o histórico; não
|
||||
certifica a situação fiscal.
|
||||
</p>
|
||||
</>
|
||||
)}
|
||||
</details>
|
||||
)}
|
||||
{field(
|
||||
'previousPpcPaid',
|
||||
'PPC efectivamente pagos no ano anterior — MZN',
|
||||
@@ -124,18 +257,31 @@ export function SimulationIrpcPecObligation({
|
||||
) : (
|
||||
<>
|
||||
<p>
|
||||
Total estimado:{' '}
|
||||
{fractionPresentation(m.total!).decimal} MZN.
|
||||
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})}/>
|
||||
{m.ppcExcess && (
|
||||
<p role="status">
|
||||
Os PPC anteriores cobrem a base limitada desta hipótese.
|
||||
Estimativa PEC: 0 MZN;diferença documental:{' '}
|
||||
{fractionPresentation(m.ppcExcess).decimal} MZN. Esta
|
||||
diferença não cria reembolso,crédito ou dedução anual.
|
||||
</p>
|
||||
)}
|
||||
<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
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { AdvanceFiscalPeriod } from '@/lib/irpc-ppc-obligation';
|
||||
import {
|
||||
newPpcObligation,
|
||||
calculatePpcObligation,
|
||||
@@ -8,9 +9,11 @@ import { fractionPresentation } from '@/lib/fiscal-rational';
|
||||
import type { AnnualBook } from '@/lib/irpc-annual-settlement';
|
||||
export function SimulationIrpcPpcObligation({
|
||||
book,
|
||||
period,
|
||||
onChange,
|
||||
}: {
|
||||
book: AnnualBook;
|
||||
period?: AdvanceFiscalPeriod;
|
||||
onChange: (value: PpcObligation) => void;
|
||||
}) {
|
||||
const p = book.ppcObligation;
|
||||
@@ -37,6 +40,7 @@ export function SimulationIrpcPpcObligation({
|
||||
book.subjectNuit,
|
||||
book.year,
|
||||
book.assessment,
|
||||
period,
|
||||
);
|
||||
const patch = (changes: Partial<PpcObligation>) =>
|
||||
onChange({ ...p, ...changes });
|
||||
|
||||
Reference in New Issue
Block a user