fix: Mark attendance from employee attendance tool (#19627)

diff --git a/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.py b/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.py
index 32fcee1..16c1a32 100644
--- a/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.py
+++ b/erpnext/hr/doctype/employee_attendance_tool/employee_attendance_tool.py
@@ -6,6 +6,7 @@
 import frappe
 import json
 from frappe.model.document import Document
+from frappe.utils import getdate
 
 
 class EmployeeAttendanceTool(Document):
@@ -43,17 +44,26 @@
 
 @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()