Skip to content

Commit

Permalink
feat - Check if similar checkin already recorded
Browse files Browse the repository at this point in the history
  • Loading branch information
maniamartial committed Jul 25, 2024
1 parent c911215 commit 6ed3617
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions navari_cams_biometric/cams_biometric/controllers/cams_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,25 @@ def handle_attendance_log(stgid, rawdata):
log_time_dt = parser.parse(log_time)
formatted_log_time = log_time_dt.strftime("%Y-%m-%d %H:%M:%S")

# Storing the values in Employee Checking doctype
employee_checking = frappe.get_doc({
"doctype": "Employee Checkin",
# Check if the employee check-in already exists
existing_checkin = frappe.db.exists("Employee Checkin", {
"employee": request_data["RealTime"]["PunchLog"]["UserId"],
"time": formatted_log_time,
"log_type": log_type,
"custom_input_type":request_data["RealTime"]["PunchLog"]["InputType"]
"log_type": log_type
})

employee_checking.insert(ignore_permissions=True)
frappe.db.commit()
if not existing_checkin:
# Storing the values in Employee Checking doctype
employee_checking = frappe.get_doc({
"doctype": "Employee Checkin",
"employee": request_data["RealTime"]["PunchLog"]["UserId"],
"time": formatted_log_time,
"log_type": log_type,
"custom_input_type": request_data["RealTime"]["PunchLog"]["InputType"]
})

employee_checking.insert(ignore_permissions=True)
frappe.db.commit()

return "done"

Expand Down

0 comments on commit 6ed3617

Please sign in to comment.