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

Add Phase 2 accounting safety regression gate

davoodmehraban89 committed Sep 28, 2026 at 18:15 UTC e519fde492e12fdb44c4b6eab3179908aeeeabf9
1 file changed +20
scripts/phase2-check.mjs new
+20
@@ -0,0 +1,20 @@
1 +import fs from 'node:fs';
2 +const af=fs.readFileSync('js/accounting-foundation.js','utf8');
3 +const render=fs.readFileSync('js/accounting-foundation-render.js','utf8');
4 +const companies=fs.readFileSync('js/companies.js','utf8');
5 +const index=fs.readFileSync('index.html','utf8');
6 +const core=fs.readFileSync('js/core.js','utf8');
7 +const backup=fs.readFileSync('js/backup.js','utf8');
8 +const sync=fs.readFileSync('js/sync.js','utf8');
9 +const must=(src,needles,label)=>{for(const n of needles)if(!src.includes(n))throw new Error(label+' missing '+n)};
10 +must(af,['AF_COMPANY_TYPES','AF_BASE_ACCOUNTS','AF_SPECIAL_ACCOUNTS','afApplyTemplate','afDimensionValuePostable','afDimensionHasValues','afDimensionValueReferenced','afChangeDimensionDepth','depthLocked','maxDepth','startDate>=endDate'],'accounting foundation');
11 +must(render,['afDimensionValuePostable','afChangeDimensionDepth','عمق قفل شده','قابل ثبت','گروه/غیرقابل ثبت'],'dimension rendering');
12 +must(companies,['company-activity-type','company-accounting-template','afApplyTemplate(newComp.id,activityType)'],'company onboarding');
13 +must(index,['company-activity-type','company-accounting-template','بازرگانی','خدماتی','تولیدی','پیمانکاری','فروشگاهی','پخش','غیرانتفاعی','خدمات حرفه‌ای'],'company activity UI');
14 +for(const coll of ['fiscalYears','accounts','dimensionTypes','dimensionValues','accountDimensionRules','branches','projects','projectLinks']){
15 + if(!core.includes("'"+coll+"'")||!sync.includes(coll)||!backup.includes(coll))throw new Error('Phase 2 persistence missing '+coll);
16 +}
17 +if(!af.includes("(v.depth||1)===Number(t.maxDepth||1)"))throw new Error('Only configured terminal depth may post');
18 +if(!af.includes("if(afDimensionHasValues(id))return alert"))throw new Error('Hierarchy depth must lock after values exist');
19 +if(!af.includes("afDimensionValueReferenced(id)"))throw new Error('Referenced analytic values must be protected');
20 +console.log('Phase 2 accounting foundation invariants passed.');