@davoodmehraban89 / Factor-easy-2 Mirror · read-only / commits / 68f82e7
Fork 0

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

Mirrored from https://github.com/davoodmehraban89/Factor-easy.git

Synced Dec 4, 01:45 UTC

docs: require atomic source link in autopost transaction

davoodmehraban89 committed Nov 17, 2026 at 14:15 UTC 68f82e70a9fdc873fefc1a28c5becce4cc4cad01
1 file changed +7
PROJECT_STATE.md
+7
@@ -375,3 +375,10 @@ Owner requests layer-by-layer click/functional testing of all controls and compa
375 ### 2026-11-17 — Ambiguous posting response must freeze source edits until reconciliation
376 - The server autopost RPC is idempotent by source type/id/version, but a lost HTTP response can leave the source locally appearing as a draft while a posted voucher already exists. Editing or deleting that source before retry could create a source/voucher mismatch.
377 - Before autopost, persist `accountingPostingPending=true`. Keep it while the RPC outcome is ambiguous; block source edit/delete while pending. On explicit Postgres RPC error (transaction rolled back) clear the marker so the draft can be corrected. On confirmed success, reconcile voucher link/status and clear the marker. A retry with the same source identity resolves a committed-but-unacknowledged request.
378 +
379 +
380 +### 2026-11-17 — Source-to-voucher link moved into the same database transaction
381 +- Permission review found that persisting `journalVoucherId/accountingStatus/documentStatus` after autopost through generic sync would require a separate commerce:update permission and would leave a partial-commit window. Do not rely on that client-side write.
382 +- Correct design: the existing `finora_journal_autopost` RPC must update the source record link/status and clear pending metadata in the same transaction that posts the journal. On idempotent replay, it must also reconcile the source link from the already-posted/reversed voucher. Client then refreshes and verifies the server-written source link; no post-RPC generic sync write is allowed.
383 +- Keep `accountingPostingPending` as a local UI freeze only, not a server-persisted field. Persist the source draft first; set the local marker immediately before RPC submission. A committed-but-unacknowledged request is safe across tabs/reloads because the database transaction writes both voucher and source link atomically. Explicit server rejection clears the local marker; ambiguous transport failure keeps it until retry/reload.
384 +- Add a new additive migration and rollback script for the RPC body, plus SQL tests proving sale and purchase source link/status are committed atomically. No migration is applied to Production.