@davoodmehraban89 / Factor-easy / commits / 825246e
Fork 0

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

Clamp cleared cheque settlement to outstanding receivables (#2)

davoodmehraban89 committed Sep 28, 2026 at 15:01 UTC 825246e7abb9087337223c8b5a74014573f5f987
1 file changed +2 -1
js/invoices.js
+2 -1
@@ -91,7 +91,8 @@ function renderDashboard(){
91 const cur=getCurrencyLabel();
92 filteredInvoices.forEach(inv=>{salesSum+=Number(inv.grandTotal||0);if(inv.paymentMethod==='credit')debtorsSum+=Number(inv.grandTotal||0);});
93 const inboundSettlements=myCheques.filter(q=>q.direction==='inbound'&&q.status==='cleared'&&(!activeCompId||q.companyId===activeCompId||(!q.companyId&&myCompanies.length===1))).reduce((a,q)=>a+Number(q.amount||0),0);
94 - debtorsSum=Math.max(0,debtorsSum-inboundSettlements);
94 + const appliedInbound=Math.min(debtorsSum,inboundSettlements);
95 + debtorsSum=Math.max(0,debtorsSum-appliedInbound);
96 const salesEl=document.getElementById('kpi-sales-sum');
97 const settledEl=document.getElementById('kpi-settled-sum');
98 const debtorsEl=document.getElementById('kpi-debtors-sum');