Files
SGF/scripts/summarize-invoice-composition.mjs
T
2026-11-04 09:37:20 +02:00

8 lines
6.4 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,'invoice-result.json',45],['boundaries',qa,'invoice-boundaries.json',4],['guards',qa,'invoice-guards.json',6],['demonstration',demo,'invoice-demo-smoke.json',13],['assets',demo,'invoice-demo-assets.json',3],['navigation','.','docs/proofs/invoice-home-20261103.json',6]]){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};}assert.equal(Object.values(tests).reduce((n,t)=>n+t.checks,0),77);
const files=['app/Modules/Purchasing/InvoiceController.php','app/Modules/Purchasing/ReceiptRuntime.php','config/receipt_qa.php','routes/web.php','app/Shared/Context/ModuleNavigation.php','app/Modules/Identity/Services/IdentityWorkflow.php','resources/js/PurchasingHome.jsx','resources/views/supplier-invoice-workspace.blade.php','public/supplier-invoice-workspace.mjs','scripts/order-native-setup.php','scripts/invoice-native-negative.php','scripts/invoice-host-setup.php','scripts/invoice-composition-proof.php','scripts/invoice-proof-body.php','scripts/invoice-boundary-proof.php','scripts/invoice-boundary-body.php','scripts/invoice-guard-proof.php','scripts/invoice-demo-smoke.php','scripts/invoice-demo-assets.mjs','scripts/receipt-composition-run.mjs','scripts/receipt-composition-http.php','scripts/receipt-composition-extra.mjs','scripts/stock-ledger-entry.php'];const sources=files.map(file=>({file,sha256:hash(file)}));for(const base of [qa,demo])for(const file of files.filter(f=>!f.startsWith('scripts/')))assert.equal(hash(path.join(base,'app',file)),hash(file));
const manifests=[];let original;for(const base of [qa,demo]){const pins={};for(const dir of ['bundle','economic','internal']){const p=path.join(base,dir,'manifest.json');pins[dir]=hash(p);const m=read(p);for(const [file,pin]of Object.entries(m.files))assert.equal(hash(path.join(base,dir,file)),pin);if(dir==='bundle')original=Object.fromEntries(['app/Services/InvoiceWorkflow.php','app/Http/Controllers/InvoiceController.php','app/Services/CommonBudget.php'].map(file=>[file,m.originals[file]]));}manifests.push(pins);}assert.deepEqual(manifests[0],manifests[1]);assert.deepEqual(manifests[0],read('docs/proofs/request-to-receipt-composition-20261103.json').pinned_manifests);
const previous=['docs/proofs/geography-composition-20261103.json','docs/proofs/request-to-receipt-composition-20261103.json','docs/proofs/order-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[1].file).preservation.installed_purchasing_sha256);
const out='docs/proofs/supplier-invoice-composition-20261103.json';assert(!fs.existsSync(out));fs.writeFileSync(out,JSON.stringify({date:new Date().toISOString(),increment:'SGF-SUPPLIER-INVOICE-MATCHING-QA-v1',passed:true,functional_code:true,checks:77,tests,sources,pinned_native_manifests:manifests[0],original_source_hashes:original,financial_effects:{single_order_commitment_minor:10000,validated_invoice_minor:[4000,6000],original_budget_consumptions:2,total_consumed_minor:10000,additional_physical_movements:0,payable_auto_recognised:false,payments_created:0,ledger_posted:false},qa_rights:['purchasing_invoices.view','purchasing_invoices.prepare','purchasing_invoices.validate'],demo:{buyer_url:'http://127.0.0.1:8070/qa/enter/actor?open=1',warehouse_url:'http://127.0.0.1:8070/qa/enter/validator?open=1',preparer_url:'http://127.0.0.1:8070/qa/enter/issuer?open=1',reviewer_url:'http://127.0.0.1:8070/qa/enter/reviewer?open=1',second_reviewer_url:'http://127.0.0.1:8070/qa/enter/auditor?open=1',initial_main_orders:0,initial_main_receipts:0,initial_invoices:0,initial_consumptions:0,approved_award_prepared:true,foreign_order_is_negative_fixture:true},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,concurrent_compras_sources_written:false,public_rights_changed:false,purchasing_activated_at_destination:false,publication:false,checkpoint:false},limitations:['Technical supplier-document matching only, using the original frozen workflow. No fiscal issuance or statement of real documentary validity.','Budget consumption is the original authorised native effect. Payable recognition, payment and ledger remain separate; the earlier common-payable11,600MZN proof is not declared joined to these100MZN invoices.','The incompatible pending70MZN document is preserved; invoice correction/rejection/credit notes and binary document attachments are outside this increment.','Date/currency/tolerance rules are those of the pinned native workflow, including current-year MZN and exact matching.','Order list pages25 and invoice-history pages15; show/revision materialises the invoices and dependencies of the selected order. Very large per-order invoice histories are not load-validated.','The boundary probes use rollback-only previews of original idempotent validation and rejected confirmations; they repeat no posted decision.','Native/economic bundles and common writer source pins are recorded; current concurrent Compras changes and existing demos were not upgraded.','Visual review, sustained load, general destination installation and owner/runtime privilege separation remain pending.'],visual_review_pending:true,deployment_capacity_validated:false},null,2)+'\n');console.log(JSON.stringify({output:out,checks:77,demo_port:8070}));