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

docs(qa): define payment correction draft-first browser contract

davoodmehraban89 committed Nov 22, 2026 at 23:42 UTC 14e8f606156324f9565095a24cfcd3510d79b4af
2 files changed +13
PROJECT_STATE.md
+7
@@ -731,3 +731,10 @@ Next action: run and inspect Quality on the latest PR212 head. If any browser te
731 - **QA-only code:** extended the existing `scripts/accounting-document-workflow.spec.js` with 4 loaded-browser, authenticated synthetic sync fixture scenarios: unallocated receipt, payment, expense, income Save. Existing `fakeServer/authenticatedMockBrowser` test harness reused; expense/income scenarios add only synthetic expense/other-income ledger role accounts to isolated fixture. They run actual `commitSavePayment` / active runtime `window.commitSaveExpense`, inspect synchronized source, linked voucher/lines and strict status/amount/one-voucher source graph.
732 - The new `issue238AssertKnownRedOrDraft` invokes `test.fail(true)` **only if exact known current POSTED defect fingerprint is observed**, then asserts desired linked DRAFT. A corrected linked DRAFT returns normal PASS; unknown or orphan/unbalanced/third-state result throws as normal CI failure BEFORE setting xfail. Print specific `FINORA_ISSUE238_SAVE_EXPECTED_RED` markers only on observed known problem. These tests prove loaded client UI behavior against synthetic Supabase, **not** a real JWT/server authorization decision.
733 - **Not yet verified** on new exact SHA: Quality browser and full repo jobs, WP1/WP2/Security must be checked after code commit. No finance app `js/`, SQL/migrations/schema/RLS/grants, protected main, Production, merging or release changed. Issue216/229/238 remain open; phase estimates unchanged.
734 +
735 +### 2026-11-22 — FIN-QA-ISSUE238-PAYMENT-CORRECTION / pre-code decision
736 +- **Owner continuation remains QA-only.** No explicit authorization for financial server/RPC, SQL migration, schema, RLS/Auth/grants, protected `main`, Production, merge or release; do not cross that boundary.
737 +- **Read-only finding at inherited code SHA `b2a9a6238eae5618840a17137bef8f91fe80a910`:** the existing normal-PASS browser test `treasury amendment in the same form preserves one record and same reference without on-open ledger writes` asserts that a posted receipt/payment correction immediately reverses the old voucher and posts the new correction. This celebrates the exact lifecycle behavior that ADR216 disallows. `js/payments.js::paymentAmendPosted` executes `jeReverse` followed by `jePostSourceRecord`; the loaded UI Save path calls it for posted receipt/payment corrections. The same source audit already calls out this path at `js/payments.js:86-128`.
738 +- **Scope of next QA correction:** keep the UI-only no-write-on-open/reference-preservation regression as a normal PASS; replace the misleading auto-post acceptance with strict browser expected-RED tests for both inbound receipt and outbound payment corrections. Drive the actual edit→Save DOM path, preserve original source and original voucher lines, require the reversal history to remain, require exactly one source-linked balanced **DRAFT** correction voucher, and require that draft not be counted as an effective posted treasury balance. Current exact defect fingerprint: correction source and linked voucher immediately `posted`, with original reversal present. A third state (orphan, unbalanced, multiple links, missing reversal/history, partial sync) must be an ordinary CI failure before xfail. A future correct state must force removal of xfail and become normal PASS.
739 +- **Important design alignment:** the existing purchase-correction expected-RED contract expects the original reversal history to be retained while the *new* correction stays DRAFT; this payment test must use the same distinction. It must not silently downgrade or delete the original posted voucher.
740 +- **Files allowed:** existing `scripts/accounting-document-workflow.spec.js`, `PROJECT_STATE.md`, `docs/EXECUTION_STATUS.md` only. No app `js/`, SQL/migrations, workflows, server/Auth/RLS/grants, financial data or history changes. Verify final exact SHA Quality/WP1/WP2/Security if triggered; report product defect separately from green QA.
docs/EXECUTION_STATUS.md
+6
@@ -213,3 +213,9 @@
213 - **شاهد مالی واقعی (محیط disposable):** کاربر غیرمالک با JWT واقعی دارای `commerce:create` و فاقد `accounting:approve` با RPC موجود `finora_journal_autopost` هم **فروش** و هم **خرید اعتباری** را posted کرد؛ بازخوانی PostgreSQL برای خرید: منبع و یک سند مرتبط posted، بدهکار هزینه ۱۷۰ و بستانکار پرداختنی ۱۷۰، audit با همان actor و شماره قطعی دوم. نشانگرهای `FINORA_ISSUE229_APPROVAL_EXPECTED_RED` و `FINORA_ISSUE229_PURCHASE_APPROVAL_EXPECTED_RED` هر دو در همان WP2 موفق ثبت شدند.
214 - **طبقه‌بندی:** گیت‌ها PASS آزمون شناسایی نقص، **قرارداد محصول FAIL/P0**؛ این اجرا به معنی رفع مشکل یا قابل انتشار شدن محصول نیست. PR231 ادغام‌نشده، Issue216/229 باز؛ main، داده واقعی، migration مالی، Auth/RBAC و تاریخچه قطعی تغییر نکرده است.
215 - **مالک و نقطه ادامه:** Codex اصلی یک مسیر تراکنشی یکپارچه source+linked-draft برای Save/Update/Delete و قطعی‌سازی مستقل با مجوز `accounting:approve` ارائه کند؛ مسیر old autopost نباید دورزننده مجوز باشد. پس از اصلاح، دو تست expected-RED مرورگر و هر دو تست JWT باید به آزمون عادی رد نقش ثبت‌کننده/موفقیت تأییدکننده تبدیل شوند و Quality/WP1/WP2/Security روی کد نهایی و بررسی تاریخچه موفق شوند. شماره گیت‌های بالا مربوط به SHA کد است؛ Commit مستنداتی بعدی نیازمند بررسی جداگانه است.
216 +
217 +
218 +### ۲۰۲۶/۱۱/۲۲ — آزمون اصلاح دریافت/پرداخت قطعی؛ تصمیم پیش از کدنویسی
219 +- یک آزمون مرورگر قبلی به‌اشتباه ثبت اصلاح دریافت/پرداخت را با برگشت سند قبلی و قطعی‌سازی فوری سند اصلاحی، PASS عادی می‌دانست؛ این رفتار با ADR216 سازگار نیست. مسیر فعال Save از `paymentAmendPosted` در `js/payments.js` عبور می‌کند.
220 +- محدودهٔ مجاز فقط QA است: آزمون عادی بازکردن فرم و عدم ایجاد ثبت در زمان بازکردن حفظ می‌شود؛ برای اصلاح دریافت و پرداخت دو آزمون مرورگر expected-RED ساخته می‌شود. اصل سند و آرتیکل‌های قطعی آن باید حفظ شوند؛ سابقهٔ برگشت باقی بماند؛ سند اصلاحی جدید باید متصل، متوازن و DRAFT باشد و تا تأیید حسابداری در ماندهٔ قطعی خزانه محاسبه نشود.
221 +- هیچ مجوز تازه‌ای برای تغییر SQL/RPC، اسکیما، RLS/Auth، کد اجرایی مالی، main یا Production وجود ندارد. فقط فایل آزمون موجود و اسناد وضعیت مجازند.