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

fix(a02): block non-atomic replacement of referenced customer/product master records

davoodmehraban89 committed Oct 31, 2026 at 00:36 UTC b6c0b47df589589b6aa34cc2d3723492c79fdec8
1 file changed +14 -12
src/controllers/ExcelController.js
+14 -12
@@ -465,13 +465,14 @@ class ExcelControllerImpl {
465 if (rows.length === 0) throw new Error('شیت کالاها خالی است');
466
467 const mode = options.mode || 'merge';
468 - const existing = await DataScope.list('products');
469 -
470 - if (mode === 'replace') {
471 - for (const p of existing) {
472 - await StorageService.delete('products', p.id);
473 - }
468 + // A multi-store accounting system must never delete referenced master data
469 + // then import row-by-row: one malformed row/crash can destroy existing
470 + // invoices, ledgers and company references. Replacement is deliberately
471 + // disabled until a transactional, referentially-safe migration exists.
472 + if (mode !== 'merge') {
473 + throw new Error('جایگزینی گروهی اطلاعات پشتیبانی نمی‌شود؛ اطلاعات موجود حفظ شدند. فقط حالت ادغام مجاز است.');
474 }
475 + const existing = await DataScope.list('products');
476
477 let added = 0, skipped = 0;
478 for (const row of rows) {
@@ -523,13 +524,14 @@ class ExcelControllerImpl {
524 if (rows.length === 0) throw new Error('شیت اشخاص خالی است');
525
526 const mode = options.mode || 'merge';
526 - const existing = await DataScope.list('contacts');
527 -
528 - if (mode === 'replace') {
529 - for (const c of existing) {
530 - await StorageService.delete('contacts', c.id);
531 - }
527 + // A multi-store accounting system must never delete referenced master data
528 + // then import row-by-row: one malformed row/crash can destroy existing
529 + // invoices, ledgers and company references. Replacement is deliberately
530 + // disabled until a transactional, referentially-safe migration exists.
531 + if (mode !== 'merge') {
532 + throw new Error('جایگزینی گروهی اطلاعات پشتیبانی نمی‌شود؛ اطلاعات موجود حفظ شدند. فقط حالت ادغام مجاز است.');
533 }
534 + const existing = await DataScope.list('contacts');
535
536 let added = 0, skipped = 0;
537 for (const row of rows) {