feat: carry documented investment credits within original project window
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-11-10 16:17:48 +02:00
parent d216830b06
commit 7476dc3430
14 changed files with 827 additions and 30 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ $identity = $pdo->query('select current_database() as name,inet_server_port() as
if ($identity['name'] !== 'proactive_investment_20261027_test' || (int) $identity['port'] !== 55441) {
throw new RuntimeException('Isolated QA identity required.');
}
$case = ['quota' => 'IrpcEconomicQuotaDraftTest', 'inclusion' => 'IrpcEconomicInclusionDraftTest', 'liquidation' => 'IrpcEconomicLiquidationDraftTest', 'association' => 'IrpcEconomicAssociationDraftTest', 'special-inclusion' => 'IrpcEconomicSpecialInclusionDraftTest', 'pt-royalty' => 'IrpcPtMzCreditDraftTest', 'pt-capital' => 'IrpcPtMzCapitalDraftTest', 'pt-government' => 'IrpcPtMzGovernmentDraftTest', 'economic-fraction' => 'IrpcEconomicFractionDraftTest', 'pt-agreement' => 'IrpcPtMzAgreementDraftTest', 'investment' => 'IrpcInvestmentCreditDraftTest', 'investment-quota' => 'IrpcInvestmentQuotaDraftTest', 'investment-window' => 'IrpcInvestmentWindowDraftTest'][$argv[2] ?? ''] ?? throw new RuntimeException('Choose an explicit supported QA case.');
$case = ['quota' => 'IrpcEconomicQuotaDraftTest', 'inclusion' => 'IrpcEconomicInclusionDraftTest', 'liquidation' => 'IrpcEconomicLiquidationDraftTest', 'association' => 'IrpcEconomicAssociationDraftTest', 'special-inclusion' => 'IrpcEconomicSpecialInclusionDraftTest', 'pt-royalty' => 'IrpcPtMzCreditDraftTest', 'pt-capital' => 'IrpcPtMzCapitalDraftTest', 'pt-government' => 'IrpcPtMzGovernmentDraftTest', 'economic-fraction' => 'IrpcEconomicFractionDraftTest', 'pt-agreement' => 'IrpcPtMzAgreementDraftTest', 'investment' => 'IrpcInvestmentCreditDraftTest', 'investment-quota' => 'IrpcInvestmentQuotaDraftTest', 'investment-window' => 'IrpcInvestmentWindowDraftTest', 'investment-carry' => 'IrpcInvestmentCarryDraftTest'][$argv[2] ?? ''] ?? throw new RuntimeException('Choose an explicit supported QA case.');
$argv = ['phpunit', '-c', 'phpunit.investmoz.xml', '--do-not-cache-result', 'tests/Feature/'.$case.'.php'];
$argc = count($argv);
$_SERVER['argv'] = $argv;
+17
View File
@@ -0,0 +1,17 @@
import fs from 'node:fs';
import assert from 'node:assert/strict';
import { investmentCase } from '../tests/frontend/helpers/irpc-investment-case.mjs';
import { prepareInvestmentCarry,recordAnnual,saveAnnualBook,annualBook,annualCurrent,calculateAnnual,annualHtml } from '../resources/js/lib/irpc-annual-settlement.ts';
import { createProjectDossierReport } from '../resources/js/lib/project-dossier-report.ts';
const out=new URL('../outputs/irpc-cbf15-carry-20261110/',import.meta.url);fs.mkdirSync(out,{recursive:true});
const original=JSON.parse(fs.readFileSync(new URL('../outputs/irpc-cbf15-window-20261110/recovered-fifth.json',import.meta.url),'utf8'));let current=prepareInvestmentCarry(original,annualBook(original));
for(const name of ['carry','expired']){
if(process.argv[2]==='recovered'){
const d=JSON.parse(fs.readFileSync(new URL('recovered-'+name+'.json',out),'utf8')),b=annualBook(d),m=b.result.model;
assert.equal(annualCurrent(d,b),true);assert.deepEqual(calculateAnnual(d,b).investmentCredit,m.investmentCredit);assert.equal(b.history.length,name==='carry'?6:7);assert.equal(b.history[0].model.investmentCredit?.version??'legacy','legacy');
const html=annualHtml(d),report=createProjectDossierReport(d,{selectedSections:new Set(['finance']),generatedAt:new Date().toISOString()});assert.match(html,/TransporteCBF15/);assert.match(JSON.stringify(report),/TransporteCBF15/);
fs.writeFileSync(new URL(name+'-report.html',out),html);fs.writeFileSync(new URL(name+'-verification.json',out),JSON.stringify({synthetic:true,apiRecovered:true,currentRecalculation:true,html:true,dossierReport:true,history:b.history.length,window:m.investmentCredit.window,nominal:m.investmentCredit.nominal,priorUse:m.investmentCredit.priorUse,available:m.investmentCredit.available,expired:m.investmentCredit.expired,deducted:m.investmentCredit.deducted,balance:m.arithmeticBalance,activeChanged:false},null,2));
}else{
current=structuredClone(current);const t=current.investmentCredit;t.startDate=name==='carry'?'2022-01-01':'2021-01-01';t.carryForward={reference:'SYNTHETIC documentary unused credit,original same project and Maputo Province10percent',useReconciled:'yes',currentState:'absent',currentReference:'SYNTHETIC no2026 realised investment'};t.assets=[{...t.assets[0],date:'2025-05-01',originYear:'2025',originNuit:t.subjectNuit,originProject:t.projectReference,originRate:'10',originReference:'SYNTHETIC qualified2025 credit,same project and province10percent; original records linked'}];t.previousUse={state:'known',amount:'1000',reference:'SYNTHETIC actual prior fiscal use1000 of original credit4000; not simulated usage'};current=recordAnnual(original,current,new Date().toISOString());fs.writeFileSync(new URL(name+'.json',out),JSON.stringify({...original,person_type:investmentCase().d.person_type,modelo_a_snapshot:saveAnnualBook(original,current)}));
}
}