import type { AdvanceFiscalPeriod } from '@/lib/irpc-ppc-obligation';
import {
newPecPlan,
calculatePecPlan,
type PecPlan,
} from '@/lib/irpc-pec-plan';
import {
fractionPresentation,
type FiscalFraction,
} from '@/lib/fiscal-rational';
export function SimulationIrpcPecPlan({
plan,
total,
notApplicable,
year,
period,
onChange,
}: {
plan?: PecPlan;
total: FiscalFraction | null;
notApplicable: boolean;
year: string;
period?: AdvanceFiscalPeriod;
onChange: (p: PecPlan) => void;
}) {
if (!plan)
return (
Prepare os montantes por prestação ou a opção de pagamento
único,sem registar pagamento.
onChange(newPecPlan(period))}
>
Simular tesouraria PEC
);
const m = calculatePecPlan(plan, total, notApplicable, year, period),
patch = (p: Partial) => onChange({ ...plan, ...p });
const field = (
key: 'reference' | 'june' | 'august' | 'october',
label: string,
) => (
{label}
patch({ [key]: e.target.value })}
/>
);
return (
Projecção PEC
{m.pending.length ? (
{m.pending.join(' ')}
) : (
Soma reconciliada:{' '}
{m.rows
.map(
(r) =>
r.month +
': ' +
fractionPresentation(r.amount).decimal +
' MZN',
)
.join('; ')}
. Prazo legal não validado.
)}
{m.needsPeriodConfirmation && !m.calendarPending && (
patch({
periodFrom: m.contextFrom,
periodTo: m.contextTo,
})
}
>
Conferi a distribuição para {m.contextFrom} — {m.contextTo}
)}
0}>
Alterar projecção PEC
Opção de preparação PEC
patch({ mode: e.target.value as PecPlan['mode'] })
}
>
Por escolher
Distribuir a estimativa por três meses
Concentrar a estimativa num mês
{field('reference', 'Fundamento do projecção PEC')}
{plan.mode === 'three' && (
<>
{field(
'june',
m.calendarPending
? 'PEC primeiro montante — mês por confirmar'
: m.nonCivil
? 'PEC 6.º mês (' + m.months[0] + ') — MZN'
: 'PEC Junho — MZN',
)}
{field(
'august',
m.calendarPending
? 'PEC segundo montante — mês por confirmar'
: m.nonCivil
? 'PEC 8.º mês (' + m.months[1] + ') — MZN'
: 'PEC Agosto — MZN',
)}
{field(
'october',
m.calendarPending
? 'PEC terceiro montante — mês por confirmar'
: m.nonCivil
? 'PEC 10.º mês (' + m.months[2] + ') — MZN'
: 'PEC Outubro — MZN',
)}
>
)}
{plan.mode === 'single' && (
Mês previsto do PEC único
patch({ singleMonth: e.target.value })
}
/>
)}
O mês escolhido é uma hipótese de tesouraria para avaliar a
viabilidade. A reconciliação da soma não valida os prazos
legais,emite guia ou regista pagamento. Alterar a estimativa
exige reconferir o plano. Guarde pelo rascunho e recalcule o
fecho para actualizar o relatório.
Fonte do projecção PEC
{m.source}
);
}