Skip to content

Commit

Permalink
Merge pull request #2373 from frappe/version-14-hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchamahabal authored Oct 31, 2024
2 parents e6197d4 + b5e51f4 commit 1d148a0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
1 change: 1 addition & 0 deletions hrms/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
"Task": "hrms.overrides.dashboard_overrides.get_dashboard_for_project",
"Project": "hrms.overrides.dashboard_overrides.get_dashboard_for_project",
"Timesheet": "hrms.overrides.dashboard_overrides.get_dashboard_for_timesheet",
"Bank Account": "hrms.overrides.dashboard_overrides.get_dashboard_for_bank_account",
}

# exempt linked doctypes from being automatically cancelled
Expand Down
13 changes: 1 addition & 12 deletions hrms/hr/doctype/attendance/attendance.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,7 @@ def on_cancel(self):
def validate_attendance_date(self):
date_of_joining = frappe.db.get_value("Employee", self.employee, "date_of_joining")

# leaves can be marked for future dates
if (
self.status != "On Leave"
and not self.leave_application
and getdate(self.attendance_date) > getdate(nowdate())
):
frappe.throw(
_("Attendance can not be marked for future dates: {0}").format(
frappe.bold(format_date(self.attendance_date)),
)
)
elif date_of_joining and getdate(self.attendance_date) < getdate(date_of_joining):
if date_of_joining and getdate(self.attendance_date) < getdate(date_of_joining):
frappe.throw(
_("Attendance date {0} can not be less than employee {1}'s joining date: {2}").format(
frappe.bold(format_date(self.attendance_date)),
Expand Down
31 changes: 22 additions & 9 deletions hrms/hr/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ def allocate_earned_leaves():

for e_leave_type in e_leave_types:
leave_allocations = get_leave_allocations(today, e_leave_type.name)

for allocation in leave_allocations:
if not allocation.leave_policy_assignment and not allocation.leave_policy:
continue
Expand Down Expand Up @@ -454,15 +453,29 @@ def round_earned_leaves(earned_leaves, rounding):


def get_leave_allocations(date, leave_type):
return frappe.db.sql(
"""select name, employee, from_date, to_date, leave_policy_assignment, leave_policy
from `tabLeave Allocation`
where
%s between from_date and to_date and docstatus=1
and leave_type=%s""",
(date, leave_type),
as_dict=1,
employee = frappe.qb.DocType("Employee")
leave_allocation = frappe.qb.DocType("Leave Allocation")
query = (
frappe.qb.from_(leave_allocation)
.join(employee)
.on(leave_allocation.employee == employee.name)
.select(
leave_allocation.name,
leave_allocation.employee,
leave_allocation.from_date,
leave_allocation.to_date,
leave_allocation.leave_policy_assignment,
leave_allocation.leave_policy,
)
.where(
(date >= leave_allocation.from_date)
& (date <= leave_allocation.to_date)
& (leave_allocation.docstatus == 1)
& (leave_allocation.leave_type == leave_type)
& (employee.status != "Left")
)
)
return query.run(as_dict=1) or []


def get_earned_leaves():
Expand Down
9 changes: 9 additions & 0 deletions hrms/overrides/dashboard_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,12 @@ def get_dashboard_for_project(data):
)

return data


def get_dashboard_for_bank_account(data):
for section in data["transactions"]:
if section.get("label") == "Transactions":
section["items"].append("Payroll Entry")
break

return data

0 comments on commit 1d148a0

Please sign in to comment.