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

docs(qa): record purchase correction Save RED, exact-code gates and WP1 pending

davoodmehraban89 committed Nov 22, 2026 at 18:47 UTC 77e3c5198f4a8f85bbb1b4ac4d90151a43d133d7
1 file changed +10
PROJECT_STATE.md
+10
@@ -653,3 +653,13 @@ Next action: run and inspect Quality on the latest PR212 head. If any browser te
653 - **Bounded QA-only plan:** extend `scripts/accounting-document-workflow.spec.js` with a **real browser expected-product-RED** for corrected posted purchase Save (use existing `createPostedPurchase`, `beginPurchaseAmendment`, genuine form quantity change, Save, server records and exact original-voucher fingerprint). Validate setup before `test.fail(true)`; expected result is corrected source `draft` + source-linked balanced `draft` voucher, **no posted correction voucher on Save**, preserve original posted source+voucher and reversal audit; a successful legacy repost must be observed as RED, NOT celebrated as a fix. Preserve prior happy-path tests as transparent legacy baseline for later migration. Do not touch `js/purchases.js`, SQL, migration, RPC, grants, RLS, Auth, production or posted financial history.
654 - **Acceptance/evidence:** exact-code four-gate CI and real JWT WP2 markers, since WP2 trigger now covers this spec. Keep Issue229 and Issue216 P0 OPEN; Codex-main still responsible for actual server-atomic lifecycle with separately approved test-DB changes. Do not raise C/F from negative QA evidence.
655 - **Prechange gates on docs-only head:** [Quality 45035378143](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45035378143), [WP1 45035378134](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45035378134) active at continuation; [WP2 45035378122](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45035378122) and [Security 45035378174](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45035378174) SUCCESS. No speculative status transfer between commits.
656 +
657 +
658 +### 2026-11-22 — FIN-P0-229-PURCHASE-AMEND-SAVE: verified browser regression and security checkpoint
659 +- **Scope and evidence:** [Draft PR233](https://github.com/davoodmehraban89/Factor-easy/pull/233), code SHA `3de78a9b04e4196d4b61ab51b6f6834c4e359385`. Added one Chromium expected-PRODUCT-RED to `scripts/accounting-document-workflow.spec.js`: "P0 #229 expected RED: posted purchase correction Save must remain linked accounting draft". The actual employee UI opens a posted purchase amendment, changes quantity, saves, waits until server persisted and UI reset, asserts the original purchase/journal/lines byte-for-byte immutable (outside `test.fail(true)`), then requires a corrected source `draft` with balanced source-linked journal `draft` and **no already posted corrective journal** on Save. Today `js/purchases.js::purchaseSaveSeamless` invokes `finalizePurchasePilotDraft(newId)` (line 113) during Save: **P0 product behavior still RED**. Existing legacy happy-path test transparently describes the old behavior, and must be revised only after the actual fix.
660 +- **Exact CODE Quality:** [45036039138](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45036039138) SUCCESS, `255 passed (4.3m)` Chromium + `4 passed` Pages; new correction expected-red test ran **31/255**. Existing purchase first Save, sale linked-draft Save and linked state expected-red tests remain; now FOUR `test.fail(true)` markers on PR233 QA baseline. A fixture error before xfail would have been unmasked failure.
661 +- **Exact CODE WP2:** [45036039174](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45036039174) SUCCESS. Real disposable Auth JWT proves `FINORA_SOURCE_JWT_ATOMIC_PASS`, `FINORA_PURCHASE_JWT_PARITY_PASS`, and **both** PRODUCT expected-red `FINORA_ISSUE229_APPROVAL_EXPECTED_RED`, `FINORA_ISSUE229_PURCHASE_APPROVAL_EXPECTED_RED`; seller commerce:create JWT **still posts sale and purchase without accounting:approve via legacy autopost**. Not a security fix.
662 +- **Exact CODE Security:** [45036039150](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45036039150) SUCCESS; conditional Dependency Review SKIPPED. **WP1:** [45036039132](https://github.com/davoodmehraban89/Factor-easy/actions/runs/45036039132) `in_progress` with conclusion `none` at document checkpoint; supabase-local-stack job SUCCESS, ledger-negative-and-behavior ongoing. **Do not claim 4/4 GREEN until exact-code WP1 concludes.** A documentation successor commit will trigger independent branch CI and may cancel a still-running predecessor because of concurrency; retain the precise evidence above, never transfer verdicts across commits.
663 +- **Independent change-scope audit:** six of six static diff checks passed: PR233 changes only `PROJECT_STATE.md`, `scripts/accounting-document-workflow.spec.js`, and `.github/workflows/free-supabase-local-e2e.yml`; WP2 now fires when `js/purchases.js` or the browser accounting contract changes; no modifications to SQL, financial JS, RPC, grants, RLS, Auth, production, protected main `dab1a45fcfc4f12e675cfe055e477138cd3e99fa`, posted history, deployment or merge. Draft PR233 and Issue229 OPEN; separate UI Draft PR232 still unmerged. Review summary posted to PR233 and [Issue229](https://github.com/davoodmehraban89/Factor-easy/issues/229).
664 +- **Conservative A–F progress (only owner END-of-session):** A architecture/audit **90%**, B server accounting core **50%**, C atomic source-linked draft lifecycle **20%**, D ledger health **55%**, E UX **53%**, F release readiness **10%**. No increase: test reproduces another P0, not a functional repair. These are subjective milestones.
665 +- **Next:** Codex-main server-atomic create/update for sale/purchase AND corrective purchase draft, linked balanced journal draft; separate real `accounting:approve` Finalize, disable legacy commerce:create-only autopost bypass, preserve immutable posted source/reversal/audit, deterministic idempotency/rollback and permanent numbers. **Explicit owner authorization still needed** for schema/permissions/RPC/migration even on disposable test database; plain "continue" not approval. Existing expected-red tests should be normal green only after correct product implementation. No Production writes.