سامانه صدور فاکتور و حسابداری
docs(company): log strict company-boundary implementation and multi-company test scope
davoodmehraban89 committed
Oct 14, 2026 at 11:43 UTC
d22d99fefab6027e34fa47eeadd981e879f34d51
1 file changed
+7
PROJECT_STATE.md
+7
@@ -261,6 +261,13 @@ The latest user message is the sole source of new instructions. Read AGENTS.md t
261
- **Acceptance evidence required:** multi-company actual Chromium fixture with distinct invoice, purchase, contact, product, payments, accounts, journal and report data and same displayed invoice numbers; switch company A→B→A yields ONLY active records and selections, active-company create stamps and source mutations fail closed; legacy unassigned not replicated or silently reassigned; parent read-only opt-in aggregate includes only chosen children and child edit lists remain segregated. Existing full Chromium, accounting Golden, 3 disposable PG, Security/CodeQL, exact-main release and Pages. No owner real-browser acceptance from CI; no production ledger/DDL/Auth/RLS/role changes or new paid service.
262
- **Security caveat:** Browser-only filtering of one authenticated user's companies is not itself a database RLS authorization barrier; true member/company permission isolation across separate users/organizations requires dedicated backend RLS/roles approval. Never claim hard server tenant boundary from this UI slice.
263
264
+### 2026-10-14 Active-company boundary implementation — BRANCH + TESTS READY / PR QA PENDING
265
+- **Implementation completed in isolated branch (no release yet):** `js/sync.js` introduces `finoraActiveCompanyId`, `finoraInActiveCompany`, `finoraScopedRows`; all ordinary owner-company getters for invoice, purchase, contact, product, cheque, payment and expense enforce the exact active company. `js/accounting-foundation.js`, `js/phase4-contracting.js`, `js/phase5-enterprise.js` scope chart/journal, contracting and advanced module lists. Two-company legacy rows missing `companyId` are quarantined from operational contexts rather than silently duplicated; one-company legacy remains readable for backwards compatibility but is not migrated. Existing `companies` and `settings` selectors remain account-wide to support authorized company choice.
266
+- **Form/save discipline:** `js/operations.js` actual CRUD overrides and `js/contacts.js`, `js/products.js`, `js/cheques.js`, `js/expenses.js`, `js/purchases.js`, `js/invoice-excel-import.js` now stamp new masters/docs with active `companyId`, guard direct edits by scoped getters and clear stale form IDs on switch. `js/companies.js` validates selected owned-company ID, blocks switch during pending sync, clears stale contact/product/invoice/purchase/payment/cheque/expense edit forms and refreshes surfaces; `js/invoices.js` now filters archive to active company even if an old ALL value survives and refuses posting when form selected company differs from active. Invoice company options and archive selector show only active company, no 'ALL'. `index.html` adds explicit parent+subsidiary opt-ins.
267
+- **Parent-only reporting exception:** holding parent must explicitly enable `showSubsidiaryOverview`, and each actual linked subsidiary must explicitly enable `allowParentOverview`; `finoraGroupOverviewRows` then renders **read-only counts by company** in settings, not mixed invoice edit/ledger or legal consolidated financial reports. No implicit rights from hierarchy, no intercompany elimination, no backend authorization claim. Existing `organizationRole`/`parentCompanyId` reused, no DDL/migration.
268
+- **Synthetic E2E added:** `scripts/accounting-document-workflow.spec.js` seeds two companies with separate same-number invoices, products, parties, purchases, receipts, expenses, cheques and journal vouchers plus orphaned records; verifies A→B→A scoped lists/selector/manager, cross-ID edit denial, orphan quarantine; separate holding/child mutual-opt-in readonly overview test and normal operations remain isolated. **14/14 changed JS/spec files V8 syntax PASS**. Full CI Chromium, accounting Golden, three disposable PostgreSQL, Security, exact-main gated Pages, real owner accept **NOT YET VERIFIED**. No production rows/roles/Auth/RLS/schema or real posted accounting modified.
269
+- **Open accounting/security risks:** one-company legacy orphan records are not automatically assigned. Browser tenant/company scoping within one owner account **is not backend per-company RLS**; a multi-user permission/isolation proof or server policy change needs separate owner authorization and independent tests. Accurate statutory holding consolidation is separate later scope. Do not claim phase owner-accepted from simulated browser tests.
270
+
271
## Current change ledger
272
| 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. |
273