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

docs(company): record owner mandate for active-company segregation before coding

davoodmehraban89 committed Oct 14, 2026 at 11:32 UTC a34ccf75251d38adb1a329f7e728e89af33a96f9
1 file changed +7
PROJECT_STATE.md
+7
@@ -254,6 +254,13 @@ The latest user message is the sole source of new instructions. Read AGENTS.md t
254 - **Independent live backend review:** `pg_get_functiondef(public.finora_sync_records)` shows both 2-param and 3-param overloads are PostgreSQL `plpgsql` routines without `EXCEPTION WHEN` partial-success handling, using transaction-scoped upsert/deletes. The browser test confirmed one RPC call for combined reversal+new posted source and no partial server writes on a simulated failed RPC. **Lost-response retries, concurrency, true bank statement reconciliation and offboarding two-user access remain unverified**; no promise of real-world exactly-once payment transfer semantics. Supabase `hcsixhqbyuhpshfwqpjx` ACTIVE_HEALTHY; no production financial rows, grants, roles, Auth/RLS/schema, vendor/SMS or paid resources changed by PR.
255 - **Next verified work:** owner authenticated disposable receipt/payment test (do not use actual bank entries) then controlled separate slices for **expense/income** source correction and **allocated receipts/cheques** after complete settlement/treasury reconciliation. Maintain immutable original accounting and single visible employee-facing document. No owner acceptance claimed yet.
256
257 +### 2026-10-14 Owner request — STRONG ACTIVE-COMPANY ISOLATION throughout ERP — STARTED
258 +- **Explicit new owner requirement:** When selecting company in settings, all normal ERP surfaces must show and operate on **that company only**, across sales/purchase archives, document management, account/customer/vendor, product, stock, bank/payment, treasury, project, ledger and reporting. Never default to all companies or allow cross-company editing, even for the same login. Exception: parent/holding report may show explicitly selected participating subsidiaries with **opt-in**, not mix ordinary source document operation or legal entities. No broad database resets or history reparenting.
259 +- **Live read-only baseline:** protected main `c5a1a93dc13f1cf39dc55d0a47a75a35d7ef50c5` Quality `38530530684`, Security `38530530636`, Release Gate `38530911178`, Pages `38531000314` all SUCCESS. `AGENTS.md` and complete `PROJECT_STATE.md` checked. Existing `js/companies.js` invoice archive filter defaults to `ALL`, `js/invoices.js` honors that filter; `js/sync.js` `getMyContacts/Products/Invoices/Purchases/Payments/Cheques/Expenses` return ALL owner records without company scope. `js/accounting-foundation.js` `afOwned` allows `!companyId`, leaking legacy owner-data into multiple company account contexts. Existing `companies` have `organizationRole='holding_parent'/'subsidiary'` and `parentCompanyId`, but no verified explicit consolidation opt-in. User asks default strict separation, not silent migration.
260 +- **Development scope:** central active-company lookup and strict company-scoped operational getters, safe explicit single-company legacy handling ONLY to avoid deleting/hiding one-company old data; multi-company `companyId`-less documents marked REVIEW/unscoped and never shown/edited in ordinary active company. Newly created contacts, products, cheques and all remaining financially relevant records must be stamped with active company. Company selection validates existing owned company, refreshes all dependent forms and clears stale edit/form context; invoice archive active-company-only with no ALL option. Edit/post/save must not be able to cross company via stale form or ID. Parent/subsidiary consolidated **read-only overview** only for holding and explicit selected child opt-in, with no crossing operational ledger or grants. Full hierarchy/tax/legal consolidation beyond data display remains separately not accepted.
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 ## Current change ledger
265 | 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. |
266