26 lines
1.9 KiB
JavaScript
26 lines
1.9 KiB
JavaScript
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-sequential-delivery-20261027');
|
|
const output=path.join(root,'outputs/irpc-l8-pec-20261027');
|
|
const results=[];
|
|
for(const name of ['payable','capped','recoverable','missing','prior-use']){
|
|
const d=JSON.parse(fs.readFileSync(path.join(output,'recovered-'+name+'.json'),'utf8'));
|
|
const book=annualBook(d),model=book.result.model;
|
|
assert.equal(annualCurrent(d,book),true);
|
|
assert.equal(calculateAnnual(d,book).status,model.status);
|
|
const html=annualHtml(d),rows=annualReportRows(d);
|
|
const dossier=createProjectDossierReport(d,{selectedSections:new Set(['finance']),generatedAt:'2026-10-27T15:00:00+02:00'});
|
|
assert.match(html,/PEC — dedução limitada/);assert.match(JSON.stringify(dossier),/PEC — dedução limitada/);
|
|
if(name==='missing'){assert.match(html,/Indeterminado/);assert.equal(model.arithmeticBalance,null);}
|
|
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:model.status,balance:model.arithmeticBalance,pec:model.pecDeduction,rows: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));
|