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

refactor(invoice): allow pure isolated list rendering with injected test rows

davoodmehraban89 committed Oct 31, 2026 at 00:25 UTC 46058b9c2339d5f73bab7b079fa1c1655af2a2a3
1 file changed +5 -5
src/views/InvoicesView.js
+5 -5
@@ -73,8 +73,8 @@ class InvoicesViewImpl {
73 if (el) el.innerHTML = this.renderTable();
74 }
75
76 - renderTable() {
77 - if (cache.invoices.length === 0) {
76 + renderTable(invoices = cache.invoices) {
77 + if (invoices.length === 0) {
78 return `
79 <div class="table-wrap">
80 <table><tbody>
@@ -90,7 +90,7 @@ class InvoicesViewImpl {
90 </div>`;
91 }
92
93 - const rows = cache.invoices.map(inv => {
93 + const rows = invoices.map(inv => {
94 const statusBadge = inv.status === 'paid'
95 ? '<span class="badge badge-success">تسویه‌شده</span>'
96 : inv.status === 'partial'
@@ -137,8 +137,8 @@ class InvoicesViewImpl {
137 }).join('');
138
139 // خلاصه
140 - const totalGrand = cache.invoices.reduce((s, i) => s + (Number(i.grandTotal) || 0), 0);
141 - const totalRemaining = cache.invoices.reduce((s, i) => s + (Number(i.remaining) || 0), 0);
140 + const totalGrand = invoices.reduce((s, i) => s + (Number(i.grandTotal) || 0), 0);
141 + const totalRemaining = invoices.reduce((s, i) => s + (Number(i.remaining) || 0), 0);
142
143 return `
144 <div class="table-wrap">