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

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

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

Synced Dec 3, 14:30 UTC

fix: include scoped settlements in contact operational balances

JVK committed Nov 13, 2026 at 09:17 UTC 9cd7bb0508233f2bada4c296599d0fe26780f9c9
4 files changed +132 -15
PROJECT_STATE.md
+3
@@ -252,3 +252,6 @@ Owner requests layer-by-layer click/functional testing of all controls and compa
252 - Focused19source/19generatedPages PASS,51static/behavioral/server/release checks PASS including49server/Golden. New regression suite verifies explicit read errors, bounded org wait/retry/close-reopen safety, invitation failure visibility and actual zero-context account loader; no mocked refresh fix claimed. Full224browser running. Detailed evidence/limits in docs/LOGIN_MEMBER_RECHECK_2026-11-01.md. PR192 phase docs remains separately open.
253 - 2026-11-10 continuation of unfinishedPR193: reconcile the existing account-error and visible organization-read feedback repair with loginPR196 and navigationPR197, preserving independent diagnostics/recovery and Settings/topbar placement. Resolve only continuity/cache/test integration conflicts, bump all three changed organization extension versions, then rerun full synthetic/browser/server checks before protected release. No production account, role, quota or financial mutation is authorized for testing; owner-session acceptance remains distinct. OldPR193 CI was incomplete and cannot establish final readiness.
254 - Final localPR193 reconciliation verification:236/236 canonical Chromium PASS(5.1m),22/22 generatedPages PASS,all51static/server/release commands PASS. Root reviewed preservation of authority/lifecycle guards and unchanged write operations; no independent final-review claim. Cache/continuity conflicts resolved without dropping login or navigation changes. Exact-head CI and protected deployment/readback are the next gates tracked inPR193. PR196 production4382e83 is verified (Quality42815871032/Security42815871028/Release42817044604/Pages42817111972;10/10public assets, fresh public diagnosticOK). PR197 merged13a21a6; deployment ledger remainsPR197. FinancialWP1 candidate61092e4 is stillunreleased; pending-edit-safe client integration,independentSQLreview,sourcecoverage,shadow/schema parity and realJWT/backup gates remain open.
255 +
256 +### 2026-11-11 — Contact operational balance repair
257 +- Owner reports treasury payments without invoice allocation do not reduce supplier balance. Scoped read-only repair: exact selected company, effective corrected/not-reversed payments, allocated settlements counted once, signed advances, no raw unposted cheque settlement. Use posted trade documents only and explicitly distinguish operational summary from complete ledger/opening balances. No financial source writes or migration. Add baseline failing browser coverage before implementation.
index.html
+1 -1
@@ -975,7 +975,7 @@ body{background:#f6f9fc}
975 <script src="js/accounting-foundation-render.js?v=20260928-phase2-v1"></script>
976 <script src="js/journal-ui.js?v=20261011-doc-manager-v1"></script>
977 <script src="js/document-management.js?v=20261011-doc-manager-v1"></script>
978 -<script src="js/drilldown.js?v=20261011-financial-cards-v1"></script>
978 +<script src="js/drilldown.js?v=20261113-contact-balance-v1"></script>
979 <script src="js/phase4-contracting.js?v=20260929-phase4-v1"></script>
980 <script src="js/phase5-domain.js?v=20260929-phase5-v1"></script>
981 <script src="js/phase5-enterprise.js?v=20261024-settings-save-v1"></script>
js/drilldown.js
+70 -14
@@ -7,20 +7,65 @@ function rowsTable(rows){return `<div class="table-responsive"><table><thead><tr
7 function invAction(i){return `<button class="btn btn-secondary btn-inline" onclick="closeFinoraDrill();editInvoice('${i.id}')">باز کردن</button> <button class="btn btn-secondary btn-inline" onclick="renderAndPrintDirect('${i.id}')">چاپ</button>`;}
8 function purAction(p){return `<button class="btn btn-secondary btn-inline" onclick="closeFinoraDrill();purEdit('${p.id}')">باز کردن</button>`;}
9 function chqAction(q){return `<button class="btn btn-secondary btn-inline" onclick="closeFinoraDrill();editCheque('${q.id}')">باز کردن</button>`;}
10 -window.openContactLedger=function(contactId){
11 - const c=getMyContacts().find(x=>x.id===contactId);if(!c)return;
12 - const rows=[];
13 - getMyInvoices().filter(i=>i.contactId===contactId).forEach(i=>rows.push({date:i.date,type:'فروش '+(i.paymentMethod==='credit'?'نسیه':'نقدی'),ref:i.number,name:(i.projectName?i.projectName+' — ':'')+(i.description||c.name),amount:i.grandTotal,action:invAction(i)}));
14 - (datastore.purchases||[]).filter(p=>p.ownerUserId===currentUser.id&&p.supplierId===contactId).forEach(p=>rows.push({date:p.date,type:'خرید '+(p.paymentMethod==='credit'?'نسیه':'نقدی'),ref:p.number,name:(p.costCenterLabel?p.costCenterLabel+' — ':'')+(p.description||c.name),amount:p.grandTotal,action:purAction(p)}));
15 - getMyCheques().filter(q=>q.contactId===contactId||(!q.contactId&&q.contactName===c.name)).forEach(q=>rows.push({date:q.due_date,type:(q.direction==='inbound'?'چک دریافتی':'چک پرداختی')+' — '+(q.status==='cleared'?'وصول/پرداخت شده':q.status==='bounced'?'برگشتی':q.status==='cancelled'?'باطل':'در جریان'),ref:q.sayad_id,name:q.bank||c.name,amount:q.amount,action:chqAction(q)}));
16 - const sales=rows.filter(r=>r.type.startsWith('فروش')).reduce((a,r)=>a+r.amount,0);
17 - const purchases=rows.filter(r=>r.type.startsWith('خرید')).reduce((a,r)=>a+r.amount,0);
18 - const receivable=getMyInvoices().filter(i=>i.contactId===contactId&&i.paymentMethod==='credit').reduce((a,i)=>a+(typeof invoiceOutstanding==='function'?invoiceOutstanding(i):Number(i.grandTotal||0)),0);
19 - const payable=(datastore.purchases||[]).filter(p=>p.ownerUserId===currentUser.id&&p.supplierId===contactId&&p.paymentMethod==='credit').reduce((a,p)=>a+(typeof purchaseOutstanding==='function'?purchaseOutstanding(p):Number(p.grandTotal||0)),0);
20 - const contactCheques=getMyCheques().filter(q=>q.contactId===contactId||(!q.contactId&&q.contactName===c.name));
21 - const net=receivable-payable;
22 - show('مرور حساب — '+c.name,`<div class="grid-kpi" style="margin-bottom:12px"><div class="kpi-unit"><div><div class="kpi-lbl">فروش</div><div class="kpi-val">${fmt(sales)}</div></div></div><div class="kpi-unit"><div><div class="kpi-lbl">خرید</div><div class="kpi-val">${fmt(purchases)}</div></div></div><div class="kpi-unit"><div><div class="kpi-lbl">مطالبات</div><div class="kpi-val">${fmt(receivable)}</div></div></div><div class="kpi-unit"><div><div class="kpi-lbl">بدهی</div><div class="kpi-val">${fmt(payable)}</div></div></div></div><div style="padding:10px 12px;margin-bottom:12px;border:1px solid var(--border);border-radius:10px"><b>مانده خالص:</b> ${fmt(Math.abs(net))} — ${net>0?'مطالبات از طرف حساب':net<0?'بدهی به طرف حساب':'تسویه'}</div>${rowsTable(rows)}`);
10 +// Operational trade summary only: opening/manual journals are shown in accounting.
11 +// Never infer settlement from a cheque's amount, contact name or lifecycle label.
12 +function contactOperationalSummary(contactId){
13 + const selected=dashboardCompanyId();
14 + const companyId=getMyCompanies().some(r=>r.id===selected)?selected:'';
15 + const scoped=r=>!!companyId&&r.companyId===companyId;
16 + const sales=getMyInvoices().filter(r=>scoped(r)&&r.contactId===contactId);
17 + const purchases=getMyPurchases().filter(r=>scoped(r)&&r.supplierId===contactId);
18 + const linkedPosted=r=>{const v=jeSourceVoucher(r);return v?.status==='posted'&&v.companyId===companyId;};
19 + const postedSales=sales.filter(r=>invoiceCreatesAccountingEntry(r.kind)&&invoiceDocumentStatus(r)==='posted'&&linkedPosted(r));
20 + const postedPurchases=purchases.filter(r=>purchaseDocumentStatus(r)==='posted'&&linkedPosted(r));
21 + const cheques=getMyCheques().filter(r=>scoped(r)&&r.contactId===contactId);
22 + const amount=r=>Number.isFinite(Number(r.amount))&&Number(r.amount)>0?Number(r.amount):0;
23 + const gross=rows=>rows.filter(r=>r.paymentMethod==='credit').reduce((n,r)=>n+Number(r.grandTotal||0),0);
24 + let review=sales.filter(r=>invoiceCreatesAccountingEntry(r.kind)&&['posted','legacy_review'].includes(invoiceDocumentStatus(r))&&!postedSales.includes(r)).length+
25 + purchases.filter(r=>['posted','legacy_review'].includes(purchaseDocumentStatus(r))&&!postedPurchases.includes(r)).length;
26 + const payments=paymentVisibleRecords().filter(r=>scoped(r)&&r.contactId===contactId).filter(r=>{
27 + const status=paymentPostingStatus(r);
28 + if(status==='reversed'||r.accountingStatus==='reversed')return false;
29 + if(r.accountingStatus==='draft'||!['inbound','outbound'].includes(r.direction)||!amount(r)){review++;return false;}
30 + if(status==='posted'&&!linkedPosted(r)){review++;return false;}
31 + if(status!=='posted'){
32 + review++;
33 + // Preserve historical non-cheque receipts/payments, visibly marked for review.
34 + if(status!=='legacy_review'||!['cash','bank','card'].includes(r.method))return false;
35 + }
36 + if(r.invoiceId||r.invoiceType){
37 + const list=r.direction==='outbound'?postedPurchases:postedSales;
38 + const type=r.direction==='outbound'?'purchase':'sale';
39 + if(r.invoiceType!==type||!list.some(i=>i.id===r.invoiceId&&i.paymentMethod==='credit')){review++;return false;}
40 + }
41 + return true;
42 + });
43 + const receivable=gross(postedSales)-payments.filter(r=>r.direction==='inbound').reduce((n,r)=>n+amount(r),0);
44 + const payable=gross(postedPurchases)-payments.filter(r=>r.direction==='outbound').reduce((n,r)=>n+amount(r),0);
45 + const unpostedCheques=cheques.filter(r=>!['bounced','cancelled'].includes(r.status)&&
46 + !(r.journalVoucherId&&jeSourceVoucher(r)?.status==='posted')).length;
47 + return {sales:postedSales,purchases:postedPurchases,payments,cheques,receivable,payable,net:receivable-payable,review,unpostedCheques};
48 }
49 +function contactSummaryNotice(summary){
50 + return '<p class="af-hint">ماندهٔ عملیاتی شرکت انتخاب‌شده؛ شامل فاکتورهای قطعی و دریافت/پرداخت‌ها. ماندهٔ افتتاحیه و اسناد دستی را در دفتر حسابداری بررسی کنید.</p>'+
51 + (summary.review?'<p class="af-hint">'+fmt(summary.review)+' ثبت قدیمی یا نامعتبر نیازمند تطبیق است؛ پرداخت چکی بدون سند و تخصیص نامعتبر در مانده محاسبه نمی‌شود.</p>':'')+
52 + (summary.unpostedCheques?'<p class="af-hint">'+fmt(summary.unpostedCheques)+' چک بدون سند حسابداری در مانده محاسبه نشده است؛ پیش از ثبت پرداخت دوباره، تطبیق دهید.</p>':'');
53 +}
54 +window.openContactLedger=function(contactId){
55 + const c=getMyContacts().find(x=>x.id===contactId);if(!c)return;
56 + const summary=contactOperationalSummary(contactId),rows=[];
57 + summary.sales.forEach(i=>rows.push({date:i.date,type:'فروش '+(i.paymentMethod==='credit'?'نسیه':'نقدی'),ref:i.number,name:c.name,amount:i.grandTotal,action:invAction(i)}));
58 + summary.purchases.forEach(p=>rows.push({date:p.date,type:'خرید '+(p.paymentMethod==='credit'?'نسیه':'نقدی'),ref:p.number,name:c.name,amount:p.grandTotal,action:purAction(p)}));
59 + summary.payments.forEach(p=>rows.push({date:p.date,type:(p.direction==='outbound'?'پرداخت':'دریافت')+(p.invoiceId?' — تخصیص به فاکتور':' — بدون تخصیص'),ref:p.reference,name:c.name,amount:p.amount,action:''}));
60 + summary.cheques.forEach(q=>rows.push({date:q.due_date,type:(q.direction==='inbound'?'چک دریافتی':'چک پرداختی')+' — '+(q.status==='cleared'?'وصول/پرداخت شده':q.status==='bounced'?'برگشتی':q.status==='cancelled'?'باطل':'در جریان'),ref:q.sayad_id,name:q.bank||c.name,amount:q.amount,action:chqAction(q)}));
61 + const kpi=(label,value)=>'<div class="kpi-unit"><div><div class="kpi-lbl">'+label+'</div><div class="kpi-val">'+fmt(Math.abs(value))+'</div></div></div>';
62 + const {receivable,payable,net}=summary;
63 + show('مرور حساب — '+c.name,contactSummaryNotice(summary)+'<div class="grid-kpi" style="margin-bottom:12px">'+
64 + kpi('فروش',summary.sales.reduce((n,r)=>n+Number(r.grandTotal||0),0))+
65 + kpi('خرید',summary.purchases.reduce((n,r)=>n+Number(r.grandTotal||0),0))+
66 + kpi(receivable<0?'پیش‌دریافت':'مطالبات',receivable)+kpi(payable<0?'پیش‌پرداخت':'بدهی',payable)+
67 + '</div><div data-contact-net="'+net+'" style="padding:10px 12px;margin-bottom:12px;border:1px solid var(--border);border-radius:10px"><b>مانده خالص عملیاتی:</b> '+fmt(Math.abs(net))+' — '+(net>0?'مطالبات از طرف حساب':net<0?'بدهی به طرف حساب':'تسویه')+'</div>'+rowsTable(rows));
68 +};
69 window.openDashboardDetail=function(kind){let title='',rows=[];const inv=getMyInvoices();if(kind==='sales'||kind==='settled'||kind==='debtors'){title=kind==='sales'?'جزئیات فروش':kind==='settled'?'فروش/دریافت وصول‌شده':'مطالبات نسیه';inv.filter(i=>kind==='sales'||(kind==='settled'&&i.paymentMethod!=='credit')||(kind==='debtors'&&i.paymentMethod==='credit')).forEach(i=>rows.push({date:i.date,type:i.kindLabel||'فاکتور',ref:i.number,name:(i.contactName||'')+(i.projectName?' — '+i.projectName:''),amount:i.grandTotal,action:invAction(i)}));}else{title='چک‌های باز صیادی';getMyCheques().filter(q=>q.status==='registered').forEach(q=>rows.push({date:q.due_date,type:q.direction==='inbound'?'دریافتی':'پرداختی',ref:q.sayad_id,name:q.contactName,amount:q.amount,action:chqAction(q)}));}show(title,rowsTable(rows));}
70 window.openReportDetail=function(kind){
71 const y=parseInt($('report-year-select')?.value||0);
@@ -130,6 +175,17 @@ function wire(){
175 }
176 const rd=window.renderDashboard;window.renderDashboard=function(){rd();wire();wireFinanceDashboard();const tb=$('dashboard-recent-table');if(tb)tb.querySelectorAll('tr').forEach(tr=>{const num=(tr.cells?.[0]?.textContent||'').replace(/^#/,'');const i=getMyInvoices().find(x=>String(x.number)===num);if(i&&tr.lastElementChild&&!tr.lastElementChild.querySelector('.dash-open')){const b=document.createElement('button');b.className='btn btn-secondary btn-inline dash-open';b.style.cssText='padding:4px 8px;font-size:11px;margin-left:4px';b.textContent='جزئیات';b.onclick=()=>editInvoice(i.id);tr.lastElementChild.prepend(b);}});};
177 const rr=window.renderFinancialReports;if(typeof rr==='function')window.renderFinancialReports=function(){rr();wire();};
133 -const rc=window.renderContacts;window.renderContacts=function(){rc();const cs=getMyContacts(),trs=document.querySelectorAll('#contacts-ledger-table-body tr');trs.forEach((tr,i)=>{const c=cs[i];if(!c||!tr.cells||tr.cells.length<7)return;tr.cells[0].style.cursor='pointer';tr.cells[0].title='مرور حساب';tr.cells[0].onclick=()=>openContactLedger(c.id);const rec=getMyInvoices().filter(i=>i.contactId===c.id&&i.paymentMethod==='credit').reduce((a,i)=>a+(typeof invoiceOutstanding==='function'?invoiceOutstanding(i):Number(i.grandTotal||0)),0);const pay=(datastore.purchases||[]).filter(p=>p.ownerUserId===currentUser.id&&p.supplierId===c.id&&p.paymentMethod==='credit').reduce((a,p)=>a+(typeof purchaseOutstanding==='function'?purchaseOutstanding(p):Number(p.grandTotal||0)),0);const net=rec-pay;tr.cells[6].innerHTML=`<div style="font-weight:bold">${fmt(Math.abs(net))}</div><button class="btn btn-secondary btn-inline" style="padding:2px 7px;font-size:11px;margin-top:3px" onclick="openContactLedger('${c.id}')">${net>0?'مطالبات':net<0?'بدهی':'مرور حساب'} ↗</button>`;});};
178 +const rc=window.renderContacts;window.renderContacts=function(){
179 + rc();const cs=getMyContacts(),trs=document.querySelectorAll('#contacts-ledger-table-body tr');
180 + trs.forEach((tr,i)=>{
181 + const c=cs[i];if(!c||!tr.cells||tr.cells.length<7)return;
182 + tr.cells[0].style.cursor='pointer';tr.cells[0].title='مرور حساب';tr.cells[0].onclick=()=>openContactLedger(c.id);
183 + const summary=contactOperationalSummary(c.id),net=summary.net;
184 + tr.cells[6].innerHTML='<div style="font-weight:bold">'+fmt(Math.abs(net))+'</div><small>مانده عملیاتی'+
185 + (summary.review||summary.unpostedCheques?' — نیازمند تطبیق':'')+'</small><br>';
186 + const b=document.createElement('button');b.className='btn btn-secondary btn-inline';b.style.cssText='padding:2px 7px;font-size:11px;margin-top:3px';
187 + b.textContent=(net>0?'مطالبات':net<0?'بدهی':'مرور حساب')+' ↗';b.addEventListener('click',()=>openContactLedger(c.id));tr.cells[6].appendChild(b);
188 + });
189 +};
190 try{if(currentUser)refreshAllSurfaces();}catch(e){console.error('drilldown init',e);}
191 })();
\ No newline at end of file
scripts/accounting-document-workflow.spec.js
+58
@@ -641,3 +641,61 @@ test('F2 validates formal invoice then saves a draft without posting any financi
641 expect(remoteInvoices(server)).toHaveLength(1);
642 expect([...server.records.values()].filter(x=>x.collection==='journalVouchers')).toHaveLength(0);
643 });
644 +
645 +for(const direction of ['outbound','inbound'])test('contact operational balance includes effective '+direction+' settlements once and isolates company',async({page})=>{
646 + const server=fakeServer();await installHarness(page,server);await authenticatedMockBrowser(page);
647 + await page.evaluate(({direction,USER})=>{
648 + const base={ownerUserId:USER,companyId:'QA_CO',contactId:'QA_CONTACT'};
649 + datastore.companies.push({id:'QA_OTHER',ownerUserId:USER,name:'Other company'});
650 + const voucher=(id,status='posted')=>({id,ownerUserId:USER,companyId:'QA_CO',status});
651 + datastore.journalVouchers.push(voucher('J_TRADE'),voucher('J_OLD','reversed'),voucher('J_NEW'),voucher('J_CANCEL','reversed'),{...voucher('J_FOREIGN'),companyId:'QA_OTHER'});
652 + const trade={...base,id:'TRADE',supplierId:'QA_CONTACT',kind:'formal',grandTotal:1000,paymentMethod:'credit',journalVoucherId:'J_TRADE',number:'TRADE-VALID'};
653 + datastore[direction==='outbound'?'purchases':'invoices']=[trade,{...trade,id:'DRAFT',number:'DRAFT-EXCLUDED',journalVoucherId:'',accountingStatus:'draft',documentStatus:'draft',grandTotal:99999},{...trade,id:'FOREIGN',number:'FOREIGN-EXCLUDED',companyId:'QA_OTHER',journalVoucherId:'J_FOREIGN',grandTotal:8000}];
654 + if(direction==='inbound')datastore.invoices.push({...trade,id:'PROFORMA',number:'PROFORMA-EXCLUDED',kind:'pre_invoice'});
655 + datastore.payments=[
656 + {...base,id:'ALLOC',direction,method:'bank',amount:200,invoiceType:direction==='outbound'?'purchase':'sale',invoiceId:'TRADE'},
657 + {...base,id:'OLD',direction,method:'bank',amount:600,journalVoucherId:'J_OLD'},
658 + {...base,id:'NEW',direction,method:'bank',amount:300,journalVoucherId:'J_NEW',correctsPaymentId:'OLD'},
659 + {...base,id:'CANCEL',direction,method:'bank',amount:700,journalVoucherId:'J_CANCEL'},
660 + {...base,id:'RAW-CHEQUE',direction,method:'cheque',amount:900},
661 + {...base,id:'OTHER',direction,method:'bank',amount:9000,companyId:'QA_OTHER'},
662 + {...base,id:'UNSCOPED',direction,method:'bank',amount:5555,companyId:''},
663 + {...base,id:'BADALLOC',direction,method:'bank',amount:6666,invoiceType:direction==='outbound'?'purchase':'sale',invoiceId:'FOREIGN'}
664 + ];
665 + datastore.cheques=[{...base,id:'CHQ',direction,amount:9999,status:'registered',contactName:'خریدار آزمایشی'}];
666 + window.__contactBefore=JSON.stringify([datastore.invoices,datastore.purchases,datastore.payments,datastore.journalVouchers,datastore.cheques]);
667 + switchView('view-contacts');renderContacts();
668 + },{direction,USER});
669 + const row=page.locator('#contacts-ledger-table-body tr').first();
670 + await expect(row.locator('td').nth(6)).toContainText('۵۰۰');
671 + await row.locator('td').nth(6).locator('button').click();
672 + const body=page.locator('#finora-drill-body');
673 + await expect(body.locator('[data-contact-net]')).toHaveAttribute('data-contact-net',direction==='outbound'?'-500':'500');
674 + await expect(body).not.toContainText('DRAFT-EXCLUDED');await expect(body).not.toContainText('FOREIGN-EXCLUDED');await expect(body).not.toContainText('PROFORMA-EXCLUDED');
675 + expect(await page.evaluate(()=>JSON.stringify([datastore.invoices,datastore.purchases,datastore.payments,datastore.journalVouchers,datastore.cheques])===window.__contactBefore)).toBe(true);
676 + await page.evaluate(()=>{closeFinoraDrill();getMySettings().default_company_id='QA_OTHER';renderContacts();openContactLedger('QA_CONTACT')});
677 + await expect(body.locator('[data-contact-net]')).toHaveAttribute('data-contact-net',direction==='outbound'?'1000':'-1000');
678 + await expect(body).toContainText(direction==='outbound'?'پیش‌پرداخت':'پیش‌دریافت');
679 +});
680 +
681 +
682 +test('contact operational balance reflects a saved unallocated supplier payment after reload',async({page})=>{
683 + const server=fakeServer();
684 + server.records.set('journalVouchers|J_PUR',{collection:'journalVouchers',id:'J_PUR',data:{companyId:'QA_CO',status:'posted'}});
685 + server.records.set('purchases|P_BAL',{collection:'purchases',id:'P_BAL',data:{companyId:'QA_CO',supplierId:'QA_CONTACT',number:'PUR-BAL',grandTotal:1000,paymentMethod:'credit',journalVoucherId:'J_PUR'}});
686 + await installHarness(page,server);await authenticatedMockBrowser(page);
687 + await page.evaluate(()=>{switchView('view-payments');renderPayments()});
688 + await page.locator('#pay-direction').selectOption('outbound');
689 + await page.locator('#pay-contact').selectOption('QA_CONTACT');
690 + await page.locator('#pay-method').selectOption('bank');
691 + await page.locator('#pay-amount').fill('450');
692 + await page.locator('#pay-save').click();
693 + await expect.poll(()=>remotePayments(server)[0]?.accountingStatus,{timeout:13000}).toBe('posted');
694 + await page.evaluate(()=>{switchView('view-contacts');renderContacts();openContactLedger('QA_CONTACT')});
695 + await expect(page.locator('[data-contact-net]')).toHaveAttribute('data-contact-net','-550');
696 + await expect(page.locator('#finora-drill-body')).toContainText('پرداخت — بدون تخصیص');
697 + await page.reload({waitUntil:'domcontentloaded'});await authenticatedMockBrowser(page);
698 + await page.evaluate(()=>openContactLedger('QA_CONTACT'));
699 + await expect(page.locator('[data-contact-net]')).toHaveAttribute('data-contact-net','-550');
700 + expect(remotePayments(server)).toHaveLength(1);
701 +});