سامانه صدور فاکتور و حسابداری
Implement enterprise task-level navigation shell
davoodmehraban89 committed
Sep 29, 2026 at 23:36 UTC
22bb7a273931e571fa917d4d82e41d81b8493e6a
7 files changed
+83
-63
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-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. | IN PROGRESS | 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. Next: implement the contract and real-DOM acceptance gates. |
37
+| 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. | IN PROGRESS | 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; CI verification is required next. |
38
| 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. |
39
| 2026-09-29 | Owner supplied another GitHub Actions failure (`golden-accounting-core-check.mjs`: `revenue report mismatch`) and asked for exact current progress plus continuous diagnosis/fix until the hardening work reaches a verified conclusion. Treat repeated run failures as blockers, distinguish superseded-run failures from current-head failures, and do not stop after a single fix while executable work remains. | IMPLEMENTATION COMPLETE / FINAL EXTERNAL VERIFICATION REMAINS | The supplied failure at `19:25:15Z` maps to the custom-chart transition around `d6b293e4`, not the later documentation head. Root accounting/report defect identified: Phase 6 `rollup()` discarded the account-master `accountType`, so `financials()` could not actually use the explicit classification promised by the earlier custom-chart hardening and silently fell back to code/title heuristics. This checkpoint preserves `accountType/systemRole` in report rollups, makes cash-flow use the explicit cash system role, and strengthens the Golden Journey with neutral arbitrary account titles plus diagnostic expected/actual values. CI run `36620001387` on `768f97ab` proves JavaScript syntax, application invariants, Phase 2–6 behavior, Golden Accounting Journey and browser-runtime install all PASS. Its only failure was the new print DOM assertion using Playwright `toContainText()` on a `<style>` element; GitHub log showed the style element actually contained `A4 landscape`. Commit `9d0a3122` corrected the assertion to inspect style `innerHTML`, archived/applied production migrations under exact versions `20260929193348` and `20260929193357`, and production rollback-only QA proved settled-cheque immutability plus case-insensitive account-code uniqueness with zero QA rows left. Depreciation reversal was then implemented without weakening immutable source history at `e70b07a1`; run `36620902948` exposed only a Node-VM harness omission (`getMyJournalVouchers` absent), corrected at `521b0de7`. No GitHub failure notification for `521b0de7` was present in the connected mailbox after the normal failure-notification window, but the exact push-run ID is unavailable through the current connector, so latest-head CI/real-DOM is NOT VERIFIED rather than assumed PASS. |
40
| 2026-09-29 | Owner reported repeated GitHub Actions `run failed` notifications and supplied a Quality log failing on stale static needle `v.status==='posted'`. Diagnose the live CI failure first, repair the gate without weakening accounting safety, verify current CI, then continue the approved hardening backlog. Reduce avoidable CI churn by batching subsequent related durable changes where practical. | FIXED / CI VERIFICATION PENDING | Root cause confirmed: `journal-engine.js` was intentionally hardened from posted-only source locking to posted+reversed locking, while `quality-check.mjs` still searched for the obsolete literal `v.status==='posted'`. The gate is being corrected to require `jeSourceLocked` plus `['posted','reversed'].includes`, which is stronger and matches live semantics. Fix commit `78c6a071` replaced the obsolete posted-only literal with the stronger `jeSourceLocked` + posted/reversed invariant. Follow-up inspection exposed a hidden Phase 2 test-script syntax defect (duplicate `const companies`) that the old syntax gate could not detect because it only parsed `js/*.js`; the next batched checkpoint removes that duplicate, makes syntax CI check every `scripts/*.mjs`, and removes duplicate Phase 6 behavior execution from `quality-check.mjs` now that Phase 6 has its own named workflow step. Root cause fixed at `78c6a071`; follow-up CI repair `20294e31` removed the hidden duplicate Phase 2 declaration, checks syntax of all MJS gates and avoids duplicate Phase 6 execution. `18ea5c8b` added Quality/Security concurrency cancellation plus real-Chromium A4/A5 pagination/page-break checks, reducing superseded-run noise. Subsequent requirement hardening: legacy-company starter-chart fix `3b3ffba2`; custom-chart system posting roles + arbitrary-code Golden Journey `d6b293e4`; role-aware AR/AP/cash-flow/project-contract reporting and prepared role uniqueness `dbe9170c`; incremental self-healing posting profiles `73bd9f3f`. Push-run IDs remain unavailable through the current connector, so latest CI/real-DOM is still NOT VERIFIED; any new failure log must be diagnosed before acceptance. |
index.html
+7
-7
@@ -236,13 +236,13 @@ body{background:#f6f9fc}
236
<div class="brand-copy"><h2>فینورا</h2><small>نسخه ۱.۰</small><span class="sr-only">فینورا — نسخه ۱.۰</span></div>
237
</div>
238
<div class="module-rail" id="module-rail">
239
- <button class="module-tab" data-module="accounting" data-view="view-accounting-foundation" onclick="openModule('accounting','view-accounting-foundation')" title="حسابداری"><span>▦</span><b>حسابداری</b></button>
240
- <button class="module-tab active" data-module="home" data-view="view-dashboard" onclick="openModule('home','view-dashboard')" title="خانه"><span>⌂</span><b>خانه</b></button>
241
- <button class="module-tab" data-module="projects" data-view="view-contracting" onclick="openModule('projects','view-contracting')" title="پروژه و پیمان"><span>▧</span><b>پیمان</b></button>
239
+ <button class="module-tab active" data-module="dashboard" data-view="view-dashboard" onclick="openModule('dashboard','view-dashboard','overview')" title="داشبورد"><span>⌂</span><b>داشبورد</b></button>
240
+ <button class="module-tab" data-module="accounting" data-view="view-accounting-foundation" onclick="openModule('accounting','view-accounting-foundation','accounts')" title="حسابداری"><span>▦</span><b>حسابداری</b></button>
241
<button class="module-tab" data-module="commerce" data-view="view-invoices" onclick="openModule('commerce','view-invoices')" title="بازرگانی"><span>⇄</span><b>بازرگانی</b></button>
242
<button class="module-tab" data-module="treasury" data-view="view-payments" onclick="openModule('treasury','view-payments')" title="خزانهداری"><span>◈</span><b>خزانه</b></button>
244
- <button class="module-tab" data-module="catalog" data-view="view-products" onclick="openModule('catalog','view-products')" title="کالا و خدمات"><span>◇</span><b>کالا</b></button>
245
- <button class="module-tab" data-module="erp" data-view="view-inventory" onclick="openModule('erp','view-inventory')" title="عملیات تکمیلی"><span>▦</span><b>ERP</b></button>
243
+ <button class="module-tab" data-module="projects" data-view="view-contracting" onclick="openModule('projects','view-contracting')" title="پروژه و قرارداد"><span>▧</span><b>پروژه</b></button>
244
+ <button class="module-tab" data-module="inventory" data-view="view-inventory" onclick="openModule('inventory','view-inventory','stock')" title="انبار"><span>▦</span><b>انبار</b></button>
245
+ <button class="module-tab" data-module="assets" data-view="view-assets" onclick="openModule('assets','view-assets','asset-register')" title="دارایی ثابت"><span>◆</span><b>دارایی</b></button>
246
<button class="module-tab" data-module="reports" data-view="view-reports" onclick="openModule('reports','view-reports')" title="گزارشها"><span>▥</span><b>گزارش</b></button>
247
<button class="module-tab" data-module="settings" data-view="view-settings" onclick="openModule('settings','view-settings')" title="تنظیمات"><span>⚙</span><b>تنظیمات</b></button>
248
</div>
@@ -253,7 +253,7 @@ body{background:#f6f9fc}
253
</aside>
254
<aside class="module-panel no-print" id="module-panel" aria-label="زیرمنوی ماژول">
255
<div class="module-panel-head">
256
- <div><small>فضای کاری</small><h3 id="module-panel-title">خانه</h3></div>
256
+ <div><small>زیرسیستم</small><h3 id="module-panel-title">داشبورد</h3></div>
257
<button class="panel-collapse" onclick="toggleModulePanel()" aria-label="جمع کردن زیرمنو" title="جمع کردن">×</button>
258
</div>
259
<div id="module-panel-links" class="module-panel-links"></div>
@@ -277,7 +277,7 @@ body{background:#f6f9fc}
277
</a>
278
279
<main class="main-surface">
280
-<div class="workspace-context no-print"><span class="workspace-eyebrow">فضای کاری</span><strong id="workspace-title">داشبورد</strong><span id="workspace-context-text">نمای یکپارچه عملیات مالی</span></div>
280
+<div class="workspace-context no-print"><span class="workspace-eyebrow">مسیر کاری</span><strong id="workspace-title">داشبورد</strong><span id="workspace-context-text">نمای یکپارچه عملیات مالی</span></div>
281
282
283
<section id="view-dashboard" class="view-pane active">
js/accounting-foundation-ui.js
+6
-6
@@ -3,18 +3,18 @@ function ensureAccountingFoundationView(){
3
if(document.getElementById('view-accounting-foundation'))return;
4
const s=document.createElement('section');s.id='view-accounting-foundation';s.className='view-pane';
5
s.innerHTML=`<div class="af-head"><div><h1>هسته حسابداری</h1><p>کدینگ، تفصیلی شناور، سال مالی، شعب و پروژههای سراسری</p></div><span class="badge badge-info">فاز ۲</span></div>
6
- <div class="card"><div style="display:flex;justify-content:space-between;gap:8px;align-items:center;flex-wrap:wrap"><div><h3>کدینگ حسابها — کل ← معین ← تفصیلی</h3><p class="af-hint">میتوانید کدینگ پیشنهادی نوع شرکت را بپذیرید، کدینگ را دستی بسازید یا روی شرکتِ دارای کدینگ خالی از Excel وارد کنید.</p></div><div style="display:flex;gap:6px;flex-wrap:wrap"><label class="btn btn-secondary btn-inline">ورود کدینگ از Excel<input type="file" accept=".xlsx,.xls" style="display:none" onchange="afImportAccountsFromExcel(event)"></label><button class="btn btn-secondary btn-inline" onclick="downloadAccountsExcelTemplate()">نمونه Excel کدینگ</button></div></div><div class="form-row">
6
+ <div class="card" data-finora-task="accounts"><div style="display:flex;justify-content:space-between;gap:8px;align-items:center;flex-wrap:wrap"><div><h3>کدینگ حسابها — کل ← معین ← تفصیلی</h3><p class="af-hint">میتوانید کدینگ پیشنهادی نوع شرکت را بپذیرید، کدینگ را دستی بسازید یا روی شرکتِ دارای کدینگ خالی از Excel وارد کنید.</p></div><div style="display:flex;gap:6px;flex-wrap:wrap"><label class="btn btn-secondary btn-inline">ورود کدینگ از Excel<input type="file" accept=".xlsx,.xls" style="display:none" onchange="afImportAccountsFromExcel(event)"></label><button class="btn btn-secondary btn-inline" onclick="downloadAccountsExcelTemplate()">نمونه Excel کدینگ</button></div></div><div class="form-row">
7
<div class="form-group"><label>سطح</label><select id="af-account-level" class="form-control" onchange="afParents()"><option value="gl">کل</option><option value="subsidiary">معین</option><option value="detail">تفصیلی</option></select></div>
8
<div class="form-group"><label>کد</label><input id="af-account-code" class="form-control"></div><div class="form-group"><label>عنوان</label><input id="af-account-title" class="form-control"></div>
9
<div class="form-group"><label>ماهیت</label><select id="af-account-nature" class="form-control"><option value="debit">بدهکار</option><option value="credit">بستانکار</option><option value="both">دوماهیتی</option></select></div><div class="form-group"><label>نوع حساب</label><select id="af-account-type" class="form-control"><option value="asset">دارایی</option><option value="liability">بدهی</option><option value="equity">حقوق مالکانه</option><option value="revenue">درآمد</option><option value="expense">هزینه</option><option value="memorandum">انتظامی</option><option value="control">کنترلی</option></select></div><div class="form-group"><label>نقش سیستمی ثبت خودکار</label><select id="af-account-role" class="form-control"><option value="">— بدون نقش پیشفرض —</option><option value="cash_default">نقد/بانک پیشفرض</option><option value="receivable_control">دریافتنی تجاری</option><option value="payable_control">پرداختنی تجاری</option><option value="revenue_default">درآمد/فروش پیشفرض</option><option value="purchase_default">خرید/بهای تمامشده پیشفرض</option><option value="expense_default">هزینه پیشفرض</option><option value="other_income_default">سایر درآمد پیشفرض</option><option value="vat_payable">مالیات پرداختنی</option><option value="vat_recoverable">مالیات دریافتنی</option></select></div></div>
10
<div class="form-group"><label>حساب والد</label><select id="af-account-parent" class="form-control"></select></div><button class="btn btn-success" onclick="afSaveAccount()">ثبت حساب</button>
11
<div class="table-responsive af-space"><table><thead><tr><th>کد</th><th>عنوان</th><th>سطح</th><th>نوع</th><th>نقش سیستمی</th><th>ماهیت</th><th>ثبت</th><th></th></tr></thead><tbody id="af-accounts-body"></tbody></table></div></div>
12
- <div class="card"><h3>قواعد تفصیلی شناور</h3><div class="form-row"><div class="form-group"><label>حساب</label><select id="af-rule-account" class="form-control"></select></div><div class="form-group"><label>تفصیلی</label><select id="af-rule-dimension" class="form-control"></select></div><div class="form-group"><label>کاربرد</label><select id="af-rule-app" class="form-control"><option value="required">الزامی</option><option value="optional">اختیاری</option><option value="unavailable">غیرمجاز</option></select></div></div><button class="btn btn-primary" onclick="afSaveRule()">ثبت قاعده</button><div id="af-rules-list" class="af-list"></div></div>
13
- <div class="card"><h3>ابعاد تحلیلی / تفصیلیهای شناور</h3><p class="af-hint">چهار جایگاه سازگار با قرارداد: شناور ۱ شعبه، شناور ۲ طرفحساب، شناور ۳ پروژه، شناور ۴ قرارداد/پیمان. موتور داخلی Generic است و میتوانید ابعاد بیشتری هم تعریف کنید. عمق ساختار بعد از ایجاد اولین مقدار قفل میشود و فقط Leaf نهایی قابل ثبت است.</p><div class="form-row"><div class="form-group"><label>کد</label><input id="af-dim-code" class="form-control"></div><div class="form-group"><label>عنوان</label><input id="af-dim-title" class="form-control"></div><div class="form-group"><label>منبع</label><select id="af-dim-source" class="form-control"><option value="manual">دستی</option><option value="contact">اشخاص</option><option value="project">پروژهها</option><option value="branch">شعب</option><option value="contract">قرارداد / پیمان</option><option value="costCenter">مرکز هزینه</option></select></div><div class="form-group"><label>عمق ساختار (Hierarchy Depth)</label><input id="af-dim-depth" type="number" min="1" max="8" value="1" class="form-control"></div></div><button class="btn btn-success" onclick="afSaveDimension()">ثبت تفصیلی</button><div id="af-dimensions-list" class="af-list"></div>
12
+ <div class="card" data-finora-task="rules"><h3>قواعد تفصیلی شناور</h3><div class="form-row"><div class="form-group"><label>حساب</label><select id="af-rule-account" class="form-control"></select></div><div class="form-group"><label>تفصیلی</label><select id="af-rule-dimension" class="form-control"></select></div><div class="form-group"><label>کاربرد</label><select id="af-rule-app" class="form-control"><option value="required">الزامی</option><option value="optional">اختیاری</option><option value="unavailable">غیرمجاز</option></select></div></div><button class="btn btn-primary" onclick="afSaveRule()">ثبت قاعده</button><div id="af-rules-list" class="af-list"></div></div>
13
+ <div class="card" data-finora-task="dimensions"><h3>ابعاد تحلیلی / تفصیلیهای شناور</h3><p class="af-hint">چهار جایگاه سازگار با قرارداد: شناور ۱ شعبه، شناور ۲ طرفحساب، شناور ۳ پروژه، شناور ۴ قرارداد/پیمان. موتور داخلی Generic است و میتوانید ابعاد بیشتری هم تعریف کنید. عمق ساختار بعد از ایجاد اولین مقدار قفل میشود و فقط Leaf نهایی قابل ثبت است.</p><div class="form-row"><div class="form-group"><label>کد</label><input id="af-dim-code" class="form-control"></div><div class="form-group"><label>عنوان</label><input id="af-dim-title" class="form-control"></div><div class="form-group"><label>منبع</label><select id="af-dim-source" class="form-control"><option value="manual">دستی</option><option value="contact">اشخاص</option><option value="project">پروژهها</option><option value="branch">شعب</option><option value="contract">قرارداد / پیمان</option><option value="costCenter">مرکز هزینه</option></select></div><div class="form-group"><label>عمق ساختار (Hierarchy Depth)</label><input id="af-dim-depth" type="number" min="1" max="8" value="1" class="form-control"></div></div><button class="btn btn-success" onclick="afSaveDimension()">ثبت تفصیلی</button><div id="af-dimensions-list" class="af-list"></div>
14
<hr><div class="form-row"><div class="form-group"><label>تفصیلی دستی</label><select id="af-value-dim" class="form-control" onchange="renderAccountingFoundation()"></select></div><div class="form-group"><label>کد مقدار</label><input id="af-value-code" class="form-control"></div><div class="form-group"><label>عنوان مقدار</label><input id="af-value-title" class="form-control"></div><div class="form-group"><label>والد / سطح بالاتر</label><select id="af-value-parent" class="form-control"></select></div></div><button class="btn btn-primary" onclick="afSaveDimensionValue()">ثبت مقدار</button><div id="af-values-list" class="af-list"></div></div>
15
- <div class="af-grid"><div class="card"><h3>سال مالی</h3><div class="form-group"><label>عنوان</label><input id="af-fy-title" class="form-control"></div><div class="form-row"><div class="form-group"><label>شروع</label><input id="af-fy-start" class="form-control" placeholder="1405/01/01"></div><div class="form-group"><label>پایان</label><input id="af-fy-end" class="form-control" placeholder="1405/12/29"></div></div><button class="btn btn-success" onclick="afSaveFiscal()">ثبت</button><div id="af-fiscal-list" class="af-list"></div></div>
16
- <div class="card"><h3>شعب</h3><div class="form-row"><div class="form-group"><label>کد</label><input id="af-branch-code" class="form-control"></div><div class="form-group"><label>نام</label><input id="af-branch-name" class="form-control"></div></div><button class="btn btn-success" onclick="afSaveBranch()">ثبت</button><div id="af-branches-list" class="af-list"></div></div></div>
17
- <div class="card"><h3>پروژههای سراسری</h3><p class="af-hint">پروژه یکبار تعریف و به چند طرفحساب متصل میشود.</p><div class="form-row"><div class="form-group"><label>کد</label><input id="af-project-code" class="form-control"></div><div class="form-group"><label>نام</label><input id="af-project-name" class="form-control"></div><div class="form-group"><label>والد</label><select id="af-project-parent" class="form-control"></select></div><div class="form-group"><label>شعبه</label><select id="af-project-branch" class="form-control"></select></div></div><div class="form-group"><label>طرفحسابهای مرتبط</label><select id="af-project-contacts" class="form-control" multiple size="4"></select></div><button class="btn btn-success" onclick="afSaveProject()">ثبت پروژه</button><div id="af-projects-list" class="af-list"></div></div>`;
15
+ <div class="af-grid"><div class="card" data-finora-task="fiscal"><h3>سال مالی</h3><div class="form-group"><label>عنوان</label><input id="af-fy-title" class="form-control"></div><div class="form-row"><div class="form-group"><label>شروع</label><input id="af-fy-start" class="form-control" placeholder="1405/01/01"></div><div class="form-group"><label>پایان</label><input id="af-fy-end" class="form-control" placeholder="1405/12/29"></div></div><button class="btn btn-success" onclick="afSaveFiscal()">ثبت</button><div id="af-fiscal-list" class="af-list"></div></div>
16
+ <div class="card" data-finora-task="branches"><h3>شعب</h3><div class="form-row"><div class="form-group"><label>کد</label><input id="af-branch-code" class="form-control"></div><div class="form-group"><label>نام</label><input id="af-branch-name" class="form-control"></div></div><button class="btn btn-success" onclick="afSaveBranch()">ثبت</button><div id="af-branches-list" class="af-list"></div></div></div>
17
+ <div class="card" data-finora-task="projects"><h3>پروژههای سراسری</h3><p class="af-hint">پروژه یکبار تعریف و به چند طرفحساب متصل میشود.</p><div class="form-row"><div class="form-group"><label>کد</label><input id="af-project-code" class="form-control"></div><div class="form-group"><label>نام</label><input id="af-project-name" class="form-control"></div><div class="form-group"><label>والد</label><select id="af-project-parent" class="form-control"></select></div><div class="form-group"><label>شعبه</label><select id="af-project-branch" class="form-control"></select></div></div><div class="form-group"><label>طرفحسابهای مرتبط</label><select id="af-project-contacts" class="form-control" multiple size="4"></select></div><button class="btn btn-success" onclick="afSaveProject()">ثبت پروژه</button><div id="af-projects-list" class="af-list"></div></div>`;
18
const main=document.querySelector('.main-surface'),p=document.getElementById('printable-invoice');if(p)main.insertBefore(s,p);else main.appendChild(s);
19
}
20
function afParents(){const l=document.getElementById('af-account-level')?.value,p=document.getElementById('af-account-parent');if(!p)return;const n=l==='subsidiary'?'gl':l==='detail'?'subsidiary':'';p.disabled=!n;p.innerHTML='<option value="">— بدون والد —</option>'+getMyAccounts().filter(x=>x.level===n).map(x=>'<option value="'+x.id+'">'+esc(x.code)+' — '+esc(x.title)+'</option>').join('')}
js/journal-ui.js
+3
-3
@@ -1,9 +1,9 @@
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>
4
- <div class="card"><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"><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"><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);
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);
7
}
8
function jeAddRow(){
9
const box=document.getElementById('je-lines');if(!box)return;const row=document.createElement('div');row.className='form-row je-line';row.innerHTML='<div class="form-group"><label>حساب</label><select class="form-control je-account" onchange="jeRenderDims(this.closest(\'.je-line\'))"><option value="">انتخاب حساب</option>'+getMyAccounts().filter(x=>x.postingAllowed&&x.active!==false).map(x=>'<option value="'+x.id+'">'+esc(x.code)+' — '+esc(x.title)+'</option>').join('')+'</select></div><div class="form-group"><label>بدهکار</label><input class="form-control je-debit" inputmode="decimal"></div><div class="form-group"><label>بستانکار</label><input class="form-control je-credit" inputmode="decimal"></div><div class="form-group"><label>شرح</label><input class="form-control je-line-desc"></div><button class="btn btn-danger btn-inline" onclick="this.closest(\'.je-line\').remove()">×</button><div class="je-dims" style="width:100%"></div>';box.appendChild(row);
js/phase6-reporting.js
+9
-9
@@ -27,15 +27,15 @@
27
function render(){
28
const root=document.getElementById('p6-reporting-root');if(!root)return;const from=document.getElementById('p6-from')?.value||'',to=document.getElementById('p6-to')?.value||'',accountId=document.getElementById('p6-account')?.value||'',dimensionValueId=document.getElementById('p6-dimension')?.value||'',f=financials(from,to),a=aging(to||getJalaliNumeric()),cf=cashFlow(from,to),led=ledger({from,to,accountId,dimensionValueId}),projects=projectContractSummary(),legacy=legacyCutoverPreview(),dr=f.trial.reduce((s,x)=>s+x.debit,0),cr=f.trial.reduce((s,x)=>s+x.credit,0);
29
const accounts=typeof getMyAccounts==='function'?getMyAccounts().filter(x=>x.postingAllowed):[],avs=analyticValues();
30
- root.innerHTML='<div class="card no-print"><h3>فیلتر گزارشهای حرفهای</h3><div class="form-row"><div class="form-group"><label>از تاریخ</label><input id="p6-from" class="form-control" value="'+esc(from)+'"></div><div class="form-group"><label>تا تاریخ</label><input id="p6-to" class="form-control" value="'+esc(to)+'"></div><div class="form-group"><label>حساب</label><select id="p6-account" class="form-control"><option value="">همه حسابها</option>'+accounts.map(x=>'<option value="'+esc(x.id)+'">'+esc((x.code||'')+' — '+x.title)+'</option>').join('')+'</select></div><div class="form-group"><label>بعد تحلیلی</label><select id="p6-dimension" class="form-control"><option value="">همه ابعاد</option>'+avs.map(x=>'<option value="'+esc(x.id)+'">'+esc(x.title)+'</option>').join('')+'</select></div></div><button class="btn btn-primary" onclick="P6Reports.render()">اعمال فیلتر</button></div>'+
31
- '<div class="grid-kpi"><div class="kpi-unit"><div><div class="kpi-lbl">جمع بدهکار</div><div class="kpi-val">'+fmt(dr)+'</div></div></div><div class="kpi-unit"><div><div class="kpi-lbl">جمع بستانکار</div><div class="kpi-val">'+fmt(cr)+'</div></div></div><div class="kpi-unit"><div><div class="kpi-lbl">سود/زیان دفتر</div><div class="kpi-val">'+fmt(f.profit)+'</div></div></div><div class="kpi-unit"><div><div class="kpi-lbl">کنترل تراز</div><div class="kpi-val">'+(Math.abs(dr-cr)<.001?'تراز':'نامتوازن')+'</div></div></div></div>'+
32
- '<div class="card"><h3>تراز آزمایشی</h3><div class="table-responsive"><table><thead><tr><th>کد</th><th>حساب</th><th>گردش بدهکار</th><th>گردش بستانکار</th><th>مانده</th></tr></thead><tbody>'+f.trial.map(x=>'<tr><td>'+esc(x.code)+'</td><td>'+esc(x.title)+'</td><td>'+fmt(x.debit)+'</td><td>'+fmt(x.credit)+'</td><td>'+fmt(x.balance)+'</td></tr>').join('')+'</tbody></table></div></div>'+
33
- '<div class="card"><h3>دفتر کل / معین / تفصیلی و تحلیلی</h3><div class="table-responsive"><table><thead><tr><th>تاریخ</th><th>شماره سند</th><th>حساب</th><th>شرح</th><th>بدهکار</th><th>بستانکار</th></tr></thead><tbody>'+led.map(r=>'<tr><td>'+esc(dateOf(r))+'</td><td><button class="btn btn-secondary btn-inline" onclick="switchView(\'view-journal\')">'+esc(r.voucher?.number||r.voucherId)+'</button></td><td>'+esc((r.account?.code||'')+' — '+(r.account?.title||''))+'</td><td>'+esc(r.description||r.voucher?.description||'')+'</td><td>'+fmt(r.debit)+'</td><td>'+fmt(r.credit)+'</td></tr>').join('')+'</tbody></table></div></div>'+
34
- '<div class="card"><h3>صورت سود و زیان / وضعیت مالی</h3><div class="table-responsive"><table><tbody><tr><td>درآمد</td><td>'+fmt(f.revenue)+'</td><td>دارایی</td><td>'+fmt(f.assets)+'</td></tr><tr><td>هزینه و بهای تمامشده</td><td>'+fmt(f.expense)+'</td><td>بدهی</td><td>'+fmt(f.liabilities)+'</td></tr><tr><td><strong>سود/زیان</strong></td><td><strong>'+fmt(f.profit)+'</strong></td><td>حقوق مالکانه</td><td>'+fmt(f.equity)+'</td></tr></tbody></table></div></div>'+
35
- '<div class="card"><h3>صورت جریان وجوه نقد</h3><div class="table-responsive"><table><tbody><tr><td>عملیاتی</td><td>'+fmt(cf.operating)+'</td></tr><tr><td>سرمایهگذاری</td><td>'+fmt(cf.investing)+'</td></tr><tr><td>تأمین مالی</td><td>'+fmt(cf.financing)+'</td></tr><tr><td><strong>خالص تغییر نقد</strong></td><td><strong>'+fmt(cf.total)+'</strong></td></tr></tbody></table></div></div>'+
36
- '<div class="card"><h3>سن مطالبات / بدهیها</h3><div class="table-responsive"><table><thead><tr><th>نوع</th><th>۰–۳۰</th><th>۳۱–۶۰</th><th>۶۱–۹۰</th><th>۹۰+</th></tr></thead><tbody><tr><td>مطالبات</td><td>'+fmt(a.receivable['0-30'])+'</td><td>'+fmt(a.receivable['31-60'])+'</td><td>'+fmt(a.receivable['61-90'])+'</td><td>'+fmt(a.receivable['90+'])+'</td></tr><tr><td>بدهی</td><td>'+fmt(a.payable['0-30'])+'</td><td>'+fmt(a.payable['31-60'])+'</td><td>'+fmt(a.payable['61-90'])+'</td><td>'+fmt(a.payable['90+'])+'</td></tr></tbody></table></div></div>'+
37
- '<div class="card"><h3>گزارش تجمیعی پروژه و پیمان</h3><div class="table-responsive"><table><thead><tr><th>پروژه</th><th>تعداد پیمان</th><th>ارزش پیمان</th><th>صورتوضعیت قطعی</th><th>سود/زیان پیمان</th></tr></thead><tbody>'+projects.map(x=>'<tr><td>'+esc(x.project.name||x.project.title||x.project.id)+'</td><td>'+x.contracts.toLocaleString('fa-IR')+'</td><td>'+fmt(x.value)+'</td><td>'+fmt(x.statements)+'</td><td>'+fmt(x.profit)+'</td></tr>').join('')+'</tbody></table></div></div>'+
38
- '<div class="card"><h3>کنترل انتقال سوابق Finora 1.0</h3><p style="font-size:12px;color:var(--text-muted);margin-bottom:10px">فقط اسناد فروش قطعی فاقد سند حسابداری نمایش داده میشوند. پیشفاکتور هرگز به دفتر منتقل نمیشود. ثبت تاریخی نیازمند کدینگ معتبر و تأیید صریح است.</p><div class="table-responsive"><table><thead><tr><th>شماره</th><th>تاریخ</th><th>نوع</th><th>مبلغ</th><th>وضعیت</th><th>عملیات</th></tr></thead><tbody>'+legacy.map(x=>'<tr><td>'+esc(x.number)+'</td><td>'+esc(x.date)+'</td><td>'+esc(x.kind)+'</td><td>'+fmt(x.amount)+'</td><td>'+esc(x.readiness==='posted'?'منتقلشده':x.readiness==='ready'?'آماده انتقال':'نیازمند تکمیل کدینگ')+'</td><td>'+(x.readiness==='ready'?'<button class="btn btn-danger btn-inline" onclick="P6Reports.postLegacyInvoice(\''+esc(x.id)+'\')">ثبت کنترلشده</button>':'—')+'</td></tr>').join('')+'</tbody></table></div></div>';
30
+ root.innerHTML='<div class="card no-print" data-finora-task="all trial ledger financials cashflow aging projects cutover"><h3>فیلتر گزارشهای حرفهای</h3><div class="form-row"><div class="form-group"><label>از تاریخ</label><input id="p6-from" class="form-control" value="'+esc(from)+'"></div><div class="form-group"><label>تا تاریخ</label><input id="p6-to" class="form-control" value="'+esc(to)+'"></div><div class="form-group"><label>حساب</label><select id="p6-account" class="form-control"><option value="">همه حسابها</option>'+accounts.map(x=>'<option value="'+esc(x.id)+'">'+esc((x.code||'')+' — '+x.title)+'</option>').join('')+'</select></div><div class="form-group"><label>بعد تحلیلی</label><select id="p6-dimension" class="form-control"><option value="">همه ابعاد</option>'+avs.map(x=>'<option value="'+esc(x.id)+'">'+esc(x.title)+'</option>').join('')+'</select></div></div><button class="btn btn-primary" onclick="P6Reports.render()">اعمال فیلتر</button></div>'+
31
+ '<div class="grid-kpi" data-finora-task="all trial financials"><div class="kpi-unit"><div><div class="kpi-lbl">جمع بدهکار</div><div class="kpi-val">'+fmt(dr)+'</div></div></div><div class="kpi-unit"><div><div class="kpi-lbl">جمع بستانکار</div><div class="kpi-val">'+fmt(cr)+'</div></div></div><div class="kpi-unit"><div><div class="kpi-lbl">سود/زیان دفتر</div><div class="kpi-val">'+fmt(f.profit)+'</div></div></div><div class="kpi-unit"><div><div class="kpi-lbl">کنترل تراز</div><div class="kpi-val">'+(Math.abs(dr-cr)<.001?'تراز':'نامتوازن')+'</div></div></div></div>'+
32
+ '<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>'+f.trial.map(x=>'<tr><td>'+esc(x.code)+'</td><td>'+esc(x.title)+'</td><td>'+fmt(x.debit)+'</td><td>'+fmt(x.credit)+'</td><td>'+fmt(x.balance)+'</td></tr>').join('')+'</tbody></table></div></div>'+
33
+ '<div class="card" data-finora-task="ledger"><h3>دفتر کل / معین / تفصیلی و تحلیلی</h3><div class="table-responsive"><table><thead><tr><th>تاریخ</th><th>شماره سند</th><th>حساب</th><th>شرح</th><th>بدهکار</th><th>بستانکار</th></tr></thead><tbody>'+led.map(r=>'<tr><td>'+esc(dateOf(r))+'</td><td><button class="btn btn-secondary btn-inline" onclick="switchView(\'view-journal\')">'+esc(r.voucher?.number||r.voucherId)+'</button></td><td>'+esc((r.account?.code||'')+' — '+(r.account?.title||''))+'</td><td>'+esc(r.description||r.voucher?.description||'')+'</td><td>'+fmt(r.debit)+'</td><td>'+fmt(r.credit)+'</td></tr>').join('')+'</tbody></table></div></div>'+
34
+ '<div class="card" data-finora-task="financials"><h3>صورت سود و زیان / وضعیت مالی</h3><div class="table-responsive"><table><tbody><tr><td>درآمد</td><td>'+fmt(f.revenue)+'</td><td>دارایی</td><td>'+fmt(f.assets)+'</td></tr><tr><td>هزینه و بهای تمامشده</td><td>'+fmt(f.expense)+'</td><td>بدهی</td><td>'+fmt(f.liabilities)+'</td></tr><tr><td><strong>سود/زیان</strong></td><td><strong>'+fmt(f.profit)+'</strong></td><td>حقوق مالکانه</td><td>'+fmt(f.equity)+'</td></tr></tbody></table></div></div>'+
35
+ '<div class="card" data-finora-task="cashflow"><h3>صورت جریان وجوه نقد</h3><div class="table-responsive"><table><tbody><tr><td>عملیاتی</td><td>'+fmt(cf.operating)+'</td></tr><tr><td>سرمایهگذاری</td><td>'+fmt(cf.investing)+'</td></tr><tr><td>تأمین مالی</td><td>'+fmt(cf.financing)+'</td></tr><tr><td><strong>خالص تغییر نقد</strong></td><td><strong>'+fmt(cf.total)+'</strong></td></tr></tbody></table></div></div>'+
36
+ '<div class="card" data-finora-task="aging"><h3>سن مطالبات / بدهیها</h3><div class="table-responsive"><table><thead><tr><th>نوع</th><th>۰–۳۰</th><th>۳۱–۶۰</th><th>۶۱–۹۰</th><th>۹۰+</th></tr></thead><tbody><tr><td>مطالبات</td><td>'+fmt(a.receivable['0-30'])+'</td><td>'+fmt(a.receivable['31-60'])+'</td><td>'+fmt(a.receivable['61-90'])+'</td><td>'+fmt(a.receivable['90+'])+'</td></tr><tr><td>بدهی</td><td>'+fmt(a.payable['0-30'])+'</td><td>'+fmt(a.payable['31-60'])+'</td><td>'+fmt(a.payable['61-90'])+'</td><td>'+fmt(a.payable['90+'])+'</td></tr></tbody></table></div></div>'+
37
+ '<div class="card" data-finora-task="projects"><h3>گزارش تجمیعی پروژه و پیمان</h3><div class="table-responsive"><table><thead><tr><th>پروژه</th><th>تعداد پیمان</th><th>ارزش پیمان</th><th>صورتوضعیت قطعی</th><th>سود/زیان پیمان</th></tr></thead><tbody>'+projects.map(x=>'<tr><td>'+esc(x.project.name||x.project.title||x.project.id)+'</td><td>'+x.contracts.toLocaleString('fa-IR')+'</td><td>'+fmt(x.value)+'</td><td>'+fmt(x.statements)+'</td><td>'+fmt(x.profit)+'</td></tr>').join('')+'</tbody></table></div></div>'+
38
+ '<div class="card" data-finora-task="cutover"><h3>کنترل انتقال سوابق Finora 1.0</h3><p style="font-size:12px;color:var(--text-muted);margin-bottom:10px">فقط اسناد فروش قطعی فاقد سند حسابداری نمایش داده میشوند. پیشفاکتور هرگز به دفتر منتقل نمیشود. ثبت تاریخی نیازمند کدینگ معتبر و تأیید صریح است.</p><div class="table-responsive"><table><thead><tr><th>شماره</th><th>تاریخ</th><th>نوع</th><th>مبلغ</th><th>وضعیت</th><th>عملیات</th></tr></thead><tbody>'+legacy.map(x=>'<tr><td>'+esc(x.number)+'</td><td>'+esc(x.date)+'</td><td>'+esc(x.kind)+'</td><td>'+fmt(x.amount)+'</td><td>'+esc(x.readiness==='posted'?'منتقلشده':x.readiness==='ready'?'آماده انتقال':'نیازمند تکمیل کدینگ')+'</td><td>'+(x.readiness==='ready'?'<button class="btn btn-danger btn-inline" onclick="P6Reports.postLegacyInvoice(\''+esc(x.id)+'\')">ثبت کنترلشده</button>':'—')+'</td></tr>').join('')+'</tbody></table></div></div>';
39
const ae=document.getElementById('p6-account'),de=document.getElementById('p6-dimension');if(ae)ae.value=accountId;if(de)de.value=dimensionValueId;
40
}
41
window.P6Reports={ledger,rollup,financials,aging,cashFlow,projectContractSummary,legacyCutoverPreview,postLegacyInvoice,render};
js/ui.js
+56
-36
@@ -58,44 +58,49 @@ function handleContactEntityChange(){const el=document.getElementById('contact-e
58
function handleQuickCEntityChange(){const el=document.getElementById('quick-c-entity');if(!el)return;applyEntityTypeToForm(el.value,{prefixId:'box-quick-c-prefix',nameId:'box-quick-c-name',econId:'box-quick-c-economic',regId:'box-quick-c-reg',nationalLabelId:'label-quick-c-national'});}
59
60
61
-/* Phase 1 scalable navigation shell */
61
+/* Enterprise two-tier navigation shell — IA v2 */
62
const FINORA_MODULES={
63
- accounting:{title:'حسابداری',context:'اسناد، کدینگ و دفاتر',groups:[{title:'عملیات',items:[['اسناد حسابداری','view-journal','▤']]},{title:'دادههای پایه',items:[['هسته حسابداری','view-accounting-foundation','▦']]}]},
64
- home:{title:'خانه',context:'نمای یکپارچه عملیات مالی',groups:[{title:'نمای کلی',items:[['داشبورد','view-dashboard','⌂']]}]},
65
- projects:{title:'پروژه و پیمان',context:'پروژهها، قراردادها، کسورات، تضمینها و صورتوضعیتها',groups:[{title:'عملیات پیمان',items:[['قراردادها و پیمان','view-contracting','▧']]},{title:'داده پایه',items:[['هسته حسابداری','view-accounting-foundation','▦']]}]},
66
- commerce:{title:'بازرگانی',context:'فروش، خرید و مدیریت اشخاص',groups:[{title:'عملیات بازرگانی',items:[['فروش','view-invoices','▤'],['خرید','view-purchases','▣'],['اشخاص','view-contacts','◎']]},{title:'داده پایه',items:[['کالا و خدمات','view-products','◇']]},{title:'کنترل',items:[['هزینهها و درآمد','view-expenses','◌']]}]},
67
- treasury:{title:'خزانهداری',context:'دریافت، پرداخت و چک',groups:[{title:'عملیات روزانه',items:[['دریافت و پرداخت','view-payments','↔'],['چکها و صیاد','view-cheques','◈']]},{title:'مرتبط',items:[['هزینهها و درآمد','view-expenses','◌']]}]},
68
- catalog:{title:'کالا و خدمات',context:'داده پایه کالا و خدمت',groups:[{title:'داده پایه',items:[['کالاها و خدمات','view-products','◇']]},{title:'گردش',items:[['فروش','view-invoices','▤'],['خرید','view-purchases','▣']]}]},
69
- erp:{title:'عملیات تکمیلی',context:'انبار، دارایی ثابت، ارز، داده و یکپارچهسازی',groups:[{title:'لجستیک و بها',items:[['انبار و بهای تمامشده','view-inventory','▦']]},{title:'دارایی و ارز',items:[['دارایی ثابت','view-assets','◆'],['ارز و نرخ تبدیل','view-currency','¤']]},{title:'داده و تحلیل',items:[['مرکز داده و هزینه','view-data-center','◎'],['اتصالات و API','view-integrations','⇆']]}]},
70
- reports:{title:'گزارشها',context:'تحلیل مالی و مدیریتی',groups:[{title:'گزارشهای حسابداری',items:[['دفاتر و صورتهای مالی','view-accounting-reports','▦'],['گزارشهای عملیاتی','view-reports','▥'],['داشبورد تحلیلی','view-dashboard','⌂']]}]},
71
- settings:{title:'تنظیمات',context:'شرکت، پیکربندی و دسترسی',groups:[{title:'مدیریت',items:[['تنظیمات و شرکتها','view-settings','⚙'],['مدیریت کاربران و لایسنس','view-admin','♙','admin']]}]}
63
+ dashboard:{title:'داشبورد',context:'نمای مدیریتی و دسترسی سریع',groups:[{title:'نمای کلی',items:[['داشبورد','view-dashboard','⌂','','overview']]}]},
64
+ accounting:{title:'حسابداری',context:'کدینگ، اسناد، دفاتر و کنترل مالی',groups:[
65
+ {title:'اطلاعات پایه',items:[['کدینگ حسابها','view-accounting-foundation','▦','','accounts'],['تفصیلیهای شناور','view-accounting-foundation','⌘','','dimensions'],['قواعد حساب و تفصیلی','view-accounting-foundation','≡','','rules'],['سالهای مالی','view-accounting-foundation','▣','','fiscal'],['شعب','view-accounting-foundation','⌂','','branches'],['ارز و نرخ تبدیل','view-currency','¤'],['مراکز هزینه','view-data-center','◎','','cost-centers']]},
66
+ {title:'عملیات حسابداری',items:[['ثبت سند حسابداری','view-journal','+','','new'],['فهرست اسناد حسابداری','view-journal','▤','','register']]},
67
+ {title:'دفاتر و گزارشها',items:[['تراز آزمایشی','view-accounting-reports','▥','','trial'],['دفتر کل / معین / تفصیلی','view-accounting-reports','▤','','ledger'],['صورتهای مالی','view-accounting-reports','◫','','financials'],['جریان وجوه نقد','view-accounting-reports','↕','','cashflow'],['سن مطالبات و بدهیها','view-accounting-reports','◷','','aging']]}
68
+ ]},
69
+ commerce:{title:'بازرگانی',context:'اشخاص، کالا، فروش و خرید',groups:[{title:'اطلاعات پایه',items:[['اشخاص','view-contacts','◎'],['کالا و خدمات','view-products','◇']]},{title:'فروش',items:[['فاکتور فروش','view-invoices','▤']]},{title:'خرید',items:[['فاکتور خرید','view-purchases','▣']]},{title:'کنترل',items:[['هزینه و درآمد','view-expenses','◌']]}]},
70
+ treasury:{title:'خزانهداری',context:'دریافت، پرداخت و اسناد بانکی',groups:[{title:'عملیات',items:[['دریافت و پرداخت','view-payments','↔'],['چکها و صیاد','view-cheques','◈']]}]},
71
+ projects:{title:'پروژه و قرارداد',context:'پروژه، پیمان، کسورات، تضمین و صورتوضعیت',groups:[{title:'اطلاعات پایه',items:[['پروژهها','view-accounting-foundation','▧','','projects']]},{title:'عملیات پیمان',items:[['قراردادها و پیمان','view-contracting','▦']]},{title:'گزارش',items:[['گزارش پروژه و پیمان','view-accounting-reports','▥','','projects']]}]},
72
+ inventory:{title:'انبار',context:'انبار، گردش، شمارش و بهای موجودی',groups:[{title:'اطلاعات پایه',items:[['تعریف انبار','view-inventory','▦','','warehouse']]},{title:'عملیات',items:[['گردش انبار','view-inventory','⇄','','movement'],['انبارگردانی','view-inventory','✓','','count']]},{title:'گزارش و کنترل',items:[['موجودی و بهای میانگین','view-inventory','▥','','stock']]}]},
73
+ assets:{title:'دارایی ثابت',context:'دارایی، استهلاک و ارزش دفتری',groups:[{title:'اطلاعات پایه',items:[['ثبت دارایی','view-assets','◆','','asset-new']]},{title:'عملیات و دفاتر',items:[['دفتر داراییها','view-assets','▤','','asset-register'],['استهلاک و سوابق','view-assets','◷','','depreciation']]}]},
74
+ reports:{title:'گزارشها',context:'گزارشهای حسابداری و مدیریتی',groups:[{title:'مدیریتی',items:[['گزارشهای عملیاتی','view-reports','▥']]},{title:'حسابداری',items:[['تراز آزمایشی','view-accounting-reports','▥','','trial'],['دفاتر حسابداری','view-accounting-reports','▤','','ledger'],['صورتهای مالی','view-accounting-reports','◫','','financials'],['جریان وجوه نقد','view-accounting-reports','↕','','cashflow'],['سن مطالبات / بدهی','view-accounting-reports','◷','','aging'],['پروژه / پیمان','view-accounting-reports','▧','','projects']]}]},
75
+ settings:{title:'تنظیمات',context:'شرکت، داده، دسترسی و یکپارچهسازی',groups:[{title:'شرکت و عملیات',items:[['شرکتها و تنظیمات عمومی','view-settings','⚙'],['تنظیمات عملیاتی','view-data-center','◌','','ops-settings']]},{title:'داده و پشتیبان',items:[['ورود/خروج داده و پشتیبان','view-data-center','⇅','','data-backup']]},{title:'یکپارچهسازی',items:[['اتصالات و API','view-integrations','⇆']]},{title:'مدیریت',items:[['کاربران و لایسنس','view-admin','♙','admin']]}]}
76
};
77
const FINORA_VIEW_HOME={
74
- 'view-contracting':'projects','view-journal':'accounting','view-accounting-foundation':'accounting','view-dashboard':'home','view-invoices':'commerce','view-purchases':'commerce','view-payments':'treasury',
75
- 'view-cheques':'treasury','view-expenses':'treasury','view-contacts':'commerce','view-products':'catalog','view-inventory':'erp','view-assets':'erp','view-currency':'erp','view-data-center':'erp','view-integrations':'erp',
76
- 'view-reports':'reports','view-accounting-reports':'reports','view-settings':'settings','view-admin':'settings'
78
+ 'view-dashboard':'dashboard','view-journal':'accounting','view-accounting-foundation':'accounting','view-accounting-reports':'accounting','view-currency':'accounting',
79
+ 'view-invoices':'commerce','view-purchases':'commerce','view-expenses':'commerce','view-contacts':'commerce','view-products':'commerce',
80
+ 'view-payments':'treasury','view-cheques':'treasury','view-contracting':'projects','view-inventory':'inventory','view-assets':'assets',
81
+ 'view-reports':'reports','view-data-center':'settings','view-integrations':'settings','view-settings':'settings','view-admin':'settings'
82
};
78
-const FINORA_COMMANDS=Object.entries(FINORA_MODULES).flatMap(([module,m])=>m.groups.flatMap(g=>g.items.map(i=>({module,moduleTitle:m.title,title:i[0],view:i[1],icon:i[2],guard:i[3]||''}))));
79
-
83
+const FINORA_COMMANDS=Object.entries(FINORA_MODULES).flatMap(([module,m])=>m.groups.flatMap(g=>g.items.map(i=>({module,moduleTitle:m.title,groupTitle:g.title,title:i[0],view:i[1],icon:i[2],guard:i[3]||'',task:i[4]||''}))));
84
+let FINORA_ACTIVE_TASK='';
85
function canShowShellCommand(cmd){
86
// Admin-only entries are shown based on the verified role of the signed-in user
87
// (server-side RLS/RPC still enforces the real permission).
88
if(cmd.guard==='admin')return !!(typeof currentUser!=='undefined'&¤tUser&¤tUser.role==='admin');
89
return true;
90
}
86
-function renderModulePanel(moduleKey,activeView){
87
- const m=FINORA_MODULES[moduleKey]||FINORA_MODULES.home;
91
+function renderModulePanel(moduleKey,activeView,activeTask=''){
92
+ const m=FINORA_MODULES[moduleKey]||FINORA_MODULES.dashboard;
93
const title=document.getElementById('module-panel-title'),box=document.getElementById('module-panel-links');
94
if(title)title.textContent=m.title;
95
if(!box)return;
91
- box.innerHTML=m.groups.map(g=>'<div class="module-group"><div class="module-group-title">'+g.title+'</div>'+g.items.filter(i=>canShowShellCommand({guard:i[3]||''})).map(i=>'<button class="module-link '+(i[1]===activeView?'active':'')+'" data-view="'+i[1]+'" onclick="navigateShell(\''+moduleKey+'\',\''+i[1]+'\')"><span class="mi">'+i[2]+'</span><span>'+i[0]+'</span></button>').join('')+'</div>').join('');
96
+ box.innerHTML=m.groups.map(g=>'<div class="module-group"><div class="module-group-title">'+g.title+'</div>'+g.items.filter(i=>canShowShellCommand({guard:i[3]||''})).map(i=>{const task=i[4]||'',active=i[1]===activeView&&task===activeTask;return '<button class="module-link '+(active?'active':'')+'" data-view="'+i[1]+'" data-task="'+task+'" onclick="navigateShell(\''+moduleKey+'\',\''+i[1]+'\',\''+task+'\')"><span class="mi">'+i[2]+'</span><span>'+i[0]+'</span></button>'}).join('')+'</div>').join('');
97
}
93
-function updateShellContext(moduleKey,viewId){
94
- const m=FINORA_MODULES[moduleKey]||FINORA_MODULES.home;
95
- const cmd=FINORA_COMMANDS.find(x=>x.module===moduleKey&&x.view===viewId);
98
+function updateShellContext(moduleKey,viewId,task=''){
99
+ const m=FINORA_MODULES[moduleKey]||FINORA_MODULES.dashboard;
100
+ const cmd=FINORA_COMMANDS.find(x=>x.module===moduleKey&&x.view===viewId&&x.task===task)||FINORA_COMMANDS.find(x=>x.module===moduleKey&&x.view===viewId);
101
const wt=document.getElementById('workspace-title'),wc=document.getElementById('workspace-context-text');
102
if(wt)wt.textContent=cmd?cmd.title:m.title;
98
- if(wc)wc.textContent=m.context||'';
103
+ if(wc)wc.textContent=(cmd&&cmd.groupTitle?cmd.groupTitle+' · ':'')+(m.context||'');
104
try{
105
const companies=typeof getMyCompanies==='function'?getMyCompanies():[];
106
const settings=typeof getMySettings==='function'?getMySettings():{};
@@ -103,24 +108,39 @@ function updateShellContext(moduleKey,viewId){
108
const cb=document.getElementById('topbar-company');if(cb)cb.textContent=active?.name||'انتخاب شرکت';
109
}catch(_){}
110
const fy=document.getElementById('topbar-fiscal-year');
106
- if(fy){
107
- try{const y=typeof getJalaliNumeric==='function'?String(getJalaliNumeric()).split('/')[0]:'';fy.textContent=y?'سال مالی '+y:'سال مالی جاری';}catch(_){fy.textContent='سال مالی جاری';}
108
- }
111
+ if(fy){try{const y=typeof getJalaliNumeric==='function'?String(getJalaliNumeric()).split('/')[0]:'';fy.textContent=y?'سال مالی '+y:'سال مالی جاری';}catch(_){fy.textContent='سال مالی جاری';}}
112
+}
113
+function tagDynamicTaskCards(viewId){
114
+ const maps={
115
+ 'view-inventory':{'تعریف انبار':'warehouse','گردش انبار':'movement','انبارگردانی':'count','موجودی و بهای میانگین موزون':'stock'},
116
+ 'view-assets':{'ثبت دارایی ثابت':'asset-new','دفتر داراییها':'asset-register','سوابق استهلاک':'depreciation'},
117
+ 'view-data-center':{'تنظیمات عملیاتی و دسترسی شرکت':'ops-settings','مراکز هزینه و تحلیل':'cost-centers','مرکز ورود، اکسل و پشتیبان':'data-backup'}
118
+ },map=maps[viewId];if(!map)return;
119
+ document.querySelectorAll('#'+viewId+' .card').forEach(card=>{const h=card.querySelector('h3')?.textContent?.trim();if(map[h])card.dataset.finoraTask=map[h]});
120
}
110
-function openModule(moduleKey,defaultView){
121
+function applyWorkspaceTask(viewId,task=''){
122
+ FINORA_ACTIVE_TASK=task||'';tagDynamicTaskCards(viewId);
123
+ const root=document.getElementById(viewId);if(!root)return;
124
+ const nodes=[...root.querySelectorAll('[data-finora-task]')];
125
+ nodes.forEach(el=>{const tasks=String(el.dataset.finoraTask||'').split(/\s+/);el.style.display=!task||tasks.includes('all')||tasks.includes(task)?'':'none'});
126
+}
127
+function openModule(moduleKey,defaultView,defaultTask=''){
128
document.querySelectorAll('.module-tab').forEach(x=>x.classList.toggle('active',x.dataset.module===moduleKey));
112
- renderModulePanel(moduleKey,defaultView);
113
- if(defaultView)navigateShell(moduleKey,defaultView,false);
129
+ renderModulePanel(moduleKey,defaultView,defaultTask);
130
+ if(defaultView)navigateShell(moduleKey,defaultView,defaultTask,false);
131
}
115
-function navigateShell(moduleKey,viewId,rerender=true){
132
+function navigateShell(moduleKey,viewId,task='',rerender=true){
133
switchView(viewId);
134
if(viewId==='view-payments'&&typeof renderPayments==='function')renderPayments();
135
if(viewId==='view-journal'&&typeof renderJournal==='function')renderJournal();
136
+ if(viewId==='view-accounting-foundation'&&typeof renderAccountingFoundation==='function')renderAccountingFoundation();
137
+ if(viewId==='view-accounting-reports'&&window.P6Reports)P6Reports.render();
138
if(viewId==='view-contracting'&&typeof renderPhase4==='function')renderPhase4();
139
if(['view-inventory','view-assets','view-currency','view-data-center','view-integrations'].includes(viewId)&&typeof p5Render==='function')p5Render(viewId);
121
- if(rerender)renderModulePanel(moduleKey,viewId);
140
+ applyWorkspaceTask(viewId,task);
141
+ if(rerender)renderModulePanel(moduleKey,viewId,task);
142
document.querySelectorAll('.module-tab').forEach(x=>x.classList.toggle('active',x.dataset.module===moduleKey));
123
- updateShellContext(moduleKey,viewId);
143
+ updateShellContext(moduleKey,viewId,task);
144
closeCommandSearch();
145
}
146
function toggleModulePanel(){
@@ -142,19 +162,19 @@ function handleCommandSearchKey(e){
162
if(e.key==='Enter'){
163
const q=(e.currentTarget.value||'').trim().toLowerCase();
164
const x=FINORA_COMMANDS.filter(canShowShellCommand).find(x=>(x.title+' '+x.moduleTitle).toLowerCase().includes(q));
145
- if(x){e.preventDefault();navigateShell(x.module,x.view);}
165
+ if(x){e.preventDefault();navigateShell(x.module,x.view,x.task||'');}
166
}
167
}
168
function closeCommandSearch(){const b=document.getElementById('command-search-results');if(b)b.classList.remove('open');}
169
function syncShellForView(viewId){
150
- const moduleKey=FINORA_VIEW_HOME[viewId]||'home';
170
+ const moduleKey=FINORA_VIEW_HOME[viewId]||'dashboard';FINORA_ACTIVE_TASK='';
171
document.querySelectorAll('.module-tab').forEach(x=>x.classList.toggle('active',x.dataset.module===moduleKey));
152
- renderModulePanel(moduleKey,viewId);
153
- updateShellContext(moduleKey,viewId);
172
+ renderModulePanel(moduleKey,viewId,'');
173
+ updateShellContext(moduleKey,viewId,'');
174
}
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();}}});
177
document.addEventListener('DOMContentLoaded',()=>{
178
try{if(localStorage.getItem('finora.shell.panelCollapsed')==='1')document.body.classList.add('shell-panel-collapsed');}catch(_){}
159
- renderModulePanel('home','view-dashboard');updateShellContext('home','view-dashboard');
179
+ renderModulePanel('dashboard','view-dashboard','overview');updateShellContext('dashboard','view-dashboard','overview');
180
});
scripts/dom-smoke.spec.js
+1
-1
@@ -1,5 +1,5 @@
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('#view-contracting')).toHaveCount(1);await expect(page.locator('[data-module="erp"]')).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');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-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.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 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(errs.filter(x=>!x.includes('ResizeObserver'))).toEqual([]);});
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="erp"]')).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 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(()=>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-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.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 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(errs.filter(x=>!x.includes('ResizeObserver'))).toEqual([]);});
3
4
5
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([]);});