Keep PPC PEC estimates and reports consistent with the prepared L6 period
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-11-14 00:23:46 +02:00
parent e9278ee446
commit 078f770dea
14 changed files with 295 additions and 21 deletions
+29 -3
View File
@@ -1,3 +1,7 @@
import {
ordinaryAdvancePeriodIssues,
type AdvanceFiscalPeriod,
} from './irpc-ppc-obligation.ts';
import {
validatePecCorrection,
correctedPecTurnover,
@@ -102,6 +106,7 @@ export function calculatePecObligation(
subjectNuit: string,
year: string,
assessment: string,
period?: AdvanceFiscalPeriod,
) {
validatePecObligation(p);
const pending: string[] = [];
@@ -138,9 +143,28 @@ export function calculatePecObligation(
'PEC: falta ano de início efectivo da actividade e suporte;constituição da empresa não substitui início.',
);
if (!pending.length && p.activityStartYear === '2026') {
notApplicable = true;
total = fraction(0n);
const validStartDate = (value?: string | null) =>
Boolean(
value &&
/^2026-\d{2}-\d{2}$/.test(value) &&
Number.isFinite(Date.parse(value)) &&
new Date(value).toISOString().slice(0, 10) === value,
);
if (
period &&
!(
validStartDate(period.from) &&
validStartDate(period.to) &&
period.from! <= period.to!
)
)
pending.push(...ordinaryAdvancePeriodIssues(period, year, 'PEC'));
if (!pending.length) {
notApplicable = true;
total = fraction(0n);
}
} else if (!pending.length) {
pending.push(...ordinaryAdvancePeriodIssues(period, year, 'PEC'));
pending.push(...turnover.pending);
if (
p.previousYear !== '2025' ||
@@ -251,8 +275,9 @@ export function pecObligationReport(
subjectNuit: string,
year: string,
assessment: string,
period?: AdvanceFiscalPeriod,
): Array<[string, string, string, string]> {
const m = calculatePecObligation(p, subjectNuit, year, assessment),
const m = calculatePecObligation(p, subjectNuit, year, assessment, period),
show = (v: FiscalFraction | null) =>
v ? fractionPresentation(v).decimal + ' MZN' : 'Indeterminado';
const originalEstimate = p.correction
@@ -261,6 +286,7 @@ export function pecObligationReport(
subjectNuit,
year,
assessment,
period,
).total
: null;
const correctionEffect =