From 4afba94d1c3dffec6cb789f69f537883b88dc32d Mon Sep 17 00:00:00 2001 From: pandiyan Date: Sun, 9 Aug 2026 11:25:24 +0530 Subject: [PATCH] test: sales team allocation totalling 100 in floating point covers the case where the percentages are correct but the accumulated sum is 100.00000000000001. two rows can never drift, since the second reconstructs exactly as 100 - first, so the case needs three rows. --- .../selling/doctype/sales_order/test_sales_order.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py index 0ec0f203c14..fdbc40ba235 100644 --- a/erpnext/selling/doctype/sales_order/test_sales_order.py +++ b/erpnext/selling/doctype/sales_order/test_sales_order.py @@ -3215,6 +3215,17 @@ class TestSalesOrder(ERPNextTestSuite): so.save() self.assertEqual(sum(d.allocated_percentage for d in so.sales_team), 100) + with self.subTest("floating-point drift in the total is tolerated"): + # 10.0 + 58.02 + 31.98 accumulates to 100.00000000000001 in binary floating point + so = make_sales_order(do_not_save=True) + for sales_person, percentage in ( + ("_Test Sales Person", 10.0), + ("_Test Sales Person 1", 58.02), + ("_Test Sales Person 2", 31.98), + ): + so.append("sales_team", {"sales_person": sales_person, "allocated_percentage": percentage}) + so.save() + def test_sales_team_disabled_sales_person_rejected(self): frappe.db.set_value("Sales Person", "_Test Sales Person 2", "enabled", 0) try: