سامانه صدور فاکتور و حسابداری
fix: simplify invoice workspace and product search
* docs: record invoice workspace cleanup request * fix: simplify invoice workspace and product search
davoodmehraban89 committed
Oct 7, 2026 at 19:05 UTC
6e7fa6e861ebdd89e5712ed7d64bb5fe3128f307
6 files changed
+38
-21
PROJECT_STATE.md
+1
-1
@@ -17,7 +17,7 @@ The latest user message is the sole source of new instructions. Read AGENTS.md t
17
## Current change ledger
18
| Date | Request / decision | Status | Evidence / next action |
19
|---|---|---|---|
20
-| 2026-10-07 | Owner requested the next integrated UX/commerce/settings hardening slice: reuse global projects from counterparty screens instead of per-contact duplicate project records; searchable large selectors across product/contact/project/account lists; refresh sale/purchase default prices after master-data edits and latest transactions; purchase-invoice UI parity with sales while preserving purchase semantics; modal/close/Escape/Enter/button real behavior QA; active-company factory reset for authorized company admin with multi-step destructive warnings; richer settings (hotkeys, quick-zero shortcuts, light/dark/auto theme, data statistics, backup/restore); configurable Excel sample/import/export field selection; and consistent Persian-digit rendering in invoice UI/print. | **IMPLEMENTED LOCALLY / CI + REAL-DOM PENDING** | Baseline `main` = `b88f0f35902cc99ebd09c9fffcd5700ce759ac69`. Implemented global project reuse/attach from counterparties, large-list search, product price-default refresh from latest posted sale/purchase, purchase project/accounting separation and commerce-switch parity, Escape/modal + configurable Ctrl+S, Ctrl+Enter, Enter-save and quick-zero hotkeys, light/dark/auto theme, active-company stats, configurable Excel templates/exports, authorized-manager active-company factory reset that skips ambiguous multi-company legacy rows, and Persian-digit normalization in isolated invoice print. Local syntax, quality, commercial, UX-R2, accounting phases 2-6 and Golden PASS; `git diff --check` PASS. Real-DOM tests added to required CI; production reset not executed. Settings reference image still not supplied, so exact visual parity to that future image is NOT VERIFIED. |
20
+| 2026-10-07 | Owner supplied live screenshots and requested immediate invoice-workspace cleanup: remove redundant top workflow buttons (sale/purchase/pre-invoice) and redundant sale/purchase shortcut buttons beside the document heading; keep Excel import + sample download; keep only the commercial-document type selector with sale, purchase, sales pre-invoice, sales progress statement; replace the separate search-above-select UX with a single in-control searchable product selector that matches product code/name/specification and numeric fragments. | **IMPLEMENTED LOCALLY / REAL-DOM CI PENDING** | Baseline `main` = `6dae96fac9bd5c513209932ae777f12bd8bd95a6`; live Supabase migration head `20261003033540`; RLS public 18/18, private 3/10. Removed redundant workflow toolbar and sale/purchase heading shortcuts; retained Excel import/sample controls and the four-value commercial-document selector. Replaced separate search-above-select UI with one integrated combobox that searches product code/name/specification/identifiers in the same field. Local syntax, quality, commercial, UX-R2, Phase 3 behavior and Golden PASS; `git diff --check` PASS. Added Real-DOM coverage for integrated search and code/name/spec matching; CI pending. No schema/RLS/auth/role/data mutation. |`r`n| 2026-10-07 | Owner requested the next integrated UX/commerce/settings hardening slice: reuse global projects from counterparty screens instead of per-contact duplicate project records; searchable large selectors across product/contact/project/account lists; refresh sale/purchase default prices after master-data edits and latest transactions; purchase-invoice UI parity with sales while preserving purchase semantics; modal/close/Escape/Enter/button real behavior QA; active-company factory reset for authorized company admin with multi-step destructive warnings; richer settings (hotkeys, quick-zero shortcuts, light/dark/auto theme, data statistics, backup/restore); configurable Excel sample/import/export field selection; and consistent Persian-digit rendering in invoice UI/print. | **IMPLEMENTED LOCALLY / CI + REAL-DOM PENDING** | Baseline `main` = `b88f0f35902cc99ebd09c9fffcd5700ce759ac69`. Implemented global project reuse/attach from counterparties, large-list search, product price-default refresh from latest posted sale/purchase, purchase project/accounting separation and commerce-switch parity, Escape/modal + configurable Ctrl+S, Ctrl+Enter, Enter-save and quick-zero hotkeys, light/dark/auto theme, active-company stats, configurable Excel templates/exports, authorized-manager active-company factory reset that skips ambiguous multi-company legacy rows, and Persian-digit normalization in isolated invoice print. Local syntax, quality, commercial, UX-R2, accounting phases 2-6 and Golden PASS; `git diff --check` PASS. Real-DOM tests added to required CI; production reset not executed. Settings reference image still not supplied, so exact visual parity to that future image is NOT VERIFIED. |
21
| 2026-10-07 | Owner directed autonomous continuation to finish the remaining Finora development backlog, starting with the agreed P0 accounting core: extensible analytical/floating dimensions, journal UX, context-driven posting rules and end-to-end accounting integration, then continue through remaining verified blockers without routine pauses. | **PR VERIFIED / MERGE PENDING** | P0 adds independent COST_CENTER analytics, role-driven dimension compatibility without rewriting posted history, strict per-fiscal-year journal numbers, voucher type/reference, generic dimension-to-legacy compatibility fields, independent project vs cost-center posting, copy-to-draft, account search, row copy, and live debit/credit/difference totals. Implementation head `de2c58a52cb36bfe54eeb3c90985cd6c94cae812`; PR #52 Quality `37539607474` SUCCESS including Accounting P0 invariant step and Real DOM smoke, Security `37539607498` SUCCESS. Local quality + phases 2-6 + Golden PASS. No schema/RLS/auth/role/destructive production data change. Next: merge after this evidence-state commit rechecks green, then verify main release/deploy exact SHA. |
22
| 2026-10-07 | Owner authorized implementation to completion of the researched commerce/accounting redesign: one invoice workspace in Commerce, context-driven reusable floating counterparties, purchase parity (quick supplier + Excel template), and selected-company factory reset that preserves the company. | **COMPLETED / MERGED / RELEASE VERIFIED** | Merged to `main` as `5ae9117c776a33a3cc39775c68ad0c10e13b9c44`. Push Quality run `37529032595` = success; Security `37529032630` = success; Release gate `37529230156` = success; exact gated Pages deployment `37529272934` = success and deployed the same SHA to `http://factoreasy.ir/`. Live HTML loads `js/commercial-rnd.js?v=20261007-commerce-r1`; live bundle contains factory-reset guard, quick supplier, and Excel-template code. PR Real-DOM/accounting gates were green. No production reset and no schema/RLS/auth/role mutation. |
23
| 2026-10-04 | Continue the recorded chart and taxpayer-reference correction after interrupted sessions. | **MERGED / CONTROLLED DOM + ACCOUNTING VERIFIED / GATED PAGES DEPLOYED** | 62 additive chart rows across all eight templates, including non-current assets and contra accounts; explicit preview/apply for compatible existing templates preserves old accounts and posted history. Actual supplied tax logo and reference-aligned totals/settlement layout; image-ready printing. Local chart invariants and 3 chart DOM tests passed; 2 print DOM tests plus single-page landscape PDF passed; accounting phases 2–6 and Golden passed. Full local DOM: 52/53 passed, Pages artifact failed on external ERR_CERT_AUTHORITY_INVALID; no gate weakened. PR #47 implementation SHA `db9e7f2375e914bfa9e78932e63222af68c4c9d3`: Quality `37170173739` and Security `37170173740` passed; inspected static job `111341365938` confirms 53/53 real-DOM tests, chart invariants, phases 2–6 and Golden passed, including Pages artifact. All three disposable DB jobs passed. Production recheck on 2026-10-04: 79 migrations, latest `20261003033540`; public RLS 18/18, private 3/10. See docs/CHART_OF_ACCOUNTS_RESEARCH_2026-10-03.md and docs/CHART_TAXPAYER_VERIFICATION_2026-10-03.md. No schema/RLS/auth/role or production record mutation. |
index.html
-2
@@ -411,8 +411,6 @@ body{background:#f6f9fc}
411
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:14px;flex-wrap:wrap;gap:10px">
412
<h2 style="font-size:17px" id="invoice-form-title">صدور فاکتور جدید</h2>
413
<div style="display:flex;gap:8px;flex-wrap:wrap;align-items:center">
414
-<button type="button" class="btn btn-primary btn-inline" style="min-height:34px;padding:4px 12px;font-size:12px" onclick="switchView('view-invoices')">🧾 فاکتور فروش</button>
415
-<button type="button" class="btn btn-secondary btn-inline" style="min-height:34px;padding:4px 12px;font-size:12px" onclick="switchView('view-purchases')">🛒 فاکتور خرید</button>
414
<label class="btn btn-secondary btn-inline" style="min-height:34px;padding:4px 10px;font-size:12px">📥 ورود اقلام از اکسل<input type="file" id="excel-import-invoice-items" style="display:none" onchange="importInvoiceItemsFromExcel(event)" accept=".xlsx, .xls" /></label>
415
<button class="btn btn-secondary btn-inline" style="display:none;padding:4px 10px;font-size:12px" id="btn-cancel-edit" onclick="cancelInvoiceEdit()">انصراف از ویرایش</button>
416
</div>
js/ux-hardening-r2.js
+15
-10
@@ -1,4 +1,4 @@
1
-// Finora UX hardening R2 — searchable selectors, keyboard UX, themes, Excel templates, stats and modal safety.
1
+// Finora UX hardening R2 — searchable selectors, keyboard UX, themes, Excel templates, stats and modal safety.
2
(function(){
3
const $=id=>document.getElementById(id);
4
function activeCompanyId(){try{return getMySettings().default_company_id||getMyCompanies()[0]?.id||''}catch(_){return''}}
@@ -13,15 +13,23 @@
13
}catch(_){}
14
return parts.filter(Boolean).join(' ').toLowerCase();
15
}
16
- function filterSelect(select,input){
17
- const q=String(input?.value||'').trim().toLowerCase();[...select.options].forEach((o,i)=>{if(i===0&&o.value===''){o.hidden=false;return}const hay=(o.dataset.search||searchMeta(o.value,o.textContent));o.dataset.search=hay;o.hidden=!!q&&!hay.includes(q)});
16
+ function comboOptions(select,q){
17
+ const query=String(q||'').trim().toLowerCase();return [...select.options].filter(o=>o.value).filter(o=>!query||(o.dataset.search||searchMeta(o.value,o.textContent)).includes(query)).slice(0,60);
18
}
19
+ function comboLabel(o){return String(o?.textContent||'').trim()}
20
window.finoraRefreshSearchableSelect=function(select){
21
if(!select||select.multiple||select.dataset.finoraSearchReady==='1'||select.classList.contains('je-account'))return;
22
const ids=['invoice-contact-id','pur-supplier','invoice-project-id','pur-costcenter','chq-contact-select','trx-contact-select','trx-project-select','company-parent-id','invoice-company-id','filter-invoice-company','af-project-parent','af-project-branch'];
23
const targeted=ids.includes(select.id)||select.classList.contains('row-product-select')||select.classList.contains('pur-prod');if(!targeted&&select.options.length<8)return;
23
- select.dataset.finoraSearchReady='1';const input=document.createElement('input');input.type='search';input.className='form-control finora-select-search';input.placeholder='جستجو...';input.autocomplete='off';input.style.marginBottom='5px';select.parentNode?.insertBefore(input,select);input.addEventListener('input',()=>filterSelect(select,input));
24
- new MutationObserver(()=>filterSelect(select,input)).observe(select,{childList:true,subtree:true});filterSelect(select,input);
24
+ select.dataset.finoraSearchReady='1';const wrap=document.createElement('div');wrap.className='finora-combobox';wrap.style.cssText='position:relative;width:100%';select.parentNode?.insertBefore(wrap,select);wrap.appendChild(select);select.style.display='none';
25
+ const input=document.createElement('input');input.type='text';input.className='form-control finora-combobox-input';input.autocomplete='off';input.placeholder=select.classList.contains('row-product-select')||select.classList.contains('pur-prod')?'انتخاب یا جستجوی کالا (نام، کد، مشخصه...)':'انتخاب یا جستجو...';wrap.insertBefore(input,select);
26
+ const list=document.createElement('div');list.className='finora-combobox-list';list.setAttribute('role','listbox');list.style.cssText='display:none;position:absolute;z-index:1200;top:calc(100% + 3px);right:0;left:0;max-height:240px;overflow:auto;background:var(--card,#fff);border:1px solid var(--border,#cbd5e1);border-radius:8px;box-shadow:0 8px 24px rgba(15,23,42,.14)';wrap.appendChild(list);
27
+ const close=()=>{list.style.display='none'};
28
+ const render=()=>{const rows=comboOptions(select,input.value);list.innerHTML=rows.length?rows.map(o=>'<button type="button" class="finora-combobox-option" data-value="'+String(o.value).replace(/&/g,'&').replace(/"/g,'"')+'" style="display:block;width:100%;text-align:right;border:0;border-bottom:1px solid var(--border,#e2e8f0);background:transparent;padding:9px 10px;cursor:pointer;color:inherit">'+comboLabel(o)+'</button>').join(''):'<div class="finora-combobox-empty" style="padding:10px;color:var(--text-muted)">موردی پیدا نشد</div>';list.style.display='block'};
29
+ const sync=()=>{const o=select.options[select.selectedIndex];input.value=o&&o.value?comboLabel(o):''};
30
+ input.addEventListener('focus',render);input.addEventListener('input',render);input.addEventListener('keydown',e=>{if(e.key==='Escape'){close();input.blur();return}if(e.key==='Enter'){const b=list.querySelector('.finora-combobox-option');if(b){e.preventDefault();b.click()}}});
31
+ list.addEventListener('mousedown',e=>{const b=e.target.closest('.finora-combobox-option');if(!b)return;e.preventDefault();select.value=b.dataset.value;select.dispatchEvent(new Event('change',{bubbles:true}));sync();close()});
32
+ select.addEventListener('change',sync);document.addEventListener('mousedown',e=>{if(!wrap.contains(e.target))close()});new MutationObserver(sync).observe(select,{childList:true,subtree:true});sync();
33
}
34
function refreshProductOptionMetadata(){document.querySelectorAll('.row-product-select,.pur-prod').forEach(sel=>[...sel.options].forEach(o=>{if(!o.value)return;const p=typeof getMyProducts==='function'?getMyProducts().find(x=>x.id===o.value):null;if(!p)return;o.dataset.price=String(sel.classList.contains('pur-prod')?(p.buy_price||0):(p.sale_price||0));o.dataset.unit=p.unit||'عدد';o.dataset.search=[p.code,p.name,p.spec,p.barcode,p.internal_id,p.official_id,p.category].filter(Boolean).join(' ').toLowerCase()}))}
35
function enhanceAll(){refreshProductOptionMetadata();document.querySelectorAll('select').forEach(finoraRefreshSearchableSelect)}
@@ -79,13 +87,10 @@
87
const ex=document.createElement('div');ex.className='accordion-item';ex.dataset.finoraTask='excel-templates';ex.innerHTML='<div class="accordion-header" onclick="toggleAccordion(this)"><span>▦ قالبهای Excel و فیلدهای قابل انتخاب</span><span>▼</span></div><div class="accordion-body"><div class="form-group"><label>نوع قالب</label><select id="finora-excel-type" class="form-control" onchange="finoraRenderExcelFields()"><option value="products">کالا و خدمات</option><option value="contacts">اشخاص</option><option value="accounts">کدینگ حسابها</option><option value="saleItems">اقلام فاکتور فروش</option><option value="purchaseItems">اقلام فاکتور خرید</option></select></div><div id="finora-excel-fields"></div><div style="display:flex;gap:8px;flex-wrap:wrap"><button class="btn btn-primary" onclick="finoraSaveExcelFields()">ذخیره فیلدها</button><button class="btn btn-secondary" onclick="finoraDownloadConfiguredTemplate(document.getElementById(\'finora-excel-type\').value)">دانلود قالب نمونه</button><button class="btn btn-secondary" onclick="finoraExportConfiguredData(document.getElementById(\'finora-excel-type\').value)">خروجی دادههای فعلی</button></div></div>';root.appendChild(ex);renderExcelFields();
88
const st=document.createElement('div');st.className='accordion-item';st.dataset.finoraTask='data-stats';st.innerHTML='<div class="accordion-header" onclick="toggleAccordion(this)"><span>◎ آمار دادههای شرکت فعال</span><span>▼</span></div><div class="accordion-body"><div id="finora-data-stats"></div><button class="btn btn-secondary" style="margin-top:10px" onclick="finoraRefreshDataStats()">بهروزرسانی آمار</button></div>';root.appendChild(st);finoraRefreshDataStats();
89
}
82
- function installCommerceToolbar(){
83
- ['view-invoices','view-purchases'].forEach(id=>{const root=$(id);if(!root||root.querySelector('.finora-commerce-toolbar'))return;const bar=document.createElement('div');bar.className='card no-print finora-commerce-toolbar';bar.style.cssText='display:flex;gap:8px;align-items:center;flex-wrap:wrap;padding:10px;margin-bottom:10px';bar.innerHTML='<strong>فاکتورها:</strong><button class="btn btn-secondary btn-inline" onclick="finoraOpenInvoiceType(\'sale\')">فروش</button><button class="btn btn-secondary btn-inline" onclick="finoraOpenInvoiceType(\'purchase\')">خرید</button><button class="btn btn-secondary btn-inline" onclick="finoraOpenInvoiceType(\'pre_invoice\')">پیشفاکتور</button>';root.insertBefore(bar,root.firstChild)})
84
- }
90
window.finoraOpenInvoiceType=function(type){if(type==='purchase'){if(typeof navigateShell==='function')navigateShell('commerce','view-purchases');else switchView('view-purchases');return}if(typeof navigateShell==='function')navigateShell('commerce','view-invoices');else switchView('view-invoices');const kind=$('invoice-kind');if(kind){kind.value=type==='pre_invoice'?'pre_invoice':type==='contract_statement'?'contract_statement':'non_formal';if(typeof handleInvoiceKindChange==='function')handleInvoiceKindChange()}}
91
const oldProductTpl=window.downloadProductsExcelTemplate,oldContactTpl=window.downloadContactsExcelTemplate;window.downloadProductsExcelTemplate=()=>finoraDownloadConfiguredTemplate('products');window.downloadContactsExcelTemplate=()=>finoraDownloadConfiguredTemplate('contacts');
92
window.downloadAccountsExcelTemplate=()=>finoraDownloadConfiguredTemplate('accounts');window.downloadInvoiceItemsExcelTemplate=()=>finoraDownloadConfiguredTemplate('saleItems');window.purDownloadExcelTemplate=()=>finoraDownloadConfiguredTemplate('purchaseItems');
88
- function boot(){installSettings();installCommerceToolbar();enhanceAll();finoraApplyTheme();finoraRefreshDataStats()}
93
+ function boot(){installSettings();enhanceAll();finoraApplyTheme();finoraRefreshDataStats()}
94
const oldRefresh=window.refreshAllSurfaces;if(typeof oldRefresh==='function')window.refreshAllSurfaces=function(){const r=oldRefresh.apply(this,arguments);setTimeout(boot,0);return r};
95
document.addEventListener('DOMContentLoaded',()=>setTimeout(boot,0));setInterval(()=>{if((getMySettings()?.ui_theme||'auto')==='auto')finoraApplyTheme()},15*60*1000);
91
-})();
\ No newline at end of file
96
+})();
scripts/commercial-rnd-check.mjs
+3
@@ -14,5 +14,8 @@ ok(commerce.includes("FACTORY_PRESERVE=new Set(['companies','settings'])"),'Fact
14
ok(commerce.includes('skippedLegacy')&&commerce.includes('companies.length===1'),'Factory reset must isolate active-company data and skip ambiguous legacy rows in multi-company mode.');
15
ok(commerce.includes("company.accountingTemplate=''")&&commerce.includes("company.activityType=''"),'Factory reset must restart accounting setup.');
16
ok(html.includes('js/commercial-rnd.js'),'Commerce slice must be loaded.');
17
+ok(!html.includes('🧾 فاکتور فروش</button>')&&!html.includes('🛒 فاکتور خرید</button>'),'Invoice form must not duplicate sale/purchase shortcut buttons beside the document heading.');
18
+ok(!fs.readFileSync('js/ux-hardening-r2.js','utf8').includes('finora-commerce-toolbar'),'Invoice workspace must not duplicate sale/purchase/pre-invoice workflow buttons above the form.');
19
+ok(['sale','purchase','pre_invoice','contract_statement'].every(v=>commerce.includes('<option value="'+v+'"')),'Unified document selector must contain sale, purchase, sales pre-invoice and sales progress statement.');
20
ok(purchase.includes("jePostSourceRecord('purchase',record)"),'Purchase posting must remain automatic.');
21
console.log('Commercial R&D invariants passed.');
\ No newline at end of file
scripts/ux-hardening-r2-check.mjs
+1
-1
@@ -11,7 +11,7 @@ const ok=(v,m)=>{if(!v)throw new Error(m)};
11
ok(index.includes('js/ux-hardening-r2.js?v=20261007-ux-r2'),'UX R2 module must be loaded.');
12
ok(projects.includes('getMyGlobalProjects')&&projects.includes('attachExistingProject')&&projects.includes('linkedContactIds'),'Counterparty project management must reuse global project master data.');
13
ok(projects.includes('createAndAttachProject')&&projects.includes('openProjectAttachModal'),'Counterparty project UI must support select-existing or create-new in place.');
14
-ok(ux.includes('select.options.length<8')&&ux.includes('finora-select-search'),'Large selectors must gain search automatically.');
14
+ok(ux.includes('select.options.length<8')&&ux.includes('finora-combobox-input')&&ux.includes('finora-combobox-option')&&!ux.includes('finora-select-search'),'Large selectors must use one integrated searchable combobox, not a separate search field plus select.');
15
ok(invoices.includes('data-search=')&&purchases.includes('data-search='),'Product selectors must search code/name/spec/ids.');
16
ok(products.includes('function syncProductDefaultPrices')&&invoices.includes("syncProductDefaultPrices(items,'sale')")&&purchases.includes("syncProductDefaultPrices(items,'purchase')"),'Latest invoice prices must refresh master sale/purchase defaults.');
17
ok(purchases.includes("projectId,projectName,costCenterId:''")&&!purchases.includes("projectId:source.costCenterId"),'Purchase project must be independent from cost-center semantics.');
scripts/ux-hardening-r2.spec.js
+18
-7
@@ -6,19 +6,20 @@ test('UX R2 adds searchable selectors, keyboard close/zeros and settings control
6
await page.addScriptTag({content:"var currentUser={id:'U1'},datastore={settings:[{ownerUserId:'U1',ui_theme:'light',hotkey_ctrl_s:true,hotkey_ctrl_enter:true,hotkey_enter_save:false,hotkey_quick_zeros:true}],products:[],contacts:[],companies:[{id:'C1',ownerUserId:'U1'}],invoices:[],purchases:[],cheques:[],accounts:[],projects:[],journalVouchers:[]};var FINORA_MODULES={settings:{groups:[]}};function getMySettings(){return datastore.settings[0]}function getMyCompanies(){return datastore.companies}function getMyProducts(){return datastore.products}function getMyContacts(){return datastore.contacts}function getMyAccounts(){return datastore.accounts}function getMyGlobalProjects(){return datastore.projects}function requireWrite(){return true}function saveDatastore(){}function toggleAccordion(){}function navigateShell(m,v){window.lastNav=m+'|'+v}function switchView(v){window.lastNav='switch|'+v}function esc(v){return String(v)}function commitSaveInvoice(){window.saved=(window.saved||0)+1};document.getElementById('mclose').onclick=()=>document.getElementById('m1').classList.remove('active');"});
7
await page.addScriptTag({path:path.resolve('js/ux-hardening-r2.js')});
8
await page.evaluate(()=>document.dispatchEvent(new Event('DOMContentLoaded')));
9
- await expect(page.locator('.finora-select-search')).toHaveCount(1);
10
- await page.locator('.finora-select-search').fill('کالا 7');
11
- expect(await page.locator('#big-select option[value="P1"]').evaluate(o=>o.hidden)).toBe(true);
12
- expect(await page.locator('#big-select option[value="P7"]').evaluate(o=>o.hidden)).toBe(false);
9
+ await expect(page.locator('.finora-combobox-input')).toHaveCount(1);
10
+ await page.locator('.finora-combobox-input').fill('کالا 7');
11
+ await expect(page.locator('.finora-combobox-list')).toBeVisible();
12
+ await expect(page.locator('.finora-combobox-option')).toHaveCount(1);
13
+ await expect(page.locator('.finora-combobox-option')).toContainText('کالا 7');
14
+ await page.locator('.finora-combobox-option').click();
15
+ expect(await page.locator('#big-select').inputValue()).toBe('P7');
16
await page.keyboard.press('Escape');await expect(page.locator('#m1')).not.toHaveClass(/active/);
17
await page.locator('#money').focus();await page.keyboard.press('+');await expect(page.locator('#money')).toHaveValue('25000');
18
await page.keyboard.press('Control+Enter');expect(await page.evaluate(()=>window.saved||0)).toBe(1);
19
await expect(page.locator('#finora-theme-select')).toBeVisible();
20
await expect(page.locator('#finora-excel-type')).toBeVisible();
21
await expect(page.locator('#finora-data-stats')).toBeVisible();
19
- await expect(page.locator('.finora-commerce-toolbar')).toHaveCount(2);
20
- await page.locator('#view-invoices .finora-commerce-toolbar').getByRole('button',{name:'خرید'}).click();expect(await page.evaluate(()=>window.lastNav)).toBe('commerce|view-purchases');
21
- await page.locator('#view-purchases .finora-commerce-toolbar').getByRole('button',{name:'فروش'}).click();expect(await page.evaluate(()=>window.lastNav)).toBe('commerce|view-invoices');
22
+ await expect(page.locator('.finora-commerce-toolbar')).toHaveCount(0);
23
});
24
test('counterparty project manager reuses global project master and attaches existing project',async({page})=>{
25
await page.setContent('<div></div>');
@@ -50,3 +51,13 @@ test('factory reset denies non-manager without touching company data',async({pag
51
expect(await page.evaluate(()=>datastore.products.length)).toBe(1);
52
expect(await page.evaluate(()=>window.lastAlert)).toContain('فقط برای مدیر/مالک');
53
});
54
+
55
+test('product combobox searches one field by code, name and specification',async({page})=>{
56
+ await page.setContent('<section id="view-settings"></section><section id="view-invoices" class="view-pane active"><select class="row-product-select" id="product-search"><option value="">انتخاب کالا</option><option value="B10">بلوک سایز ۱۰</option><option value="C3">سیمان تیپ ۲</option></select></section>');
57
+ await page.addScriptTag({content:"var currentUser={id:'U1'},datastore={settings:[{ownerUserId:'U1'}],products:[{id:'B10',code:'BLK-310',name:'بلوک سایز ۱۰',spec:'سبک AAC'},{id:'C3',code:'CEM-003',name:'سیمان تیپ ۲',spec:'پاکتی'}],contacts:[],companies:[{id:'C1',ownerUserId:'U1'}],accounts:[],projects:[],invoices:[],purchases:[],cheques:[],journalVouchers:[]};var FINORA_MODULES={settings:{groups:[]}};function getMySettings(){return datastore.settings[0]}function getMyCompanies(){return datastore.companies}function getMyProducts(){return datastore.products}function getMyContacts(){return datastore.contacts}function getMyAccounts(){return datastore.accounts}function getMyGlobalProjects(){return datastore.projects}function requireWrite(){return true}function saveDatastore(){}function toggleAccordion(){}function esc(v){return String(v)}"});
58
+ await page.addScriptTag({path:path.resolve('js/ux-hardening-r2.js')});await page.evaluate(()=>document.dispatchEvent(new Event('DOMContentLoaded')));
59
+ const input=page.locator('#product-search').locator('xpath=..').locator('.finora-combobox-input');
60
+ await input.fill('310');await expect(page.locator('#product-search').locator('xpath=..').locator('.finora-combobox-option')).toContainText('بلوک سایز ۱۰');
61
+ await input.fill('AAC');await expect(page.locator('#product-search').locator('xpath=..').locator('.finora-combobox-option')).toContainText('بلوک سایز ۱۰');
62
+ await input.fill('سیمان');await expect(page.locator('#product-search').locator('xpath=..').locator('.finora-combobox-option')).toContainText('سیمان تیپ ۲');
63
+});