feat(portal): deliver ordinary national credit fraction and education continuity
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import fs from 'node:fs';
|
||||
import { internationalCase } from '../tests/frontend/helpers/irpc-international-case.mjs';
|
||||
import { recordAnnual, saveAnnualBook } from '../resources/js/lib/irpc-annual-settlement.ts';
|
||||
const out = new URL('../outputs/irpc-national-fraction-20261110/', import.meta.url);
|
||||
fs.mkdirSync(out, { recursive: true });
|
||||
for (const [name, amount, reference] of [
|
||||
['ordinary', '100', 'SYNTHETIC QA: net foreign taxable component included in this ordinary base after corresponding costs/losses/deductions'],
|
||||
['exact', '0.01', 'SYNTHETIC QA: exact net component correspondence'],
|
||||
['missing', '100', ''],
|
||||
]) {
|
||||
const c = internationalCase('100');
|
||||
Object.assign(c.b.internationalCredits.positions[0], { nationalMethod: 'proportional', incomeAmount: amount, nationalBasisReference: reference });
|
||||
const book = recordAnnual(c.d, c.b, '2026-11-10T13:00:00+02:00');
|
||||
const snapshot = { ...c.d, modelo_a_snapshot: saveAnnualBook(c.d, book) };
|
||||
fs.writeFileSync(new URL(name + '.json', out), JSON.stringify(snapshot));
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
$root = dirname(__DIR__);
|
||||
if (($argv[1] ?? '') !== 'test' || basename($root) !== 'portal-investidor') {
|
||||
throw new RuntimeException('Explicit local test operation required.');
|
||||
}
|
||||
foreach (['APP_ENV' => 'testing', 'APP_KEY' => 'base64:'.base64_encode(str_repeat('Q', 32)),
|
||||
'APP_CONFIG_CACHE' => $root.'/outputs/irpc-national-fraction-20261110/no-config.php',
|
||||
'DB_CONNECTION' => 'pgsql', 'DB_HOST' => '127.0.0.1', 'DB_PORT' => '55441',
|
||||
'DB_DATABASE' => 'proactive_investment_20261027_test', 'DB_USERNAME' => 'investmoz_test', '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=proactive_investment_20261027_test', 'investmoz_test', '');
|
||||
$identity = $pdo->query('select current_database() as name,inet_server_port() as port')->fetch(PDO::FETCH_ASSOC);
|
||||
if ($identity['name'] !== 'proactive_investment_20261027_test' || (int) $identity['port'] !== 55441) {
|
||||
throw new RuntimeException('Isolated QA identity required.');
|
||||
}
|
||||
$argv = ['phpunit', '-c', 'phpunit.investmoz.xml', '--do-not-cache-result', 'tests/Feature/IrpcNationalFractionDraftTest.php'];
|
||||
$argc = count($argv);
|
||||
$_SERVER['argv'] = $argv;
|
||||
$_SERVER['argc'] = $argc;
|
||||
require $root.'/vendor/autoload.php';
|
||||
require $root.'/vendor/phpunit/phpunit/phpunit';
|
||||
@@ -0,0 +1,25 @@
|
||||
import fs from 'node:fs';
|
||||
import assert from 'node:assert/strict';
|
||||
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 out = new URL('../outputs/irpc-national-fraction-20261110/', import.meta.url);
|
||||
const cases = [];
|
||||
for (const name of ['ordinary', 'exact', 'missing']) {
|
||||
const d = JSON.parse(fs.readFileSync(new URL('recovered-' + name + '.json', out), 'utf8'));
|
||||
const b = annualBook(d), m = b.result.model, fresh = calculateAnnual(d, b);
|
||||
assert.equal(annualCurrent(d, b), true);
|
||||
assert.deepEqual(fresh.internationalCredit, m.internationalCredit);
|
||||
assert.deepEqual(fresh.arithmeticBalance, m.arithmeticBalance);
|
||||
const html = annualHtml(d);
|
||||
const rows = annualReportRows(d);
|
||||
const dossier = createProjectDossierReport(d, { selectedSections: new Set(['finance']), generatedAt: '2026-11-10T13:00:00+02:00' });
|
||||
if (name !== 'missing') {
|
||||
assert.match(html, /derivação L6/);
|
||||
assert.match(JSON.stringify(dossier), /IRPC-national-fraction\/1/);
|
||||
} else assert.equal(m.arithmeticBalance, null);
|
||||
fs.writeFileSync(new URL('report-' + name + '.html', out), html);
|
||||
fs.writeFileSync(new URL('dossier-' + name + '.json', out), JSON.stringify(dossier));
|
||||
cases.push({ name, status: m.status, nationalLimit: m.internationalCredit.positions[0].nationalLimit, balance: m.arithmeticBalance, apiRecovered: true, current: true, html: true, dossier: true, reportRows: rows.length });
|
||||
}
|
||||
fs.writeFileSync(new URL('recovered-reports.json', out), JSON.stringify({ synthetic: true, activeDatabaseChanged: false, cases }, null, 2));
|
||||
console.log(JSON.stringify(cases));
|
||||
Reference in New Issue
Block a user