Skip to content

Commit

Permalink
fix: Allow float for Maximum Leave Allocation Allowed (backport #789)…
Browse files Browse the repository at this point in the history
… (#800)

Co-authored-by: niraj gautam <[email protected]>
  • Loading branch information
mergify[bot] and niraj2477 authored Aug 17, 2023
1 parent f3a11e8 commit b931037
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions hrms/hr/doctype/leave_allocation/leave_allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ def validate_leave_days_and_dates(self):
def validate_leave_allocation_days(self):
company = frappe.db.get_value("Employee", self.employee, "company")
leave_period = get_leave_period(self.from_date, self.to_date, company)
max_leaves_allowed = flt(
frappe.db.get_value("Leave Type", self.leave_type, "max_leaves_allowed")
)
max_leaves_allowed = frappe.db.get_value("Leave Type", self.leave_type, "max_leaves_allowed")

if max_leaves_allowed > 0:
leave_allocated = 0
if leave_period:
Expand Down Expand Up @@ -251,8 +250,8 @@ def set_total_leaves_allocated(self):

def limit_carry_forward_based_on_max_allowed_leaves(self):
max_leaves_allowed = frappe.db.get_value("Leave Type", self.leave_type, "max_leaves_allowed")
if max_leaves_allowed and self.total_leaves_allocated > flt(max_leaves_allowed):
self.total_leaves_allocated = flt(max_leaves_allowed)
if max_leaves_allowed and self.total_leaves_allocated > max_leaves_allowed:
self.total_leaves_allocated = max_leaves_allowed
self.unused_leaves = max_leaves_allowed - flt(self.new_leaves_allocated)

def set_carry_forwarded_leaves_in_previous_allocation(self, on_cancel=False):
Expand Down
2 changes: 1 addition & 1 deletion hrms/hr/doctype/leave_type/leave_type.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
},
{
"fieldname": "max_leaves_allowed",
"fieldtype": "Int",
"fieldtype": "Float",
"label": "Maximum Leave Allocation Allowed"
},
{
Expand Down

0 comments on commit b931037

Please sign in to comment.