feat(irpc): demonstrate ordinary economic credit and compatible carry in QA
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import fs from 'node:fs';
|
||||
import {economicCase} from '../tests/frontend/helpers/irpc-economic-case.mjs';
|
||||
import {recordAnnual, saveAnnualBook} from '../resources/js/lib/irpc-annual-settlement.ts';
|
||||
const cases = {};
|
||||
for (const name of ['payable', 'combined', 'quota', 'prior-use', 'duplicate', 'missing-gross-up', 'article40', 'shared-paper', 'partial-parcel', 'fractional', 'recoverable']) {
|
||||
const c = economicCase(name === 'combined');
|
||||
const previous = structuredClone(c.b); delete previous.economicCredits;
|
||||
c.b.history = [recordAnnual(c.d, previous, '2026-10-28T12:00:00+02:00').result];
|
||||
const r = c.b.economicCredits.rows[0], p = c.b.internationalCredits.positions[0], f = p.payments[0];
|
||||
if (name === 'quota') r.nationalLimit = '5';
|
||||
if (name === 'prior-use') r.previousUse.amount = '3';
|
||||
if (name === 'duplicate' || name === 'shared-paper') {
|
||||
Object.assign(f, {issuer: r.taxIssuer, document: r.taxDocument, proofAmount: '20', parcel: name === 'duplicate' ? r.taxParcel : 'foreign-tax-line', parcelReference: 'SYNTHETIC QA documented tax line in shared paper, no actual tax evidence'});
|
||||
}
|
||||
if (name === 'missing-gross-up') r.grossUpIncluded = '';
|
||||
if (name === 'article40') r.article40 = 'yes';
|
||||
if (name === 'partial-parcel') f.parcel = 'foreign-tax-line';
|
||||
if (name === 'fractional') Object.assign(r, {proofAmount: '0.01', taxAmount: '0.01', grossUpIncluded: '0.006'});
|
||||
if (name === 'recoverable') {f.proofAmount = '2000'; f.amount = '2000'; p.nationalLimit = '2000'; p.incomeAmount = '6250';}
|
||||
c.d.modelo_a_snapshot = saveAnnualBook(c.d, recordAnnual(c.d, c.b, '2026-10-28T14:00:00+02:00'));
|
||||
cases[name] = c.d;
|
||||
}
|
||||
fs.writeFileSync(new URL('../tests/frontend/fixtures/irpc-economic-preserved.json', import.meta.url), JSON.stringify({synthetic: true, actualTaxEvidence: false, cases}));
|
||||
console.log('Prepared eleven synthetic economic-credit cases with accepted annual/carry history.');
|
||||
@@ -0,0 +1,22 @@
|
||||
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-economic-20261028/', import.meta.url);
|
||||
const receipts = [];
|
||||
for (const name of ['payable', 'combined', 'quota', 'prior-use', 'duplicate', 'missing-gross-up', 'article40', 'shared-paper', 'partial-parcel', 'fractional', 'recoverable']) {
|
||||
const d = JSON.parse(fs.readFileSync(new URL('recovered-' + name + '.json', output), 'utf8'));
|
||||
const b = annualBook(d), m = b.result.model;
|
||||
assert.equal(annualCurrent(d, b), true); assert.deepEqual(calculateAnnual(d, b), m);
|
||||
assert.equal(b.history.length, 1); assert.equal(b.history[0].model.payable.numerator, name === 'combined' ? '550' : '700');
|
||||
const html = annualHtml(d), dossier = createProjectDossierReport(d, {selectedSections: new Set(['finance']), generatedAt: '2026-10-28T14:00:00+02:00'});
|
||||
assert.match(html, /Crédito económico — antes do internacional/); assert.match(JSON.stringify(dossier), /Crédito económico/);
|
||||
if (name === 'combined') {assert.match(html, /538.00/); assert.match(html, /Saldo anterior — PEC — 2023/);}
|
||||
if (name === 'payable') {assert.match(html, /688.00/); assert.match(html, /1396.00/);}
|
||||
if (name === 'fractional') assert.deepEqual(m.arithmeticBalance, {numerator: '349997', denominator: '500'});
|
||||
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, economicDeduction: m.economicCredit.deducted, 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.map(({name, status, balance}) => ({name, status, balance})), null, 2));
|
||||
Reference in New Issue
Block a user