سامانه صدور فاکتور و حسابداری

docs: correct journal RPC integration status and define source autopost work

davoodmehraban89 committed Nov 17, 2026 at 13:51 UTC 875822e6d95867dc31891bd342912515beefc399
1 file changed +7
PROJECT_STATE.md
+7
@@ -358,3 +358,10 @@ Owner requests layer-by-layer click/functional testing of all controls and compa
358 - WP3 strict tenant-isolation E2E exact SHA passed after tightening denial assertions to HTTP 401/403; WP2 Auth/JWT organization membership isolation also passed. Quality static/browser and independent C8, D1/D2 and identity database jobs all passed. PR #211 remains Draft; PR #206 (WP1 DB candidate) remains Draft. Neither has been merged. No Production Supabase access/write, migration, deployment, or posted financial record mutation occurred.
359 - Explicit limits: WP1 harness is source-derived disposable PostgreSQL and is not production schema parity or hosted Auth/JWT/PostgREST acceptance. Full candidate DOWN/UP was disposable only. Eleven prerequisite DOWN scripts are not each independently rehearsed by the correction-cycle test (the separate full candidate conservative DOWN/UP is a distinct test). Browser UI still does not use the dedicated journal RPC surface: `journal-engine.js` and `journal-ui.js` retain synchronous local datastore operations and `sync.js` generic `finora_sync_records`. Therefore do not claim the ledger is fully server-authoritative or merge/release this candidate.
360 - Next authorized work after owner continuation: a separate feature branch for the async journal repository adapter and UI integration, scoped first to manual journal lifecycle (create/update/post/delete/reverse/read graph). Add tests for server reconciliation, exact version/CAS, idempotent ambiguous retries, duplicate submissions, membership revocation, organization switching, pending generic sync, offline/timeout/committed-but-refresh-failed states, and no generic sync writes for journal collections. Preserve all legacy source workflows; do not migrate sales/purchases until adapter integration and manual lifecycle are proven. No new schema migration or Production operation in this package. Follow with sales/purchase source RPC adapter only after a separately reviewed test-backed package.
361 +
362 +
363 +### 2026-11-17 — Source-path audit correction before sales/purchase RPC integration
364 +- Re-read exact branch source after the WP1-WP3 checkpoint. The previous continuity note that *all* manual journal UI remains synchronous/local is stale: `js/journal-ui.js` already routes manual create/update/post/delete/reverse/copy through `jeRpcCreateDraft`, `jeRpcUpdateDraft`, `jeRpcPost`, `jeRpcDeleteDraft`, and `jeRpcReverse`. `js/journal-rpc.js` is loaded before `journal-ui.js`; adapter contract tests exist. Do not redo this completed manual UI wiring.
365 +- Remaining confirmed gap: `js/invoices.js::finalizeInvoiceDocument` and `js/purchases.js::finalizePurchasePilotDraft` still call `jePostSourceRecord`, whose `jeAutoPost` path locally creates/posts journal rows and later relies on generic `finora_sync_records`. `js/sync.js::computeDiff/runSync` still includes `journalVouchers`, `journalLines`, and `journalLineDimensions`.
366 +- Server-side `public.finora_journal_autopost` already exists for sale/purchase in migration `20261016103100_phase1a_autopost_server_authority.sql`; it validates persisted source identity/version, derives authoritative posting lines from the approved account-role snapshot, compares client line sets when supplied, enforces idempotent replay, and posts atomically with the journal rows. It requires the source business record to be persisted first. Therefore the next implementation is a narrow client orchestration adapter: flush/persist the draft source without dirty generic journal diffs, call the dedicated auto-post RPC, reconcile the returned voucher, then persist only the source-to-voucher link/status. Preserve retry safety when the RPC committed but its response/refresh was lost.
367 +- No direct writes to journal collections through generic sync are to be introduced. Do not globally remove journal collections from generic sync until every legacy producer and correction/reversal path is migrated and regression-tested. No new migration or Production operation is required for this client package.