mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-16 10:20:31 +00:00
fix: tolerate floating-point drift in sales team allocated percentage
the total of allocated_percentage was compared to 100 with exact float equality, so a correct allocation could be rejected when the sum drifts in binary floating point (10.0 + 58.02 + 31.98 -> 100.00000000000001). round the total to the field precision before comparing, in both SellingController.calculate_contribution and Customer.validate.
This commit is contained in:
@@ -254,7 +254,7 @@ class SellingController(StockController):
|
||||
|
||||
total += sales_person.allocated_percentage
|
||||
|
||||
if sales_team and total != 100.0:
|
||||
if sales_team and flt(total, self.precision("allocated_percentage", "sales_team")) != 100.0:
|
||||
throw(_("Total allocated percentage for sales team should be 100"))
|
||||
|
||||
def validate_sales_team(self, sales_team):
|
||||
|
||||
Reference in New Issue
Block a user