28 lines
2.0 KiB
JavaScript
28 lines
2.0 KiB
JavaScript
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));
|