سامانه صدور فاکتور و حسابداری
docs: record safety review before guarding linked-draft UI actions
davoodmehraban89 committed
Nov 22, 2026 at 16:50 UTC
f483c9d2288c816db8824a7f11dbe122dcb1e96b
1 file changed
+7
PROJECT_STATE.md
+7
@@ -614,3 +614,10 @@ Next action: run and inspect Quality on the latest PR212 head. If any browser te
614
- **New *separate* scoped branch:** `fix/issue229-linked-draft-status-20261122`, created from exact PR231 head. Fix **only** the UI classification of a business source with an existing **draft** linked journal in `js/invoices.js::invoiceDocumentStatus` and `js/purchases.js::purchaseDocumentStatus`. Current invoice logic incorrectly labels any linked voucher as posted; purchase logic labels linked draft legacy_review. Ensure conflicting posted source flags against linked draft yield `legacy_review`, and missing linked voucher is not misrepresented as posted solely because link ID is nonempty. Do not alter server RPC/migrations/financial posting, original posted history, generic sync, RLS or permissions.
615
- **Acceptance:** turn exactly the SECOND Issue229 `test.fail` browser case into a normal PASS (leave the purchase Save auto-post expected RED untouched), and strengthen status test for linked draft, conflicting statuses and dangling link, without weakening posted/reversed/tenant-safe gates. Verify syntax and exact-head Quality/WP1/WP2/Security on an isolated Draft PR stacked on PR231; independent Codex-main review before merge. No production/main changes or deployment.
616
- **Next:** commit minimal source/test patch after this pre-code decision and inspect real CI with exact code SHA. Report A–F conservatively; only raise E/C marginally on actual verified successful UI regression, not claim closure of Issue229.
617
+
618
+
619
+### 2026-11-22 — ISSUE229-UI-STATE additional safety audit (decision BEFORE UI guard changes)
620
+- **New verified review finding:** After classifying source-linked journal `draft` correctly, existing `js/invoices.js::invoiceMayEdit` would newly allow editing linked sale drafts through generic sync, which cannot atomically update the journal graph. `js/purchases.js::render` would show Edit/Finalize/Delete on linked purchase drafts; `purEdit` and `purSave` would allow generic business-source edits even though direct linked draft Finalize/Delete is currently unsupported. **Do not ship a UI status fix that opens an unsafe incomplete mutation path.**
621
+- **Bounded mitigation:** in the same isolated PR232 add **client-side defensive read-only guards** for source-linked draft record in invoice edit guard and purchase edit form + Save, and suppress purchase Edit/Finalize/Delete actions for a linked draft until Codex-main implements proper transactional RPCs. Keep visible accurate "draft" status and an explicit pending-lifecycle explanation. These are UI affordance safeguards, **NOT security boundaries** or backend authorization, and must not replace source-linked atomic edits/finalization.
622
+- **Test:** extend existing Issue229 linked-draft Playwright normal-PASS contract to assert linked invoice cannot be directly edited and that purchase actions for linked draft are not falsely offered. Also include effective partially-reversed source status display as posted while immutable posted history is retained. Preserve first purchase Save `test.fail` and both real-JWT product expected-RED markers.
623
+- **Pre-change SHA:** `9259160087d03982355dd2e4b844932d7c6408b1`, Draft PR232; exact-head CI was running, not acceptance. After this note apply minimal UI/test patch and retest full Quality/WP1/WP2/Security on final code SHA. No merge/main/SQL/RLS/Auth/real financial data changes.