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

fix(expense): count only current active income and expense revisions in project totals

davoodmehraban89 committed Oct 14, 2026 at 11:45 UTC ef1f550a63e271d3da274da11bddf55b2a7e2ee6
1 file changed +2 -2
js/accounting.js
+2 -2
@@ -17,8 +17,8 @@ function getProjectFinancials(projectId){
17 const companies=getMyCompanies(),active=getMySettings().default_company_id||companies[0]?.id||'',legacyOk=companies.length===1,companyOk=i=>!active||i.companyId===active||(!i.companyId&&legacyOk);
18 const sales=getMyInvoices().filter(i=>companyOk(i)&&i.projectId===projectId&&typeof invoiceDocumentStatus==='function'&&invoiceDocumentStatus(i)==='posted').reduce((s,i)=>s+n(i.grandTotal),0);
19 const purchases=getMyPurchases().filter(i=>companyOk(i)&&purchaseAffectsBalance(i)&&(i.projectId===projectId||i.costCenterId===projectId)).reduce((s,i)=>s+n(i.grandTotal),0);
20 - const expenses=getMyExpenses().filter(e=>companyOk(e)&&e.projectId===projectId&&e.kind==='expense').reduce((s,e)=>s+n(e.amount),0);
21 - const income=getMyExpenses().filter(e=>companyOk(e)&&e.projectId===projectId&&e.kind==='income').reduce((s,e)=>s+n(e.amount),0);
20 + const expenses=(typeof expenseEffectiveRecords==='function'?expenseEffectiveRecords():getMyExpenses()).filter(e=>companyOk(e)&&e.projectId===projectId&&e.kind==='expense').reduce((s,e)=>s+n(e.amount),0);
21 + const income=(typeof expenseEffectiveRecords==='function'?expenseEffectiveRecords():getMyExpenses()).filter(e=>companyOk(e)&&e.projectId===projectId&&e.kind==='income').reduce((s,e)=>s+n(e.amount),0);
22 const receipts=(typeof paymentEffectiveRecords==='function'?paymentEffectiveRecords():getMyPayments()).filter(p=>companyOk(p)&&p.projectId===projectId&&p.direction==='inbound').reduce((s,p)=>s+n(p.amount),0);
23 const payments=(typeof paymentEffectiveRecords==='function'?paymentEffectiveRecords():getMyPayments()).filter(p=>companyOk(p)&&p.projectId===projectId&&p.direction==='outbound').reduce((s,p)=>s+n(p.amount),0);
24 return {sales,purchases,expenses,income,receipts,payments,accrualProfit:sales+income-purchases-expenses,cashNet:receipts+income-payments-expenses};