feat: carry documented investment credits within original project window
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -106,7 +106,7 @@ type AnnualRecord = {
|
||||
model: AnnualModel;
|
||||
};
|
||||
export type AnnualBook = {
|
||||
version: 1 | 2;
|
||||
version: 1 | 2 | 3;
|
||||
subjectNuit: string;
|
||||
year: string;
|
||||
reference: string;
|
||||
@@ -164,6 +164,27 @@ export function prepareInvestmentCredit(
|
||||
c.qualification.to = a.period?.to ?? '';
|
||||
return { ...next, version: 2, investmentCredit: c };
|
||||
}
|
||||
export function prepareInvestmentCarry(
|
||||
d: Record<string, unknown>,
|
||||
b: AnnualBook,
|
||||
): AnnualBook {
|
||||
const next = prepareInvestmentCredit(d, b);
|
||||
if (next.investmentCredit!.carryForward) return next;
|
||||
return {
|
||||
...next,
|
||||
version: 3,
|
||||
investmentCredit: {
|
||||
...next.investmentCredit!,
|
||||
version: 2,
|
||||
carryForward: {
|
||||
reference: '',
|
||||
useReconciled: '',
|
||||
currentState: '',
|
||||
currentReference: '',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
export function prepareEconomicBook(b: AnnualBook): AnnualBook {
|
||||
if (b.economicCredits) return b;
|
||||
const next = prepareInternationalBook(b),
|
||||
@@ -279,9 +300,10 @@ export function validateAnnual(b: AnnualBook) {
|
||||
validateInternational(b.internationalCredits);
|
||||
if (
|
||||
!b ||
|
||||
![1, 2].includes(b.version) ||
|
||||
(b.version === 2 && b.investmentCredit === undefined) ||
|
||||
(b.investmentCredit !== undefined && b.version !== 2) ||
|
||||
![1, 2, 3].includes(b.version) ||
|
||||
(b.version >= 2 && b.investmentCredit === undefined) ||
|
||||
(b.investmentCredit !== undefined &&
|
||||
b.version !== (b.investmentCredit.carryForward ? 3 : 2)) ||
|
||||
[
|
||||
'subjectNuit',
|
||||
'year',
|
||||
@@ -2132,6 +2154,28 @@ export function annualReportRows(
|
||||
show(m.investmentCredit.nominal) +
|
||||
'; uso anterior ' +
|
||||
show(m.investmentCredit.priorUse) +
|
||||
(m.investmentCredit.input.carryForward
|
||||
? '; TransporteCBF15/1: nominal corrente ' +
|
||||
show(
|
||||
m.investmentCredit.currentNominal ??
|
||||
null,
|
||||
) +
|
||||
'; nominal de origem anterior ' +
|
||||
show(
|
||||
m.investmentCredit.carryNominal ?? null,
|
||||
) +
|
||||
'; parcela expirada ' +
|
||||
show(m.investmentCredit.expired ?? null) +
|
||||
'; ' +
|
||||
m.investmentCredit.input.carryForward
|
||||
.reference +
|
||||
'; investimento corrente ' +
|
||||
m.investmentCredit.input.carryForward
|
||||
.currentState +
|
||||
': ' +
|
||||
m.investmentCredit.input.carryForward
|
||||
.currentReference
|
||||
: '') +
|
||||
'; disponível ' +
|
||||
show(m.investmentCredit.available) +
|
||||
'; dedução ' +
|
||||
@@ -2189,6 +2233,32 @@ export function annualReportRows(
|
||||
'; outros benefícios: ' +
|
||||
m.investmentCredit.input
|
||||
.noOtherBenefitsReference +
|
||||
(m.investmentCredit.input.carryForward
|
||||
? '; origens: ' +
|
||||
m.investmentCredit.input.assets
|
||||
.filter(
|
||||
(r) => r.originYear !== undefined,
|
||||
)
|
||||
.map(
|
||||
(r) =>
|
||||
r.issuer +
|
||||
'/' +
|
||||
r.document +
|
||||
'/' +
|
||||
r.parcel +
|
||||
': exercício ' +
|
||||
r.originYear +
|
||||
'; NUIT ' +
|
||||
r.originNuit +
|
||||
'; projecto ' +
|
||||
r.originProject +
|
||||
', taxa ' +
|
||||
r.originRate +
|
||||
'%; ' +
|
||||
r.originReference,
|
||||
)
|
||||
.join(' | ')
|
||||
: '') +
|
||||
'; uso anterior: ' +
|
||||
m.investmentCredit.input.previousUse.reference +
|
||||
'; ' +
|
||||
|
||||
Reference in New Issue
Block a user