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

fix(finance): preserve valid zero VAT rate when reopening invoices

davoodmehraban89 committed Oct 31, 2026 at 18:22 UTC 14046054b10bc9e7980c697db2cf3b20bbbb423c
2 files changed +10 -2
src/views/InvoiceFormView.js
+1 -1
@@ -211,7 +211,7 @@ class InvoiceFormViewImpl {
211 <input type="checkbox" id="invVatEnabled" ${d.vatEnabled ? 'checked' : ''} onchange="window.InvoiceFormView._recalc()" />
212 مالیات ارزش افزوده
213 </label>
214 - <input type="text" inputmode="numeric" class="form-control" id="invVatRate" aria-label="درصد مالیات بر ارزش افزوده" style="width:80px;min-height:34px" data-decimals="2" value="${NumberInput.format(d.vatRate || 10, 2)}" oninput="window.InvoiceFormView._recalc()" />
214 + <input type="text" inputmode="numeric" class="form-control" id="invVatRate" aria-label="درصد مالیات بر ارزش افزوده" style="width:80px;min-height:34px" data-decimals="2" value="${NumberInput.format(d.vatRate ?? 10, 2)}" oninput="window.InvoiceFormView._recalc()" />
215 <span style="font-size:12.5px;color:var(--text-muted)">٪</span>
216 </div>
217
tests/number-input-fractions.test.mjs
+9 -1
@@ -89,5 +89,13 @@ test('invoice quantity, reorder threshold and stocktake adjustment opt in to thr
89 assert.ok(src.includes('data-decimals="3" value="${NumberInput.format(' + name + ', 3)}"'), path);
90 }
91 const invoice = readFileSync(new URL('../src/views/InvoiceFormView.js', import.meta.url), 'utf8');
92 - assert.ok(invoice.includes('data-decimals="2" value="${NumberInput.format(d.vatRate || 10, 2)}"'), 'VAT fractional input');
92 + assert.ok(invoice.includes('data-decimals="2" value="${NumberInput.format(d.vatRate ?? 10, 2)}"'), 'VAT fractional input');
93 +});
94 +
95 +test('an explicit zero VAT rate remains zero when reopening an invoice', () => {
96 + const savedRate = 0;
97 + assert.equal(NumberInput.format(savedRate ?? 10, 2), '0');
98 + assert.equal(NumberInput.format(null ?? 10, 2), '10');
99 + const form = readFileSync(new URL('../src/views/InvoiceFormView.js', import.meta.url), 'utf8');
100 + assert.ok(form.includes('d.vatRate ?? 10, 2'), 'zero tax must not be replaced with ten percent');
101 });