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

docs(pilot): record correction MVP implementation, pending tests, and per-document limitations

davoodmehraban89 committed Oct 14, 2026 at 08:25 UTC 150a21e316fc85fde20874e408cdb67848687c6e
1 file changed +6
PROJECT_STATE.md
+6
@@ -177,6 +177,12 @@ The latest user message is the sole source of new instructions. Read AGENTS.md t
177 - **Authority boundary:** user authorizes the **feature design/development** and ordinary reversible PR, but production posted-data bulk conversion, schema/RLS/Auth/role changes, real ledger correction/deletion, closed-period reversal, offboarding, or migration are **not** authorized by a feature request alone. Test isolated synthetic ledger only, preserve tenant isolation and accounting Golden. No existing production 'final' record is automatically modified. Verify exact SHA Quality/Security/Chromium/three disposable PostgreSQL and independent posting invariants before release; keep owner live acceptance OPEN.
178 - **Baseline before changes:** protected `main=9d40b70be90172772d12eb9fa33915fe9c055c67`, prior Phase 1 security audit PR #123 merged with Quality, Security, Release Gate, Pages successful. Live Supabase state to be checked read-only before merge. Rollback targeted PR revert; correction/cancellation must retain audit history.
179
180 +### 2026-10-14 Pilot correction MVP — CODE + SYNTHETIC E2E TESTS IMPLEMENTED ON BRANCH / CI NOT YET RUN
181 +- **Implemented (isolated GitHub branch only):** `js/journal-engine.js` now has `jeReturnPostedToDraft`, `jeUpdateDraft`, `jeCancelPostedManual`. `js/journal-ui.js` exposes editable saved manual drafts and buttons «برگشت به موقت» and «ابطال» for posted **manual** vouchers, preserving old voucher/lines and creating a balanced posted reversal plus a new linked draft. `js/invoices.js` adds `reopenPostedInvoiceAsDraft`, `cancelPostedInvoicePilot`, `deleteInvoicePilotDraft` for **sale invoices** only. `js/document-management.js` shows confirmed corrective return, auditable cancellation and draft-only delete; old original invoice/number/posted voucher remain linked and unchanged, correction gets a new unique number/ID, `correctsInvoiceId` and `correctionReversalId`, and can be edited and re-finalized through the existing path. It checks owner, active company, open fiscal year, current source posting, an electronic-document exclusion and visible payment references. The server's immutable posted journal triggers are not disabled or changed.
182 +- **Tests:** added two isolated authenticated-mock Chromium journeys in `scripts/accounting-document-workflow.spec.js`: sale save→post→return-to-draft→edit→repost and manual journal post→return→edit→repost→cancel with old ledger history/amount immutability, no duplicate replay, reconciliation and reload. Authoring-side JS syntax parsed **5/5 PASS** via V8 on actual GitHub branch blobs; Chromium E2E, Golden, 3 disposable PostgreSQL, CodeQL, CI and owner real authenticated acceptance **PENDING/NOT VERIFIED** until exact PR-head workflows complete. Do not merge/release on syntax alone.
183 +- **Explicit coverage caveat:** this **is not an 'all financial documents' implementation yet**: purchase source, receipts, payment settlements, expenses, tax-submitted/legal documents, closed fiscal periods, and historical records without valid source-voucher linkage are intentionally not converted automatically. Individual record deletion of a posted voucher is never performed; the visible 'delete/cancel' action records reversal, which is legally and technically distinct. Draft sale deletion is allowed only if not linked to journal/tax doc/payments. No automatic bulk unposting of previously posted records.
184 +- **Risk and follow-up:** `jeReverse` stages multiple saves on the existing debounced sync path; invoice correction requires a server acknowledgment before showing success, whereas manual journal correction relies on existing sync badge. Validate server-side immutable triggers and race/partial write scenarios in independent controlled tests before accepting production correction. If these safeguards fail CI, do not merge. No schema, RLS, Auth, user roles, SMS or live financial documents touched in this branch. Rollback by reverting exact scoped code PR; actual user reversals after future rollout remain immutable historical business events and cannot be erased by code rollback.
185 +
186 ## Current change ledger
187 | 2026-10-07 | Owner requested accounting/product usability refinement from live screenshots: automatic non-user-entered floating-detail codes, contextual in-product guides (especially accounting/chart/dimensions), remove duplicate product internal tax ID and use product code as internal item ID, strengthen in-control product/person search, introduce hierarchical product group/subgroup coding with deterministic 6-digit product codes, and keep sale/purchase commercial-document workspace layout stable while only semantic fields change. | **IMPLEMENTED / LOCAL VERIFICATION PASSED / CI PENDING** | Baseline main = `7e58c75f7d754f378d94ca3f356c1ae580aa7ee3`. Automatic dimension type/value codes, contextual guides, product-code-as-internal-ID, normalized multi-token search, and additive six-digit product coding implemented. Existing historical codes preserved. Commercial sale/purchase workspaces now share a stable `صدور سند تجاری` header/actions layout; duplicate purchase sidebar injection removed; the public selector is the single document-type selector and the legacy internal invoice-kind control is hidden. Local syntax/static/commerce/UX/accounting phases 2–6/Golden checks passed; protected-branch CI remains pending. |
188