22# License: GNU General Public License v3. See license.txt
33
44
5+ from datetime import date
6+
57import frappe
68from frappe import _
79from frappe .model .document import Document
10+ from frappe .query_builder .terms import ValueWrapper
811from frappe .utils import (
912 add_days ,
1013 cint ,
@@ -249,10 +252,11 @@ def publish_update(self):
249252
250253
251254@frappe .whitelist ()
252- def get_events (start , end , filters = None ):
255+ def get_events (start : date | str , end : date | str , filters : str | list | None = None ) -> list [ dict ] :
253256 employee = frappe .db .get_value ("Employee" , {"user_id" : frappe .session .user })
254257 if not employee :
255258 return []
259+
256260 if isinstance (filters , str ):
257261 import json
258262
@@ -270,7 +274,7 @@ def add_attendance(filters):
270274 "Attendance" ,
271275 fields = [
272276 "name" ,
273- "' Attendance' as doctype" ,
277+ ValueWrapper ( " Attendance" ). as_ ( " doctype") ,
274278 "attendance_date" ,
275279 "employee_name" ,
276280 "status" ,
@@ -279,7 +283,7 @@ def add_attendance(filters):
279283 filters = filters ,
280284 )
281285 for record in attendance :
282- record ["title" ] = f"{ record . employee_name } : { record . status } "
286+ record ["title" ] = f"{ record [ ' employee_name' ] } : { record [ ' status' ] } "
283287 return attendance
284288
285289
@@ -338,7 +342,7 @@ def mark_attendance(
338342
339343
340344@frappe .whitelist ()
341- def mark_bulk_attendance (data ):
345+ def mark_bulk_attendance (data : str | dict ):
342346 import json
343347
344348 if isinstance (data , str ):
@@ -348,11 +352,11 @@ def mark_bulk_attendance(data):
348352 frappe .throw (_ ("Please select a date." ))
349353 return
350354
351- for date in data .unmarked_days :
355+ for attendance_date in data .unmarked_days :
352356 doc_dict = {
353357 "doctype" : "Attendance" ,
354358 "employee" : data .employee ,
355- "attendance_date" : get_datetime (date ),
359+ "attendance_date" : get_datetime (attendance_date ),
356360 "status" : data .status ,
357361 "half_day_status" : "Absent" if data .status == "Half Day" else None ,
358362 "shift" : data .shift ,
0 commit comments