سامانه صدور فاکتور و حسابداری

Gate negative inventory prevention

davoodmehraban89 committed Sep 29, 2026 at 22:40 UTC bc5ec91d1fbdd1338f75e46432a6e11dd9d2f72c
1 file changed +1 -1
scripts/phase5-behavior-check.mjs
+1 -1
@@ -9,7 +9,7 @@ eq(D.convert(10,600000),6000000,'fx conversion');
9 D.validateMovement({kind:'transfer',productId:'P1',warehouseId:'W1',toWarehouseId:'W2',qty:1});
10 let rejected=false;try{D.validateMovement({kind:'transfer',productId:'P1',warehouseId:'W1',toWarehouseId:'W1',qty:1})}catch{rejected=true}if(!rejected)throw new Error('same-warehouse transfer accepted');
11 D.validateRestore({formatVersion:5,warehouses:[]},['warehouses']);rejected=false;try{D.validateRestore({evil:[]},['warehouses'])}catch{rejected=true}if(!rejected)throw new Error('unknown restore collection accepted');
12 -const app=fs.readFileSync('js/phase5-enterprise.js','utf8');for(const x of ['p5PostMovement','p5SaveCount','p5RunDepreciation','p5SaveRate','p5SaveCostCenter','p5PreviewRestore','p5QueueEvent','p5ValidateIntegrationEndpoint','20*1024*1024','salvage<0','getMyExchangeRates().length','accountType:typeof afAccountTypeForCode','status:\'posted\''])if(!app.includes(x))throw new Error('Phase5 application invariant missing '+x);
12 +const app=fs.readFileSync('js/phase5-enterprise.js','utf8');for(const x of ['p5PostMovement','p5SaveCount','p5RunDepreciation','p5SaveRate','p5SaveCostCenter','p5PreviewRestore','p5QueueEvent','p5ValidateIntegrationEndpoint','20*1024*1024','salvage<0','getMyExchangeRates().length','accountType:typeof afAccountTypeForCode','p5Stock(m.productId,m.warehouseId)<m.qty','status:\'posted\''])if(!app.includes(x))throw new Error('Phase5 application invariant missing '+x);
13 const intCtx={URL};vm.createContext(intCtx);vm.runInContext(app,intCtx);if(vm.runInContext("p5ValidateIntegrationEndpoint('https://hooks.example.com/events')",intCtx)!=='https://hooks.example.com/events')throw new Error('valid HTTPS integration endpoint rejected');for(const bad of ['http://hooks.example.com','https://user:pass@hooks.example.com','https://localhost/hook','https://192.168.1.20/hook']){let blocked=false;try{intCtx.bad=bad;vm.runInContext("p5ValidateIntegrationEndpoint(bad)",intCtx)}catch{blocked=true}if(!blocked)throw new Error('unsafe integration endpoint accepted: '+bad)}
14 const backup=fs.readFileSync('js/backup.js','utf8');if(!backup.includes('20*1024*1024'))throw new Error('backup import size bound missing');
15 console.log('Phase 5 behavioral/domain scenarios passed.');