@davoodmehraban89 / Factor-easy-2 Mirror · read-only / commits / 91e62bb
Fork 0

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

Mirrored from https://github.com/davoodmehraban89/Factor-easy.git

Synced Dec 3, 22:00 UTC

Behavior-test leaf-only dimensions and depth lock

davoodmehraban89 committed Sep 29, 2026 at 22:27 UTC 91e62bb12df5186360970c6ad6db09b4394d2df6
1 file changed +4
scripts/phase2-check.mjs
+4
@@ -36,4 +36,8 @@ const imported=vm.runInContext(`afNormalizeAccountImportRows([
36 if(imported.length!==3||imported[2].level!=='detail'||imported[2].parentCode!=='11'||imported[2].normalBalance!=='debit')throw new Error('Chart Excel normalization behavior failed');
37 let badParent=false;try{vm.runInContext(`afNormalizeAccountImportRows([{'کد':'1101','عنوان':'بانک','سطح':'تفصیلی','کد والد':'99'}])`,ctx)}catch(_){badParent=true}
38 if(!badParent)throw new Error('Chart import must reject invalid hierarchy');
39 +ctx.values=[{id:'ROOT',dimensionTypeId:'D1',depth:1,active:true},{id:'LEAF',dimensionTypeId:'D1',parentId:'ROOT',depth:2,active:true}];ctx.dimTypes=[{id:'D1',sourceEntity:'manual',maxDepth:2,active:true}];ctx.alerts=[];Object.assign(ctx,{requireWrite:()=>true,alert:m=>ctx.alerts.push(m),prompt:()=>3,saveDatastore:()=>true,renderAccountingFoundation:()=>{}});vm.runInContext("getMyDimensionValues=()=>values;getMyDimensionTypes=()=>dimTypes;",ctx);
40 +const leafState=vm.runInContext("({root:afDimensionValuePostable(values[0],dimTypes[0]),leaf:afDimensionValuePostable(values[1],dimTypes[0])})",ctx);
41 +if(leafState.root!==false||leafState.leaf!==true)throw new Error('leaf-only analytic posting behavior failed');
42 +vm.runInContext("afChangeDimensionDepth('D1')",ctx);if(ctx.dimTypes[0].maxDepth!==2||ctx.alerts.length!==1)throw new Error('dimension depth changed after values existed');
43 console.log('Phase 2 accounting foundation invariants passed.');