diff --git a/hrms/hr/doctype/leave_application/leave_application.py b/hrms/hr/doctype/leave_application/leave_application.py index c8824d9eef..6403524ac9 100755 --- a/hrms/hr/doctype/leave_application/leave_application.py +++ b/hrms/hr/doctype/leave_application/leave_application.py @@ -333,6 +333,8 @@ def validate_block_days(self): frappe.throw(_("You are not authorized to approve leaves on Block Dates"), LeaveDayBlockedError) def validate_balance_leaves(self): + precision = cint(frappe.db.get_single_value("System Settings", "float_precision")) or 2 + if self.from_date and self.to_date: self.total_leave_days = get_number_of_leave_days( self.employee, @@ -359,9 +361,9 @@ def validate_balance_leaves(self): consider_all_leaves_in_the_allocation_period=True, for_consumption=True, ) - self.leave_balance = leave_balance.get("leave_balance") - leave_balance_for_consumption = leave_balance.get("leave_balance_for_consumption") - + leave_balance_for_consumption = flt( + leave_balance.get("leave_balance_for_consumption"), precision + ) if self.status != "Rejected" and ( leave_balance_for_consumption < self.total_leave_days or not leave_balance_for_consumption ): @@ -830,7 +832,7 @@ def get_number_of_leave_days( def get_leave_details(employee, date, for_salary_slip=False): allocation_records = get_leave_allocation_records(employee, date) leave_allocation = {} - precision = cint(frappe.db.get_single_value("System Settings", "float_precision", cache=True)) + precision = cint(frappe.db.get_single_value("System Settings", "float_precision")) or 2 for d in allocation_records: allocation = allocation_records.get(d, frappe._dict())