Skip to content

Commit a615de6

Browse files
authored
Merge pull request #1645 from frappe/version-14-hotfix
chore: release v14
2 parents 943ec5d + 9365b55 commit a615de6

File tree

7 files changed

+95
-25
lines changed

7 files changed

+95
-25
lines changed

hrms/hr/doctype/attendance/attendance.json

+11-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
"idx": 1,
208208
"is_submittable": 1,
209209
"links": [],
210-
"modified": "2023-06-15 20:09:21.730465",
210+
"modified": "2024-04-05 20:55:02.905452",
211211
"modified_by": "Administrator",
212212
"module": "HR",
213213
"name": "Attendance",
@@ -254,6 +254,16 @@
254254
"share": 1,
255255
"submit": 1,
256256
"write": 1
257+
},
258+
{
259+
"email": 1,
260+
"export": 1,
261+
"print": 1,
262+
"read": 1,
263+
"report": 1,
264+
"role": "Employee",
265+
"select": 1,
266+
"share": 1
257267
}
258268
],
259269
"search_fields": "employee,employee_name,attendance_date,status",

hrms/hr/doctype/attendance/attendance.py

+30-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
)
1818

1919
from hrms.hr.doctype.shift_assignment.shift_assignment import has_overlapping_timings
20-
from hrms.hr.utils import get_holiday_dates_for_employee, validate_active_employee
20+
from hrms.hr.utils import (
21+
get_holiday_dates_for_employee,
22+
get_holidays_for_employee,
23+
validate_active_employee,
24+
)
2125

2226

2327
class DuplicateAttendanceError(frappe.ValidationError):
@@ -227,25 +231,27 @@ def unlink_attendance_from_checkins(self):
227231

228232
@frappe.whitelist()
229233
def get_events(start, end, filters=None):
234+
from frappe.desk.reportview import get_filters_cond
235+
230236
events = []
231237

232238
employee = frappe.db.get_value("Employee", {"user_id": frappe.session.user})
233239

234240
if not employee:
235241
return events
236242

237-
from frappe.desk.reportview import get_filters_cond
238-
239243
conditions = get_filters_cond("Attendance", filters, [])
240244
add_attendance(events, start, end, conditions=conditions)
245+
add_holidays(events, start, end, employee)
241246
return events
242247

243248

