frappe / biometric-attendance-sync-tool

A simple tool for syncing Biometric Attendance data with your ERPNext server
GNU General Public License v3.0
182 stars 207 forks source link

Biometric Attendance Sync Tool - Time Sync Issue #64

Open KuPVC opened 5 months ago

KuPVC commented 5 months ago

I am trying to use the Biometric Attendance Sync Tool (https://github.com/frappe/biometric-attendance-sync-tool) to synchronize attendance data from a local machine to ERPNext hosted on Frappe Cloud. The synchronization process is working, and all data is being posted successfully except for the time field.

The issue I am facing is that the time from the biometric device is not being fetched correctly. Instead, the current time (local machine time) is being used for the time field in ERPNext. I have checked the tool's configuration and ensured that the time zone settings are correct.

Has anyone encountered a similar issue? Is there a way to ensure that the time from the biometric device is accurately synced with ERPNext? Any guidance or suggestions would be greatly appreciated.

Thank you in advance for your help!

I tried a custom script to check the same and please find the details below.

import requests import json

Enter your ERPNext API credentials and URL

ERPNEXT_API_KEY = 'your_api_key' ERPNEXT_API_SECRET = 'your_api_secret' ERPNEXT_URL = 'your_erpnext_url'

Data to send to ERPNext

data = { 'employee_field_value': '20018', 'timestamp': '2024-04-25 17:04:34', 'device_id': 'deskdevice', 'log_type': 'IN' }

ERPNext endpoint and headers

endpoint = f"{ERPNEXT_URL}/api/method/hrms.hr.doctype.employee_checkin.employee_checkin.add_log_based_on_employee_field" headers = { 'Authorization': f"token {ERPNEXT_API_KEY}:{ERPNEXT_API_SECRET}", 'Accept': 'application/json', 'Content-Type': 'application/json' }

Send a POST request to ERPNext with the data

response = requests.post(endpoint, headers=headers, json=data)

Check the response status code and print the result

if response.status_code == 200: print("Data sent successfully!") print(response.json()) else: print("Failed to send data to ERPNext.") print(response.text)

-----------------------------------------------------------

python3 test.py

Data sent successfully! {'message': {'name': 'EMP-CKIN-04-2024-000009', 'owner': 'email id masked', 'creation': '2024-04-26 15:43:51.149027', 'modified': '2024-04-26 15:43:51.149027', 'modified_by': 'email id masked', 'docstatus': 0, 'idx': 0, 'employee': 'IDH-0001', 'employee_name': 'Employee', 'log_type': 'IN', 'shift': 'Office Shift', 'time': '2024-04-26 15:43:51.153962', 'device_id': 'deskdevice', 'skip_auto_attendance': 0, 'shift_start': '2024-04-26 08:00:00', 'shift_end': '2024-04-26 17:00:00', 'shift_actual_start': '2024-04-26 06:00:00', 'shift_actual_end': '2024-04-27 00:00:00', 'doctype': 'Employee Checkin'}}

tmcbabu commented 1 day ago

Is this problem resolved? What was the reason? I am also facing same issue.

Tahir Mahmood