سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 4, 10:30 UTC
docs: record owner multi-company invoice isolation regression and acceptance gates
davoodmehraban89 committed
Oct 14, 2026 at 12:26 UTC
b83321ce004c7aef1cfd33ec08d6b6789d5893fe
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 regression — invoice/purchase listings must obey active Settings company — STARTED
258
+- **New owner request:** a user belonging to multiple companies must see **only invoices for the company currently selected under Settings**, not combined documents from other companies. Do not delete/migrate historical data. Changing default company must immediately update displayed register. This applies to invoice archive, purchase register, central document management, and must not be bypassed by a stale 'show all companies' dropdown. Existing financial entries and source correction chains must remain intact.
259
+- **Verified starting baseline:** protected main `c5a1a93dc13f1cf39dc55d0a47a75a35d7ef50c5`, `AGENTS.md` plus full `PROJECT_STATE.md` read, live existing invoices code: `renderInvoices` chooses `#filter-invoice-company` and defaults to ALL; `renderCompanies` reinstalls **نمایش همه شرکتها** on each render; `purchaseVisibleRecords` returns all owners' purchases without company scoping. Central manager already filters by `afCompanyId`, but must be tested with both companies. `setDefaultCompany` calls `refreshAllSurfaces` and renders immediately.
260
+- **Fix contract:** derive active company only from owned Settings `default_company_id` or owned first company fallback `afCompanyId` (do not trust unowned arbitrary ID), and **fail closed** when none selected. Remove the cross-company selection from invoice archive, synchronize invoicing seller header to active setting, restrict visible invoice/purchase logical leaf records and direct edit/print entry where necessary, maintain separate original/revision chain per company. Reset any in-progress edited document on company switch to prevent accidental cross-company writes. No RLS/schema/Auth grants/data changes.
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
## 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