سامانه صدور فاکتور و حسابداری
docs(pilot): record purchase correction implementation and pending independent QA
davoodmehraban89 committed
Oct 14, 2026 at 08:57 UTC
8c34a143c71ebf65789c179a54a4f8fa1d254eee
1 file changed
+6
PROJECT_STATE.md
+6
@@ -197,6 +197,12 @@ The latest user message is the sole source of new instructions. Read AGENTS.md t
197
- **Next dependencies and constraints:** first verify current source and live Supabase read-only, use isolated synthetic read/write fixture for tests and same-commit state notes, PR-head and protected-main Quality/Security/Chromium/Golden/three disposable PostgreSQL plus gated Pages. Do not mutate real production financial records or Auth/RLS/schema. Receipts/payments and expenses/income remain distinct follow-up types and are not implemented by a purchase-only slice.
198
- **Rollback:** revert specific JS/document manager/QA PR. A real user financial reversal is immutable historical evidence and cannot be erased by code rollback. Owner acceptance on actual app is separate from CI.
199
200
+### 2026-10-14 Purchase pilot correction implementation checkpoint — SIX PARSE PASSES, E2E PENDING
201
+- `js/purchases.js`: new posted purchase eligibility on authenticated owner/active company, source-linked posted purchase voucher, current and source open fiscal years, no linked purchase payments, product catalog matches, and nonnegative available stock if the purchase is compensated. `returnPostedPurchaseAsDraft` records linked **posted balancing reversal** and adds a distinct user-owned corrective purchase draft with new unique supplier number/ID and source lineage; `finalizePurchasePilotDraft` posts an explicitly edited replacement through existing purchase journal and waits for `finora_sync_records` server sync acknowledgment; `cancelPostedPurchasePilot` creates compensating posting instead of physical delete; `deletePurchasePilotDraft` is draft-only. Normal new purchase creation remains auto-posted by existing code; editing a correction draft does not auto-post or reset supplier default prices.
202
+- `js/document-management.js` plus `js/journal-ui.js`: purchase register in **same حسابداری ← مدیریت اسناد** area and purchase actions; `js/purchases.js` own list now shows posted/draft/reversed/legacy states and corresponding actions. `js/accounting.js` excludes reversed/correction-draft purchases from derived stock and project costs while retaining historical unlinked purchase treatment. `js/payments.js` disallows allocating payment to unposted/reversed purchase.
203
+- Two synthetic authenticated Chromium journeys appended to `scripts/accounting-document-workflow.spec.js`: posted purchase→UI return→manual edit→draft save→explicit repost with old lines unchanged and balanced, linked history and reload; payment-allocation block, stock-consumption block, cancel with original retained. Fixture adds isolated supplier and purchase accounts. **Six changed JS/Playwright files parsed PASS in V8**, actual DOM, Golden, 3 disposable PostgreSQL, CodeQL and protected release gates **NOT YET RUN** at this checkpoint.
204
+- **Known boundary:** Other document classes (receipts/payments as sources, expenses/income, taxpayer submissions, standalone legacy unlinked) are not touched. Production financial rows and SQL/Auth/RLS/schema remain unchanged. The no-negative-inventory guard is a bounded catalog/derived-stock check, not evidence of fully reconciled warehouse reservations. User authenticated on-site correction acceptance OPEN. Do not merge without tests.
205
+
206
## Current change ledger
207
| 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. |
208