From 71f5470dfdee39322d007e24c2f9b5c60bb6db0b Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 4 Jun 2024 15:19:42 +0530 Subject: [PATCH] fix: convert percentage from str to float (#41766) --- .../doctype/cost_center_allocation/cost_center_allocation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/doctype/cost_center_allocation/cost_center_allocation.py b/erpnext/accounts/doctype/cost_center_allocation/cost_center_allocation.py index 784ad27dd47..34b2ec68743 100644 --- a/erpnext/accounts/doctype/cost_center_allocation/cost_center_allocation.py +++ b/erpnext/accounts/doctype/cost_center_allocation/cost_center_allocation.py @@ -4,7 +4,7 @@ import frappe from frappe import _ from frappe.model.document import Document -from frappe.utils import add_days, format_date, getdate +from frappe.utils import add_days, flt, format_date, getdate class MainCostCenterCantBeChild(frappe.ValidationError): @@ -60,7 +60,7 @@ class CostCenterAllocation(Document): self.validate_child_cost_centers() def validate_total_allocation_percentage(self): - total_percentage = sum([d.percentage for d in self.get("allocation_percentages", [])]) + total_percentage = sum([flt(d.percentage) for d in self.get("allocation_percentages", [])]) if total_percentage != 100: frappe.throw(_("Total percentage against cost centers should be 100"), WrongPercentageAllocation)