Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow float for Maximum Leave Allocation Allowed (backport #789) #800

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading