feat: qualify treaty interest under governmental financing agreements
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-11-10 14:18:47 +02:00
parent b10b35f308
commit 7c8d4726e9
10 changed files with 464 additions and 64 deletions
@@ -86,59 +86,176 @@ export function SimulationIrpcPtCdt({
))}
{p.treatyMethod === 'ptMzInterest' &&
p.treatyPreparation?.governmentInterestExemption === 'yes' && (
<fieldset className="rounded border p-3">
<fieldset className="space-y-2 rounded border p-3">
<legend>
Isenção por devedor público português — art.11(3)a
Fundamento da isenção dos juros — art.11(3)
</legend>
<p>
Escolha a qualificação documentada do devedor.
Beneficiários públicos e acordos entre governos do
art.11(3)b exigem correspondência própria. A isenção
na fonte não gera reembolso de imposto pago pelo
portal.
</p>
<label className="block">
Devedor dos juros
Fundamento
<select
aria-label={
prefix + 'Devedor público português'
prefix +
'Fundamento da isenção governamental'
}
value={
p.treatyPreparation.governmentPayer ?? ''
p.treatyPreparation.governmentBasis ??
(p.treatyPreparation.governmentPayer
? 'payer'
: '')
}
onChange={(e) =>
change('governmentPayer', e.target.value)
change('governmentBasis', e.target.value)
}
>
<option value="">Por documentar</option>
<option value="state">Estado português</option>
<option value="subdivision">
Subdivisão política ou administrativa
portuguesa
<option value="">Escolha o fundamento</option>
<option value="payer">
Devedor público português —11(3)a
</option>
<option value="local">
Autarquia portuguesa
<option value="agreement">
Instituição/organismo e financiamento sob
acordo PT–MZ —11(3)b
</option>
</select>
</label>
<label className="block">
Suporte da qualificação do devedor
<input
aria-label={
prefix + 'Suporte do devedor público'
}
value={
p.treatyPreparation
.governmentPayerReference ?? ''
}
onChange={(e) =>
change(
'governmentPayerReference',
e.target.value,
)
}
/>
</label>
{p.treatyPreparation.governmentBasis === 'agreement' ? (
<>
<p>
O beneficiário é o sujeito corrente:{' '}
{p.subjectNuit}. Confirme a
instituição/organismo, o financiamento por
ela concedido e o acordo entre os governos
de Portugal e Moçambique. A isenção não é
inferida pelo nome; outros
beneficiários/regimes conservam
correspondência própria.
</p>
{(
[
[
'institutionRecipient',
'Beneficiário corrente qualificado como instituição/organismo11(3)b',
],
[
'financingGranted',
'Juros resultam de financiamento concedido por esse beneficiário',
],
[
'bilateralAgreement',
'Financiamento no âmbito de acordo concluído entre os governos PT–MZ',
],
] as const
).map(([key, label]) => (
<label key={key} className="block">
{label}
<select
aria-label={prefix + label}
value={
p.treatyPreparation?.[key] ?? ''
}
onChange={(e) =>
change(key, e.target.value)
}
>
<option value="">
Informação em falta
</option>
<option value="yes">
Sim — documentado
</option>
<option value="no">
Não — documentado
</option>
</select>
</label>
))}
{(
[
[
'institutionReference',
'Suporte da qualificação do beneficiário corrente',
],
[
'financingReference',
'Suporte do financiamento e ligação aos juros',
],
[
'agreementReference',
'Acordo PT–MZ e cláusula aplicável a este financiamento',
],
] as const
).map(([key, label]) => (
<label key={key} className="block">
{label}
<input
aria-label={prefix + label}
value={
p.treatyPreparation?.[key] ?? ''
}
onChange={(e) =>
change(key, e.target.value)
}
/>
</label>
))}
</>
) : (
<>
<p>
Qualifique o devedor público português com
suporte próprio. A isenção na fonte não
gera, no portal, reembolso do imposto pago.
</p>
<label className="block">
Devedor dos juros
<select
aria-label={
prefix + 'Devedor público português'
}
value={
p.treatyPreparation
.governmentPayer ?? ''
}
onChange={(e) =>
change(
'governmentPayer',
e.target.value,
)
}
>
<option value="">Por documentar</option>
<option value="state">
Estado português
</option>
<option value="subdivision">
Subdivisão política/administrativa
portuguesa
</option>
<option value="local">
Autarquia portuguesa
</option>
</select>
</label>
<label className="block">
Suporte da qualificação do devedor
<input
aria-label={
prefix +
'Suporte do devedor público'
}
value={
p.treatyPreparation
.governmentPayerReference ?? ''
}
onChange={(e) =>
change(
'governmentPayerReference',
e.target.value,
)
}
/>
</label>
</>
)}
</fieldset>
)}
{facts.map(([key, label]) => (
+103 -16
View File
@@ -27,6 +27,14 @@ export type InternationalTaxProof = AnnualPpc & {
exerciseReference: string;
};
export type PtMzRoyaltyPreparation = {
governmentBasis?: '' | 'payer' | 'agreement';
institutionRecipient?: '' | 'yes' | 'no';
financingGranted?: '' | 'yes' | 'no';
bilateralAgreement?: '' | 'yes' | 'no';
institutionReference?: string;
financingReference?: string;
agreementReference?: string;
governmentPayer?: '' | 'state' | 'subdivision' | 'local';
governmentPayerReference?: string;
capitalDefinition?: '' | 'yes' | 'no';
@@ -253,6 +261,41 @@ export function validateInternational(c: InternationalCredits) {
(p.treatyPreparation?.governmentPayerReference !== undefined &&
typeof p.treatyPreparation.governmentPayerReference !==
'string') ||
(p.treatyPreparation?.governmentBasis !== undefined &&
!['', 'payer', 'agreement'].includes(
p.treatyPreparation.governmentBasis,
)) ||
(p.treatyPreparation &&
[
'institutionRecipient',
'financingGranted',
'bilateralAgreement',
].some((k) => {
const v = (
p.treatyPreparation as unknown as Record<
string,
unknown
>
)[k];
return (
v !== undefined &&
(typeof v !== 'string' || !yesNo.includes(v))
);
})) ||
(p.treatyPreparation &&
[
'institutionReference',
'financingReference',
'agreementReference',
].some((k) => {
const v = (
p.treatyPreparation as unknown as Record<
string,
unknown
>
)[k];
return v !== undefined && typeof v !== 'string';
})) ||
!evidenceValid(p.previousUse) ||
!Array.isArray(p.payments)
)
@@ -417,20 +460,53 @@ export function ptMzTreatyLimit(p: InternationalPosition) {
throw Error(
'Definição convencional de dividendos/juros por documentar.',
);
let governmentExemption: {
payer: 'state' | 'subdivision' | 'local';
reference: string;
} | null = null;
let governmentExemption:
| { payer: 'state' | 'subdivision' | 'local'; reference: string }
| {
basis: 'agreement';
recipient: 'institution';
reference: string;
financingReference: string;
agreementReference: string;
}
| null = null;
if (p.treatyMethod === 'ptMzInterest') {
if (q.governmentInterestExemption === 'yes') {
if (!q.governmentPayer || !q.governmentPayerReference?.trim())
if (q.governmentBasis === 'agreement') {
if (
q.institutionRecipient !== 'yes' ||
q.financingGranted !== 'yes' ||
q.bilateralAgreement !== 'yes' ||
!q.institutionReference?.trim() ||
!q.financingReference?.trim() ||
!q.agreementReference?.trim()
)
throw Error(
'Art11(3)b: instituição/organismo beneficiário corrente, financiamento por ele concedido e acordo entre os governos PT–MZ exigem correspondência documental própria.',
);
governmentExemption = {
basis: 'agreement',
recipient: 'institution',
reference: q.institutionReference,
financingReference: q.financingReference,
agreementReference: q.agreementReference,
};
} else if (
q.governmentBasis === undefined ||
q.governmentBasis === 'payer'
) {
if (!q.governmentPayer || !q.governmentPayerReference?.trim())
throw Error(
'Isenção11(3)a exige devedor Estado português/subdivisão/autarquia documentado; para11(3)b escolha e documente o fundamento próprio.',
);
governmentExemption = {
payer: q.governmentPayer,
reference: q.governmentPayerReference,
};
} else
throw Error(
'Isenção11(3)a exige devedor documentado: Estado português, subdivisão política/administrativa ou autarquia; beneficiários/acordos11(3)b permanecem separados.',
'Escolha o fundamento da isenção; uma selecção limpa não reutiliza a decisão anterior.',
);
governmentExemption = {
payer: q.governmentPayer,
reference: q.governmentPayerReference,
};
} else if (q.governmentInterestExemption !== 'no')
throw Error(
'Corresponda a aplicação ou não aplicação da isenção11(3); desconhecido não significa limite ordinário10%.',
@@ -455,7 +531,9 @@ export function ptMzTreatyLimit(p: InternationalPosition) {
);
return {
version: governmentExemption
? 'IRPC-PT-MZ-government-interest/1'
? 'basis' in governmentExemption
? 'IRPC-PT-MZ-agreement-interest/1'
: 'IRPC-PT-MZ-government-interest/1'
: p.treatyMethod === 'ptMzRoyalty'
? 'IRPC-PT-MZ-royalty-credit/1'
: 'IRPC-PT-MZ-capital-credit/1',
@@ -473,13 +551,22 @@ export function ptMzTreatyLimit(p: InternationalPosition) {
to: q.to,
reference: governmentExemption
? q.reference +
'; devedor ' +
governmentExemption.payer +
'; ' +
governmentExemption.reference
('payer' in governmentExemption
? '; devedor ' +
governmentExemption.payer +
'; ' +
governmentExemption.reference
: '; instituição ' +
governmentExemption.reference +
'; financiamento ' +
governmentExemption.financingReference +
'; acordo PT–MZ ' +
governmentExemption.agreementReference)
: q.reference,
source: governmentExemption
? 'CDT PT–MZ, RAR36/1992 art11(3)a,PDF11, e23(3)a,PDF21; CIRPC65(2). Devedor Estado português/subdivisão/autarquia documentado. Juros isentos no Estado da fonte; limite convencional zero, sem crédito ou reembolso do imposto indevidamente pago pelo portal. Art11(3)b e demais situações permanecem separados.'
? 'basis' in governmentExemption
? 'CDT PT–MZ, RAR36/1992 art11(3)b,PDF11, e23(3)a,PDF21; CIRPC65(2). Instituição/organismo beneficiário corrente, financiamento por ele concedido no âmbito de acordo entre governos PT–MZ documentados. Juros isentos na fonte, limite0; não gera crédito ou reembolso no portal de imposto pago em desconformidade. Outros beneficiários/regimes mantêm correspondência própria.'
: 'CDT PT–MZ, RAR36/1992 art11(3)a,PDF11, e23(3)a,PDF21; CIRPC65(2). Devedor Estado português/subdivisão/autarquia documentado. Juros isentos no Estado da fonte; limite convencional zero, sem crédito ou reembolso do imposto indevidamente pago pelo portal. Art11(3)b e demais situações permanecem separados.'
: p.treatyMethod === 'ptMzRoyalty'
? 'CDT PT–MZ, RAR36/1992 art12(2/4–6),PDF13–14 e23(3)a,PDF21; Protocolo RAR36/2009 arts1/7,PDF1–2; CIRPC65(2). Royalties ordinárias não digitais, sem EP/instalação fixa ligada nem excesso por relações especiais. Não confundir com retenção L5 paga por devedor moçambicano; sem isenção ou tax sparing presumidos.'
: 'CDT PT–MZ, RAR36/1992 art23(3)a,PDF21; CIRPC65(2). ' +