@davoodmehraban89 / Factor-easy / commits / 0c54d45
Fork 0

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

feat: add ctrl-enter save shortcut

Davood Mehraban committed Oct 7, 2026 at 12:15 UTC 0c54d4554401b0b266dfb4679dc8863d243a7d71
4 files changed +8 -6
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 save/quick-zero hotkeys, light/dark/auto theme, active-company stats, configurable Excel templates/exports, safer 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 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, safer 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. |
js/ux-hardening-r2.js
+4 -3
@@ -34,7 +34,7 @@
34 function resolveTheme(mode){if(mode==='dark'||mode==='light')return mode;const h=new Date().getHours();return h>=7&&h<19?'light':'dark'}
35 window.finoraApplyTheme=function(){ensureThemeCss();const mode=getMySettings()?.ui_theme||'auto',r=resolveTheme(mode);document.body.classList.toggle('finora-theme-dark',r==='dark');document.documentElement.dataset.finoraTheme=r}
36 function saveExperience(){
37 - if(!requireWrite())return;const s=getMySettings();s.ui_theme=$('finora-theme-select').value;s.hotkey_ctrl_s=$('finora-hotkey-ctrls').checked;s.hotkey_enter_save=$('finora-hotkey-enter').checked;s.hotkey_quick_zeros=$('finora-hotkey-zeros').checked;saveDatastore();finoraApplyTheme();alert('تنظیمات تجربه کاربری ذخیره شد.');
37 + if(!requireWrite())return;const s=getMySettings();s.ui_theme=$('finora-theme-select').value;s.hotkey_ctrl_s=$('finora-hotkey-ctrls').checked;s.hotkey_ctrl_enter=$('finora-hotkey-ctrlenter').checked;s.hotkey_enter_save=$('finora-hotkey-enter').checked;s.hotkey_quick_zeros=$('finora-hotkey-zeros').checked;saveDatastore();finoraApplyTheme();alert('تنظیمات تجربه کاربری ذخیره شد.');
38 }
39 window.finoraSaveExperienceSettings=saveExperience;
40 function activeSave(){
@@ -43,6 +43,7 @@
43 document.addEventListener('keydown',e=>{
44 const s=typeof getMySettings==='function'?getMySettings():{};if(e.key==='Escape'){if(closeTopModal()){e.preventDefault();return}}
45 if((e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==='s'&&s.hotkey_ctrl_s!==false){e.preventDefault();activeSave();return}
46 + if((e.ctrlKey||e.metaKey)&&e.key==='Enter'&&s.hotkey_ctrl_enter!==false){e.preventDefault();activeSave();return}
47 const t=e.target;if(s.hotkey_quick_zeros&&t?.matches?.('input[inputmode="decimal"],input[type="number"]')&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&(e.code==='NumpadAdd'||e.code==='NumpadSubtract'||e.key==='+'||e.key==='-')){e.preventDefault();const zeros=(e.code==='NumpadSubtract'||e.key==='-')?'00':'000',raw=String(t.value||'').replace(/,/g,'');t.value=raw+zeros;t.dispatchEvent(new Event('input',{bubbles:true}));return}
48 if(s.hotkey_enter_save&&e.key==='Enter'&&!e.shiftKey&&!e.ctrlKey&&!e.altKey&&!t?.matches?.('textarea,select,button')){e.preventDefault();activeSave()}
49 });
@@ -73,8 +74,8 @@
74 window.finoraRefreshDataStats=function(){const h=$('finora-data-stats');if(h)h.innerHTML=statsHtml()}
75 function installSettings(){
76 const root=$('view-settings');if(!root||$('finora-experience-card'))return;try{if(typeof FINORA_MODULES!=='undefined'&&!FINORA_MODULES.settings.groups.some(g=>g.title==='تجربه کاربری'))FINORA_MODULES.settings.groups.splice(2,0,{title:'تجربه کاربری',items:[['ظاهر و میانبرها','view-settings','⌨','','experience'],['قالب‌های Excel','view-settings','▦','','excel-templates'],['آمار داده‌ها','view-settings','◎','','data-stats']]})}catch(_){}
76 - const s=getMySettings(),exp=document.createElement('div');exp.id='finora-experience-card';exp.className='accordion-item open';exp.dataset.finoraTask='experience';exp.innerHTML='<div class="accordion-header" onclick="toggleAccordion(this)"><span>⌨ ظاهر و میانبرهای صفحه‌کلید</span><span>▼</span></div><div class="accordion-body"><div class="form-row"><div class="form-group"><label>تم ظاهری</label><select id="finora-theme-select" class="form-control"><option value="auto">خودکار (روز روشن / شب تاریک)</option><option value="light">روشن</option><option value="dark">تاریک</option></select></div></div><label><input type="checkbox" id="finora-hotkey-ctrls"> Ctrl+S برای ذخیره</label><br><label><input type="checkbox" id="finora-hotkey-enter"> Enter برای ذخیره فرم فعال</label><br><label><input type="checkbox" id="finora-hotkey-zeros"> + افزودن سه صفر و − افزودن دو صفر در فیلد مبلغ</label><p class="af-hint">Escape همیشه پنجره باز را می‌بندد. میانبرهای عددی فقط داخل فیلدهای مبلغ عمل می‌کنند.</p><button class="btn btn-primary" onclick="finoraSaveExperienceSettings()">ذخیره تنظیمات</button></div>';root.insertBefore(exp,root.firstElementChild?.nextSibling||null);
77 - $('finora-theme-select').value=s.ui_theme||'auto';$('finora-hotkey-ctrls').checked=s.hotkey_ctrl_s!==false;$('finora-hotkey-enter').checked=!!s.hotkey_enter_save;$('finora-hotkey-zeros').checked=!!s.hotkey_quick_zeros;
77 + const s=getMySettings(),exp=document.createElement('div');exp.id='finora-experience-card';exp.className='accordion-item open';exp.dataset.finoraTask='experience';exp.innerHTML='<div class="accordion-header" onclick="toggleAccordion(this)"><span>⌨ ظاهر و میانبرهای صفحه‌کلید</span><span>▼</span></div><div class="accordion-body"><div class="form-row"><div class="form-group"><label>تم ظاهری</label><select id="finora-theme-select" class="form-control"><option value="auto">خودکار (روز روشن / شب تاریک)</option><option value="light">روشن</option><option value="dark">تاریک</option></select></div></div><label><input type="checkbox" id="finora-hotkey-ctrls"> Ctrl+S برای ذخیره</label><br><label><input type="checkbox" id="finora-hotkey-ctrlenter"> Ctrl+Enter برای ذخیره</label><br><label><input type="checkbox" id="finora-hotkey-enter"> Enter برای ذخیره فرم فعال</label><br><label><input type="checkbox" id="finora-hotkey-zeros"> + افزودن سه صفر و − افزودن دو صفر در فیلد مبلغ</label><p class="af-hint">Escape همیشه پنجره باز را می‌بندد. میانبرهای عددی فقط داخل فیلدهای مبلغ عمل می‌کنند.</p><button class="btn btn-primary" onclick="finoraSaveExperienceSettings()">ذخیره تنظیمات</button></div>';root.insertBefore(exp,root.firstElementChild?.nextSibling||null);
78 + $('finora-theme-select').value=s.ui_theme||'auto';$('finora-hotkey-ctrls').checked=s.hotkey_ctrl_s!==false;$('finora-hotkey-ctrlenter').checked=s.hotkey_ctrl_enter!==false;$('finora-hotkey-enter').checked=!!s.hotkey_enter_save;$('finora-hotkey-zeros').checked=!!s.hotkey_quick_zeros;
79 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();
80 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();
81 }
scripts/ux-hardening-r2-check.mjs
+1 -1
@@ -16,7 +16,7 @@ ok(invoices.includes('data-search=')&&purchases.includes('data-search='),'Produc
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.');
18 ok(ux.includes("navigateShell('commerce','view-purchases')")&&ux.includes("navigateShell('commerce','view-invoices')"),'Purchase/sale switching must preserve Commerce shell.');
19 -ok(ux.includes('hotkey_ctrl_s')&&ux.includes('hotkey_enter_save')&&ux.includes('hotkey_quick_zeros'),'Keyboard settings are incomplete.');
19 +ok(ux.includes('hotkey_ctrl_s')&&ux.includes('hotkey_ctrl_enter')&&ux.includes('hotkey_enter_save')&&ux.includes('hotkey_quick_zeros'),'Keyboard settings are incomplete.');
20 ok(ux.includes("ui_theme||'auto'")&&ux.includes('finora-theme-dark'),'Light/dark/auto theme support is missing.');
21 ok(ux.includes('excel_template_fields')&&ux.includes('finoraDownloadConfiguredTemplate')&&ux.includes('finoraExportConfiguredData'),'Configurable Excel templates/exports are missing.');
22 ok(ux.includes('finora-data-stats')&&ux.includes("ownedRows('products')")&&ux.includes("ownedRows('journalVouchers')"),'Active-company data statistics are missing.');
scripts/ux-hardening-r2.spec.js
+2 -1
@@ -3,7 +3,7 @@ const path=require('node:path');
3 test('UX R2 adds searchable selectors, keyboard close/zeros and settings controls',async({page})=>{
4 let opts='';for(let i=0;i<10;i++)opts+='<option value="P'+i+'">کالا '+i+'</option>';
5 await page.setContent('<section id="view-settings" class="view-pane"></section><section id="view-invoices" class="view-pane active"><div><select id="big-select">'+opts+'</select></div><input id="money" inputmode="decimal" value="25"></section><div id="m1" class="modal-backdrop active"><button id="mclose">بستن</button></div>');
6 - await page.addScriptTag({content:"var currentUser={id:'U1'},datastore={settings:[{ownerUserId:'U1',ui_theme:'light',hotkey_ctrl_s: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 esc(v){return String(v)};document.getElementById('mclose').onclick=()=>document.getElementById('m1').classList.remove('active');"});
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 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);
@@ -12,6 +12,7 @@ test('UX R2 adds searchable selectors, keyboard close/zeros and settings control
12 expect(await page.locator('#big-select option[value="P7"]').evaluate(o=>o.hidden)).toBe(false);
13 await page.keyboard.press('Escape');await expect(page.locator('#m1')).not.toHaveClass(/active/);
14 await page.locator('#money').focus();await page.keyboard.press('+');await expect(page.locator('#money')).toHaveValue('25000');
15 + await page.keyboard.press('Control+Enter');expect(await page.evaluate(()=>window.saved||0)).toBe(1);
16 await expect(page.locator('#finora-theme-select')).toBeVisible();
17 await expect(page.locator('#finora-excel-type')).toBeVisible();
18 await expect(page.locator('#finora-data-stats')).toBeVisible();