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

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

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

Synced Dec 4, 01:45 UTC

Prevent double counting cheque settlements in receivables

davoodmehraban89 committed Sep 28, 2026 at 15:12 UTC 20601b17d0af7c81ad099819b98a58bd89a97cff
1 file changed +3 -3
js/invoices.js
+3 -3
@@ -90,9 +90,9 @@ function renderDashboard(){
90 const filteredInvoices=activeCompId?myInvoices.filter(inv=>inv.companyId===activeCompId):myInvoices;
91 const cur=getCurrencyLabel();
92 filteredInvoices.forEach(inv=>{salesSum+=Number(inv.grandTotal||0);if(inv.paymentMethod==='credit')debtorsSum+=(typeof invoiceOutstanding==='function'?invoiceOutstanding(inv):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 - const appliedInbound=Math.min(debtorsSum,inboundSettlements);
95 - debtorsSum=Math.max(0,debtorsSum-appliedInbound);
93 + // Receivables are reduced by first-class allocated receipts in invoiceOutstanding().
94 + // Cheques are lifecycle records and must not also reduce receivables here, otherwise
95 + // a receipt recorded with method=cheque would be counted twice.
96 const salesEl=document.getElementById('kpi-sales-sum');
97 const settledEl=document.getElementById('kpi-settled-sum');
98 const debtorsEl=document.getElementById('kpi-debtors-sum');