سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 4, 01:45 UTC
test: assert authoritative server source persistence for posting idempotency
davoodmehraban89 committed
Nov 17, 2026 at 17:25 UTC
0cd5a40b4bc27b437d12ad7437f8bd4a8e4ab4c4
1 file changed
+6
-1
scripts/posting-idempotency-check.mjs
+6
-1
@@ -2,6 +2,7 @@ import {readFileSync} from 'node:fs';
2
import assert from 'node:assert/strict';
3
const migration=readFileSync('supabase/migrations/20261011174445_posted_source_idempotency_index.sql','utf8');
4
const invoice=readFileSync('js/invoices.js','utf8');
5
+const journalRpc=readFileSync('js/journal-rpc.js','utf8');
6
const manager=readFileSync('js/document-management.js','utf8');
7
const product=readFileSync('js/products.js','utf8');
8
const inventory=readFileSync('js/phase5-enterprise.js','utf8');
@@ -16,7 +17,11 @@ assert.match(migration,/posted','reversed'/);
17
assert.match(invoice,/documentStatus:'draft',accountingStatus:'draft'/);
18
assert.match(invoice,/async function finalizeInvoiceDocument\(/);
19
assert.match(invoice,/await runSync\(\)/);
19
-assert.match(invoice,/syncSnap\.has\('journalVouchers\|'/);
20
+assert.match(invoice,/jeRpcAutoPost\('sale',invoiceId\)/);
21
+assert.match(journalRpc,/jeRpcPersistSourceRecord\(collection,sourceId\)/);
22
+assert.match(journalRpc,/syncSnap\.get\(key\)===expected/);
23
+assert.match(journalRpc,/await runSync\(\)/);
24
+assert.match(journalRpc,/jeRpcAssertNoGenericJournalDiff\(\)/);
25
assert.doesNotMatch(invoice,/if\(invoiceCreatesAccountingEntry\(kind\).*?jePostSourceRecord\('sale',record\)/s);
26
assert.match(manager,/invoiceDocumentStatus\(inv\)/);
27
assert.match(product,/invoiceDocumentStatus\(x\)==='posted'/);