@davoodmehraban89 / Factor-easy-2 Mirror · read-only / commits / b027817
Fork 0

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

Mirrored from https://github.com/davoodmehraban89/Factor-easy.git

Synced Dec 3, 20:45 UTC

Preserve Iran enterprise v2 routing after repeated v1 load

davoodmehraban89 committed Sep 30, 2026 at 06:17 UTC b0278172ba2110dcaf9cd0d2edb784417a0fdff5
2 files changed +10 -9
PROJECT_STATE.md
+9 -9
@@ -29,17 +29,17 @@ The worker is the implementation owner/coordinating project manager. The owner h
29 ## Current change ledger
30 | Date | Request / decision | Status | Evidence / next action |
31 |---|---|---|---|
32 -| 2026-09-30 | Owner authorizes `@GitHub` and `@Supabase` to perform the required remaining work without further routine permission prompts and directs the project to continue until executable remaining work is finished. | IMPLEMENTED / FINAL CI VERIFICATION PENDING | Pre-implementation reconciliation: live head `9d9caade2c3e34d7608e540e40b09ab23f0d19e9`; Quality `36639873677` failed only because the Real-DOM test selected `natural` before trying to populate hidden legal-only company fields; all syntax, application, Phase 2–6, enterprise payroll/service-period and Golden Accounting Journey gates passed; Security `36639873830` and Pages `36639873547` passed. Request/authority was recorded at `38beab7f`. This implementation checkpoint fixes only the Playwright ordering: populate registration/holding role while legal, switch to natural, then assert hidden fields are cleared and organization role resets. Product semantics are not weakened. Fresh full Quality/Security/Pages must pass before this row becomes COMPLETED. Supabase remains `ACTIVE_HEALTHY`, 21 migrations through `20260929221754`, RLS on all three public tables, performance advisor clean; 6 reviewed SECURITY DEFINER warnings + leaked-password warning remain. |
32 +| 2026-09-30 | Owner authorizes `@GitHub` and `@Supabase` to perform the required remaining work without further routine permission prompts and directs the project to continue until executable remaining work is finished. | IMPLEMENTED / FINAL CI VERIFICATION PENDING | Request/authority recorded at `38beab7f`. Pre-request Quality `36639873677` failed only because Real-DOM populated a hidden legal-only company field after switching to natural; test ordering was corrected at `23ed19b2`. Fresh Quality `36661125768` then passed syntax, application invariants, Phase 2–6, enterprise behavior, Golden Accounting Journey and the two other Chromium tests, and exposed a deeper real browser defect: after the static v1+v2 enterprise scripts load, `ui.js` dynamically loads v1 again on DOMContentLoaded, so the v2 `enterpriseRender` wrapper is overwritten and navigating to payroll falls back to employees. This checkpoint hardens the v1 dispatcher: when v2 task renderer exists, payroll/benefits/pettyops/costing/group delegate to it even after a repeated v1 evaluation. Product behavior, not the test expectation, is fixed. Fresh full Quality/Security/Pages must pass before COMPLETED. Supabase remains `ACTIVE_HEALTHY`, 21 migrations through `20260929221754`, RLS on all three public tables, performance advisor clean; 6 reviewed SECURITY DEFINER warnings + leaked-password warning remain. |
33 | 2026-09-30 | Expand Finora into a high-assurance Iran-first enterprise ERP governed by current Iranian accounting/tax/VAT/Taxpayer-System/commerce/labor/social-security requirements; include standards-aware statements/chart templates, HR/payroll/benefits/leave, treasury/petty cash, inventory/costing/ABC/performance budgets, intercompany/group controls and compliance traceability. Natural/legal identity, operational activity and group-company structure must remain separate concepts. | IN PROGRESS | Iran compliance baseline: `docs/IRAN_COMPLIANCE_MATRIX_V1.md`. Implemented foundations include starter-chart roles, natural/legal cleanup, employees/contracts/leave/cashboxes/petty-cash/compliance registry, accounting-connected payroll, benefit accruals, petty-cash lifecycle, performance budgets, ABC allocation and intercompany/parent controls. Production migrations `20260929220543`, `20260929220613`, `20260929221252`, `20260929221754` are applied and archived. Do **not** claim statutory consolidation, full tax submission, full HR/CRM, or every Iranian rule complete until their lifecycle/accounting/permissions/tests exist. |
34 -| 2026-09-30 | Daily-use accountant-first ERP: primary `پروژه` becomes `پیمان‌ها`; first-login display name + non-privileged professional role; commercial company-capacity licensing; distinguish multi-company licensing from true holding; improve Chart of Accounts workflow and expand evidence-backed ERP roadmap. | IN PROGRESS | License capacity is live (`licenses.max_companies`, admin RPC, server company-count enforcement); professional role remains separate from system `user/admin`; Chart of Accounts search/filter/hierarchy/safe edit/deactivate exists; roadmap: `docs/FINORA_ERP_EXPANSION_ROADMAP_V4.md`. Final current-head Real-DOM verification is pending the test-order fix above. |
35 -| 2026-09-30 | Preserve approved accountant-first two-tier shell, persistent contextual-panel handle, task-focused navigation, isolated printing, and separate company legal identity/legal form/activity/group metadata. | IMPLEMENTED / FINAL VERIFICATION PENDING | Canonical UX evidence: `docs/FINORA_UX_ACCOUNTING_BENCHMARK_V3.md`; current failure is a Playwright fixture-order defect, not a proven product regression. Browser-PDF tests for A4/A5 isolation pass in run `36639873677`; physical-printer validation remains `NOT VERIFIED`. |
34 +| 2026-09-30 | Daily-use accountant-first ERP: primary `پروژه` becomes `پیمان‌ها`; first-login display name + non-privileged professional role; commercial company-capacity licensing; distinguish multi-company licensing from true holding; improve Chart of Accounts workflow and expand evidence-backed ERP roadmap. | IN PROGRESS | License capacity is live (`licenses.max_companies`, admin RPC, server company-count enforcement); professional role remains separate from system `user/admin`; Chart of Accounts search/filter/hierarchy/safe edit/deactivate exists; roadmap: `docs/FINORA_ERP_EXPANSION_ROADMAP_V4.md`. Final current-head Real-DOM verification is pending the enterprise dispatcher fix above. |
35 +| 2026-09-30 | Preserve approved accountant-first two-tier shell, persistent contextual-panel handle, task-focused navigation, isolated printing, and separate company legal identity/legal form/activity/group metadata. | IMPLEMENTED / FINAL VERIFICATION PENDING | Canonical UX evidence: `docs/FINORA_UX_ACCOUNTING_BENCHMARK_V3.md`. Browser-PDF A4/A5 isolation and expired-license Chromium tests pass in both `36639873677` and `36661125768`; physical-printer validation remains `NOT VERIFIED`. |
36
37 ## Current verified live state — 2026-09-30
38 -- Pre-request live head: `9d9caade2c3e34d7608e540e40b09ab23f0d19e9` (`Make Iran enterprise scripts idempotent in browser`).
38 +- Pre-request live head: `9d9caade2c3e34d7608e540e40b09ab23f0d19e9`.
39 - Request/reconciliation commit: `38beab7f60e1add6e43ebb5e6292dd1447b05da6`.
40 -- Pre-fix Quality `36639873677`: FAIL only at Real-DOM. Failure: test selected `natural`, which immediately hid `#company-reg-input`, then attempted to fill that hidden legal-only field. Other two DOM tests (expired-license enforcement and isolated CSS-paper PDF) passed.
41 -- In that Quality run: JavaScript syntax PASS; application invariants PASS; Phase 2 PASS; Phase 3 static + behavioral PASS; Phase 4 PASS; Phase 5 PASS; Iran enterprise behavior PASS; Phase 6 PASS; 20k reporting performance PASS; Golden Accounting Journey PASS.
42 -- Security `36639873830`: PASS. Pages `36639873547`: PASS.
40 +- Real-DOM ordering repair: `23ed19b219c02f76b78a3ddb00d69016592269c1`.
41 +- Quality `36661125768`: FAIL only at Real-DOM payroll navigation after all accounting/domain gates PASS; exact root cause is repeated v1 script evaluation overwriting the v2 renderer wrapper. This checkpoint repairs the product dispatcher and requires a fresh run.
42 +- Security before this checkpoint: `36639873830` PASS. Pages before this checkpoint: `36639873547` PASS.
43 - Supabase project `hcsixhqbyuhpshfwqpjx`: `ACTIVE_HEALTHY`, PostgreSQL `17.6.1.166`, 21 migrations through `20260929221754 iran_enterprise_financial_controls`.
44 - Public tables: `profiles` 4 rows, `licenses` 4 rows, `records` 97 rows; RLS enabled on all three. `licenses.max_companies` exists with default 1.
45 - Performance advisor: no findings.
@@ -96,7 +96,7 @@ Approved target: `docs/reference/finora-ui-target-v1.jpg` (owner-upload SHA-256
96 - PostgreSQL 17.11 platform upgrade/reindex checks: NOT PERFORMED.
97
98 ## Exact next executable work
99 -1. Verify the fresh implementation head with full Quality/Security/Pages; Quality must include Real-DOM and accounting/domain invariants.
100 -2. If a new failure appears, diagnose the exact current-head failure, fix it without weakening product/accounting invariants, update this file in the same durable commit, and rerun.
99 +1. Verify the fresh enterprise-dispatcher implementation head with full Quality/Security/Pages; Quality must include Real-DOM and accounting/domain invariants.
100 +2. If a new current-head failure appears, diagnose it, fix the product or test harness at the correct layer without weakening accounting invariants, update this file in the same durable commit, and rerun.
101 3. Recheck Supabase migrations/RLS/advisors and record any drift.
102 4. Continue the active Iran-first enterprise ledger only where a complete vertical slice can be implemented and verified; external/manual boundaries stay explicitly NOT VERIFIED.
js/enterprise-iran.js
+1
@@ -13,6 +13,7 @@ function entMoney(v){return Number(v||0).toLocaleString('fa-IR')}
13 function ensureEnterpriseView(){let r=document.getElementById('view-enterprise');if(!r){r=document.createElement('section');r.id='view-enterprise';r.className='view-pane';document.querySelector('.main-surface')?.appendChild(r)}return r}
14 function enterpriseEndServiceEstimate(c){const s=new Date(c.startDate),e=c.endDate?new Date(c.endDate):new Date();if(!isFinite(s)||!isFinite(e)||e<s)return 0;return Math.max(0,Math.round(Number(c.lastMonthlyWage||0)*((e-s)/31557600000)))}
15 function enterpriseRender(task='employees'){
16 + if(typeof entRenderV2==='function'&&['payroll','benefits','pettyops','costing','group'].includes(task))return entRenderV2(task);
17 const r=ensureEnterpriseView(),cid=entCid(),emps=entRows('employees').filter(x=>x.companyId===cid),contracts=entRows('employmentContracts').filter(x=>x.companyId===cid),leaves=entRows('employeeLeave').filter(x=>x.companyId===cid),cash=entRows('cashboxes').filter(x=>x.companyId===cid),petty=entRows('pettyCashFunds').filter(x=>x.companyId===cid);
18 const eo='<option value="">— انتخاب کارکن —</option>'+emps.map(x=>'<option value="'+esc(x.id)+'">'+esc(x.personnelNo+' · '+x.fullName)+'</option>').join('');
19 const views={