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

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

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

Synced Dec 4, 01:45 UTC

Drive account balances from allocated invoice settlements

davoodmehraban89 committed Sep 28, 2026 at 15:07 UTC 1629835703b8db54e23b6c721c9573c423521ca7
1 file changed +1 -1
js/drilldown.js
+1 -1
@@ -46,6 +46,6 @@ function wire(){
46 }
47 const rd=window.renderDashboard;window.renderDashboard=function(){rd();wire();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);}});};
48 const rr=window.renderFinancialReports;if(typeof rr==='function')window.renderFinancialReports=function(){rr();wire();};
49 -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+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+Number(p.grandTotal||0),0);const cq=getMyCheques().filter(q=>q.contactId===c.id||(!q.contactId&&q.contactName===c.name));const received=cq.filter(q=>q.direction==='inbound'&&q.status==='cleared').reduce((a,q)=>a+Number(q.amount||0),0);const paid=cq.filter(q=>q.direction==='outbound'&&q.status==='cleared').reduce((a,q)=>a+Number(q.amount||0),0);const net=(rec-Math.min(rec,received))-(pay-Math.min(pay,paid));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>`;});};
49 +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 cq=getMyCheques().filter(q=>q.contactId===c.id||(!q.contactId&&q.contactName===c.name));const received=cq.filter(q=>q.direction==='inbound'&&q.status==='cleared').reduce((a,q)=>a+Number(q.amount||0),0);const paid=cq.filter(q=>q.direction==='outbound'&&q.status==='cleared').reduce((a,q)=>a+Number(q.amount||0),0);const net=(rec-Math.min(rec,received))-(pay-Math.min(pay,paid));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>`;});};
50 try{if(currentUser)refreshAllSurfaces();}catch(e){console.error('drilldown init',e);}
51 })();
\ No newline at end of file