Support documented full annual noncivil PPC PEC estimates and dossier continuity
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import fs from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
import {noncivilCase} from '../tests/frontend/helpers/irpc-annual-noncivil-case.mjs';
|
||||
import {annualAdvanceCashflow,annualAdvancePeriod,annualBook,annualCurrent,annualHtml,recordAnnual,saveAnnualBook} from '../resources/js/lib/irpc-annual-settlement.ts';
|
||||
import {createProjectDossierReport} from '../resources/js/lib/project-dossier-report.ts';
|
||||
const out=new URL('../outputs/irpc-noncivil-20261114/',import.meta.url);
|
||||
fs.mkdirSync(out,{recursive:true});
|
||||
for(const name of ['three','single','missing','changed']){
|
||||
if(process.argv[2]==='generate'){
|
||||
const {d,b}=noncivilCase();
|
||||
if(name==='single')Object.assign(b.pecObligation.plan,{mode:'single',singleMonth:'2026-01'});
|
||||
if(name==='missing')b.advancePeriodDeclaration.previousReference='';
|
||||
if(name==='changed')b.ppcObligation.previousTax='200000';
|
||||
const prior=recordAnnual(d,{...b,ppcObligation:undefined,pecObligation:undefined,advancePeriodDeclaration:undefined},'2026-11-14T08:00:00Z');
|
||||
d.modelo_a_snapshot=saveAnnualBook(d,recordAnnual(d,{...prior,ppcObligation:b.ppcObligation,pecObligation:b.pecObligation,advancePeriodDeclaration:b.advancePeriodDeclaration},'2026-11-14T08:01:00Z'));
|
||||
fs.writeFileSync(new URL(name+'.json',out),JSON.stringify(d));
|
||||
}else{
|
||||
const d=JSON.parse(fs.readFileSync(new URL('recovered-'+name+'.json',out),'utf8')),b=annualBook(d),period=annualAdvancePeriod(d,b),m=annualAdvanceCashflow(b,period);
|
||||
assert.equal(annualCurrent(d,b),true);assert.equal(b.history.length,1);
|
||||
assert.deepEqual(b.result.model.arithmeticBalance,b.history[0].model.arithmeticBalance);
|
||||
assert.deepEqual(b.result.model.advancePeriod,period);
|
||||
if(['three','single'].includes(name))assert.deepEqual(m.total,{numerator:'112000',denominator:'1'});
|
||||
else assert.equal(m.total,null);
|
||||
if(name==='changed'){assert.equal(m.ppcKnown,false);assert.equal(m.pecKnown,true);}
|
||||
const html=annualHtml(d),report=createProjectDossierReport(d,{selectedSections:new Set(['finance']),generatedAt:'2026-11-14T08:02:00Z'});
|
||||
assert.match(html,/Projecção mensal conjunta PPC\/PEC/);assert.match(JSON.stringify(report),/Projecção mensal conjunta PPC\/PEC/);
|
||||
if(['three','single'].includes(name)){assert.match(html,/2025-11/);assert.match(html,/2026-03/);assert.match(JSON.stringify(report),/112000/);}
|
||||
fs.writeFileSync(new URL(name+'-report.html',out),html);
|
||||
fs.writeFileSync(new URL(name+'-verification.json',out),JSON.stringify({synthetic:true,nativeApiRecovery:true,historyPreserved:true,independentAnnualCalculationUnchanged:true,period,model:m},null,2));
|
||||
}
|
||||
}
|
||||
console.log(process.argv[2]==='generate'?'Generated four synthetic annual noncivil cases':'Verified four recovered annual noncivil cases and reports');
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
$root = dirname(__DIR__);
|
||||
if (($argv[1] ?? '') !== 'test' || basename($root) !== 'portal-investidor') {
|
||||
throw new RuntimeException('Explicit isolated QA test operation required');
|
||||
}
|
||||
foreach (['APP_ENV' => 'testing', 'APP_KEY' => 'base64:'.base64_encode(str_repeat('Q', 32)),
|
||||
'APP_CONFIG_CACHE' => $root.'/outputs/irpc-noncivil-20261114/no-config.php', 'DB_CONNECTION' => 'pgsql', 'DB_HOST' => '127.0.0.1', 'DB_PORT' => '55441',
|
||||
'DB_DATABASE' => 'investmoz_demography_test', 'DB_USERNAME' => 'demography_qa', 'DB_PASSWORD' => '', 'DB_URL' => '', 'DATABASE_URL' => '',
|
||||
'CACHE_STORE' => 'array', 'SESSION_DRIVER' => 'array', 'QUEUE_CONNECTION' => 'sync', 'MAIL_MAILER' => 'array', 'SUITECRM_ENABLED' => 'false'] as $key => $value) {
|
||||
putenv($key.'='.$value);
|
||||
$_ENV[$key] = $_SERVER[$key] = $value;
|
||||
}
|
||||
$pdo = new PDO('pgsql:host=127.0.0.1;port=55441;dbname=investmoz_demography_test', 'demography_qa', '');
|
||||
$identity = $pdo->query('select current_database(),inet_server_port()')->fetch(PDO::FETCH_NUM);
|
||||
if ($identity !== ['investmoz_demography_test', 55441] && $identity !== ['investmoz_demography_test', '55441']) {
|
||||
throw new RuntimeException('Isolated QA identity required');
|
||||
}
|
||||
$argv = ['phpunit', '-c', 'phpunit.investmoz.xml', '--do-not-cache-result', 'tests/Feature/IrpcAnnualNoncivilDraftTest.php'];
|
||||
$_SERVER['argv'] = $argv;
|
||||
$_SERVER['argc'] = count($argv);
|
||||
require $root.'/vendor/autoload.php';
|
||||
require $root.'/vendor/phpunit/phpunit/phpunit';
|
||||
Reference in New Issue
Block a user