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

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

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

Synced Dec 3, 23:15 UTC

docs: record ADR216 purchase Save expected-RED browser acceptance scope

davoodmehraban89 committed Nov 22, 2026 at 08:35 UTC 2fac41454c156272784eb5ec8cd6d6226152331b
1 file changed +7
PROJECT_STATE.md
+7
@@ -514,3 +514,10 @@ Next action: run and inspect Quality on the latest PR212 head. If any browser te
514 - **Coverage gap and reuse:** Effective `supabase/migrations/20261117110000_wp1_autopost_source_link_atomic.sql` handles both `sale/invoices` and `purchase/purchases`. Existing `supabase/tests/wp1_phase1a_stage1_sale_purchase_negatives.sql` executes purchase positive plus invalid accounts using SQL role simulation, but `scripts/wp2-source-autopost-jwt-e2e.mjs` proves **only sale** using a genuine Auth-issued user token over HTTP and never validates the matching **purchase** path, audited replay or posted-source guard as JWT owner. This is specific unverified behavior, not a reason to reimplement existing purchase code or add another engine.
515 - **QA-only scope:** new branch `qa/purchase-source-jwt-20261122` from green PR227 HEAD; extend same existing WP2 script and synthetic approved account role snapshot to include legitimate `purchase_default` expense and `payable_control` liability. Test persisted **credit purchase** source → real JWT `finora_journal_autopost`, debit purchase expense and credit accounts payable, source links/status/counter/audit, replay with different caller voucher ID, and authenticated posted purchase data/link tamper rejection; assert unchanged persisted records, audit and counter. Keep existing sale/Auth/tenant tests unchanged. Only existing PROJECT_STATE, docs/EXECUTION_STATUS and docs/ACCOUNTING_CORE_ROADMAP_V1, and WP2 script may change; current WP2 path filter already covers this file. No SQL migration, financial JS, RLS, production settings, deployed data or main change.
516 - **Acceptance:** exact SHA WP2 real Auth/JWT local Supabase test, Quality/WP1/Security gates, preserve RED and remedy only a proven test/setup mismatch. Detect actual accepted invalid purchase edit as a product defect for Codex main. Any status short of completed SUCCESS must remain pending. Passing does **not** mean draft-first source linkage/ATF permanent numbering/cheque/history/production acceptance. Keep parent PR227 GREEN head unchanged, child PR Draft for independent Codex review.
517 +
518 +
519 +### 2026-11-22 — FIN-QA-ADR216-PURCHASE-SAVE-RED (decision recorded BEFORE test work)
520 +- **Verified preceding checkpoint:** Draft PR228 exact HEAD `ae6a0557d575389853c4545ca99ec57c8015a0e0` Quality 44986537956 SUCCESS (251/251 Chromium +4/4 auxiliary, all three DB jobs), WP1 44986538027 SUCCESS (both ledger and local stack jobs), WP2 44986537948 SUCCESS (genuine Auth JWT sale+credit purchase source→**posted** voucher, replay, forged edit/delete guards), Security 44986537938 SUCCESS (CodeQL+safety; Dependency Review SKIPPED). PR228 still Draft/unmerged; protected main unchanged `dab1a45fcfc4f12e675cfe055e477138cd3e99fa`.
521 +- **Discovered P0 product mismatch documented in Issue229:** Actual staged `js/purchases.js::purSave` invoked by ordinary visible Save button immediately calls `jeRpcAutoPost('purchase',record.id)` and commits a posted voucher; current `js/invoices.js::invoiceDocumentStatus` mislabels any journalVoucherId as posted even if linked journal status is draft; `js/purchases.js::purchaseDocumentStatus` labels linked drafts as `legacy_review`. These fail ADR0216 source-linked draft-first *before* independent authorized posting. Existing `scripts/accounting-document-workflow.spec.js` has formal SALE Save→draft→explicit post journey but lacks matching PURCHASE Save no-post/linked-draft acceptance. This is not a reason to rewrite engine.
522 +- **Bounded QA-only execution:** branch `qa/draft-first-save-red-evidence-20261122` stacked on immutable PR228; append 2 precise **expected failing** Playwright tests to EXISTING `scripts/accounting-document-workflow.spec.js`. One should exercise actual browser purchase Save button against existing isolated mock server and require no posting, source+linked draft, so it exposes current auto-post defect. Other should require both sale and purchase status selectors to recognize a posted-*false* linked journal draft as draft, rather than treating presence of a link as posted/legacy. Label `test.fail` with Issue229/ADR216 and explicit TODO to remove expected-failure annotation when product implementation is delivered. This is a *RED acceptance contract*, NOT proof of working product or a test-suite weakness. Do not change production JS, SQL migrations, RLS/Auth, issue owner-held financial modules, or hosted/production data.
523 +- **Exit criteria:** actual Playwright runner reports 2 **expected failures** reaching the intended assertions (not a setup/network error), while Quality and any triggered WP1/WP2/Security workflows remain inspectable on exact SHA. If fixture/setup fails, repair only fixture/test; do not change financial code or weaken conditions. Handoff to Codex main: implement canonical source-linked draft-first transaction and correct both status selectors, then remove `test.fail` and prove actual PASS with real JWT browser/DB tests. No implementation merge/deploy and no Issue216/229 closure from this QA branch.