feat(irpc): demonstrate documented prior credit and PEC balances in QA
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import fs from 'node:fs';
|
||||
import {carryCase} from '../tests/frontend/helpers/irpc-carry-case.mjs';
|
||||
import {internationalCase} from '../tests/frontend/helpers/irpc-international-case.mjs';
|
||||
import {recordAnnual, saveAnnualBook} from '../resources/js/lib/irpc-annual-settlement.ts';
|
||||
const cases = {};
|
||||
for (const name of ['payable', 'expired', 'missing-use', 'overallocated', 'fractional', 'recoverable']) {
|
||||
const c = carryCase(), previous = internationalCase();
|
||||
const frozen = recordAnnual(previous.d, previous.b, '2026-10-27T17:00:00+02:00').result;
|
||||
c.b.history = [frozen];
|
||||
const l = c.b.creditCarry.lots[0];
|
||||
if (name === 'expired') l.year = '2020';
|
||||
if (name === 'missing-use') l.usesState = '';
|
||||
if (name === 'overallocated') {l.eligible = '5000'; l.selected = '1400';}
|
||||
if (name === 'fractional') {
|
||||
Object.assign(l, {eligible: '2/3', originDeducted: '1/3', selected: '1/3', usesState: 'absent', uses: []});
|
||||
c.b.creditCarry.currentInternational = '1/3';
|
||||
}
|
||||
if (name === 'recoverable') {l.eligible = '2000'; l.selected = '1300'; c.b.creditCarry.currentPec = '0';}
|
||||
c.d.modelo_a_snapshot = saveAnnualBook(c.d, recordAnnual(c.d, c.b, '2026-10-28T12:00:00+02:00'));
|
||||
cases[name] = c.d;
|
||||
}
|
||||
fs.writeFileSync(new URL('../tests/frontend/fixtures/irpc-carry-preserved.json', import.meta.url), JSON.stringify({synthetic: true, actualBalances: false, cases}));
|
||||
console.log('Prepared six synthetic carry API cases with frozen international-credit history.');
|
||||
@@ -0,0 +1,27 @@
|
||||
import fs from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
import {annualBook, annualCurrent, calculateAnnual, annualHtml} from '../resources/js/lib/irpc-annual-settlement.ts';
|
||||
import {createProjectDossierReport} from '../resources/js/lib/project-dossier-report.ts';
|
||||
const output = new URL('../outputs/irpc-l8-carry-20261028/', import.meta.url);
|
||||
const receipts = [];
|
||||
for (const name of ['payable', 'expired', 'missing-use', 'overallocated', 'fractional', 'recoverable']) {
|
||||
const d = JSON.parse(fs.readFileSync(new URL('recovered-' + name + '.json', output), 'utf8'));
|
||||
const b = annualBook(d), m = b.result.model, fresh = calculateAnnual(d, b);
|
||||
assert.equal(annualCurrent(d, b), true);
|
||||
assert.deepEqual(fresh, m);
|
||||
assert.equal(b.history.length, 1);
|
||||
assert.equal(b.history[0].model.payable.numerator, '700');
|
||||
const html = annualHtml(d);
|
||||
const dossier = createProjectDossierReport(d, {selectedSections: new Set(['finance']), generatedAt: '2026-10-28T12:00:00+02:00'});
|
||||
assert.match(html, /Afectação escolhida entre exercícios/);
|
||||
assert.match(JSON.stringify(dossier), /Saldo anterior — PEC — 2023/);
|
||||
assert.match(html, /último exercício ordinário/);
|
||||
if (name === 'payable') assert.match(html, /550.00/);
|
||||
if (name === 'expired') {assert.equal(m.creditCarry.lots[0].expired, true); assert.equal(m.status, 'indeterminate');}
|
||||
if (name === 'fractional') assert.deepEqual(m.arithmeticBalance, {numerator: '1822', denominator: '3'});
|
||||
fs.writeFileSync(new URL('report-' + name + '.html', output), html);
|
||||
fs.writeFileSync(new URL('dossier-' + name + '.json', output), JSON.stringify(dossier));
|
||||
receipts.push({name, status: m.status, balance: m.arithmeticBalance, apiRecovered: true, recalculationEqual: true, html: true, dossier: true, frozenHistoryPreserved: true});
|
||||
}
|
||||
fs.writeFileSync(new URL('recovered-report-receipt.json', output), JSON.stringify({synthetic: true, activeChanged: false, receipts}, null, 2));
|
||||
console.log(JSON.stringify(receipts, null, 2));
|
||||
Reference in New Issue
Block a user