Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Biometric Attendance Sync Tool - Time Sync Issue #64

Open
KuPVC opened this issue Apr 26, 2024 · 0 comments
Open

Biometric Attendance Sync Tool - Time Sync Issue #64

KuPVC opened this issue Apr 26, 2024 · 0 comments

Comments

@KuPVC
Copy link

KuPVC commented Apr 26, 2024

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'}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant