This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
import fs from 'node:fs';
|
||||
import crypto from 'node:crypto';
|
||||
const source = new URL('../resources/data/iso3166.tab', import.meta.url);
|
||||
const text = fs.readFileSync(source, 'utf8').replace(/\r\n/g, '\n');
|
||||
const codes = text.split('\n').filter(line => line && !line.startsWith('#')).map(line => line.split('\t')[0]);
|
||||
if (new Set(codes).size !== codes.length || codes.some(code => !/^[A-Z]{2}$/.test(code))) throw Error('Invalid existing ISO catalogue');
|
||||
const hash = crypto.createHash('sha256').update(text).digest('hex');
|
||||
fs.writeFileSync(new URL('../resources/js/lib/country-iso-codes.ts', import.meta.url),
|
||||
'// Derived code projection of resources/data/iso3166.tab; keep the existing PHP catalogue authoritative.\n' +
|
||||
'// Source SHA256 (LF): ' + hash + '; regenerate with node tools/country-iso-projection.mjs\n' +
|
||||
"export const countryIsoCodes = '" + codes.join(' ') + "'.split(' ');\n");
|
||||
@@ -0,0 +1,16 @@
|
||||
import fs from 'node:fs';
|
||||
import {internationalCase} from '../tests/frontend/helpers/irpc-international-case.mjs';
|
||||
import {recordAnnual} from '../resources/js/lib/irpc-annual-settlement.ts';
|
||||
const cases = {};
|
||||
for (const name of ['payable','treaty','missing','limited-collecta','duplicate','absent','prior-use']) {
|
||||
const c = name === 'limited-collecta' ? internationalCase('2000','2000') : internationalCase();
|
||||
const p = c.b.internationalCredits.positions[0];
|
||||
if (name === 'treaty') Object.assign(p, {treaty: 'yes', treatyLimit: '6', treatyReference: 'SYNTHETIC QA convention ceiling only, no actual treaty assertion'});
|
||||
if (name === 'missing') p.treaty = '';
|
||||
if (name === 'limited-collecta') p.incomeAmount = '6250';
|
||||
if (name === 'duplicate') Object.assign(p.payments[0], {issuer: c.b.ppc.rows[0].issuer, document: c.b.ppc.rows[0].document, proofAmount: '500'});
|
||||
if (name === 'absent') {c.b.internationalCredits.state = 'absent';c.b.internationalCredits.positions = [];}
|
||||
if (name === 'prior-use') Object.assign(p.previousUse, {amount: '3', reference: 'SYNTHETIC QA: documented actual previous credit use of 3 MZN'});
|
||||
cases[name] = recordAnnual(c.d, c.b, '2026-10-27T17:00:00+02:00');
|
||||
}
|
||||
fs.writeFileSync(new URL('../tests/frontend/fixtures/irpc-international-preserved.json', import.meta.url), JSON.stringify({synthetic: true, actualConventionData: false, base: 'irpc-assessment-preserved.json', cases}));
|
||||
@@ -0,0 +1,26 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import assert from 'node:assert/strict';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import {annualBook,annualCurrent,calculateAnnual,annualHtml,annualReportRows} from '../resources/js/lib/irpc-annual-settlement.ts';
|
||||
import {createProjectDossierReport} from '../resources/js/lib/project-dossier-report.ts';
|
||||
const root=path.dirname(path.dirname(fileURLToPath(import.meta.url)));
|
||||
assert.equal(path.basename(root),'portal-investidor-irpc-international-qa-20261027');
|
||||
const output=path.join(root,'outputs/irpc-l8-international-20261027');
|
||||
const results=[];
|
||||
for(const name of ['payable','treaty','missing','limited-collecta','duplicate','absent','prior-use']){
|
||||
const d=JSON.parse(fs.readFileSync(path.join(output,'recovered-'+name+'.json'),'utf8'));
|
||||
const book=annualBook(d),m=book.result.model;
|
||||
assert.equal(annualCurrent(d,book),true);
|
||||
const fresh=calculateAnnual(d,book);assert.equal(fresh.status,m.status);assert.deepEqual(fresh.arithmeticBalance,m.arithmeticBalance);assert.deepEqual(fresh.internationalCredit,m.internationalCredit);
|
||||
const html=annualHtml(d),rows=annualReportRows(d);
|
||||
const dossier=createProjectDossierReport(d,{selectedSections:new Set(['finance']),generatedAt:'2026-10-27T17:00:00+02:00'});
|
||||
assert.match(html,/Crédito internacional — antes do PEC/);assert.match(JSON.stringify(dossier),/Crédito internacional — antes do PEC/);
|
||||
if(['missing','duplicate'].includes(name)){assert.match(html,/Indeterminado/);assert.equal(m.arithmeticBalance,null);}
|
||||
if(name==='payable'){assert.match(html,/700.00/);assert.match(html,/1400.00/);assert.match(html,/1200.00/);}
|
||||
fs.writeFileSync(path.join(output,'report-'+name+'.html'),html);
|
||||
fs.writeFileSync(path.join(output,'dossier-'+name+'.json'),JSON.stringify(dossier));
|
||||
results.push({case:name,status:m.status,balance:m.arithmeticBalance,international:m.internationalCredit,pec:m.pecDeduction,reportRows:rows.length,history:book.history.length,apiRoundTrip:true,current:true,dossier:true});
|
||||
}
|
||||
fs.writeFileSync(path.join(output,'recovered-report-receipt.json'),JSON.stringify({synthetic:true,activeChanged:false,results},null,2));
|
||||
console.log(JSON.stringify(results.map(({case:name,status,balance,history})=>({case:name,status,balance,history})),null,2));
|
||||
Reference in New Issue
Block a user