From ec0b80801f115fa8f87a5a5ce2524d35c82c25a9 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 18:03:08 +0530 Subject: [PATCH 1/3] fix: stop leave allocation for left employees (backport #2358) (#2362) Co-authored-by: Aysha <74527579+AyshaHakeem@users.noreply.github.com> --- hrms/hr/utils.py | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/hrms/hr/utils.py b/hrms/hr/utils.py index 12848bb79b..0425ed7e5f 100644 --- a/hrms/hr/utils.py +++ b/hrms/hr/utils.py @@ -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 @@ -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(): From 5ed555ff8f19e5725822c6e995f64c979568b625 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 18:08:09 +0530 Subject: [PATCH 2/3] fix: submit attendance request for future dates (backport #2352) (#2365) Co-authored-by: Aysha <74527579+AyshaHakeem@users.noreply.github.com> --- hrms/hr/doctype/attendance/attendance.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/hrms/hr/doctype/attendance/attendance.py b/hrms/hr/doctype/attendance/attendance.py index 192c820d4f..cd94b2476a 100644 --- a/hrms/hr/doctype/attendance/attendance.py +++ b/hrms/hr/doctype/attendance/attendance.py @@ -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)), From b5e51f425ac9a4cf1a181b335dc3625267509c28 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 12:58:08 +0530 Subject: [PATCH 3/3] feat: add Payroll Entry to Bank Account dashboard (backport #2369) (#2371) Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com> --- hrms/hooks.py | 1 + hrms/overrides/dashboard_overrides.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/hrms/hooks.py b/hrms/hooks.py index 77f5df1a47..231ef8f539 100644 --- a/hrms/hooks.py +++ b/hrms/hooks.py @@ -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 diff --git a/hrms/overrides/dashboard_overrides.py b/hrms/overrides/dashboard_overrides.py index 88c5e0639a..f14d74a0ef 100644 --- a/hrms/overrides/dashboard_overrides.py +++ b/hrms/overrides/dashboard_overrides.py @@ -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