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

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

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

Synced Dec 3, 20:45 UTC

Rebuild accountant navigation and company identity UX

davoodmehraban89 committed Sep 30, 2026 at 00:24 UTC 4918150787d11174af91149cb581b675237b8f3a
10 files changed +125 -23
.github/workflows/quality.yml
+1 -1
@@ -37,7 +37,7 @@ jobs:
37 run: node scripts/golden-accounting-core-check.mjs
38 - name: Install browser smoke-test runtime
39 run: |
40 - npm install --no-save @playwright/test@1.55.0
40 + npm install --no-save @playwright/test@1.55.0 pdf-lib@1.17.1
41 npx playwright install --with-deps chromium
42 - name: Real DOM smoke
43 run: |
PROJECT_STATE.md
+1 -1
@@ -34,7 +34,7 @@ Before doing any project work:
34 ## Current change ledger
35 | Date | Request / decision | Status | Evidence / next action |
36 |---|---|---|---|
37 -| 2026-09-30 | Owner rejects the current first-pass accountant UX as insufficient and requests a broader evidence-based redesign synthesis from strong Iranian and international accounting/ERP products. Apply the best compatible patterns to Finora without cloning a vendor: preserve the narrow primary rail + adjacent contextual subsystem panel; remove repeated/unrelated accounting-document surfaces leaking into other subsystem workspaces; replace the disappearing `×` close affordance with a persistent edge-mounted collapse/expand handle so the contextual panel is always recoverable; and extend company definition so operational activity type (trading/service/manufacturing/etc.) is separate from person/legal identity and legal form (natural person, joint-stock/private/public, LLC, partnership, etc., plus institution/public/government/other where applicable). User supplied four current Finora screenshots as direct defect/design evidence. | IN PROGRESS | Benchmark reviewed across Iranian patterns (Rahkaran/System Group, Sepidar, Parmis Star, Mahak and prior repo research) and international official structures (Microsoft Dynamics 365 Finance, Oracle Fusion Financials, SAP S/4HANA Finance, Xero, Zoho Books, QuickBooks, Sage Intacct, Acumatica, Odoo/NetSuite references). Strong recurring pattern: stable top-level financial domains, task-focused contextual navigation, global create/search, separation of master/setup vs transactions vs reports, and legal-entity/company context distinct from operational accounting classification. Current screenshots prove `اسناد حسابداری` is leaking below Inventory and Settings task content and the contextual panel uses a top `×` that becomes unavailable after collapse. Before product edits, reconcile latest CI: run `36627449874` on `fb275453` passed syntax + application + Phase 2–6 + Golden Journey; only Real-DOM failed on non-formal paper-kind expectation and a brittle raw-PDF regex parser. Fix that verified regression in the same UX slice, then implement shell/task/company changes, extend real-DOM gates and record verified evidence. No schema/RLS/auth/role change is planned; company metadata remains inside the existing records model. |
37 +| 2026-09-30 | Owner rejects the current first-pass accountant UX as insufficient and requests a broader evidence-based redesign synthesis from strong Iranian and international accounting/ERP products. Apply the best compatible patterns to Finora without cloning a vendor: preserve the narrow primary rail + adjacent contextual subsystem panel; remove repeated/unrelated accounting-document surfaces leaking into other subsystem workspaces; replace the disappearing `×` close affordance with a persistent edge-mounted collapse/expand handle so the contextual panel is always recoverable; and extend company definition so operational activity type (trading/service/manufacturing/etc.) is separate from person/legal identity and legal form (natural person, joint-stock/private/public, LLC, partnership, etc., plus institution/public/government/other where applicable). User supplied four current Finora screenshots as direct defect/design evidence. | IN PROGRESS | Benchmark reviewed across Iranian patterns (Rahkaran/System Group, Sepidar, Parmis Star, Mahak and prior repo research) and international official structures (Microsoft Dynamics 365 Finance, Oracle Fusion Financials, SAP S/4HANA Finance, Xero, Zoho Books, QuickBooks, Sage Intacct, Acumatica, Odoo/NetSuite references). Strong recurring pattern: stable top-level financial domains, task-focused contextual navigation, global create/search, separation of master/setup vs transactions vs reports, and legal-entity/company context distinct from operational accounting classification. Current screenshots prove `اسناد حسابداری` is leaking below Inventory and Settings task content and the contextual panel uses a top `×` that becomes unavailable after collapse. Root cause confirmed in code: `ensureJournalView()` created `#view-journal` with class `view` instead of the shell's canonical `view-pane`, so `switchView()` never hid it; this is why the screenshots show Accounting Journal under unrelated modules. Implementation in this checkpoint converts it to a true view pane, removes the internal `فاز ۳` production badge, adds the persistent edge handle and global quick-create menu, and separates company person/sector/legal-form/activity metadata without a database schema change. Benchmark synthesis is archived in `docs/FINORA_UX_ACCOUNTING_BENCHMARK_V3.md`. Before product edits, reconcile latest CI: run `36627449874` on `fb275453` passed syntax + application + Phase 2–6 + Golden Journey; only Real-DOM failed on non-formal paper-kind expectation and a brittle raw-PDF regex parser. Fix that verified regression in the same UX slice, then implement shell/task/company changes, extend real-DOM gates and record verified evidence. No schema/RLS/auth/role change is planned; company metadata remains inside the existing records model. |
38 | 2026-09-29 | Owner clarified the navigation interaction after reviewing Rahkaran web: primary modules must NOT expand accordion-style beneath themselves; selecting Accounting/another module must populate the adjacent vertical contextual panel, matching the approved screenshot. Owner also supplied three real browser-print PDFs proving a severe print-isolation regression: formal invoice and pre-invoice include application UI pages before the invoice; non-formal A5 also includes UI pages and opens with incorrect A4/default behavior. Research Rahkaran web/module concepts, then repair all invoice print modes so only the print document enters the print tree with deterministic paper/orientation/pagination. | IMPLEMENTED / CI FINAL VERIFICATION PENDING | External review confirms Rahkaran Cloud is web-delivered and organized as modular financial/sales/logistics/etc. solutions; Rahkaran accounting training exposes distinct account-definition, voucher-entry and reporting tasks rather than one dumped workspace. User PDFs are stronger direct evidence for the print defect: UI is printed before the invoice in all three samples. Rahkaran review confirms the useful pattern is modular task separation (base information/account structure, voucher operations, reporting) while the owner explicitly rejects Rahkaran-style cascading expansion for Finora. Current Finora desktop already renders those groups in the adjacent vertical `module-panel` rather than nested beneath the rail, so that interaction is retained and now treated as a contract. Print root cause confirmed: browser printing still depended on hiding the live application DOM; the supplied PDFs demonstrate that this isolation is not reliable enough. This checkpoint moves invoice/electronic-document printing into a dedicated same-origin iframe document containing only invoice pages, with explicit CSS `@page` A4-landscape for formal/pre-invoice and A5-landscape for non-formal, plus a strict live-DOM fallback. Real-DOM tests now assert zero application-shell nodes in the print document and Chromium PDF generation checks actual A4/A5 landscape MediaBox dimensions. Immediate pre-CI syntax review caught over-escaped regex literals in the newly added PDF MediaBox test itself (product print code parsed cleanly); `6686c9ed` replaced them with explicit RegExp constructors and the full DOM smoke script parses successfully. Superseded Quality run `36627088224` on `49c16bcf` then passed the repository syntax gate and failed only because `quality-check.mjs` still required the removed legacy local-page-size variable `const a4Landscape=isFormal||isPreInvoice`. `cc4fa1f` updated the general quality contract. Quality run `36627278247` then passed syntax, application invariants and Phase 2, and its Phase 3 engine checks themselves printed PASS before a second stale print needle in `phase3-check.mjs` stopped the workflow. This checkpoint updates that remaining Phase 3 static print contract to the isolated-frame/A4/A5 invariants; no accounting behavior is changed. Final implementation head before this docs-only checkpoint is `fb275453`: isolated print implementation `49c16bcf`, test-syntax repair `6686c9ed`, general print gate `cc4fa1f`, Phase 3 print gate `fb275453`. Superseded runs `36627088224` and `36627278247` are fully diagnosed stale-gate failures, not product-print failures. No failure notification is currently present for `fb275453`, but push-run IDs/success notifications are not exposed by the connector, so latest Quality/real-DOM/PDF acceptance remains NOT VERIFIED rather than assumed PASS. Supabase was rechecked ACTIVE_HEALTHY with 17 migrations through `20260929193357`, and RLS remains enabled on profiles/licenses/records; this slice made no database/schema/RLS/auth changes. Physical printer behavior remains NOT VERIFIED even after browser-PDF acceptance. |
39 | 2026-09-29 | Owner rejected the current workspace-dump navigation. Redesign Finora around the approved two-tier enterprise shell shown in the canonical screenshot: primary module rail + rich contextual subsystem menu; replace `خانه` with `داشبورد`; keep owner-approved domain grouping such as sales/purchases/contacts under بازرگانی; give accounting and every major module organized groups (e.g. پایه/عملیات/دفاتر و گزارش‌ها/ابزارها) with one clear action/view per menu item. Before implementation, research multiple Iranian accounting/ERP products (not one vendor), official product structures/demos plus user/accounting-community feedback, synthesize patterns without copying a vendor, then migrate existing working views into the hierarchy without feature loss or fake modules. | IMPLEMENTED / CI FINAL VERIFICATION PENDING | Research completed across the approved screenshot, live shell, Sepidar official system/accounting pages and training UI, Rahkaran/System Group module structure, Holoo task/report material, Gheyas/user feedback and independent review feedback. Synthesis is recorded in `docs/FINORA_INFORMATION_ARCHITECTURE_V2.md`: nine primary business modules, rich grouped contextual menus, task-level navigation, no `خانه`, no standalone `کالا`, no generic `ERP`, and no fake future modules. IA contract committed at `9631f6ef`. This implementation checkpoint replaces the rail with Dashboard/Accounting/Commerce/Treasury/Projects/Inventory/Fixed Assets/Reports/Settings; removes `خانه`, standalone `کالا` and generic `ERP`; expands Accounting into grouped base/operations/books-report commands; and introduces task-level workspace focusing so account chart, floating dimensions, rules, fiscal years, branches, projects, journal entry/register, reports, inventory/assets/data-center tasks no longer dump unrelated cards together. Commerce retains contacts/products/sales/purchases. Real-DOM gates are extended to verify the new hierarchy and focused task behavior. Pre-CI review found and corrected one contradictory legacy `erp` rail assertion, added task-aware command-search routing/context, and hides the empty fiscal/branch grid wrapper when another accounting task is focused. Quality run `36624026541` on `dcb0d4ab` proved JavaScript syntax PASS but exposed a stale Phase 5 gate that still required every Phase 5 view to map to the removed generic `erp` module. The gate is updated in this checkpoint to verify the new canonical ownership (`inventory`, `assets`, accounting currency, settings data/integrations), reject deprecated `home/catalog/erp` rail entries, and require the new accounting hierarchy. Dashboard is also rebuilt in this checkpoint to match the approved analytical direction without fabricated values: white enterprise KPI cards for assets/cash/receivables/payables, six-month cash-in/out SVG from actual payment records, account-status bars, task-level quick access and latest journal vouchers. All values are derived from the existing ledger/operational data and remain zero/empty when no production accounting data exists. Quality run `36624183478` on the pre-dashboard `c254e5f1` passed syntax, application invariants, Phase 2–6, Golden Journey and browser installation; Real-DOM alone failed because `openModule()` rendered the selected task and then `switchView()` reset the contextual panel before the non-rerendering navigation returned. The product navigation state bug is fixed here by making `openModule()` complete the canonical task navigation/rerender path. The analytical dashboard checkpoint `96adf600` is retained. Direct-view compatibility is hardened: switchView clears any previous task filter; task navigation then reapplies the requested focus. Real-DOM verifies focused mode and reset-to-full-view behavior. Settings is also decomposed into task-level routes: company, account/password, invoice defaults, operational settings, data/backup, integrations, about, and admin/license. Topbar company and fiscal-year pills now deep-link directly to their canonical tasks instead of dumping the full settings page. Real-DOM adds a focused company-settings assertion. Run `36624545469` on `f3f15aa` proved the new enterprise shell/task navigation Real-DOM PASS; the only failure was the separate expired-license test because the dashboard visual rebuild had removed the legacy `user-license-status-badge` element that `updateLicenseDisplay()` owns. This is a real UI regression, not a test-only issue. The badge is restored inside the new dashboard header in this checkpoint, preserving license visibility/enforcement while keeping the new analytical layout. Real-DOM acceptance is extended once more to render the redesigned dashboard under the stubbed authenticated session and require the assets KPI, cash-flow SVG and recent-journal surface to exist before continuing accounting/inventory/print checks. CI verification is required next. Durable implementation chain: IA research/contract `9631f6ef`; shell/task routing `22bb7a27`; navigation/search gates `dcb0d4ab`; stale CI ownership gate repair `c254e5f1`; analytical dashboard `96adf600`; module-open state fix `4cecc1f6`; direct-view task reset `f3f15aa2`; focused settings `b2fff128`; restored license badge `9b99e7e1`; dashboard DOM gate `761131c6`. Run `36624545469` proved the enterprise shell/task navigation itself passes real DOM and all Phase 2–6/Golden gates; its remaining expired-license failure was caused by the dashboard badge regression fixed at `9b99e7e1`. No failure notification has been observed yet for the latest code head `761131c6`, but the exact latest push-run ID is unavailable through the connector, so final combined CI remains NOT VERIFIED. |
40 | 2026-09-29 | Continue post-release hardening after the executable accounting/database fixes; close remaining verifiable acceptance gaps without claiming external/manual checks. | IN PROGRESS | Browser checkpoint `2c6bab32` adds real-Chromium expired-license enforcement: expired subscription renders expired, `canWrite()` is false and `requireWrite()` blocks mutation. This checkpoint also adds a deterministic 20,008-line Phase 6 reporting workload covering rollup/trial-balance equality, P&L correctness, ledger row preservation and a 5-second CI regression ceiling. Pre-CI review caught that the dated ledger filter correctly excludes the two February seed lines, so the expected January workload is 20,006 rather than 20,008; the assertion is corrected in this checkpoint before acceptance. Latest executable code head is `9822bad8`: it corrects the dated performance expectation before acceptance. The prior superseded run `36621990092` on `b992e486` confirms syntax, application invariants and Phase 2–5 (including depreciation reversal) all PASS, then fails only on the now-corrected January ledger-row expectation before Golden/DOM steps. Additional live production rollback-only security QA exercised all three admin license mutation RPCs (`cancel`, `extend`, `set`) under a non-admin authenticated JWT; all were denied with the shared internal admin guard, while `is_admin=false`; transaction rolled back. Supabase performance advisor remains clean; security advisor still reports the five intentional SECURITY DEFINER-callability warnings plus leaked-password protection disabled. Latest `9822bad8` push-run ID remains unavailable through the connector and no failure notification has appeared yet, so combined Quality/real-DOM remains NOT VERIFIED. |
docs/FINORA_UX_ACCOUNTING_BENCHMARK_V3.md new
+43
@@ -0,0 +1,43 @@
1 +# Finora UX / Accounting Benchmark V3 — 2026-09-30
2 +
3 +## Why this revision exists
4 +The owner rejected the first-pass accountant UX as too weak. Four current Finora screenshots show two concrete defects: the Accounting Journal workspace leaks below unrelated Inventory/Settings workspaces, and the contextual subsystem panel uses a top close button that disappears with the panel. This revision treats accountant workflow and information architecture as a product contract, not decoration.
5 +
6 +## Representative benchmark set
7 +Iran / local-market patterns reviewed: Rahkaran/System Group and Sepidar (module-oriented enterprise/SME accounting), Parmis Star (modular accounting/treasury/inventory/commerce), Mahak (task-oriented commerce/treasury/accounting), plus the prior repository research covering Holoo and Gheyas. International official product structures reviewed: Microsoft Dynamics 365 Finance, Oracle Fusion Cloud Financials, SAP S/4HANA/Fiori, QuickBooks Online, Xero, Zoho Books, Sage Intacct, Acumatica, Odoo Accounting, and NetSuite.
8 +
9 +Primary official references:
10 +- Microsoft Dynamics 365 Finance navigation and finance areas: https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/user-interface/page-navigation and https://learn.microsoft.com/en-us/dynamics365/finance/
11 +- Oracle Fusion Financials overview/navigation: https://docs.oracle.com/en/cloud/saas/financials/25d/facsf/overview-of-oracle-financials-cloud.html
12 +- SAP Fiori spaces/pages and S/4HANA finance: https://help.sap.com/docs/btp/sap-fiori-launchpad-for-sap-btp/spaces-and-pages and https://help.sap.com/docs/SAP_S4HANA_CLOUD/0fa84c9d9c634132b7c4abb9ffdd8f06/d230dc878a5e427c88d37db7d7f1cd17-568.html
13 +- QuickBooks navigation/+Create/bookmarks: https://quickbooks.intuit.com/learn-support/en-us/help-article/bookkeeping-processes/understand-navigation-menu-quickbooks-online/L310NeoHY_US_en_US
14 +- Xero web navigation: https://central.xero.com/0/article/Menus-icons-and-tabs-in-Xero
15 +- Zoho Books module model: https://www.zoho.com/us/books/help/accountant/accountant.html
16 +- Sage Intacct core financials: https://www.sage.com/en-us/sage-business-cloud/intacct/product-capabilities/core-financials/
17 +- Acumatica financial management: https://www.acumatica.com/cloud-erp-software/financial-management/
18 +- Odoo chart/accounting structure: https://www.odoo.com/documentation/17.0/applications/finance/accounting/get_started/chart_of_accounts.html
19 +- NetSuite role/navigation model: https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_4323290738.html
20 +- Sepidar system grouping: https://www.sepidarsystem.com/products/sepidar/
21 +- Parmis Star ERP/module grouping: https://www.parmisit.com/products/parmis-star-erp-solution
22 +- Mahak company-accounting capability grouping: https://www.mahaksoft.com/%D8%AD%D8%B3%D8%A7%D8%A8%D8%AF%D8%A7%D8%B1%DB%8C-%D8%B4%D8%B1%DA%A9%D8%AA%DB%8C/
23 +
24 +Apple does not provide a first-party enterprise accounting/ERP suite comparable to Dynamics/SAP/Oracle; therefore Finora must not invent an “Apple accounting” workflow. Apple can be a visual-usability reference, not an accounting-domain source.
25 +
26 +## Patterns worth adopting
27 +1. **Stable business domains, contextual tasks:** Dynamics uses dashboard/navigation pane/workspaces/modules; SAP uses role-based spaces/pages; Oracle exposes a global navigation area plus task applications. Finora keeps a narrow stable primary rail and one adjacent contextual task panel.
28 +2. **Never strand navigation:** collapsing a task panel must leave a persistent recovery affordance. Finora uses an edge-mounted handle, not a disappearing ×.
29 +3. **One workspace owns the screen:** unrelated task surfaces must never remain visible. Accounting Journal is a normal view-pane and is hidden when Inventory, Settings, Assets, etc. are active.
30 +4. **Global create + global search:** QuickBooks/Xero/Zoho make frequent creation/search actions reachable without drilling through menus. Finora adds a real quick-create menu using only implemented workflows.
31 +5. **Setup / transactions / reports are distinct:** account structure and dimensions belong to setup; journals and operational documents to transactions; ledgers/statements/aging to reports. Contextual groups follow this mental model.
32 +6. **Legal entity context is not business activity:** Dynamics/Oracle/SAP distinguish legal entity/company context from ledger/accounting configuration. Finora therefore stores person type, ownership/sector and legal form separately from activity type used to seed accounting.
33 +7. **Role/context density over decorative UI:** professional systems optimize for repeatable tasks, drill-down, search, recent/favorite access and clear state. Finora should remain restrained and accountant-first.
34 +
35 +## Finora V3 acceptance contract
36 +- Primary rail never expands accordion children beneath itself.
37 +- Contextual panel remains adjacent to the rail and can always be collapsed/reopened from its edge handle.
38 +- No development labels such as “Phase 3” appear in production UI.
39 +- Journal workspace cannot leak into Inventory/Settings/other modules.
40 +- Company master distinguishes: person type; ownership/sector; legal registration form; operational activity type.
41 +- No fake module is exposed. Quick-create routes only to implemented screens.
42 +- Print isolation remains deterministic: formal/pre-invoice A4 landscape; non-formal A5 landscape.
43 +- Real-DOM CI verifies the navigation handle, workspace isolation, company legal-form controls and print PDF page sizes.
index.html
+27 -7
@@ -138,7 +138,9 @@ body{background:#f6f9fc}
138 .module-panel-head{height:var(--shell-top);display:flex;align-items:center;justify-content:space-between;padding:13px 16px;border-bottom:1px solid var(--shell-line)}
139 .module-panel-head small{display:block;color:#94a3b8;font-size:10px;margin-bottom:3px}
140 .module-panel-head h3{font-size:16px;color:#0f172a}
141 -.panel-collapse{width:30px;height:30px;border:1px solid var(--shell-line);border-radius:8px;background:#fff;color:#475569;cursor:pointer;font-size:18px}
141 +.module-panel-handle{position:fixed;z-index:325;top:50%;right:calc(var(--shell-rail) + var(--shell-panel) - 1px);transform:translate(50%,-50%);width:24px;height:54px;border:1px solid #cbd5e1;border-radius:10px 0 0 10px;background:#fff;color:#087c8a;box-shadow:0 4px 14px rgba(15,23,42,.12);cursor:pointer;font:700 20px/1 Arial,sans-serif;transition:right .2s ease,background .15s ease}
142 +.module-panel-handle:hover{background:#effafb}
143 +.module-panel-handle:focus-visible{outline:3px solid rgba(7,139,155,.22);outline-offset:2px}
144 .module-panel-links{height:calc(100vh - var(--shell-top));overflow-y:auto;padding:11px}
145 .module-group{padding:5px 0 11px;border-bottom:1px solid #f0f3f7;margin-bottom:8px}
146 .module-group:last-child{border-bottom:0}
@@ -162,11 +164,13 @@ body{background:#f6f9fc}
164 .topbar-actions{display:flex;gap:7px;align-items:center}
165 .topbar-pill{height:38px;border:1px solid #dce4ee;border-radius:9px;background:#fff;color:#334155;padding:0 11px;font:inherit;font-size:11.5px;font-weight:650;cursor:pointer;white-space:nowrap}
166 .topbar-pill:hover{border-color:#a9cbd0;background:#f7fbfc}
167 +.quick-create{position:relative}.quick-create-menu{display:none;position:absolute;top:44px;left:0;width:230px;background:#fff;border:1px solid var(--shell-line);border-radius:10px;padding:7px;box-shadow:0 16px 35px rgba(15,23,42,.14);z-index:420}.quick-create-menu.open{display:block}.quick-create-menu button{width:100%;border:0;background:transparent;border-radius:7px;padding:9px 10px;text-align:right;font:inherit;font-size:11.5px;color:#334155;cursor:pointer}.quick-create-menu button:hover{background:#f0f8fa;color:#087c8a}.quick-create-menu .quick-create-group{padding:5px 8px 4px;color:#94a3b8;font-size:9.5px;font-weight:800}
168 .main-surface{margin-right:calc(var(--shell-rail) + var(--shell-panel));padding:calc(var(--shell-top) + 18px) 22px 90px;max-width:calc(100% - var(--shell-rail) - var(--shell-panel));transition:margin-right .2s ease,max-width .2s ease}
169 .workspace-context{display:flex;align-items:center;gap:9px;margin:0 0 14px;padding:0 2px;color:#64748b;font-size:11px}
170 .workspace-context strong{color:#0f172a;font-size:13px}
171 .workspace-eyebrow{color:#078b9b;font-weight:800}
172 .shell-panel-collapsed .module-panel{transform:translateX(100%);opacity:0;pointer-events:none}
173 +.shell-panel-collapsed .module-panel-handle{right:calc(var(--shell-rail) - 1px)}
174 .shell-panel-collapsed .topbar{right:var(--shell-rail)}
175 .shell-panel-collapsed .main-surface{margin-right:var(--shell-rail);max-width:calc(100% - var(--shell-rail))}
176 .grid-kpi .kpi-gradient{background:#fff!important;border:1px solid var(--shell-line)!important;box-shadow:0 2px 7px rgba(15,23,42,.035)!important}
@@ -180,7 +184,7 @@ body{background:#f6f9fc}
184 @media(max-width:1180px){.fin-kpi-grid{grid-template-columns:repeat(2,1fr)}.fin-dashboard-grid,.fin-dashboard-bottom{grid-template-columns:1fr}}@media(max-width:620px){.fin-dashboard-head{align-items:flex-start;flex-direction:column}.fin-kpi-grid{grid-template-columns:1fr 1fr}.fin-kpi-card{padding:11px;min-height:100px}.fin-kpi-card strong{font-size:15px}.fin-quick-grid{grid-template-columns:repeat(2,1fr)}}
185 @media(max-width:1100px){:root{--shell-panel:210px}.topbar{padding-inline:12px}.topbar-pill.fiscal-pill{display:none}}
186 @media(max-width:820px){
183 - .app-shell-nav,.module-panel{display:none!important}
187 + .app-shell-nav,.module-panel,.module-panel-handle{display:none!important}
188 .topbar,.shell-panel-collapsed .topbar{right:0;height:58px;padding:8px 10px;gap:7px}
189 .topbar-menu{display:none}
190 .topbar-actions .topbar-pill{display:none}
@@ -259,10 +263,10 @@ body{background:#f6f9fc}
263 <aside class="module-panel no-print" id="module-panel" aria-label="زیرمنوی ماژول">
264 <div class="module-panel-head">
265 <div><small>زیرسیستم</small><h3 id="module-panel-title">داشبورد</h3></div>
262 - <button class="panel-collapse" onclick="toggleModulePanel()" aria-label="جمع کردن زیرمنو" title="جمع کردن">×</button>
266 </div>
267 <div id="module-panel-links" class="module-panel-links"></div>
268 </aside>
269 +<button id="module-panel-handle" class="module-panel-handle no-print" type="button" onclick="toggleModulePanel()" aria-label="جمع کردن پنل زیرسیستم" aria-controls="module-panel" aria-expanded="true" title="جمع/باز کردن پنل زیرسیستم">›</button>
270 <header class="topbar no-print">
271 <button class="topbar-menu" onclick="toggleModulePanel()" aria-label="منو">☰</button>
272 <div class="global-search">
@@ -272,7 +276,19 @@ body{background:#f6f9fc}
276 <div class="topbar-actions">
277 <button class="topbar-pill fiscal-pill" id="topbar-fiscal-year" onclick="navigateShell('accounting','view-accounting-foundation','fiscal')" title="سال مالی">سال مالی جاری</button>
278 <button class="topbar-pill" id="topbar-company" onclick="navigateShell('settings','view-settings','company')" title="شرکت فعال">شرکت فعال</button>
275 - <button class="topbar-pill" onclick="startNewInvoice()" title="عملیات سریع">+ عملیات سریع</button>
279 + <div class="quick-create">
280 + <button class="topbar-pill" id="quick-create-toggle" onclick="toggleQuickCreateMenu(event)" aria-haspopup="true" aria-expanded="false" title="ایجاد سریع">+ ایجاد سریع</button>
281 + <div class="quick-create-menu" id="quick-create-menu" role="menu" aria-label="ایجاد سریع">
282 + <div class="quick-create-group">اسناد و عملیات</div>
283 + <button onclick="navigateShell('commerce','view-invoices');closeQuickCreateMenu()">فاکتور فروش</button>
284 + <button onclick="navigateShell('commerce','view-purchases');closeQuickCreateMenu()">فاکتور خرید</button>
285 + <button onclick="navigateShell('treasury','view-payments');closeQuickCreateMenu()">دریافت / پرداخت</button>
286 + <button onclick="navigateShell('accounting','view-journal','new');closeQuickCreateMenu()">سند حسابداری</button>
287 + <div class="quick-create-group">اطلاعات پایه</div>
288 + <button onclick="navigateShell('commerce','view-contacts');closeQuickCreateMenu()">طرف حساب</button>
289 + <button onclick="navigateShell('commerce','view-products');closeQuickCreateMenu()">کالا / خدمت</button>
290 + </div>
291 + </div>
292 </div>
293 </header>
294
@@ -618,8 +634,12 @@ body{background:#f6f9fc}
634 <div class="accordion-header" onclick="toggleAccordion(this)"><span>🏢 اطلاعات فروشگاه و چاپ (مدیریت شرکت‌ها)</span><span>▼</span></div>
635 <div class="accordion-body">
636 <div class="form-row">
621 -<div class="form-group"><label>نوع شخص</label><select id="company-entity-type" class="form-control"><option value="legal">حقوقی</option><option value="natural">حقیقی</option></select></div>
622 -<div class="form-group"><label>نوع فعالیت</label><select id="company-activity-type" class="form-control"><option value="trading">بازرگانی</option><option value="service">خدماتی</option><option value="manufacturing">تولیدی</option><option value="contracting">پیمانکاری</option><option value="retail">فروشگاهی</option><option value="distribution">پخش</option><option value="nonprofit">غیرانتفاعی</option><option value="professional">خدمات حرفه‌ای</option></select></div>
637 +<div class="form-group"><label>نوع شخص</label><select id="company-entity-type" class="form-control" onchange="handleCompanyEntityTypeChange()"><option value="legal">حقوقی</option><option value="natural">حقیقی / کسب‌وکار فردی</option></select></div>
638 +<div class="form-group" id="company-sector-box"><label>ماهیت مالکیت / بخش</label><select id="company-sector" class="form-control"><option value="private">خصوصی</option><option value="cooperative">تعاونی</option><option value="public_non_government">عمومی غیردولتی</option><option value="government">دولتی / حکومتی</option><option value="other">سایر</option></select></div>
639 +<div class="form-group" id="company-legal-form-box"><label>قالب حقوقی ثبت</label><select id="company-legal-form" class="form-control"><option value="private_joint_stock">سهامی خاص</option><option value="public_joint_stock">سهامی عام</option><option value="limited_liability">با مسئولیت محدود</option><option value="general_partnership">تضامنی</option><option value="relative_partnership">نسبی</option><option value="mixed_non_stock">مختلط غیرسهامی</option><option value="mixed_stock">مختلط سهامی</option><option value="cooperative">تعاونی</option><option value="noncommercial_institution">مؤسسه غیرتجاری</option><option value="other">سایر / نامشخص</option></select></div>
640 +<div class="form-group"><label>نوع فعالیت عملیاتی</label><select id="company-activity-type" class="form-control"><option value="trading">بازرگانی</option><option value="service">خدماتی</option><option value="manufacturing">تولیدی</option><option value="contracting">پیمانکاری</option><option value="retail">فروشگاهی</option><option value="distribution">پخش</option><option value="nonprofit">غیرانتفاعی</option><option value="professional">خدمات حرفه‌ای</option></select></div>
641 +</div>
642 +<div class="form-row">
643 <div class="form-group"><label>راه‌اندازی حسابداری</label><select id="company-accounting-template" class="form-control"><option value="recommended">اعمال کدینگ پیشنهادی Finora</option><option value="empty">شروع با کدینگ خالی</option></select></div>
644 <div class="form-group"><label>نام شرکت / فروشگاه</label><input type="text" id="company-name-input" class="form-control" placeholder="آرا سپهر راستین" /></div>
645 <div class="form-group"><label>تلفن</label><input type="text" id="company-phone-input" class="form-control" /></div>
@@ -635,7 +655,7 @@ body{background:#f6f9fc}
655 <div style="display:flex;gap:8px;flex-wrap:wrap"><button id="company-save-btn" class="btn btn-success" onclick="commitSaveCompany()">➕ ثبت شرکت جدید</button><button id="company-edit-cancel-btn" class="btn btn-secondary" style="display:none" onclick="cancelCompanyEdit()">انصراف از اصلاح</button></div>
656 <div style="margin-top:16px">
657 <h4 style="font-size:14px;margin-bottom:8px">لیست شرکت‌های ثبت‌شده</h4>
638 -<div class="table-responsive"><table><thead><tr><th>نام</th><th>شناسه ملی</th><th>کد اقتصادی</th><th>پیش‌فرض</th><th>عملیات</th></tr></thead><tbody id="companies-table-body"></tbody></table></div>
658 +<div class="table-responsive"><table><thead><tr><th>نام</th><th>شخصیت / قالب</th><th>نوع فعالیت</th><th>شناسه ملی</th><th>کد اقتصادی</th><th>پیش‌فرض</th><th>عملیات</th></tr></thead><tbody id="companies-table-body"></tbody></table></div>
659 </div>
660 </div>
661 </div>
js/companies.js
+25 -4
@@ -1,4 +1,19 @@
1 let editingCompanyId='';
2 +const COMPANY_ACTIVITY_LABELS={trading:'بازرگانی',service:'خدماتی',manufacturing:'تولیدی',contracting:'پیمانکاری',retail:'فروشگاهی',distribution:'پخش',nonprofit:'غیرانتفاعی',professional:'خدمات حرفه‌ای'};
3 +const COMPANY_LEGAL_FORM_LABELS={natural_person:'شخص حقیقی',private_joint_stock:'سهامی خاص',public_joint_stock:'سهامی عام',limited_liability:'با مسئولیت محدود',general_partnership:'تضامنی',relative_partnership:'نسبی',mixed_non_stock:'مختلط غیرسهامی',mixed_stock:'مختلط سهامی',cooperative:'تعاونی',noncommercial_institution:'مؤسسه غیرتجاری',other:'سایر / نامشخص'};
4 +const COMPANY_SECTOR_LABELS={private:'خصوصی',cooperative:'تعاونی',public_non_government:'عمومی غیردولتی',government:'دولتی / حکومتی',other:'سایر'};
5 +function handleCompanyEntityTypeChange(){
6 + const entity=document.getElementById('company-entity-type'),sectorBox=document.getElementById('company-sector-box'),legalBox=document.getElementById('company-legal-form-box'),sector=document.getElementById('company-sector'),legal=document.getElementById('company-legal-form');
7 + const isLegal=(entity?.value||'legal')==='legal';
8 + if(sectorBox)sectorBox.style.display=isLegal?'':'none';if(legalBox)legalBox.style.display=isLegal?'':'none';
9 + if(!isLegal){if(sector)sector.value='private';if(legal)legal.value='other';}
10 + else if(legal&&!legal.value)legal.value='limited_liability';
11 +}
12 +function companyLegalSummary(c){
13 + if((c.entity_type||'legal')==='natural')return 'حقیقی / کسب‌وکار فردی';
14 + const sector=COMPANY_SECTOR_LABELS[c.organizationSector||'private']||'خصوصی',form=COMPANY_LEGAL_FORM_LABELS[c.legalForm||'other']||'سایر / نامشخص';
15 + return sector+' · '+form;
16 +}
17
18 function resetCompanyForm(){
19 editingCompanyId='';
@@ -6,6 +21,9 @@ function resetCompanyForm(){
21 const el=document.getElementById(id);if(el)el.value='';
22 });
23 const entity=document.getElementById('company-entity-type');if(entity)entity.value='legal';
24 + const sector=document.getElementById('company-sector');if(sector)sector.value='private';
25 + const legal=document.getElementById('company-legal-form');if(legal)legal.value='limited_liability';
26 + handleCompanyEntityTypeChange();
27 const activity=document.getElementById('company-activity-type');if(activity)activity.value='trading';
28 const template=document.getElementById('company-accounting-template');if(template){template.value='recommended';template.disabled=false;}
29 const saveBtn=document.getElementById('company-save-btn');
@@ -18,8 +36,9 @@ function editCompany(id){
36 const comp=getMyCompanies().find(c=>c.id===id);
37 if(!comp)return;
38 editingCompanyId=id;
21 - const values={'company-entity-type':comp.entity_type||'legal','company-activity-type':comp.activityType||'trading','company-name-input':comp.name||'','company-phone-input':comp.phone||'','company-national-input':comp.national_id||'','company-economic-input':comp.economic_code||'','company-reg-input':comp.reg_number||'','company-postal-input':comp.postal_code||'','company-address-input':comp.address||'','company-footer-input':comp.footer||''};
39 + const values={'company-entity-type':comp.entity_type||'legal','company-sector':comp.organizationSector||'private','company-legal-form':comp.legalForm||'other','company-activity-type':comp.activityType||'trading','company-name-input':comp.name||'','company-phone-input':comp.phone||'','company-national-input':comp.national_id||'','company-economic-input':comp.economic_code||'','company-reg-input':comp.reg_number||'','company-postal-input':comp.postal_code||'','company-address-input':comp.address||'','company-footer-input':comp.footer||''};
40 Object.keys(values).forEach(id=>{const el=document.getElementById(id);if(el)el.value=values[id];});
41 + handleCompanyEntityTypeChange();
42 const template=document.getElementById('company-accounting-template');if(template){const hasChart=(datastore.accounts||[]).some(a=>a.ownerUserId===currentUser.id&&a.companyId===comp.id);template.value=comp.accountingTemplate?'recommended':'empty';template.disabled=!!comp.accountingTemplate||hasChart;}
43 const saveBtn=document.getElementById('company-save-btn');
44 if(saveBtn){saveBtn.innerHTML='💾 ذخیره اصلاحات';saveBtn.className='btn btn-primary';}
@@ -36,8 +55,10 @@ function commitSaveCompany(){
55 const raw_name=document.getElementById('company-name-input').value;
56 if(!raw_name.trim()){alert('نام شرکت الزامی است.');return;}
57 const activityType=document.getElementById('company-activity-type')?.value||'trading';
58 + const organizationSector=entity_type==='legal'?(document.getElementById('company-sector')?.value||'private'):'private';
59 + const legalForm=entity_type==='legal'?(document.getElementById('company-legal-form')?.value||'other'):'natural_person';
60 const templateChoice=document.getElementById('company-accounting-template')?.value||'empty';
40 - const payload={entity_type,activityType,name:formatEntityName(raw_name,entity_type),phone:document.getElementById('company-phone-input').value||'',national_id:document.getElementById('company-national-input').value||'',economic_code:document.getElementById('company-economic-input').value||'',reg_number:document.getElementById('company-reg-input').value||'',postal_code:document.getElementById('company-postal-input').value||'',address:document.getElementById('company-address-input').value||'',footer:document.getElementById('company-footer-input')?.value||'از خرید شما سپاسگزاریم.'};
61 + const payload={entity_type,organizationSector,legalForm,activityType,name:formatEntityName(raw_name,entity_type),phone:document.getElementById('company-phone-input').value||'',national_id:document.getElementById('company-national-input').value||'',economic_code:document.getElementById('company-economic-input').value||'',reg_number:document.getElementById('company-reg-input').value||'',postal_code:document.getElementById('company-postal-input').value||'',address:document.getElementById('company-address-input').value||'',footer:document.getElementById('company-footer-input')?.value||'از خرید شما سپاسگزاریم.'};
62 if(payload.national_id&&getMyCompanies().some(x=>x.id!==editingCompanyId&&x.national_id===payload.national_id)){alert('شناسه ملی شرکت تکراری است.');return;}
63 if(editingCompanyId){
64 const comp=datastore.companies.find(c=>c.id===editingCompanyId&&c.ownerUserId===currentUser.id);
@@ -70,9 +91,9 @@ function renderCompanies(){
91 const defCompId=mySettings.default_company_id||(myCompanies[0]?.id);
92 if(tbody){
93 if(myCompanies.length===0){
73 - tbody.innerHTML='<tr><td colspan="5" style="text-align:center;color:var(--text-muted);padding:20px">هیچ شرکتی ثبت نشده است. لطفاً ابتدا شرکت خود را ثبت کنید.</td></tr>';
94 + tbody.innerHTML='<tr><td colspan="7" style="text-align:center;color:var(--text-muted);padding:20px">هیچ شرکتی ثبت نشده است. لطفاً ابتدا شرکت خود را ثبت کنید.</td></tr>';
95 }else{
75 - tbody.innerHTML=myCompanies.map(c=>`<tr><td><strong>${esc(c.name)}</strong></td><td>${esc(c.national_id||'—')}</td><td>${esc(c.economic_code||'—')}</td><td>${c.id===defCompId?'<span class="badge badge-success">پیش‌فرض</span>':`<button class="btn btn-secondary btn-inline" style="padding:2px 8px;font-size:11px" onclick="setDefaultCompany('${c.id}')">انتخاب</button>`}</td><td><button class="btn btn-secondary btn-inline" style="padding:2px 8px;font-size:11px;margin-left:5px" data-company-id="${c.id}" onclick="editCompany(this.dataset.companyId)">✏️ اصلاح</button>${myCompanies.length>1?`<button class="btn btn-danger btn-inline" style="padding:2px 8px;font-size:11px" onclick="deleteCompany('${c.id}')">حذف</button>`:'—'}</td></tr>`).join('');
96 + tbody.innerHTML=myCompanies.map(c=>`<tr><td><strong>${esc(c.name)}</strong></td><td>${esc(companyLegalSummary(c))}</td><td>${esc(COMPANY_ACTIVITY_LABELS[c.activityType||'trading']||c.activityType||'—')}</td><td>${esc(c.national_id||'—')}</td><td>${esc(c.economic_code||'—')}</td><td>${c.id===defCompId?'<span class="badge badge-success">پیش‌فرض</span>':`<button class="btn btn-secondary btn-inline" style="padding:2px 8px;font-size:11px" onclick="setDefaultCompany('${c.id}')">انتخاب</button>`}</td><td><button class="btn btn-secondary btn-inline" style="padding:2px 8px;font-size:11px;margin-left:5px" data-company-id="${c.id}" onclick="editCompany(this.dataset.companyId)">✏️ اصلاح</button>${myCompanies.length>1?`<button class="btn btn-danger btn-inline" style="padding:2px 8px;font-size:11px" onclick="deleteCompany('${c.id}')">حذف</button>`:'—'}</td></tr>`).join('');
97 }
98 }
99 if(invoiceCompSelect){
js/journal-ui.js
+1 -1
@@ -1,6 +1,6 @@
1 /* Phase 3 — journal UI */
2 function ensureJournalView(){
3 - if(document.getElementById('view-journal'))return;const s=document.createElement('section');s.id='view-journal';s.className='view';s.innerHTML=`<div class="af-head"><div><h1>اسناد حسابداری</h1><p>ثبت دوبل، قطعی‌سازی، برگشت و تراز آزمایشی</p></div><span class="badge badge-info">فاز ۳</span></div>
3 + if(document.getElementById('view-journal'))return;const s=document.createElement('section');s.id='view-journal';s.className='view-pane';s.innerHTML=`<div class="af-head"><div><h1>اسناد حسابداری</h1><p>ثبت دوبل، قطعی‌سازی و برگشت اسناد</p></div></div>
4 <div class="card" data-finora-task="new"><h3>ثبت سند حسابداری</h3><div class="form-row"><div class="form-group"><label>تاریخ</label><input id="je-date" class="form-control"></div><div class="form-group"><label>شرح</label><input id="je-desc" class="form-control"></div></div><div id="je-lines"></div><div style="display:flex;gap:8px;flex-wrap:wrap"><button class="btn btn-secondary" onclick="jeAddRow()">+ آرتیکل</button><button class="btn btn-success" onclick="jeSaveManual()">ثبت پیش‌نویس</button></div></div>
5 <div class="card" data-finora-task="register"><h3>فهرست اسناد حسابداری</h3><div class="table-responsive"><table><thead><tr><th>شماره</th><th>تاریخ</th><th>شرح</th><th>وضعیت</th><th>بدهکار</th><th>بستانکار</th><th>عملیات</th></tr></thead><tbody id="je-vouchers"></tbody></table></div></div>
6 <div class="card" data-finora-task="trial"><h3>تراز آزمایشی</h3><div class="table-responsive"><table><thead><tr><th>کد</th><th>حساب</th><th>بدهکار</th><th>بستانکار</th><th>مانده</th></tr></thead><tbody id="je-trial"></tbody></table></div></div>`;const main=document.querySelector('.main-surface'),p=document.getElementById('printable-invoice');p?main.insertBefore(s,p):main.appendChild(s);
js/print.js
+2 -1
@@ -13,7 +13,8 @@ function buildTaxLogo(){
13 </svg>`;
14 }
15 function getInvoicePrintSpec(inv){
16 - if(inv&&inv.kind==='non_formal')return {paper:'A5',orientation:'landscape',widthMm:210,heightMm:148,marginMm:5};
16 + const kind=String(inv?.kind||'').toLowerCase();
17 + if(kind==='non_formal'||kind==='informal')return {paper:'A5',orientation:'landscape',widthMm:210,heightMm:148,marginMm:5};
18 return {paper:'A4',orientation:'landscape',widthMm:297,heightMm:210,marginMm:5};
19 }
20 function buildIsolatedPrintDocument(content,spec){
js/ui.js
+14 -2
@@ -130,6 +130,7 @@ function openModule(moduleKey,defaultView,defaultTask=''){
130 if(defaultView)navigateShell(moduleKey,defaultView,defaultTask,true);else renderModulePanel(moduleKey,'','');
131 }
132 function navigateShell(moduleKey,viewId,task='',rerender=true){
133 + if(viewId==='view-journal'&&typeof ensureJournalView==='function')ensureJournalView();
134 switchView(viewId);
135 if(viewId==='view-payments'&&typeof renderPayments==='function')renderPayments();
136 if(viewId==='view-journal'&&typeof renderJournal==='function')renderJournal();
@@ -143,12 +144,22 @@ function navigateShell(moduleKey,viewId,task='',rerender=true){
144 updateShellContext(moduleKey,viewId,task);
145 closeCommandSearch();
146 }
147 +function syncModulePanelHandle(){
148 + const collapsed=document.body.classList.contains('shell-panel-collapsed'),h=document.getElementById('module-panel-handle');
149 + if(!h)return;h.textContent=collapsed?'‹':'›';h.setAttribute('aria-expanded',collapsed?'false':'true');h.setAttribute('aria-label',collapsed?'باز کردن پنل زیرسیستم':'جمع کردن پنل زیرسیستم');
150 +}
151 function toggleModulePanel(){
152 document.body.classList.toggle('shell-panel-collapsed');
153 const collapsed=document.body.classList.contains('shell-panel-collapsed');
154 const p=document.getElementById('module-panel');if(p)p.classList.toggle('collapsed',collapsed);
155 + syncModulePanelHandle();
156 try{localStorage.setItem('finora.shell.panelCollapsed',collapsed?'1':'0');}catch(_){}
157 }
158 +function toggleQuickCreateMenu(event){
159 + if(event)event.stopPropagation();const m=document.getElementById('quick-create-menu'),b=document.getElementById('quick-create-toggle');if(!m)return;
160 + const open=!m.classList.contains('open');m.classList.toggle('open',open);if(b)b.setAttribute('aria-expanded',open?'true':'false');
161 +}
162 +function closeQuickCreateMenu(){const m=document.getElementById('quick-create-menu'),b=document.getElementById('quick-create-toggle');if(m)m.classList.remove('open');if(b)b.setAttribute('aria-expanded','false');}
163 function renderCommandSearch(query){
164 const box=document.getElementById('command-search-results');if(!box)return;
165 const q=(query||'').trim().toLowerCase();
@@ -172,9 +183,10 @@ function syncShellForView(viewId){
183 renderModulePanel(moduleKey,viewId,'');
184 updateShellContext(moduleKey,viewId,'');
185 }
175 -document.addEventListener('click',e=>{if(!e.target.closest('.global-search'))closeCommandSearch();});
176 -document.addEventListener('keydown',e=>{if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==='k'){e.preventDefault();const s=document.getElementById('global-command-search');if(s){s.focus();s.select();}}});
186 +document.addEventListener('click',e=>{if(!e.target.closest('.global-search'))closeCommandSearch();if(!e.target.closest('.quick-create'))closeQuickCreateMenu();});
187 +document.addEventListener('keydown',e=>{if(e.key==='Escape')closeQuickCreateMenu();if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==='k'){e.preventDefault();const s=document.getElementById('global-command-search');if(s){s.focus();s.select();}}});
188 document.addEventListener('DOMContentLoaded',()=>{
189 try{if(localStorage.getItem('finora.shell.panelCollapsed')==='1')document.body.classList.add('shell-panel-collapsed');}catch(_){}
190 + syncModulePanelHandle();
191 renderModulePanel('dashboard','view-dashboard','overview');updateShellContext('dashboard','view-dashboard','overview');
192 });
scripts/dom-smoke.spec.js
+3 -2
@@ -1,8 +1,9 @@
1 const {test,expect}=require('@playwright/test');
2 -test('real DOM shell and post-login smoke',async({page})=>{const errs=[];page.on('pageerror',e=>errs.push(String(e)));await page.goto('http://127.0.0.1:4173/index.html',{waitUntil:'domcontentloaded'});await expect(page.locator('#auth-screen')).toBeVisible();await expect(page.locator('[data-module="projects"]')).toHaveCount(1);await expect(page.locator('[data-module="dashboard"]')).toContainText('داشبورد');await expect(page.locator('[data-module="home"]')).toHaveCount(0);await expect(page.locator('[data-module="catalog"]')).toHaveCount(0);await expect(page.locator('[data-module="erp"]')).toHaveCount(0);await expect(page.locator('#view-contracting')).toHaveCount(1);await expect(page.locator('[data-module="inventory"]')).toHaveCount(1);await expect(page.locator('[data-module="assets"]')).toHaveCount(1);for(const id of ['view-inventory','view-assets','view-currency','view-data-center','view-integrations'])await expect(page.locator('#'+id)).toHaveCount(1);expect(await page.evaluate(()=>{const a=[...document.querySelectorAll('[id]')].map(x=>x.id),s=new Set(),d=[];for(const id of a){if(s.has(id))d.push(id);s.add(id)}return d})).toEqual([]);await page.evaluate(async()=>{fetchCurrentUser=async()=>({id:'smoke-user',email:'smoke@example.test',fullName:'Smoke Admin',username:'smoke',role:'admin',subscription:{type:'lifetime',status:'active',endDate:'2099-01-01'}});pullAll=async()=>{};refreshAllSurfaces=()=>{window.__smokeRefresh=true};maybeMigrateLegacyData=()=>{window.__smokeMigrate=true};await enterApp({id:'smoke-user'});});await expect(page.locator('#auth-screen')).toBeHidden();await expect(page.locator('body')).toHaveClass(/is-admin/);await expect(page.locator('#logged-user-label')).toContainText('Smoke Admin');await page.evaluate(()=>openModule('accounting','view-accounting-foundation','accounts'));await expect(page.locator('#module-panel-links')).toContainText('اطلاعات پایه');await expect(page.locator('#module-panel-links')).toContainText('عملیات حسابداری');await expect(page.locator('#module-panel-links')).toContainText('دفاتر و گزارش‌ها');await expect(page.locator('#module-panel-links [data-task="accounts"]')).toHaveClass(/active/);await page.fill('#global-command-search','تراز آزمایشی');await expect(page.locator('#command-search-results')).toContainText('تراز آزمایشی');await expect(page.locator('#view-accounting-foundation [data-finora-task="accounts"]')).toBeVisible();await expect(page.locator('#view-accounting-foundation [data-finora-task="dimensions"]')).toBeHidden();await page.evaluate(()=>switchView('view-accounting-foundation'));await expect(page.locator('#view-accounting-foundation [data-finora-task="dimensions"]')).toBeVisible();await page.evaluate(()=>navigateShell('accounting','view-accounting-foundation','accounts'));await page.evaluate(()=>navigateShell('settings','view-settings','company'));await expect(page.locator('#view-settings [data-finora-task="company"]')).toBeVisible();await expect(page.locator('#view-settings [data-finora-task="account"]')).toBeHidden();await page.evaluate(()=>navigateShell('accounting','view-journal','new'));await expect(page.locator('#view-journal [data-finora-task="new"]')).toBeVisible();await expect(page.locator('#view-journal [data-finora-task="register"]')).toBeHidden();await page.evaluate(()=>navigateShell('accounting','view-journal','register'));await expect(page.locator('#view-journal [data-finora-task="register"]')).toBeVisible();await expect(page.locator('#view-journal [data-finora-task="new"]')).toBeHidden();await page.evaluate(()=>navigateShell('accounting','view-accounting-reports','trial'));await expect(page.locator('#p6-reporting-root [data-finora-task="trial"]')).toBeVisible();await expect(page.locator('#p6-reporting-root [data-finora-task="ledger"]')).toBeHidden();expect(await page.evaluate(()=>({refresh:window.__smokeRefresh,migrate:window.__smokeMigrate,admin:canShowShellCommand({guard:'admin'})}))).toEqual({refresh:true,migrate:true,admin:true});await page.evaluate(()=>{saveDatastore=()=>{};datastore.companies=[{id:'C1',ownerUserId:'smoke-user',name:'Smoke Co'}];datastore.settings=[{ownerUserId:'smoke-user',default_company_id:'C1'}];datastore.products=[{id:'P1',ownerUserId:'smoke-user',companyId:'C1',code:'1',name:'Smoke Product',type:'good',unit:'عدد',buy_price:100,sale_price:150,stock:0}];for(const k of ['warehouses','stockMovements','inventoryCounts','fixedAssets','assetDepreciations','currencies','exchangeRates','costCenters','importBatches','integrationConnections','integrationOutbox','phase5Audit'])datastore[k]=[];switchView('view-inventory');p5Render('view-inventory');});await page.evaluate(()=>{switchView('view-dashboard');renderDashboard();});await expect(page.locator('#kpi-assets-sum')).toHaveCount(1);await expect(page.locator('#dashboard-cashflow-chart svg')).toHaveCount(1);await expect(page.locator('#dashboard-recent-journals')).toHaveCount(1);await page.evaluate(()=>{switchView('view-accounting-foundation');renderAccountingFoundation();});await expect(page.locator('#view-accounting-foundation')).toContainText('ورود کدینگ از Excel');await expect(page.locator('#view-accounting-foundation')).toContainText('شناور ۴ قرارداد/پیمان');await expect(page.locator('#af-account-type')).toHaveCount(1);await expect(page.locator('#af-account-role')).toHaveCount(1);await expect(page.locator('#af-dim-source option[value="contract"]')).toHaveCount(1);await page.evaluate(()=>{switchView('view-inventory');p5Render('view-inventory');});await expect(page.locator('#p5-inventory-root')).toContainText('انبار اصلی');await expect(page.locator('#p5-inventory-root')).toContainText('Smoke Product');await page.evaluate(()=>{switchView('view-accounting-reports');P6Reports.render();});await expect(page.locator('#p6-reporting-root')).toContainText('تراز آزمایشی');await expect(page.locator('#p6-reporting-root')).toContainText('صورت جریان وجوه نقد');expect(await page.evaluate(()=>{const a=[...document.querySelectorAll('[id]')].map(x=>x.id),s=new Set(),d=[];for(const id of a){if(s.has(id))d.push(id);s.add(id)}return d})).toEqual([]);await page.evaluate(()=>{window.__FINORA_PRINT_TEST_MODE=true;window.print=()=>{};const items=Array.from({length:25},(_,i)=>({prodName:'Item '+(i+1),qty:1,unit:'عدد',price:100,lineTotal:100}));datastore.invoices=[{id:'PRINT_FORMAL',ownerUserId:'smoke-user',companyId:'C1',contactId:'',kind:'formal',number:'F-1',date:'1405/07/07',items,subtotal:2500,discount:0,vat:250,grandTotal:2750,paymentMethod:'cash'}];renderAndPrintDirect('PRINT_FORMAL');});await expect(page.locator('#printable-invoice .invoice-a4-page')).toHaveCount(3);expect(await page.locator('#dynamic-print-orientation').evaluate(el=>el.innerHTML.includes('A4 landscape'))).toBe(true);await expect(page.locator('#finora-print-frame')).toHaveCount(1);expect(await page.locator('#finora-print-frame').evaluate(f=>({paper:f.contentDocument.querySelector('#finora-print-document')?.dataset.paper,orientation:f.contentDocument.querySelector('#finora-print-document')?.dataset.orientation,appUi:f.contentDocument.querySelectorAll('.view-pane,.app-shell-nav,.module-panel,.topbar').length,pages:f.contentDocument.querySelectorAll('.invoice-a4-page').length}))).toEqual({paper:'A4',orientation:'landscape',appUi:0,pages:3});await page.emulateMedia({media:'print'});expect(await page.locator('#printable-invoice .invoice-a4-page').first().evaluate(el=>getComputedStyle(el).breakAfter)).toBe('page');await page.emulateMedia({media:'screen'});await page.evaluate(()=>{datastore.invoices[0].id='PRINT_NONFORMAL';datastore.invoices[0].kind='informal';renderAndPrintDirect('PRINT_NONFORMAL');});await expect(page.locator('#printable-invoice .invoice-a4-page')).toHaveCount(3);expect(await page.locator('#dynamic-print-orientation').evaluate(el=>el.innerHTML.includes('A5 landscape'))).toBe(true);expect(await page.locator('#finora-print-frame').evaluate(f=>({paper:f.contentDocument.querySelector('#finora-print-document')?.dataset.paper,orientation:f.contentDocument.querySelector('#finora-print-document')?.dataset.orientation,appUi:f.contentDocument.querySelectorAll('.view-pane,.app-shell-nav,.module-panel,.topbar').length,pages:f.contentDocument.querySelectorAll('.invoice-a4-page').length}))).toEqual({paper:'A5',orientation:'landscape',appUi:0,pages:3});expect(errs.filter(x=>!x.includes('ResizeObserver'))).toEqual([]);});
2 +const {PDFDocument}=require('pdf-lib');
3 +test('real DOM shell and post-login smoke',async({page})=>{const errs=[];page.on('pageerror',e=>errs.push(String(e)));await page.goto('http://127.0.0.1:4173/index.html',{waitUntil:'domcontentloaded'});await expect(page.locator('#auth-screen')).toBeVisible();await expect(page.locator('[data-module="projects"]')).toHaveCount(1);await expect(page.locator('[data-module="dashboard"]')).toContainText('داشبورد');await expect(page.locator('[data-module="home"]')).toHaveCount(0);await expect(page.locator('[data-module="catalog"]')).toHaveCount(0);await expect(page.locator('[data-module="erp"]')).toHaveCount(0);await expect(page.locator('#view-contracting')).toHaveCount(1);await expect(page.locator('[data-module="inventory"]')).toHaveCount(1);await expect(page.locator('[data-module="assets"]')).toHaveCount(1);for(const id of ['view-inventory','view-assets','view-currency','view-data-center','view-integrations'])await expect(page.locator('#'+id)).toHaveCount(1);expect(await page.evaluate(()=>{const a=[...document.querySelectorAll('[id]')].map(x=>x.id),s=new Set(),d=[];for(const id of a){if(s.has(id))d.push(id);s.add(id)}return d})).toEqual([]);await page.evaluate(async()=>{fetchCurrentUser=async()=>({id:'smoke-user',email:'smoke@example.test',fullName:'Smoke Admin',username:'smoke',role:'admin',subscription:{type:'lifetime',status:'active',endDate:'2099-01-01'}});pullAll=async()=>{};refreshAllSurfaces=()=>{window.__smokeRefresh=true};maybeMigrateLegacyData=()=>{window.__smokeMigrate=true};await enterApp({id:'smoke-user'});});await expect(page.locator('#auth-screen')).toBeHidden();await expect(page.locator('body')).toHaveClass(/is-admin/);await expect(page.locator('#logged-user-label')).toContainText('Smoke Admin');await expect(page.locator('#module-panel-handle')).toBeVisible();await expect(page.locator('.module-panel-head .panel-collapse')).toHaveCount(0);await page.evaluate(()=>toggleModulePanel());await expect(page.locator('body')).toHaveClass(/shell-panel-collapsed/);await expect(page.locator('#module-panel-handle')).toBeVisible();await expect(page.locator('#module-panel-handle')).toHaveAttribute('aria-expanded','false');await page.click('#module-panel-handle');await expect(page.locator('body')).not.toHaveClass(/shell-panel-collapsed/);await page.evaluate(()=>openModule('accounting','view-accounting-foundation','accounts'));await expect(page.locator('#module-panel-links')).toContainText('اطلاعات پایه');await expect(page.locator('#module-panel-links')).toContainText('عملیات حسابداری');await expect(page.locator('#module-panel-links')).toContainText('دفاتر و گزارش‌ها');await expect(page.locator('#module-panel-links [data-task="accounts"]')).toHaveClass(/active/);await page.fill('#global-command-search','تراز آزمایشی');await expect(page.locator('#command-search-results')).toContainText('تراز آزمایشی');await expect(page.locator('#view-accounting-foundation [data-finora-task="accounts"]')).toBeVisible();await expect(page.locator('#view-accounting-foundation [data-finora-task="dimensions"]')).toBeHidden();await page.evaluate(()=>switchView('view-accounting-foundation'));await expect(page.locator('#view-accounting-foundation [data-finora-task="dimensions"]')).toBeVisible();await page.evaluate(()=>navigateShell('accounting','view-accounting-foundation','accounts'));await page.evaluate(()=>navigateShell('settings','view-settings','company'));await expect(page.locator('#view-settings [data-finora-task="company"]')).toBeVisible();await expect(page.locator('#view-settings [data-finora-task="account"]')).toBeHidden();await expect(page.locator('#company-legal-form')).toContainText('سهامی خاص');await expect(page.locator('#company-legal-form')).toContainText('با مسئولیت محدود');await page.selectOption('#company-entity-type','natural');await page.evaluate(()=>handleCompanyEntityTypeChange());await expect(page.locator('#company-legal-form-box')).toBeHidden();await page.selectOption('#company-entity-type','legal');await page.evaluate(()=>handleCompanyEntityTypeChange());await expect(page.locator('#company-legal-form-box')).toBeVisible();await page.evaluate(()=>navigateShell('accounting','view-journal','new'));await expect(page.locator('#view-journal [data-finora-task="new"]')).toBeVisible();await expect(page.locator('#view-journal [data-finora-task="register"]')).toBeHidden();await page.evaluate(()=>navigateShell('accounting','view-journal','register'));await expect(page.locator('#view-journal [data-finora-task="register"]')).toBeVisible();await expect(page.locator('#view-journal [data-finora-task="new"]')).toBeHidden();await page.evaluate(()=>navigateShell('accounting','view-accounting-reports','trial'));await expect(page.locator('#p6-reporting-root [data-finora-task="trial"]')).toBeVisible();await expect(page.locator('#p6-reporting-root [data-finora-task="ledger"]')).toBeHidden();expect(await page.evaluate(()=>({refresh:window.__smokeRefresh,migrate:window.__smokeMigrate,admin:canShowShellCommand({guard:'admin'})}))).toEqual({refresh:true,migrate:true,admin:true});await page.evaluate(()=>{saveDatastore=()=>{};datastore.companies=[{id:'C1',ownerUserId:'smoke-user',name:'Smoke Co'}];datastore.settings=[{ownerUserId:'smoke-user',default_company_id:'C1'}];datastore.products=[{id:'P1',ownerUserId:'smoke-user',companyId:'C1',code:'1',name:'Smoke Product',type:'good',unit:'عدد',buy_price:100,sale_price:150,stock:0}];for(const k of ['warehouses','stockMovements','inventoryCounts','fixedAssets','assetDepreciations','currencies','exchangeRates','costCenters','importBatches','integrationConnections','integrationOutbox','phase5Audit'])datastore[k]=[];switchView('view-inventory');p5Render('view-inventory');});await expect(page.locator('#view-journal')).toBeHidden();await page.evaluate(()=>{switchView('view-dashboard');renderDashboard();});await expect(page.locator('#kpi-assets-sum')).toHaveCount(1);await expect(page.locator('#dashboard-cashflow-chart svg')).toHaveCount(1);await expect(page.locator('#dashboard-recent-journals')).toHaveCount(1);await page.evaluate(()=>{switchView('view-accounting-foundation');renderAccountingFoundation();});await expect(page.locator('#view-accounting-foundation')).toContainText('ورود کدینگ از Excel');await expect(page.locator('#view-accounting-foundation')).toContainText('شناور ۴ قرارداد/پیمان');await expect(page.locator('#af-account-type')).toHaveCount(1);await expect(page.locator('#af-account-role')).toHaveCount(1);await expect(page.locator('#af-dim-source option[value="contract"]')).toHaveCount(1);await page.evaluate(()=>{switchView('view-inventory');p5Render('view-inventory');});await expect(page.locator('#p5-inventory-root')).toContainText('انبار اصلی');await expect(page.locator('#p5-inventory-root')).toContainText('Smoke Product');await page.evaluate(()=>{switchView('view-accounting-reports');P6Reports.render();});await expect(page.locator('#p6-reporting-root')).toContainText('تراز آزمایشی');await expect(page.locator('#p6-reporting-root')).toContainText('صورت جریان وجوه نقد');expect(await page.evaluate(()=>{const a=[...document.querySelectorAll('[id]')].map(x=>x.id),s=new Set(),d=[];for(const id of a){if(s.has(id))d.push(id);s.add(id)}return d})).toEqual([]);await page.evaluate(()=>{window.__FINORA_PRINT_TEST_MODE=true;window.print=()=>{};const items=Array.from({length:25},(_,i)=>({prodName:'Item '+(i+1),qty:1,unit:'عدد',price:100,lineTotal:100}));datastore.invoices=[{id:'PRINT_FORMAL',ownerUserId:'smoke-user',companyId:'C1',contactId:'',kind:'formal',number:'F-1',date:'1405/07/07',items,subtotal:2500,discount:0,vat:250,grandTotal:2750,paymentMethod:'cash'}];renderAndPrintDirect('PRINT_FORMAL');});await expect(page.locator('#printable-invoice .invoice-a4-page')).toHaveCount(3);expect(await page.locator('#dynamic-print-orientation').evaluate(el=>el.innerHTML.includes('A4 landscape'))).toBe(true);await expect(page.locator('#finora-print-frame')).toHaveCount(1);expect(await page.locator('#finora-print-frame').evaluate(f=>({paper:f.contentDocument.querySelector('#finora-print-document')?.dataset.paper,orientation:f.contentDocument.querySelector('#finora-print-document')?.dataset.orientation,appUi:f.contentDocument.querySelectorAll('.view-pane,.app-shell-nav,.module-panel,.topbar').length,pages:f.contentDocument.querySelectorAll('.invoice-a4-page').length}))).toEqual({paper:'A4',orientation:'landscape',appUi:0,pages:3});await page.emulateMedia({media:'print'});expect(await page.locator('#printable-invoice .invoice-a4-page').first().evaluate(el=>getComputedStyle(el).breakAfter)).toBe('page');await page.emulateMedia({media:'screen'});await page.evaluate(()=>{datastore.invoices[0].id='PRINT_NONFORMAL';datastore.invoices[0].kind='informal';renderAndPrintDirect('PRINT_NONFORMAL');});await expect(page.locator('#printable-invoice .invoice-a4-page')).toHaveCount(3);expect(await page.locator('#dynamic-print-orientation').evaluate(el=>el.innerHTML.includes('A5 landscape'))).toBe(true);expect(await page.locator('#finora-print-frame').evaluate(f=>({paper:f.contentDocument.querySelector('#finora-print-document')?.dataset.paper,orientation:f.contentDocument.querySelector('#finora-print-document')?.dataset.orientation,appUi:f.contentDocument.querySelectorAll('.view-pane,.app-shell-nav,.module-panel,.topbar').length,pages:f.contentDocument.querySelectorAll('.invoice-a4-page').length}))).toEqual({paper:'A5',orientation:'landscape',appUi:0,pages:3});expect(errs.filter(x=>!x.includes('ResizeObserver'))).toEqual([]);});
4
5
6 test('expired license browser enforcement',async({page})=>{const errs=[];page.on('pageerror',e=>errs.push(String(e)));await page.goto('http://127.0.0.1:4173/index.html',{waitUntil:'domcontentloaded'});await page.evaluate(async()=>{window.__licenseAlerts=[];window.alert=m=>window.__licenseAlerts.push(String(m));fetchCurrentUser=async()=>({id:'expired-user',email:'expired@example.test',fullName:'Expired User',username:'expired',role:'user',subscription:{type:'monthly',status:'active',startDate:'2025-01-01',endDate:'2025-01-31'}});pullAll=async()=>{};refreshAllSurfaces=()=>{updateLicenseDisplay(currentUser)};maybeMigrateLegacyData=()=>{};await enterApp({id:'expired-user'});});await expect(page.locator('#auth-screen')).toBeHidden();await expect(page.locator('#user-license-status-badge')).toContainText('منقضی شده');expect(await page.evaluate(()=>canWrite())).toBe(false);expect(await page.evaluate(()=>requireWrite())).toBe(false);expect(await page.evaluate(()=>window.__licenseAlerts.some(x=>x.includes('منقضی')&&x.includes('امکان ثبت یا ویرایش')))).toBe(true);expect(errs.filter(x=>!x.includes('ResizeObserver'))).toEqual([]);});
7
8
8 -test('isolated print document honors CSS paper size in Chromium PDF',async({page,context})=>{await page.goto('http://127.0.0.1:4173/index.html',{waitUntil:'domcontentloaded'});const docs=await page.evaluate(()=>({a4:buildIsolatedPrintDocument('<div class="invoice-a4-page">FORMAL_ONLY</div>',{paper:'A4',orientation:'landscape',widthMm:297,heightMm:210,marginMm:5}),a5:buildIsolatedPrintDocument('<div class="invoice-a4-page">NONFORMAL_ONLY</div>',{paper:'A5',orientation:'landscape',widthMm:210,heightMm:148,marginMm:5})}));for(const [kind,html] of Object.entries(docs)){const p=await context.newPage();await p.setContent(html,{waitUntil:'domcontentloaded'});expect(await p.locator('body').innerText()).toContain(kind==='a4'?'FORMAL_ONLY':'NONFORMAL_ONLY');expect(await p.locator('.view-pane,.app-shell-nav,.module-panel,.topbar').count()).toBe(0);const pdf=await p.pdf({preferCSSPageSize:true,printBackground:true});const raw=pdf.toString('latin1');expect((raw.match(new RegExp('/Type\\\\s*/Page\\\\b','g'))||[]).length).toBe(1);const boxes=[...raw.matchAll(new RegExp('/MediaBox\\\\s*\\\\[\\\\s*0\\\\s+0\\\\s+([0-9.]+)\\\\s+([0-9.]+)\\\\s*\\\\]','g'))].map(m=>[Number(m[1]),Number(m[2])]);expect(boxes.length).toBeGreaterThan(0);const [w,h]=boxes[0];expect(w).toBeGreaterThan(h);if(kind==='a4'){expect(w).toBeGreaterThan(830);expect(h).toBeGreaterThan(580);}else{expect(w).toBeGreaterThan(580);expect(w).toBeLessThan(620);expect(h).toBeGreaterThan(400);expect(h).toBeLessThan(440);}await p.close();}});
9 +test('isolated print document honors CSS paper size in Chromium PDF',async({page,context})=>{await page.goto('http://127.0.0.1:4173/index.html',{waitUntil:'domcontentloaded'});const docs=await page.evaluate(()=>({a4:buildIsolatedPrintDocument('<div class="invoice-a4-page">FORMAL_ONLY</div>',{paper:'A4',orientation:'landscape',widthMm:297,heightMm:210,marginMm:5}),a5:buildIsolatedPrintDocument('<div class="invoice-a4-page">NONFORMAL_ONLY</div>',{paper:'A5',orientation:'landscape',widthMm:210,heightMm:148,marginMm:5})}));for(const [kind,html] of Object.entries(docs)){const p=await context.newPage();await p.setContent(html,{waitUntil:'domcontentloaded'});expect(await p.locator('body').innerText()).toContain(kind==='a4'?'FORMAL_ONLY':'NONFORMAL_ONLY');expect(await p.locator('.view-pane,.app-shell-nav,.module-panel,.topbar').count()).toBe(0);const pdf=await p.pdf({preferCSSPageSize:true,printBackground:true});const parsed=await PDFDocument.load(pdf);expect(parsed.getPageCount()).toBe(1);const {width:w,height:h}=parsed.getPage(0).getSize();expect(w).toBeGreaterThan(h);if(kind==='a4'){expect(w).toBeGreaterThan(830);expect(h).toBeGreaterThan(580);}else{expect(w).toBeGreaterThan(580);expect(w).toBeLessThan(620);expect(h).toBeGreaterThan(400);expect(h).toBeLessThan(440);}await p.close();}});
scripts/quality-check.mjs
+8 -4
@@ -18,7 +18,7 @@ if(!index.includes("frame-ancestors 'none'")||!index.includes('upgrade-insecure-
18 if(!index.includes('name="referrer" content="strict-origin-when-cross-origin"'))throw new Error('Referrer policy metadata missing');
19 for(const needle of ["replace(/&/g,'&amp;')","replace(/</g,'&lt;')","replace(/>/g,'&gt;')","replace(/\"/g,'&quot;')","replace(/'/g,'&#39;')"])if(!fs.readFileSync(path.join(root,'js','core.js'),'utf8').includes(needle))throw new Error('HTML escaping invariant missing '+needle);
20 if(!index.includes('فینورا — نسخه ۱.۰')||!index.includes('نسخه ۱.۰'))throw new Error('Visible application version is inconsistent');
21 -for(const shellId of ['module-rail','module-panel','module-panel-links','global-command-search','command-search-results','topbar-company','topbar-fiscal-year','workspace-title','workspace-context-text'])if(!ids.includes(shellId))throw new Error('Phase 1 shell missing #'+shellId);
21 +for(const shellId of ['module-rail','module-panel','module-panel-handle','module-panel-links','global-command-search','command-search-results','quick-create-toggle','quick-create-menu','topbar-company','topbar-fiscal-year','workspace-title','workspace-context-text'])if(!ids.includes(shellId))throw new Error('Phase 1 shell missing #'+shellId);
22 for(const cls of ['module-rail','module-panel','topbar','global-search'])if(!index.includes('class="'+cls)&&!index.includes('class="sidebar '+cls)&&!index.includes('class="'+cls+' '))throw new Error('Phase 1 shell class missing: '+cls);
23
24
@@ -29,10 +29,10 @@ const files=fs.readdirSync(path.join(root,'js')).filter(n=>n.endsWith('.js'));
29 const all=Object.fromEntries(files.map(n=>[n,fs.readFileSync(path.join(root,'js',n),'utf8')]));
30 const must={
31 'invoices.js':['function commitSaveInvoice','function editInvoice','paymentMethod'],
32 - 'print.js':['function renderAndPrintDirect','FORMAL_ROWS_PER_PAGE=12','const isPreInvoice=','function getInvoicePrintSpec','function buildIsolatedPrintDocument','function printIsolatedDocument',"frame.id='finora-print-frame'","paper:'A4'","paper:'A5'"],
32 + 'print.js':['function renderAndPrintDirect','FORMAL_ROWS_PER_PAGE=12','const isPreInvoice=','function getInvoicePrintSpec',"kind==='non_formal'||kind==='informal'",'function buildIsolatedPrintDocument','function printIsolatedDocument',"frame.id='finora-print-frame'","paper:'A4'","paper:'A5'"],
33 'purchases.js':['window.purSave=function','window.purEdit=function','window.purPrint=function','window.purRefreshProjects=function','pur-payment-method','companyId'],
34 'projects.js':['editContactProject','deleteContactProject','addSubproject','editSubproject','deleteSubproject','usedExpense','usedPayment','projectDirectionLabel(s.direction||p.direction)','project-direction-select','return new Promise'],
35 - 'companies.js':['Object.entries(datastore)',"key!=='companies'",'default_company_id'],
35 + 'companies.js':['Object.entries(datastore)',"key!=='companies'",'default_company_id','organizationSector','legalForm','handleCompanyEntityTypeChange','companyLegalSummary'],
36 'operations.js':['editContact','editProduct','editCheque','editExpense','deleteInvoice','refreshExpenseProjects','projectId','getMyPayments','companyId',"q.status&&q.status!=='registered'",'چک تعیین‌تکلیف‌شده برای حفظ سابقه قابل حذف نیست'],
37 'selfcheck.js':['datastore.payments','invoices.has','purchases.has'],
38 'payments.js':['commitSavePayment','invoiceOutstanding','purchaseOutstanding','companyOk','legacyOk','amount>outstanding',"direction!=='inbound'","direction!=='outbound'",'projectId',"paymentMethod!=='credit'","old.invoiceType===invoiceType"],
@@ -40,7 +40,7 @@ const must={
40 'accounting-foundation.js':['getMyFiscalYears','getMyAccounts','getMyDimensionTypes','getMyGlobalProjects','afMigrateLegacyProjects','postingAllowed','linkedContactIds'],
41 'accounting-foundation-ui.js':['view-accounting-foundation','af-account-level','af-rule-dimension','af-project-contacts'],
42 'accounting-foundation-render.js':['renderAccountingFoundation','afResolvedValues','af-projects-list'],
43 - 'ui.js':["dock.dataset.view===viewId",'FINORA_MODULES','FINORA_VIEW_HOME','FINORA_COMMANDS','renderModulePanel','updateShellContext','global-command-search',"localStorage.setItem('finora.shell.panelCollapsed'"],
43 + 'ui.js':["dock.dataset.view===viewId",'FINORA_MODULES','FINORA_VIEW_HOME','FINORA_COMMANDS','renderModulePanel','updateShellContext','global-command-search','syncModulePanelHandle','toggleQuickCreateMenu',"localStorage.setItem('finora.shell.panelCollapsed'"],
44 'accounting.js':['productMovement','getInventorySnapshot','getProjectFinancials','accrualProfit','cashNet','i.prodId||i.productId','companyId===active','companyOk'],
45 'drilldown.js':['openContactLedger','openDashboardDetail','openReportDetail','openFinancialSummaryDetail',"status==='cleared'"],
46 'sync.js':['getMyPurchases'],
@@ -109,3 +109,7 @@ for(const x of ['p5ApplyRestore','importProductsFromExcel(event)','validated-bac
109 const p6=all['phase6-reporting.js']||'';for(const x of ['ledger','cashFlow','projectContractSummary','legacyCutoverPreview','postLegacyInvoice'])if(!p6.includes(x))throw new Error('Phase6 report capability missing '+x);
110 if(!index.includes('id="view-accounting-reports"')||!index.includes('phase6-reporting.js'))throw new Error('Phase6 report workspace missing');
111
112 +
113 +if(!all['journal-ui.js']?.includes("s.className='view-pane'")||all['journal-ui.js']?.includes('فاز ۳'))throw new Error('Journal workspace must be isolated as a view-pane without development phase labels');
114 +for(const id of ['company-sector','company-legal-form'])if(!ids.includes(id))throw new Error('Company legal identity control missing #'+id);
115 +if(index.includes('class="panel-collapse"'))throw new Error('Disappearing panel close button must not return; use persistent edge handle');