فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

feat(A03): include per-company audit head anchors in full backup

davoodmehraban89 committed Oct 20, 2026 at 08:42 UTC 5c72b762a65abeaa95b52ed9667aee86fc1e0517
1 file changed +10
src/core/StorageService.js
+10
@@ -1,4 +1,5 @@
1 import { isAuditServiceRow, AuditService } from './AuditService.js';
2 +import { verifyChain } from './AuditChain.js';
3
4 // ============================================================
5 // StorageService — IndexedDB wrapper
@@ -387,9 +388,18 @@ class StorageServiceImpl {
388 data.users = data.users.map(stripCredentials);
389 }
390
391 + const auditAnchors = {};
392 + for (const companyId of new Set((data.audit_events || []).map(row => row.companyId))) {
393 + const rows = data.audit_events.filter(row => row.companyId === companyId)
394 + .sort((a,b) => (a.chainIndex ?? 0) - (b.chainIndex ?? 0));
395 + const result = verifyChain(rows);
396 + if (!result.valid) throw new Error('زنجیره ممیزی در پشتیبان کامل نامعتبر است');
397 + auditAnchors[companyId] = { count: result.count, headHash: result.headHash };
398 + }
399 return {
400 app: 'Factor-easyPro',
401 version: DB_VERSION,
402 + auditAnchors,
403 exportedAt: new Date().toISOString(),
404 data
405 };