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

feat(A03): persist retail journal and append-only audit event atomically

davoodmehraban89 committed Oct 14, 2026 at 23:22 UTC 8be5280e5db3bfbeb7258cb3dccfa22c26a4abbf
1 file changed +7 -1
src/core/RetailPostingService.js
+7 -1
@@ -2,6 +2,7 @@
2 import { StorageService } from './StorageService.js';
3 import { DataScope } from './DataScope.js';
4 import { Auth } from './Auth.js';
5 +import { AuditService } from './AuditService.js';
6 import { validateJournal, journalSourceKey, assertJalaliDate } from './AccountingCore.mjs';
7 import { previewSaleReturnSettlement } from './ReturnSettlementCore.mjs';
8 import { LEDGER_CODES, INVOICE_DIRECTIONS, amount, positiveAmount,
@@ -12,7 +13,8 @@ export const FINANCE_STORES = Object.freeze([
13 'account_chart','fiscal_periods','journal_entries','journal_lines',
14 'invoices','invoice_items','stock_movements','products','contacts','treasury',
15 'warehouses','inventory_balances','stocktakes','stocktake_lines',
15 - 'settlements','expenses','cheques','settings','account_mappings'
16 + 'settlements','expenses','cheques','settings','account_mappings',
17 + 'audit_events'
18 ]);
19 const uid=p=>StorageService.uid(p);
20 const actor=()=>Auth.current()?.id||null;
@@ -191,6 +193,10 @@ class RetailPostingServiceImpl {
193 await tx.put('journal_lines',{...line,id:uid('jl_'),journalId:journal.id,
194 companyId:ctx.companyId,position});
195 }
196 + await AuditService.append(tx, { companyId: ctx.companyId,
197 + eventType: 'commercial_journal_posted', sourceType: kind, sourceId: journal.id,
198 + commandKey: 'retail-journal:' + key, businessDate: ctx.date,
199 + lineCount: filtered.length });
200 return journal;
201 }
202 async stock(tx,ctx,warehouseId,item,direction,costValue,refId,refType='invoice') {