mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-18 01:36:55 +00:00
fix: convert percentage from str to float (#41766)
(cherry picked from commit 71f5470dfd)
Co-authored-by: Nabin Hait <nabinhait@gmail.com>
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
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):
|
class MainCostCenterCantBeChild(frappe.ValidationError):
|
||||||
@@ -60,7 +60,7 @@ class CostCenterAllocation(Document):
|
|||||||
self.validate_child_cost_centers()
|
self.validate_child_cost_centers()
|
||||||
|
|
||||||
def validate_total_allocation_percentage(self):
|
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:
|
if total_percentage != 100:
|
||||||
frappe.throw(_("Total percentage against cost centers should be 100"), WrongPercentageAllocation)
|
frappe.throw(_("Total percentage against cost centers should be 100"), WrongPercentageAllocation)
|
||||||
|
|||||||
Reference in New Issue
Block a user