Clarify viability simulation purpose and preserve PEC cash-flow hypotheses
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
import {
|
||||
newPecPlan,
|
||||
calculatePecPlan,
|
||||
pecPlanSource,
|
||||
type PecPlan,
|
||||
} from '@/lib/irpc-pec-plan';
|
||||
import {
|
||||
fractionPresentation,
|
||||
type FiscalFraction,
|
||||
} from '@/lib/fiscal-rational';
|
||||
export function SimulationIrpcPecPlan({
|
||||
plan,
|
||||
total,
|
||||
notApplicable,
|
||||
year,
|
||||
onChange,
|
||||
}: {
|
||||
plan?: PecPlan;
|
||||
total: FiscalFraction | null;
|
||||
notApplicable: boolean;
|
||||
year: string;
|
||||
onChange: (p: PecPlan) => void;
|
||||
}) {
|
||||
if (!plan)
|
||||
return (
|
||||
<div className="rounded border p-3">
|
||||
<p>
|
||||
Prepare os montantes por prestação ou a opção de pagamento
|
||||
único,sem registar pagamento.
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
disabled={
|
||||
!total || notApplicable || BigInt(total.numerator) <= 0n
|
||||
}
|
||||
onClick={() => onChange(newPecPlan())}
|
||||
>
|
||||
Simular tesouraria PEC
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
const m = calculatePecPlan(plan, total, notApplicable, year),
|
||||
patch = (p: Partial<PecPlan>) => onChange({ ...plan, ...p });
|
||||
const field = (
|
||||
key: 'reference' | 'june' | 'august' | 'october',
|
||||
label: string,
|
||||
) => (
|
||||
<label className="block">
|
||||
{label}
|
||||
<input
|
||||
aria-label={label}
|
||||
value={plan[key]}
|
||||
onChange={(e) => patch({ [key]: e.target.value })}
|
||||
/>
|
||||
</label>
|
||||
);
|
||||
return (
|
||||
<section
|
||||
aria-label="Projecção de tesouraria PEC"
|
||||
className="rounded border p-3"
|
||||
>
|
||||
<h6>Projecção PEC</h6>
|
||||
{m.pending.length ? (
|
||||
<p role="status">{m.pending.join(' ')}</p>
|
||||
) : (
|
||||
<p>
|
||||
Soma reconciliada:{' '}
|
||||
{m.rows
|
||||
.map(
|
||||
(r) =>
|
||||
r.month +
|
||||
': ' +
|
||||
fractionPresentation(r.amount).decimal +
|
||||
' MZN',
|
||||
)
|
||||
.join('; ')}
|
||||
. Prazo legal não validado.
|
||||
</p>
|
||||
)}
|
||||
<details open={m.pending.length > 0}>
|
||||
<summary>Alterar projecção PEC</summary>
|
||||
<label className="block">
|
||||
Opção de preparação PEC
|
||||
<select
|
||||
aria-label="Opção de preparação PEC"
|
||||
value={plan.mode}
|
||||
onChange={(e) =>
|
||||
patch({ mode: e.target.value as PecPlan['mode'] })
|
||||
}
|
||||
>
|
||||
<option value="">Por escolher</option>
|
||||
<option value="three">
|
||||
Distribuir a estimativa por três meses
|
||||
</option>
|
||||
<option value="single">
|
||||
Concentrar a estimativa num mês
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
{field('reference', 'Fundamento do projecção PEC')}
|
||||
{plan.mode === 'three' && (
|
||||
<>
|
||||
{field('june', 'PEC Junho — MZN')}
|
||||
{field('august', 'PEC Agosto — MZN')}
|
||||
{field('october', 'PEC Outubro — MZN')}
|
||||
</>
|
||||
)}
|
||||
{plan.mode === 'single' && (
|
||||
<label className="block">
|
||||
Mês previsto do PEC único
|
||||
<input
|
||||
aria-label="Mês previsto do PEC único"
|
||||
type="month"
|
||||
value={plan.singleMonth}
|
||||
onChange={(e) =>
|
||||
patch({ singleMonth: e.target.value })
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
)}
|
||||
</details>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
<details>
|
||||
<summary>Fonte do projecção PEC</summary>
|
||||
<p>{pecPlanSource}</p>
|
||||
</details>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user