244249
def add_attendance(events, start, end, conditions=None):
245-
query = """select name, attendance_date, status
250+
query = """select name, attendance_date, status, employee_name
246251
from `tabAttendance` where
247252
attendance_date between %(from_date)s and %(to_date)s
248253
and docstatus < 2"""
254+
249255
if conditions:
250256
query += conditions
251257

@@ -255,13 +261,32 @@ def add_attendance(events, start, end, conditions=None):
255261
"doctype": "Attendance",
256262
"start": d.attendance_date,
257263
"end": d.attendance_date,
258-
"title": cstr(d.status),
264+
"title": f"{d.employee_name}: {cstr(d.status)}",
265+
"status": d.status,
259266
"docstatus": d.docstatus,
260267
}
261268
if e not in events:
262269
events.append(e)
263270

264271

272+
def add_holidays(events, start, end, employee=None):
273+
holidays = get_holidays_for_employee(employee, start, end)
274+
if not holidays:
275+
return
276+
277+
for holiday in holidays:
278+
events.append(
279+
{
280+
"doctype": "Holiday",
281+
"start": holiday.holiday_date,
282+
"end": holiday.holiday_date,
283+
"title": _("Holiday") + ": " + cstr(holiday.description),
284+
"name": holiday.name,
285+
"allDay": 1,
286+
}
287+
)
288+
289+
265290
def mark_attendance(
266291
employee,
267292
attendance_date,
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
// Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
22
// For license information, please see license.txt
33
frappe.views.calendar["Attendance"] = {
4+
field_map: {
5+
start: "start",
6+
end: "end",
7+
id: "name",
8+
title: "title",
9+
allDay: "allDay",
10+
color: "color",
11+
},
12+
get_css_class: function (data) {
13+
if (data.doctype === "Holiday") return "default";
14+
else if (data.doctype === "Attendance") {
15+
if (data.status === "Absent" || data.status === "On Leave") {
16+
return "danger";
17+
}
18+
if (data.status === "Half Day") return "warning";
19+
return "success";
20+
}
21+
},
422
options: {
523
header: {
6-
left: 'prev,next today',
7-
center: 'title',
8-
right: 'month'
9-
}
24+
left: "prev,next today",
25+
center: "title",
26+
right: "month",
27+
},
1028
},
11-
get_events_method: "hrms.hr.doctype.attendance.attendance.get_events"
29+
get_events_method: "hrms.hr.doctype.attendance.attendance.get_events",
1230
};

hrms/hr/doctype/compensatory_leave_request/test_compensatory_leave_request.py

+19-9
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def test_half_day_compensatory_leave(self):
132132
def test_request_on_leave_period_boundary(self):
133133
frappe.db.delete("Leave Period")
134134
create_leave_period("2023-01-01", "2023-12-31", "_Test Company")
135+
create_holiday_list("2023-01-01", "2023-12-31")
135136

136137
employee = get_employee()
137138
boundary_date = "2023-12-31"
@@ -149,9 +150,11 @@ def test_request_on_leave_period_boundary(self):
149150
reason="test",
150151
)
151152
)
153+
compensatory_leave_request.insert()
152154
self.assertRaises(frappe.ValidationError, compensatory_leave_request.submit)
153155

154-
create_leave_period("2023-01-01", "2023-12-31", "_Test Company")
156+
create_leave_period("2024-01-01", "2024-12-31", "_Test Company")
157+
compensatory_leave_request.reload()
155158
compensatory_leave_request.submit()
156159

157160

@@ -195,20 +198,27 @@ def mark_attendance(employee, date=None, status="Present"):
195198
attendance.submit()
196199

197200

198-
def create_holiday_list():
199-
if frappe.db.exists("Holiday List", "_Test Compensatory Leave"):
200-
return
201+
def create_holiday_list(from_date=None, to_date=None):
202+
list_name = "_Test Compensatory Leave"
203+
if frappe.db.exists("Holiday List", list_name):
204+
frappe.db.delete("Holiday List", list_name)
205+
frappe.db.delete("Holiday", {"parent": list_name})
206+
207+
if from_date:
208+
holiday_date = add_days(from_date, 1)
209+
else:
210+
holiday_date = today()
201211

202212
holiday_list = frappe.get_doc(
203213
{
204214
"doctype": "Holiday List",
205-
"from_date": add_months(today(), -3),
206-
"to_date": add_months(today(), 3),
215+
"from_date": from_date or add_months(today(), -3),
216+
"to_date": to_date or add_months(today(), 3),
207217
"holidays": [
208-
{"description": "Test Holiday", "holiday_date": today()},
209-
{"description": "Test Holiday 1", "holiday_date": add_days(today(), -1)},
218+
{"description": "Test Holiday", "holiday_date": holiday_date},
219+
{"description": "Test Holiday 1", "holiday_date": add_days(holiday_date, -1)},
210220
],
211-
"holiday_list_name": "_Test Compensatory Leave",
221+
"holiday_list_name": list_name,
212222
}
213223
)
214224
holiday_list.save()

hrms/hr/doctype/employee_checkin/employee_checkin.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
{
2525
"fieldname": "employee",
2626
"fieldtype": "Link",
27+
"in_standard_filter": 1,
2728
"label": "Employee",
2829
"options": "Employee",
2930
"reqd": 1,
@@ -109,7 +110,7 @@
109110
}
110111
],
111112
"links": [],
112-
"modified": "2023-05-12 14:52:22.660264",
113+
"modified": "2024-04-02 01:50:23.150627",
113114
"modified_by": "Administrator",
114115
"module": "HR",
115116
"name": "Employee Checkin",

hrms/hr/doctype/shift_assignment/shift_assignment.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
{
2424
"fieldname": "employee",
2525
"fieldtype": "Link",
26+
"in_standard_filter": 1,
2627
"label": "Employee",
2728
"options": "Employee",
2829
"reqd": 1,
@@ -47,6 +48,7 @@
4748
"fieldname": "shift_type",
4849
"fieldtype": "Link",
4950
"in_list_view": 1,
51+
"in_standard_filter": 1,
5052
"label": "Shift Type",
5153
"options": "Shift Type",
5254
"reqd": 1,
@@ -103,7 +105,7 @@
103105
],
104106
"is_submittable": 1,
105107
"links": [],
106-
"modified": "2023-06-23 12:08:23.247882",
108+
"modified": "2024-04-04 17:13:13.137431",
107109
"modified_by": "Administrator",
108110
"module": "HR",
109111
"name": "Shift Assignment",

hrms/overrides/employee_payment_entry.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def set_missing_ref_details(
3131
self,
3232
force: bool = False,
3333
update_ref_details_only_for: list | None = None,
34-
ref_exchange_rate: float | None = None,
34+
reference_exchange_details: dict | None = None,
3535
) -> None:
3636
for d in self.get("references"):
3737
if d.allocated_amount:
@@ -45,8 +45,12 @@ def set_missing_ref_details(
4545
)
4646

4747
# Only update exchange rate when the reference is Journal Entry
48-
if ref_exchange_rate and d.reference_doctype == "Journal Entry":
49-
ref_details.update({"exchange_rate": ref_exchange_rate})
48+
if (
49+
reference_exchange_details
50+
and d.reference_doctype == reference_exchange_details.reference_doctype
51+
and d.reference_name == reference_exchange_details.reference_name
52+
):
53+
ref_details.update({"exchange_rate": reference_exchange_details.exchange_rate})
5054

5155
for field, value in ref_details.items():
5256
if d.exchange_gain_loss:

0 commit comments

Comments
 (0)