فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

Add fiscal-period and Jalali date filters to accounting reports and CSV export

davoodmehraban89 committed Oct 13, 2026 at 13:25 UTC 1c8c4063d43986f7222ca27450191b42730c2835
1 file changed +21 -3
src/views/AccountingView.js
+21 -3
@@ -28,6 +28,7 @@ class AccountingViewImpl {
28 this.accounts = [];
29 this.periods = [];
30 this.journals = [];
31 + this.reportFilter = {periodId:'',from:'',to:''};
32 this.busy = false;
33 }
34 async reload() {
@@ -146,10 +147,22 @@ class AccountingViewImpl {
147 </table></div></div>`;
148 }
149 async renderReports() {
149 - const r = await Ledger.financialReports();
150 + const r = await Ledger.financialReports(this.reportFilter);
151 + const filter=this.reportFilter;
152 + const periodOptions=this.periods.map(p=>`<option value="${html(p.id)}" ${p.id===filter.periodId?'selected':''}>${html(p.name)}</option>`).join('');
153 const rows = r.trial.map(x => `<tr><td>${html(x.code)}</td><td>${html(x.name)}</td><td>${Formatters.number(x.debit)}</td><td>${Formatters.number(x.credit)}</td><td>${Formatters.number(x.balance)}</td></tr>`).join('');
154 const detail = r.detail.map(x => `<tr><td>${html(x.date)}</td><td>${html(x.description)}</td><td>${html(x.code+' — '+x.name)}</td><td>${Formatters.number(x.debit)}</td><td>${Formatters.number(x.credit)}</td></tr>`).join('');
152 - return `<div class="card"><div class="toolbar"><strong>گزارش‌های مبتنی بر اسناد قطعی دفتر کل</strong><button class="btn btn-secondary" onclick="window.AccountingView.exportReports()">خروجی CSV</button></div>
155 + return `<div class="card"><div class="toolbar"><strong>گزارش‌های مبتنی بر اسناد قطعی دفتر کل</strong>
156 + <button class="btn btn-secondary" onclick="window.AccountingView.exportReports()">خروجی CSV</button></div>
157 + <div class="toolbar" style="margin:8px 0;flex-wrap:wrap;gap:8px">
158 + <label>دوره مالی <select class="form-control" style="min-width:140px" onchange="window.AccountingView.setReportFilter('periodId',this.value)">
159 + <option value="">تمام دوره‌ها</option>${periodOptions}</select></label>
160 + <label>از تاریخ <input class="form-control" style="width:135px" placeholder="۱۴۰۵/۰۱/۰۱" value="${html(filter.from)}"
161 + onchange="window.AccountingView.setReportFilter('from',this.value)"></label>
162 + <label>تا تاریخ <input class="form-control" style="width:135px" placeholder="۱۴۰۵/۱۲/۲۹" value="${html(filter.to)}"
163 + onchange="window.AccountingView.setReportFilter('to',this.value)"></label>
164 + </div>
165 + <p style="font-size:12px;color:var(--text-muted)">سود و زیان و ریز اسناد براساس فیلتر محاسبه می‌شوند. ترازنامه تا تاریخ انتهای بازه، تجمعی است.</p>
166 <p>درآمد: ${Formatters.number(r.profitLoss.revenue)} ریال | هزینه و بهای تمام‌شده: ${Formatters.number(r.profitLoss.expenses)} ریال | سود خالص: ${Formatters.number(r.profitLoss.netProfit)} ریال</p>
167 <p>دارایی: ${Formatters.number(r.balanceSheet.assets)} | بدهی: ${Formatters.number(r.balanceSheet.liabilities)} | حقوق مالکانه با سود جاری: ${Formatters.number(r.balanceSheet.equityWithProfit)} | اختلاف ترازنامه: ${Formatters.number(r.balanceSheet.difference)}</p>
168 <h3>تراز حساب‌ها</h3><div class="table-wrap"><table><thead><tr><th>کد</th><th>حساب</th><th>بدهکار</th><th>بستانکار</th><th>مانده</th></tr></thead><tbody>${rows||'<tr><td colspan="5">بدون گردش</td></tr>'}</tbody></table></div>
@@ -157,7 +170,7 @@ class AccountingViewImpl {
170 }
171 async exportReports() {
172 try {
160 - const r = await Ledger.financialReports();
173 + const r = await Ledger.financialReports(this.reportFilter);
174 const esc = v => '"'+String(v??'').replace(/"/g,'""')+'"';
175 const csv = [['date','description','account_code','account_name','debit_irr','credit_irr'],...r.detail.map(x=>[x.date,x.description,x.code,x.name,x.debit,x.credit])].map(a=>a.map(esc).join(',')).join('\r\n');
176 const blob = new Blob(['\ufeff',csv],{type:'text/csv;charset=utf-8'});
@@ -212,6 +225,11 @@ class AccountingViewImpl {
225 } catch(error){Toast.error('خروجی مغایرت: '+error.message);}
226 }
227
228 + setReportFilter(key,value) {
229 + if (!['periodId','from','to'].includes(key)) return;
230 + this.reportFilter={...this.reportFilter,[key]:key==='periodId'?value:digits(value).trim()};
231 + return this.refresh();
232 + }
233 setTrialPeriod(id) { this.selectedTrialPeriod = id; return this.refresh(); }
234 openPeriodModal() {
235 const body = `<div class="form-group"><label class="form-label">نام دوره</label>