@davoodmehraban89 / Factor-easy / commits / 1a53322
Fork 0

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

docs(pilot): record owner correction/cancellation request and immutable-ledger scope

davoodmehraban89 committed Oct 14, 2026 at 08:19 UTC 1a5332250d1ab48bebf2811664e4a0c13f437985
1 file changed +7
PROJECT_STATE.md
+7
@@ -170,6 +170,13 @@ The latest user message is the sole source of new instructions. Read AGENTS.md t
170 - **Source review of all 21 public authenticated-callable SECURITY DEFINER routines** completed using `pg_get_functiondef`, grouped into six admin license mutators (explicit `is_admin`), two read predicates, seven office, five organizational/invitation, one own-profile RPC. Static guard presence does **not** prove correct tenant isolation or absence of privilege escalation. Authenticated two-user revocation/adversarial parameter checks, private RPC exposure, leaked-password protection, backup/restore and migration parity remain OPEN and require appropriate approval/test identities.
171 - **Boundaries:** Owner-directed deferral of F0-01 slowness persists; F0-01/Phase 0 OPEN. Phase 1 audit slice metadata verification PASS only; **Phase 1 owner acceptance NOT CLAIMED**. No JS runtime, production SQL DDL/DML, Auth/RLS/grant change, new identities, financial records, subscription payments or secrets touched. PR Quality/Security and any post-merge exact-SHA gates **PENDING at this checkpoint**; do not claim release until verified. Rollback revert documentation+read-only SQL check.
172
173 +### 2026-10-14 Owner pilot request — allow correction and cancellation of finalized accounting documents — IMPLEMENTATION GATED
174 +- **New explicit owner request:** while Finora is an incomplete pilot, expose in document management an action described as «برگشت سند قطعی به حالت موقت» so previously finalized records can be amended and re-finalized, and provide deletion/cancellation of documents. Owner requests this even for older finalized documents. This is separate from earlier OTP and slow startup scope.
175 +- **Accounting contract verified before implementation:** `js/journal-engine.js` has distinct draft/posted/reversed states and `jeReverse`, `jeCopyVoucherToDraft`, `jeDeleteDraft`; `js/invoices.js` finalizes new sale invoices explicitly with idempotent source-linked journal posting, and blocks edits to posted sources. Existing `public.finora_guard_posted_journal` and child triggers reject direct changes/deletes of posted or reversed vouchers and lines; only posted→reversed with linked reversal ID is allowed. Current docs require immutable posted history and balanced reversals. **Never** grant direct editing/physical deletion of historical posted rows.
176 +- **Safe product interpretation and first slice:** Provide understandable UX for **post→linked reversal→new editable draft→edit→post** preserving original source/voucher and explicit previous-ID provenance; for 'delete' of posted records expose **audited cancellation/reversal**, not physical erase. For never-posted drafts, permit deletion with confirmation and block any linked references. Use explicit confirmation, authorization `requireWrite`, owner/company/fiscal-period checks, and no retroactive mutation of old finance entries. Start with manual journal and sales invoices under «مدیریت اسناد» in an isolated PR; other document types (purchases, receipts, payments, expenses, tax submissions, linked documents, legacy chartless records) require separate type-specific QA/approval; do not present them as implemented. If atomic data persistence cannot be guaranteed, do not enable live controls prematurely.
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 ## Current change ledger
181 | 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. |
182