From b0ed010d4ec1ada813a0938c5c3c5719aa372204 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 3 Apr 2024 09:21:33 +0530 Subject: [PATCH 01/11] fix: employee filter in list view of employee checkin (backport #1612) (#1615) * fix: employee filter in list view of employee checkin (#1612) (cherry picked from commit 62313145d79f0f317025244aca92e1f6577d1ab1) # Conflicts: # hrms/hr/doctype/employee_checkin/employee_checkin.json * chore: fix conflicts --------- Co-authored-by: Jeevan syriac <95610320+Jeevansyriac@users.noreply.github.com> Co-authored-by: Rucha Mahabal --- hrms/hr/doctype/employee_checkin/employee_checkin.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hrms/hr/doctype/employee_checkin/employee_checkin.json b/hrms/hr/doctype/employee_checkin/employee_checkin.json index 0eb63c1bdc..14eb5cbcfa 100644 --- a/hrms/hr/doctype/employee_checkin/employee_checkin.json +++ b/hrms/hr/doctype/employee_checkin/employee_checkin.json @@ -24,6 +24,7 @@ { "fieldname": "employee", "fieldtype": "Link", + "in_standard_filter": 1, "label": "Employee", "options": "Employee", "reqd": 1, @@ -109,7 +110,7 @@ } ], "links": [], - "modified": "2023-05-12 14:52:22.660264", + "modified": "2024-04-02 01:50:23.150627", "modified_by": "Administrator", "module": "HR", "name": "Employee Checkin", From 8ef26a625d97fabec368c385b4992bd7843f99e6 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 09:55:10 +0530 Subject: [PATCH 02/11] fix: employee filter in list view of shift assignment (backport #1624) (#1626) * fix: employee filter in list view of shift assignment (#1624) (cherry picked from commit 4e3feab634e055108089b10081fa21aa03c01672) # Conflicts: # hrms/hr/doctype/shift_assignment/shift_assignment.json * chore: fix conflicts --------- Co-authored-by: Jeevan syriac <95610320+Jeevansyriac@users.noreply.github.com> Co-authored-by: Rucha Mahabal --- hrms/hr/doctype/shift_assignment/shift_assignment.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hrms/hr/doctype/shift_assignment/shift_assignment.json b/hrms/hr/doctype/shift_assignment/shift_assignment.json index 1a1cd3632b..a2b562be89 100644 --- a/hrms/hr/doctype/shift_assignment/shift_assignment.json +++ b/hrms/hr/doctype/shift_assignment/shift_assignment.json @@ -23,6 +23,7 @@ { "fieldname": "employee", "fieldtype": "Link", + "in_standard_filter": 1, "label": "Employee", "options": "Employee", "reqd": 1, @@ -103,7 +104,7 @@ ], "is_submittable": 1, "links": [], - "modified": "2023-06-23 12:08:23.247882", + "modified": "2024-04-04 16:10:34.273274", "modified_by": "Administrator", "module": "HR", "name": "Shift Assignment", From d339d3b02af3d6730efc58decfbd601a41143ed5 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 17:42:46 +0530 Subject: [PATCH 03/11] ci: fix flaky test data (backport #1619) (#1632) * ci: fix compensatory leave test (cherry picked from commit 94835de6bacd14b78b2e20cd97bd22c40b431569) * ci: fix test for tds overwrite using additional salary - tds will be different as per no of payment days in the current month, just check for absence of additional salary (cherry picked from commit 7ca74124351ec764354114e46690c453f04c8c2d) # Conflicts: # hrms/payroll/doctype/additional_salary/test_additional_salary.py * chore: fix conflicts --------- Co-authored-by: Rucha Mahabal --- .../test_compensatory_leave_request.py | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/hrms/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py b/hrms/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py index 8f1b753d5c..d699f82413 100644 --- a/hrms/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py +++ b/hrms/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py @@ -132,6 +132,7 @@ def test_half_day_compensatory_leave(self): def test_request_on_leave_period_boundary(self): frappe.db.delete("Leave Period") create_leave_period("2023-01-01", "2023-12-31", "_Test Company") + create_holiday_list("2023-01-01", "2023-12-31") employee = get_employee() boundary_date = "2023-12-31" @@ -149,9 +150,11 @@ def test_request_on_leave_period_boundary(self): reason="test", ) ) + compensatory_leave_request.insert() self.assertRaises(frappe.ValidationError, compensatory_leave_request.submit) - create_leave_period("2023-01-01", "2023-12-31", "_Test Company") + create_leave_period("2024-01-01", "2024-12-31", "_Test Company") + compensatory_leave_request.reload() compensatory_leave_request.submit() @@ -195,20 +198,27 @@ def mark_attendance(employee, date=None, status="Present"): attendance.submit() -def create_holiday_list(): - if frappe.db.exists("Holiday List", "_Test Compensatory Leave"): - return +def create_holiday_list(from_date=None, to_date=None): + list_name = "_Test Compensatory Leave" + if frappe.db.exists("Holiday List", list_name): + frappe.db.delete("Holiday List", list_name) + frappe.db.delete("Holiday", {"parent": list_name}) + + if from_date: + holiday_date = add_days(from_date, 1) + else: + holiday_date = today() holiday_list = frappe.get_doc( { "doctype": "Holiday List", - "from_date": add_months(today(), -3), - "to_date": add_months(today(), 3), + "from_date": from_date or add_months(today(), -3), + "to_date": to_date or add_months(today(), 3), "holidays": [ - {"description": "Test Holiday", "holiday_date": today()}, - {"description": "Test Holiday 1", "holiday_date": add_days(today(), -1)}, + {"description": "Test Holiday", "holiday_date": holiday_date}, + {"description": "Test Holiday 1", "holiday_date": add_days(holiday_date, -1)}, ], - "holiday_list_name": "_Test Compensatory Leave", + "holiday_list_name": list_name, } ) holiday_list.save() From 32abbc25de5630d49574bd70b7f92552526dc6df Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 20:13:37 +0530 Subject: [PATCH 04/11] fix: shift type filter in list view of shift assignment (backport #1625) (#1628) * fix: shift type filter in list view of shift assignment (#1625) Co-authored-by: Rucha Mahabal (cherry picked from commit 438a449385dbefe3e6e7241e754f742fc1458e28) # Conflicts: # hrms/hr/doctype/shift_assignment/shift_assignment.json * chore: fix conflicts --------- Co-authored-by: Jeevan syriac <95610320+Jeevansyriac@users.noreply.github.com> Co-authored-by: Rucha Mahabal --- hrms/hr/doctype/shift_assignment/shift_assignment.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hrms/hr/doctype/shift_assignment/shift_assignment.json b/hrms/hr/doctype/shift_assignment/shift_assignment.json index a2b562be89..a4cacd4823 100644 --- a/hrms/hr/doctype/shift_assignment/shift_assignment.json +++ b/hrms/hr/doctype/shift_assignment/shift_assignment.json @@ -48,6 +48,7 @@ "fieldname": "shift_type", "fieldtype": "Link", "in_list_view": 1, + "in_standard_filter": 1, "label": "Shift Type", "options": "Shift Type", "reqd": 1, @@ -104,7 +105,7 @@ ], "is_submittable": 1, "links": [], - "modified": "2024-04-04 16:10:34.273274", + "modified": "2024-04-04 17:13:13.137431", "modified_by": "Administrator", "module": "HR", "name": "Shift Assignment", From e252e894ca513deccf2d009d893108a232711034 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 21:17:48 +0530 Subject: [PATCH 05/11] fix: use reference name while updating exc rate (backport #1623) (#1634) (cherry picked from commit a24fbd0638f4b043200a044b187f3e7fe968e807) Co-authored-by: ruthra kumar --- hrms/overrides/employee_payment_entry.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hrms/overrides/employee_payment_entry.py b/hrms/overrides/employee_payment_entry.py index ec8ce5df86..8fb2a0bba4 100644 --- a/hrms/overrides/employee_payment_entry.py +++ b/hrms/overrides/employee_payment_entry.py @@ -31,7 +31,7 @@ def set_missing_ref_details( self, force: bool = False, update_ref_details_only_for: list | None = None, - ref_exchange_rate: float | None = None, + reference_exchange_details: dict | None = None, ) -> None: for d in self.get("references"): if d.allocated_amount: @@ -45,8 +45,12 @@ def set_missing_ref_details( ) # Only update exchange rate when the reference is Journal Entry - if ref_exchange_rate and d.reference_doctype == "Journal Entry": - ref_details.update({"exchange_rate": ref_exchange_rate}) + if ( + reference_exchange_details + and d.reference_doctype == reference_exchange_details.reference_doctype + and d.reference_name == reference_exchange_details.reference_name + ): + ref_details.update({"exchange_rate": reference_exchange_details.exchange_rate}) for field, value in ref_details.items(): if d.exchange_gain_loss: From 061840ba8fd67e6a85f80926883a4bec0ff13592 Mon Sep 17 00:00:00 2001 From: Viny Selopal Date: Thu, 28 Mar 2024 12:31:59 +0530 Subject: [PATCH 06/11] feat: show holidays and colour code in attendance calendar (cherry picked from commit 4e3952187b3a2eab6890bd6fbb5496086098e8d0) --- hrms/hr/doctype/attendance/attendance.py | 37 ++++++++++++++++--- .../doctype/attendance/attendance_calendar.js | 35 ++++++++++++++---- 2 files changed, 58 insertions(+), 14 deletions(-) diff --git a/hrms/hr/doctype/attendance/attendance.py b/hrms/hr/doctype/attendance/attendance.py index 1937ff3ff8..a05f07c7a0 100644 --- a/hrms/hr/doctype/attendance/attendance.py +++ b/hrms/hr/doctype/attendance/attendance.py @@ -17,7 +17,11 @@ ) from hrms.hr.doctype.shift_assignment.shift_assignment import has_overlapping_timings -from hrms.hr.utils import get_holiday_dates_for_employee, validate_active_employee +from hrms.hr.utils import ( + get_holiday_dates_for_employee, + get_holidays_for_employee, + validate_active_employee, +) class DuplicateAttendanceError(frappe.ValidationError): @@ -238,14 +242,16 @@ def get_events(start, end, filters=None): conditions = get_filters_cond("Attendance", filters, []) add_attendance(events, start, end, conditions=conditions) + add_holidays(events, start, end, employee) return events def add_attendance(events, start, end, conditions=None): - query = """select name, attendance_date, status - from `tabAttendance` where - attendance_date between %(from_date)s and %(to_date)s - and docstatus < 2""" + query = """select name, attendance_date, status, employee_name + from `tabAttendance` where + attendance_date between %(from_date)s and %(to_date)s + and docstatus < 2""" + if conditions: query += conditions @@ -255,13 +261,32 @@ def add_attendance(events, start, end, conditions=None): "doctype": "Attendance", "start": d.attendance_date, "end": d.attendance_date, - "title": cstr(d.status), + "title": f"{d.employee_name}-{cstr(d.status)}", + "status": d.status, "docstatus": d.docstatus, } if e not in events: events.append(e) +def add_holidays(events, start, end, employee=None): + holidays = get_holidays_for_employee(employee, start, end) + if not holidays: + return + + for holiday in holidays: + events.append( + { + "doctype": "Holiday", + "start": holiday.holiday_date, + "end": holiday.holiday_date, + "title": _("Holiday") + ": " + cstr(holiday.description), + "name": holiday.name, + "allDay": 1, + } + ) + + def mark_attendance( employee, attendance_date, diff --git a/hrms/hr/doctype/attendance/attendance_calendar.js b/hrms/hr/doctype/attendance/attendance_calendar.js index 6341c8794f..7ae7ef9b13 100644 --- a/hrms/hr/doctype/attendance/attendance_calendar.js +++ b/hrms/hr/doctype/attendance/attendance_calendar.js @@ -1,12 +1,31 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt frappe.views.calendar["Attendance"] = { - options: { - header: { - left: 'prev,next today', - center: 'title', - right: 'month' - } - }, - get_events_method: "hrms.hr.doctype.attendance.attendance.get_events" + field_map: { + start: "start", + end: "end", + id: "name", + title: "title", + allDay: "allDay", + color: "color", + }, + get_css_class: function (data) { + console.log("data", data); + if (data.doctype === "Holiday") return "default"; + if (data.doctype === "Attendance") { + if (data.status === "Absent" || data.status === "On Leave") { + return "danger"; + } + if (data.status === "Half Day") return "warning"; + return "success"; + } + }, + options: { + header: { + left: "prev,next today", + center: "title", + right: "month", + }, + }, + get_events_method: "hrms.hr.doctype.attendance.attendance.get_events", }; From 58340c19f499328e1e4ee9c9e51d6ded9c911989 Mon Sep 17 00:00:00 2001 From: Viny Selopal Date: Thu, 28 Mar 2024 13:31:53 +0530 Subject: [PATCH 07/11] refactor: move import statements up (cherry picked from commit b64d6b5a3b6d4b8835558804690219ff6d9b02c7) --- hrms/hr/doctype/attendance/attendance.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hrms/hr/doctype/attendance/attendance.py b/hrms/hr/doctype/attendance/attendance.py index a05f07c7a0..b6f7582c09 100644 --- a/hrms/hr/doctype/attendance/attendance.py +++ b/hrms/hr/doctype/attendance/attendance.py @@ -2,8 +2,11 @@ # License: GNU General Public License v3. See license.txt +import json + import frappe from frappe import _ +from frappe.desk.reportview import get_filters_cond from frappe.model.document import Document from frappe.utils import ( add_days, @@ -16,6 +19,8 @@ nowdate, ) +from erpnext.controllers.status_updater import validate_status + from hrms.hr.doctype.shift_assignment.shift_assignment import has_overlapping_timings from hrms.hr.utils import ( get_holiday_dates_for_employee, @@ -34,7 +39,6 @@ class OverlappingShiftAttendanceError(frappe.ValidationError): class Attendance(Document): def validate(self): - from erpnext.controllers.status_updater import validate_status validate_status(self.status, ["Present", "Absent", "On Leave", "Half Day", "Work From Home"]) validate_active_employee(self.employee) @@ -238,8 +242,6 @@ def get_events(start, end, filters=None): if not employee: return events - from frappe.desk.reportview import get_filters_cond - conditions = get_filters_cond("Attendance", filters, []) add_attendance(events, start, end, conditions=conditions) add_holidays(events, start, end, employee) @@ -324,7 +326,6 @@ def mark_attendance( @frappe.whitelist() def mark_bulk_attendance(data): - import json if isinstance(data, str): data = json.loads(data) From 447c615cc002f98a5c82d115f7766ab710a19254 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Fri, 5 Apr 2024 21:07:47 +0530 Subject: [PATCH 08/11] chore: fix formatting (cherry picked from commit 592010eda37a25a748cf614a10a4187fd38a5daa) --- .../doctype/attendance/attendance_calendar.js | 53 +++++++++---------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/hrms/hr/doctype/attendance/attendance_calendar.js b/hrms/hr/doctype/attendance/attendance_calendar.js index 7ae7ef9b13..605bc32cc7 100644 --- a/hrms/hr/doctype/attendance/attendance_calendar.js +++ b/hrms/hr/doctype/attendance/attendance_calendar.js @@ -1,31 +1,30 @@ // Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors // For license information, please see license.txt frappe.views.calendar["Attendance"] = { - field_map: { - start: "start", - end: "end", - id: "name", - title: "title", - allDay: "allDay", - color: "color", - }, - get_css_class: function (data) { - console.log("data", data); - if (data.doctype === "Holiday") return "default"; - if (data.doctype === "Attendance") { - if (data.status === "Absent" || data.status === "On Leave") { - return "danger"; - } - if (data.status === "Half Day") return "warning"; - return "success"; - } - }, - options: { - header: { - left: "prev,next today", - center: "title", - right: "month", - }, - }, - get_events_method: "hrms.hr.doctype.attendance.attendance.get_events", + field_map: { + start: "start", + end: "end", + id: "name", + title: "title", + allDay: "allDay", + color: "color", + }, + get_css_class: function (data) { + if (data.doctype === "Holiday") return "default"; + else if (data.doctype === "Attendance") { + if (data.status === "Absent" || data.status === "On Leave") { + return "danger"; + } + if (data.status === "Half Day") return "warning"; + return "success"; + } + }, + options: { + header: { + left: "prev,next today", + center: "title", + right: "month", + }, + }, + get_events_method: "hrms.hr.doctype.attendance.attendance.get_events", }; From 549e033569bab3e54b36939a0188f2eaf278ce1c Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Fri, 5 Apr 2024 21:15:24 +0530 Subject: [PATCH 09/11] chore: add read perm for Employee on Attendance (cherry picked from commit c82d9a40e7ec8102169ac0241a8f2727d991868b) # Conflicts: # hrms/hr/doctype/attendance/attendance.json --- hrms/hr/doctype/attendance/attendance.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hrms/hr/doctype/attendance/attendance.json b/hrms/hr/doctype/attendance/attendance.json index edc808f693..c614480b8e 100644 --- a/hrms/hr/doctype/attendance/attendance.json +++ b/hrms/hr/doctype/attendance/attendance.json @@ -207,7 +207,11 @@ "idx": 1, "is_submittable": 1, "links": [], +<<<<<<< HEAD "modified": "2023-06-15 20:09:21.730465", +======= + "modified": "2024-04-05 20:55:02.905452", +>>>>>>> c82d9a40e (chore: add read perm for Employee on Attendance) "modified_by": "Administrator", "module": "HR", "name": "Attendance", @@ -254,6 +258,16 @@ "share": 1, "submit": 1, "write": 1 + }, + { + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "Employee", + "select": 1, + "share": 1 } ], "search_fields": "employee,employee_name,attendance_date,status", From 012912ade528b02806c79513d3f2df4f5efee454 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Fri, 5 Apr 2024 21:19:50 +0530 Subject: [PATCH 10/11] chore: fix formatting & imports (cherry picked from commit a7aab2a7a9a5dadb6e4d3a40a899ef3819d96023) --- hrms/hr/doctype/attendance/attendance.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/hrms/hr/doctype/attendance/attendance.py b/hrms/hr/doctype/attendance/attendance.py index b6f7582c09..67d655161d 100644 --- a/hrms/hr/doctype/attendance/attendance.py +++ b/hrms/hr/doctype/attendance/attendance.py @@ -2,11 +2,8 @@ # License: GNU General Public License v3. See license.txt -import json - import frappe from frappe import _ -from frappe.desk.reportview import get_filters_cond from frappe.model.document import Document from frappe.utils import ( add_days, @@ -19,8 +16,6 @@ nowdate, ) -from erpnext.controllers.status_updater import validate_status - from hrms.hr.doctype.shift_assignment.shift_assignment import has_overlapping_timings from hrms.hr.utils import ( get_holiday_dates_for_employee, @@ -39,6 +34,7 @@ class OverlappingShiftAttendanceError(frappe.ValidationError): class Attendance(Document): def validate(self): + from erpnext.controllers.status_updater import validate_status validate_status(self.status, ["Present", "Absent", "On Leave", "Half Day", "Work From Home"]) validate_active_employee(self.employee) @@ -235,6 +231,8 @@ def unlink_attendance_from_checkins(self): @frappe.whitelist() def get_events(start, end, filters=None): + from frappe.desk.reportview import get_filters_cond + events = [] employee = frappe.db.get_value("Employee", {"user_id": frappe.session.user}) @@ -250,9 +248,9 @@ def get_events(start, end, filters=None): def add_attendance(events, start, end, conditions=None): query = """select name, attendance_date, status, employee_name - from `tabAttendance` where - attendance_date between %(from_date)s and %(to_date)s - and docstatus < 2""" + from `tabAttendance` where + attendance_date between %(from_date)s and %(to_date)s + and docstatus < 2""" if conditions: query += conditions @@ -263,7 +261,7 @@ def add_attendance(events, start, end, conditions=None): "doctype": "Attendance", "start": d.attendance_date, "end": d.attendance_date, - "title": f"{d.employee_name}-{cstr(d.status)}", + "title": f"{d.employee_name}: {cstr(d.status)}", "status": d.status, "docstatus": d.docstatus, } @@ -326,6 +324,7 @@ def mark_attendance( @frappe.whitelist() def mark_bulk_attendance(data): + import json if isinstance(data, str): data = json.loads(data) From ddc118318bd75ad86881f6b25d5fb998e69f3780 Mon Sep 17 00:00:00 2001 From: Rucha Mahabal Date: Fri, 5 Apr 2024 23:16:53 +0530 Subject: [PATCH 11/11] chore: fix conflicts --- hrms/hr/doctype/attendance/attendance.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hrms/hr/doctype/attendance/attendance.json b/hrms/hr/doctype/attendance/attendance.json index c614480b8e..ae22e5fd17 100644 --- a/hrms/hr/doctype/attendance/attendance.json +++ b/hrms/hr/doctype/attendance/attendance.json @@ -207,11 +207,7 @@ "idx": 1, "is_submittable": 1, "links": [], -<<<<<<< HEAD - "modified": "2023-06-15 20:09:21.730465", -======= "modified": "2024-04-05 20:55:02.905452", ->>>>>>> c82d9a40e (chore: add read perm for Employee on Attendance) "modified_by": "Administrator", "module": "HR", "name": "Attendance",