From 06ea957ae5e398a58237c77e63b5108e97acef9c Mon Sep 17 00:00:00 2001 From: priyanshshah2442 Date: Mon, 9 Jun 2025 18:43:58 +0530 Subject: [PATCH] fix: test case to verify correct setting of discount amount and percentage (cherry picked from commit 3f0c5be5d9d5efde5fd9086791c503431dc559a9) --- .../doctype/purchase_invoice/test_purchase_invoice.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py index 055f5ca9676..99eb1de2cf8 100644 --- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -2806,6 +2806,17 @@ class TestPurchaseInvoice(FrappeTestCase, StockTestMixin): # Test 4 - Since this PI is overbilled by 130% and only 120% is allowed, it will fail self.assertRaises(frappe.ValidationError, pi.submit) + def test_discount_percentage_not_set_when_amount_is_manually_set(self): + pi = make_purchase_invoice(do_not_save=True) + discount_amount = 7 + pi.discount_amount = discount_amount + pi.save() + self.assertEqual(pi.additional_discount_percentage, None) + pi.set_posting_time = 1 + pi.posting_date = add_days(today(), -1) + pi.save() + self.assertEqual(pi.discount_amount, discount_amount) + def set_advance_flag(company, flag, default_account): frappe.db.set_value(