Support documented full annual noncivil PPC PEC estimates and dossier continuity
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -6,28 +6,20 @@ import {
|
||||
type FiscalFraction,
|
||||
} from './fiscal-rational.ts';
|
||||
|
||||
export type AdvanceFiscalPeriod = {
|
||||
from?: string | null;
|
||||
to?: string | null;
|
||||
} | null;
|
||||
export type { AdvanceFiscalPeriod } from './irpc-advance-calendar.ts';
|
||||
import {
|
||||
advanceCalendar,
|
||||
type AdvanceFiscalPeriod,
|
||||
} from './irpc-advance-calendar.ts';
|
||||
export function ordinaryAdvancePeriodIssues(
|
||||
period: AdvanceFiscalPeriod | undefined,
|
||||
year: string,
|
||||
component: 'PPC' | 'PEC' | 'PPC/PEC' = 'PPC/PEC',
|
||||
subjectNuit?: string,
|
||||
): string[] {
|
||||
if (!period) return [];
|
||||
return period.from === year + '-01-01' && period.to === year + '-12-31'
|
||||
? []
|
||||
: [
|
||||
component +
|
||||
': o período L6 ' +
|
||||
(period.from || 'por confirmar') +
|
||||
' — ' +
|
||||
(period.to || 'por confirmar') +
|
||||
' não corresponde ao ano civil ' +
|
||||
year +
|
||||
'. Reconciliar o enquadramento antes de usar as estimativas ordinárias; a preparação fica conservada.',
|
||||
];
|
||||
return advanceCalendar(period, year, subjectNuit).pending.map(
|
||||
(message) => component + ': ' + message,
|
||||
);
|
||||
}
|
||||
|
||||
export const ppcObligationVersion = 'IRPC-PPC-obligation/1';
|
||||
@@ -85,13 +77,16 @@ export function calculatePpcObligation(
|
||||
) {
|
||||
validatePpcObligation(p);
|
||||
const pending: string[] = [];
|
||||
const calendar = advanceCalendar(period, year, subjectNuit);
|
||||
const noncivilPreparation =
|
||||
calendar.candidate && period?.declaration?.mode === 'annual_non_civil';
|
||||
let base: FiscalFraction | null = null,
|
||||
annualBeforeRounding: FiscalFraction | null = null,
|
||||
instalment: FiscalFraction | null = null;
|
||||
if (
|
||||
p.scope !== 'ordinary_resident' ||
|
||||
assessment !== 'normal' ||
|
||||
p.previousFullCalendarYear !== 'yes' ||
|
||||
p.previousFullCalendarYear !== (noncivilPreparation ? 'no' : 'yes') ||
|
||||
year !== '2026' ||
|
||||
p.year !== year ||
|
||||
p.previousYear !== '2025' ||
|
||||
@@ -99,7 +94,9 @@ export function calculatePpcObligation(
|
||||
p.subjectNuit !== subjectNuit
|
||||
)
|
||||
pending.push(
|
||||
'PPC: confirmar titular,2026,residente geral com actividade comercial/industrial/agrícola e exercício civil completo2025. Outros períodos/regimes e anualização permanecem separados.',
|
||||
noncivilPreparation
|
||||
? 'PPC: confirmar titular2026 e período anterior anual não civil com termo2025;indique Não em ano civil completo e confronte a correspondência documentada.'
|
||||
: 'PPC: confirmar titular,2026,residente geral com actividade comercial/industrial/agrícola e exercício civil completo2025. Outros períodos/regimes e anualização permanecem separados.',
|
||||
);
|
||||
if (!p.assessmentReference.trim() || !p.withholdingReference.trim())
|
||||
pending.push(
|
||||
@@ -113,7 +110,17 @@ export function calculatePpcObligation(
|
||||
pending.push(
|
||||
'PPC: montantes anteriores em MZN desconhecidos ou inválidos; zero deve ser explícito.',
|
||||
);
|
||||
pending.push(...ordinaryAdvancePeriodIssues(period, year, 'PPC'));
|
||||
pending.push(
|
||||
...ordinaryAdvancePeriodIssues(period, year, 'PPC', subjectNuit),
|
||||
);
|
||||
if (
|
||||
calendar.mode === 'annual_non_civil' &&
|
||||
(!period?.ppcBasisKey ||
|
||||
period.declaration?.ppcBasisKey !== period.ppcBasisKey)
|
||||
)
|
||||
pending.push(
|
||||
'PPC: montantes ou fontes alterados;reconfira a sua correspondência com o período anterior,sem substituir os valores.',
|
||||
);
|
||||
if (!pending.length) {
|
||||
base = subtractFractions(
|
||||
decimalFraction(p.previousTax),
|
||||
@@ -135,7 +142,25 @@ export function calculatePpcObligation(
|
||||
}
|
||||
return {
|
||||
version: ppcObligationVersion,
|
||||
source: ppcObligationSource,
|
||||
source:
|
||||
calendar.mode === 'annual_non_civil'
|
||||
? ppcObligationSource
|
||||
.replace(
|
||||
'ano civil e exercício anterior completo2025',
|
||||
'períodos anuais completos não civis com termo2026/2025',
|
||||
)
|
||||
.replace(
|
||||
'Maio,Julho,Setembro',
|
||||
'5.º/7.º/9.º mês do período',
|
||||
)
|
||||
.replace(
|
||||
'Períodos especiais,',
|
||||
'Períodos curtos e outros regimes,',
|
||||
) +
|
||||
' ' +
|
||||
calendar.source
|
||||
: ppcObligationSource,
|
||||
nonCivil: calendar.mode === 'annual_non_civil',
|
||||
pending,
|
||||
base,
|
||||
annualBeforeRounding,
|
||||
@@ -147,7 +172,7 @@ export function calculatePpcObligation(
|
||||
)
|
||||
: null,
|
||||
schedule: instalment
|
||||
? ['2026-05', '2026-07', '2026-09'].map((month) => ({
|
||||
? calendar.ppcMonths.map((month) => ({
|
||||
month,
|
||||
amount: instalment,
|
||||
}))
|
||||
@@ -184,7 +209,7 @@ export function ppcObligationReport(
|
||||
m.schedule
|
||||
.map((s) => s.month + ': ' + show(s.amount))
|
||||
.join('; ') +
|
||||
'. Previsão de obrigação; não é pagamento nem dedução anual.',
|
||||
'. Estimativa fiscal para viabilidade; não é pagamento nem dedução anual.',
|
||||
p.assessmentReference +
|
||||
'; ' +
|
||||
p.withholdingReference +
|
||||
|
||||
Reference in New Issue
Block a user