This commit is contained in:
@@ -84,7 +84,7 @@ void test('CBF15 requires actual project,source and first-exercise conditions wi
|
||||
{ soleProject: '' },
|
||||
{ noOtherBenefits: 'no' },
|
||||
{ assessmentKey: 'stale' },
|
||||
{ startDate: '2025-01-01' },
|
||||
{ startDate: '2027-01-01' },
|
||||
]) {
|
||||
const c = investmentCase();
|
||||
Object.assign(c.b.investmentCredit, patch);
|
||||
@@ -188,7 +188,7 @@ void test('CBF15 calculation-save-recovery-HTML and dossier reports retain sourc
|
||||
numerator: '200',
|
||||
denominator: '1',
|
||||
});
|
||||
assert.match(annualHtml(d), /IRPC-CBF15\/1/);
|
||||
assert.match(annualHtml(d), /IRPC-CBF15\/2/);
|
||||
assert.match(
|
||||
JSON.stringify(
|
||||
createProjectDossierReport(d, {
|
||||
@@ -196,7 +196,7 @@ void test('CBF15 calculation-save-recovery-HTML and dossier reports retain sourc
|
||||
generatedAt: '2026-11-10T19:00:00+02:00',
|
||||
}),
|
||||
),
|
||||
/IRPC-CBF15\/1/,
|
||||
/IRPC-CBF15\/2/,
|
||||
);
|
||||
const old = internationalCase();
|
||||
assert.equal(calculateAnnual(old.d, old.b).investmentCredit, undefined);
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { investmentCase } from './helpers/irpc-investment-case.mjs';
|
||||
import {
|
||||
calculateAnnual,
|
||||
recordAnnual,
|
||||
saveAnnualBook,
|
||||
annualBook,
|
||||
annualCurrent,
|
||||
annualHtml,
|
||||
} from '../../resources/js/lib/irpc-annual-settlement.ts';
|
||||
import { createProjectDossierReport } from '../../resources/js/lib/project-dossier-report.ts';
|
||||
void test('CBF15 includes first through fifth civil fiscal exercises, including a late-year start', () => {
|
||||
for (const [start, exercise] of [
|
||||
['2026-06-01', 1],
|
||||
['2025-12-31', 2],
|
||||
['2024-12-31', 3],
|
||||
['2023-12-31', 4],
|
||||
['2022-12-31', 5],
|
||||
]) {
|
||||
const c = investmentCase();
|
||||
c.b.investmentCredit.startDate = start;
|
||||
const m = calculateAnnual(c.d, c.b);
|
||||
assert.deepEqual(m.pending, []);
|
||||
assert.equal(m.investmentCredit.window.exercise, exercise);
|
||||
assert.equal(m.investmentCredit.window.status, 'active');
|
||||
assert.equal(
|
||||
m.investmentCredit.window.lastYear,
|
||||
Number(start.slice(0, 4)) + 4,
|
||||
);
|
||||
assert.deepEqual(m.investmentCredit.deducted, {
|
||||
numerator: '500',
|
||||
denominator: '1',
|
||||
});
|
||||
}
|
||||
});
|
||||
void test('CBF15 sixth exercise expires without erasing actual investment or creating a carry/refund', () => {
|
||||
const c = investmentCase();
|
||||
c.b.investmentCredit.startDate = '2021-12-31';
|
||||
const m = calculateAnnual(c.d, c.b);
|
||||
assert.deepEqual(m.pending, []);
|
||||
assert.equal(m.investmentCredit.window.exercise, 6);
|
||||
assert.equal(m.investmentCredit.window.status, 'expired');
|
||||
assert.deepEqual(m.investmentCredit.deducted, {
|
||||
numerator: '0',
|
||||
denominator: '1',
|
||||
});
|
||||
assert.deepEqual(m.arithmeticBalance, {
|
||||
numerator: '700',
|
||||
denominator: '1',
|
||||
});
|
||||
assert.equal(m.investmentCredit.rows[0].input.amount, '10000');
|
||||
assert.match(m.investmentCredit.rows[0].reason, /quinto/);
|
||||
assert.equal(m.investmentCredit.carryCreated, false);
|
||||
});
|
||||
void test('CBF15 does not admit future/invalid start dates or import older assets as current-year investments', () => {
|
||||
for (const start of ['2027-01-01', '2025-02-29', '0000-01-01', '']) {
|
||||
const c = investmentCase();
|
||||
c.b.investmentCredit.startDate = start;
|
||||
assert.equal(calculateAnnual(c.d, c.b).arithmeticBalance, null);
|
||||
}
|
||||
const c = investmentCase();
|
||||
c.b.investmentCredit.startDate = '2022-01-01';
|
||||
c.b.investmentCredit.assets[0].date = '2025-12-31';
|
||||
assert.equal(calculateAnnual(c.d, c.b).arithmeticBalance, null);
|
||||
});
|
||||
void test('CBF15 existing project uses procedural start; new project can invest before operations within the same window', () => {
|
||||
const c = investmentCase();
|
||||
c.b.investmentCredit.startKind = 'existing';
|
||||
c.b.investmentCredit.startDate = '2022-12-31';
|
||||
assert.deepEqual(calculateAnnual(c.d, c.b).pending, []);
|
||||
c.b.investmentCredit.startDate = '2026-06-01';
|
||||
assert.equal(calculateAnnual(c.d, c.b).arithmeticBalance, null);
|
||||
c.b.investmentCredit.startKind = 'new';
|
||||
assert.deepEqual(calculateAnnual(c.d, c.b).pending, []);
|
||||
});
|
||||
void test('CBF15 fifth-year then expiry recovers and reports window while preserving earlier result', () => {
|
||||
const c = investmentCase();
|
||||
c.b.investmentCredit.startDate = '2022-12-31';
|
||||
let b = recordAnnual(c.d, c.b, '2026-11-10T14:00:00Z');
|
||||
b.investmentCredit.startDate = '2021-12-31';
|
||||
b = recordAnnual(c.d, b, '2026-11-10T14:01:00Z');
|
||||
const d = { ...c.d, modelo_a_snapshot: saveAnnualBook(c.d, b) },
|
||||
back = annualBook(d);
|
||||
assert.equal(annualCurrent(d, back), true);
|
||||
assert.equal(back.history.length, 1);
|
||||
assert.deepEqual(back.history[0].model.investmentCredit.deducted, {
|
||||
numerator: '500',
|
||||
denominator: '1',
|
||||
});
|
||||
assert.deepEqual(
|
||||
calculateAnnual(d, back).investmentCredit,
|
||||
back.result.model.investmentCredit,
|
||||
);
|
||||
assert.match(annualHtml(d), /JanelaCBF15\/1/);
|
||||
assert.match(annualHtml(d), /prazo expirado/);
|
||||
assert.match(
|
||||
JSON.stringify(
|
||||
createProjectDossierReport(d, {
|
||||
selectedSections: new Set(['finance']),
|
||||
generatedAt: '2026-11-10T14:01:00Z',
|
||||
}),
|
||||
),
|
||||
/JanelaCBF15/,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user