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:
@@ -1,3 +1,5 @@
|
||||
import {validateAdvancePeriodDeclaration,type AdvancePeriodDeclaration} from './irpc-advance-calendar.ts';
|
||||
export {advanceCalendar,newAdvancePeriodDeclaration} from './irpc-advance-calendar.ts';
|
||||
import { calculatePecPlan } from './irpc-pec-plan.ts';
|
||||
import {pecCorrectionVersion} from './irpc-pec-correction.ts';
|
||||
import {pecPlanVersion} from './irpc-pec-plan.ts';
|
||||
@@ -127,6 +129,7 @@ export type AnnualBook = {
|
||||
creditCarry?: CreditCarry;
|
||||
economicCredits?: EconomicCredits;
|
||||
investmentCredit?: InvestmentCredit;
|
||||
advancePeriodDeclaration?: AdvancePeriodDeclaration;
|
||||
ppcObligation?: PpcObligation;
|
||||
pecObligation?: PecObligation;
|
||||
result?: AnnualRecord;
|
||||
@@ -298,6 +301,7 @@ function books(d: Record<string, unknown>): Record<string, AnnualBook> {
|
||||
return m;
|
||||
}
|
||||
export function validateAnnual(b: AnnualBook) {
|
||||
if(b?.advancePeriodDeclaration!==undefined)validateAdvancePeriodDeclaration(b.advancePeriodDeclaration);
|
||||
if(b?.pecObligation!==undefined)validatePecObligation(b.pecObligation);
|
||||
if (b?.ppcObligation !== undefined) validatePpcObligation(b.ppcObligation);
|
||||
if (b?.investmentCredit !== undefined)
|
||||
@@ -422,9 +426,15 @@ export function annualAssessment(d: Record<string, unknown>) {
|
||||
: zero(),
|
||||
};
|
||||
}
|
||||
export function annualAdvancePeriod(d: Record<string, unknown>): AdvanceFiscalPeriod {
|
||||
export function advancePeriodBasis(b:AnnualBook,kind:'ppc'|'pec'):string {
|
||||
let value:unknown=b.ppcObligation??null;
|
||||
if(kind==='pec'){if(b.pecObligation){const {plan:_,...basis}=b.pecObligation;value=basis;}else value=null;}
|
||||
return closureFingerprint([b.subjectNuit,b.year,b.assessment,value]);
|
||||
}
|
||||
export function annualAdvancePeriod(d: Record<string, unknown>,b?: AnnualBook): AdvanceFiscalPeriod {
|
||||
const prepared = normalBook(d).periodsFx;
|
||||
return prepared ? {from: prepared.from, to: prepared.to} : annualAssessment(d).period;
|
||||
const dates=prepared ? {from: prepared.from, to: prepared.to} : annualAssessment(d).period;
|
||||
return b?.advancePeriodDeclaration ? {...dates,subjectNuit:b.subjectNuit,ppcBasisKey:advancePeriodBasis(b,'ppc'),pecBasisKey:advancePeriodBasis(b,'pec'),declaration:structuredClone(b.advancePeriodDeclaration)} : dates;
|
||||
}
|
||||
|
||||
export function reuseAnnualAssessment(
|
||||
@@ -574,7 +584,7 @@ function dependencies(d: Record<string, unknown>, includeInvestment = false) {
|
||||
}
|
||||
function key(d: Record<string, unknown>, b: AnnualBook) {
|
||||
const { result: _, history: __, ...input } = b;
|
||||
const period = annualAdvancePeriod(d);
|
||||
const period = annualAdvancePeriod(d,b);
|
||||
const periodGuard = ordinaryAdvancePeriodIssues(period, b.year).length > 0 &&
|
||||
(b.ppcObligation || b.pecObligation && !calculatePecObligation(b.pecObligation,b.subjectNuit,b.year,b.assessment,period).notApplicable);
|
||||
return closureFingerprint([
|
||||
@@ -1603,7 +1613,7 @@ export function calculateAnnual(d: Record<string, unknown>, b: AnnualBook) {
|
||||
return {
|
||||
version: annualSettlementVersion,
|
||||
input: structuredClone(input),
|
||||
...(b.ppcObligation || b.pecObligation ? {advancePeriod: annualAdvancePeriod(d)} : {}),
|
||||
...(b.ppcObligation || b.pecObligation ? {advancePeriod: annualAdvancePeriod(d,b)} : {}),
|
||||
subjectNuit: b.subjectNuit,
|
||||
year: b.year,
|
||||
assessment: assessment?.record
|
||||
@@ -2445,7 +2455,7 @@ export function annualAdvanceCashflow(b: Pick<AnnualBook, 'subjectNuit' | 'year'
|
||||
if (BigInt(p.total.numerator) === 0n) pecKnown = true;
|
||||
else if (!b.pecObligation.plan) pending.push('Distribua a hipótese de tesouraria PEC para completar os meses da projecção conjunta.');
|
||||
else {
|
||||
const allocation = calculatePecPlan(b.pecObligation.plan, p.total, p.notApplicable, b.year);
|
||||
const allocation = calculatePecPlan(b.pecObligation.plan, p.total, p.notApplicable, b.year, period);
|
||||
sources.push(b.pecObligation.plan.reference, allocation.source);
|
||||
pending.push(...allocation.pending);
|
||||
pecKnown = allocation.allocationReconciled;
|
||||
|
||||
Reference in New Issue
Block a user