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

fix(ui): warn before saving excessive invoice discount

Factor EasyPro QA committed Nov 1, 2026 at 21:24 UTC 905536f09153ed24fdbdd9f48afeb236b20b3a07
2 files changed +9
src/views/InvoiceFormView.js
+4
@@ -804,6 +804,10 @@ class InvoiceFormViewImpl {
804 }
805
806 this._recalc(); // read payment state from the same calculation shown in the summary
807 + if (document.getElementById('invDiscType').value === 'fixed' && discountInput > ctx.totals.subtotal) {
808 + Toast.warning('تخفیف کل نمی‌تواند بیشتر از مبلغ فاکتور باشد');
809 + return;
810 + }
811 if (partialPaidAmount !== undefined && partialPaidAmount > ctx.totals.grandTotal) {
812 Toast.warning('مبلغ پرداخت‌شده نمی‌تواند از مبلغ کل فاکتور بیشتر باشد');
813 return;
tests/invoice-discount-input-integrity.test.mjs
+5
@@ -121,4 +121,9 @@ test('global fixed discount equal to subtotal is valid and produces zero total',
121 assert.equal(invoice.totalDiscount, 2700);
122 assert.equal(invoice.grandTotal, 0);
123 assert.equal(invoice.remaining, 0);
124 +});
125 +test('invoice form rejects excessive global fixed discount before invoking persistence', () => {
126 + const view = readFileSync(new URL('../src/views/InvoiceFormView.js', import.meta.url), 'utf8');
127 + assert.match(view, /discountInput > ctx\.totals\.subtotal/);
128 + assert.match(view, /تخفیف کل نمی‌تواند بیشتر از مبلغ فاکتور باشد/);
129 });
\ No newline at end of file