سامانه صدور فاکتور و حسابداری
docs: record active-company UI scoping fix and two-company regression coverage
davoodmehraban89 committed
Oct 14, 2026 at 12:31 UTC
a16cca20d029c3e551d20c767ac4e60ac20e3fc4
1 file changed
+6
PROJECT_STATE.md
+6
@@ -261,6 +261,12 @@ The latest user message is the sole source of new instructions. Read AGENTS.md t
261
- **Acceptance:** isolated two-company authenticated browser fixture showing same user, different sales and purchases; settings switch company A→B→A refreshes company-specific invoice archive and central manager and purchase list immediately, no 'ALL' escape; switching during edit does not permit cross-company invoice writes; legacy missing-company record held for reconciliation. Full Playwright Chromium/Golden/3 disposable DB and CodeQL release on exact SHA; owner authenticated browser acceptance remains independent/open.
262
- **Rollback:** revert isolated UI/data-filter PR. No live production accounting records mutated.
263
264
+### 2026-10-14 Active Settings company for invoice visibility — IMPLEMENTED ON PR BRANCH / QA PENDING
265
+- **Regression reproduced from main:** `renderCompanies` installed `نمایش همه شرکتها` and `renderInvoices` obeyed that selector, leaking all user-owned companies into the same invoice archive; `purchaseVisibleRecords` returned the owner's whole purchase store without company filtering. No evidence of cross-account RLS bypass: this is a **same-user, multi-company UI scope regression**.
266
+- **Code changed (isolated only):** `js/companies.js` now restricts both invoice seller/header and archive-company selectors to the **sole active company chosen in Settings** (disabled selectors, no ALL), validates company ownership on `setDefaultCompany`, closes any in-flight sales/purchase edits before switching, refreshes document manager and topbar. `js/invoices.js` and `js/purchases.js` fold original/correction versions and **only expose records with companyId === active owned company**, never unassigned records when another company is active; direct stale ID edit/save and print are guarded by active company; `js/print.js` denies stale off-company sale print. Other tenant/company business rows remain unchanged in cloud storage and accounting history. No DB/Auth/RLS/grant migrations.
267
+- **Real-DOM regression authored:** an isolated two-company one-user fixture has separate sale and purchase draft rows plus an unassigned legacy invoice. Check selected Settings company A restricts sale archive, purchase register, central manager, seller header; NO `ALL` selection; Settings B switches all three lists immediately with no reload and excludes A/legacy; off-company direct edit stays denied; switching company during an edit clears the draft context; switching back and app reload preserve separation and both companies' source rows.
268
+- **Verification at checkpoint:** each changed JavaScript file V8-parse and browser test compile are to be checked before PR; exact PR-head Quality, Chromium, Golden accounting, three PostgreSQL databases and Security are PENDING. Do not merge until green. Phase 0 owner affected-ISP login and real authenticated user multi-company acceptance remain OPEN. Rollback by revert scoped code PR.
269
+
270
## Current change ledger
271
| 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. |
272