Files
SGF/scripts/summarize-purchasing-integrated.mjs
2026-11-04 09:37:20 +02:00

10 lines
5.9 KiB
JavaScript

import fs from 'node:fs';import path from 'node:path';import crypto from 'node:crypto';import assert from 'node:assert/strict';
const [qaTag,demoTag]=process.argv.slice(2);assert([qaTag,demoTag].every(t=>/^[a-f0-9]{12}$/.test(t??'')));const run=JSON.parse(fs.readFileSync('C:/laragon/data/sgf-tempo/run/modular-regression-current.json')),qa=path.join(run.root,'private/receipt-composition-'+qaTag),demo=path.join(run.root,'private/receipt-composition-'+demoTag),read=p=>JSON.parse(fs.readFileSync(p,'utf8')),hash=p=>crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex'),tests={};
for(const [name,base,file,count]of [['integration',qa,'integrated-result.json',29],['guards',qa,'integrated-navigation-guard.json',5],['home','.','docs/proofs/purchasing-workspace-home-20261103.json',6],['demo',demo,'integrated-smoke.json',25],['assets',demo,'integrated-demo-assets.json',3]]){const p=path.join(base,file),r=read(p);assert(r.passed);assert.equal(Array.isArray(r.checks)?r.checks.length:r.checks,count);tests[name]={file:base==='.'?file:'private/'+path.basename(base)+'/'+file,sha256:hash(p),checks:count,result:r};}
const files=['app/Modules/Purchasing/WorkspaceNavigation.php','app/Shared/Context/ModuleNavigation.php','resources/js/PurchasingHome.jsx','routes/web.php','resources/views/purchasing-workspace.blade.php','resources/views/partials/purchasing-navigation.blade.php',...['request','supplier','sourcing','order','receipt','supplier-invoice','supplier-obligation'].map(f=>'resources/views/'+f+'-workspace.blade.php')];for(const base of [qa,demo])for(const f of files)assert.equal(hash(path.join(base,'app',f)),hash(f),f);
const pins=[];for(const base of [qa,demo]){const p={};for(const dir of ['bundle','economic','internal']){p[dir]=hash(path.join(base,dir,'manifest.json'));for(const [f,h]of Object.entries(read(path.join(base,dir,'manifest.json')).files))assert.equal(hash(path.join(base,dir,f)),h);}pins.push(p);}assert.deepEqual(pins[0],pins[1]);assert.deepEqual(pins[0],read('docs/proofs/supplier-obligation-composition-20261103.json').pinned_native_manifests);
const previous=['docs/proofs/supplier-obligation-composition-20261103.json','docs/proofs/supplier-invoice-composition-20261103.json','docs/proofs/request-to-receipt-composition-20261103.json','docs/proofs/geography-composition-20261103.json','docs/proofs/module-association-consolidation-summary-20261102.json'].map(file=>({file,sha256:hash(file)})),assoc=read(previous.at(-1).file);assert.equal(hash('app/Modules/Identity/Services/ModuleAssociationReview.php'),assoc.source_sha256);assert.equal(hash('app/Modules/Identity/Http/ModuleRecordsController.php'),assoc.controller_sha256);assert.equal(hash('packages/purchasing/current.json'),read(previous[0].file).preservation.installed_purchasing_sha256);
const financialSources=['app/Modules/Purchasing/RequestController.php','app/Modules/Purchasing/SourcingController.php','app/Modules/Purchasing/OrderController.php','app/Modules/Purchasing/ReceiptController.php','app/Modules/Purchasing/InvoiceController.php','app/Modules/Purchasing/ObligationController.php','packages/payables/src/Payables.php'];for(const base of [qa,demo])for(const f of financialSources)assert.equal(hash(path.join(base,'app',f)),hash(f),f);
const checks=Object.values(tests).reduce((n,t)=>n+t.checks,0);assert.equal(checks,68);const out='docs/proofs/purchasing-integrated-composition-20261103.json';assert(!fs.existsSync(out));
fs.writeFileSync(out,JSON.stringify({date:new Date().toISOString(),increment:'SGF-PURCHASING-INTEGRATED-QA-v1',passed:true,functional_code:true,checks,tests,sources:files.map(file=>({file,sha256:hash(file)})),financial_sources_unchanged_between_compositions:financialSources.map(file=>({file,sha256:hash(file)})),pinned_native_manifests:pins[0],native_authority:{same_request_award_order_invoice_and_payable_book:true,host_budget_unchanged:true,principal_minor:10000,consumption_minor:10000,stock_movements:1,automatic_payments:0,ledger_posted:false},new_right_names:[],demo:{port:8072,entry:'http://127.0.0.1:8072/qa/enter/requester?open=1',roles:['requester','approver','actor','validator','issuer','reviewer','auditor'],initial_main_requests:0,initial_main_awards:0,initial_main_orders:0,initial_main_invoices:0,initial_obligations:0,prepared_native_suppliers:3,prepared_approved_budget_minor:100000,reference_rows:20407,locations_assigned:0},integration_run:{business_path_executed_once:true,initial_positive_checks:26,final_boundary_checks_resumed:3,reason:'With geography enabled the finance user can select Commercial: a valid different module yields409, rather than403 for an unavailable module. The final assertion was corrected; no business commands or valid suites were repeated.'},prior_proofs_preserved:previous,preservation:{installed_purchasing_sha256:hash('packages/purchasing/current.json'),target_database_connected:false,protected_six_records_changed:false,blocked_cache_cleared:false,previous_demo_data_written:false,public_rights_changed:false,publication:false,checkpoint:false},limitations:['Integrated purchasing composition only; not a claim that all six ERP modules share one final installation.','Supplier financial review and cartography functionality reuse prior proofs; new checks verify mounting and absence of automatic localisation, without rerunning those suites.','Main book starts empty. Three supplier fixtures and one approved1000MZN budget are prepared; foreign request exists solely for isolation.','Payments, history responsibility migration, accounting of this new invoice origin, invoice correction/attachments and real operations remain separate.','Runtime remains pinned to the tested native bundle while native synthetic schema provisioning uses current project migrations.','Visual review, sustained load and general deployment/least-privilege installation remain pending.'],visual_review_pending:true,deployment_capacity_validated:false},null,2)+'\n');console.log(JSON.stringify({output:out,checks,demo_port:8072}));