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

fix: ordered full history restore

davoodmehraban89 committed Oct 20, 2026 at 08:41 UTC 964ac57f93bff6fbb26b9db905774fd35fb706a3
1 file changed +3 -1
src/core/StorageService.js
+3 -1
@@ -449,7 +449,9 @@ class StorageServiceImpl {
449 } else if (APPEND_ONLY_STORES.has(store)) {
450 // Backup replay may re-add history but can never rewrite it.
451 // A conflicting record aborts the WHOLE multi-store restore.
452 - for (const item of items) {
452 + const historical = store === 'audit_events'
453 + ? [...items].sort((a,b) => (a.chainIndex ?? 0) - (b.chainIndex ?? 0)) : items;
454 + for (const item of historical) {
455 if (!item.id || typeof item.id !== 'string' ||
456 !item.companyId || typeof item.companyId !== 'string') {
457 throw new Error('رکورد تاریخچه ممیزی یا اصلاح سند نامعتبر است');