fix: Mark attendance from employee attendance tool (#19627)
This commit is contained in:
		
							parent
							
								
									6a743be1de
								
							
						
					
					
						commit
						1a92eb14ed
					
				| @ -6,6 +6,7 @@ from __future__ import unicode_literals | ||||
| import frappe | ||||
| import json | ||||
| from frappe.model.document import Document | ||||
| from frappe.utils import getdate | ||||
| 
 | ||||
| 
 | ||||
| class EmployeeAttendanceTool(Document): | ||||
| @ -43,17 +44,26 @@ def get_employees(date, department = None, branch = None, company = None): | ||||
| 
 | ||||
| @frappe.whitelist() | ||||
| def mark_employee_attendance(employee_list, status, date, leave_type=None, company=None): | ||||
| 
 | ||||
| 	employee_list = json.loads(employee_list) | ||||
| 	for employee in employee_list: | ||||
| 		attendance = frappe.new_doc("Attendance") | ||||
| 		attendance.employee = employee['employee'] | ||||
| 		attendance.employee_name = employee['employee_name'] | ||||
| 		attendance.attendance_date = date | ||||
| 		attendance.status = status | ||||
| 
 | ||||
| 		if status == "On Leave" and leave_type: | ||||
| 			attendance.leave_type = leave_type | ||||
| 		if company: | ||||
| 			attendance.company = company | ||||
| 			leave_type = leave_type | ||||
| 		else: | ||||
| 			attendance.company = frappe.db.get_value("Employee", employee['employee'], "Company") | ||||
| 			leave_type = None | ||||
| 
 | ||||
| 		if not company: | ||||
| 			company = frappe.db.get_value("Employee", employee['employee'], "Company") | ||||
| 
 | ||||
| 		attendance=frappe.get_doc(dict( | ||||
| 			doctype='Attendance', | ||||
| 			employee=employee.get('employee'), | ||||
| 			employee_name=employee.get('employee_name'), | ||||
| 			attendance_date=getdate(date), | ||||
| 			status=status, | ||||
| 			leave_type=leave_type, | ||||
| 			company=company | ||||
| 		)) | ||||
| 		attendance.insert() | ||||
| 		attendance.submit() | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user