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/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)), 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(): 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