We want to create a hardware device which allows employees to punch in and out of work using a RFID reader which stores the information in ERPNext.
Most of our users are not salaried but get paid by the hour. Currently the information about work times is recorded outside of ERPNext using a RFID tracker that writes to a SQL database and has closed source software for the analytics.
We will create a hardware device which will read an RFID tag and allow our employees to punch in an out which will call our ERPNext API. All data will be stored in ERPNext. The project itself will be completely open source so people can DIY or they might eventually be able to buy pre-fabricated devices with RFID chips from us if there is enough interest in this thing.
The prototype hardware will consist of an Arduino Uno, a simple display and 3 buttons (come, go, info), a buzzer and a Mifare RFID reader (RC522).
Basic function description:
User presents RFID-tag to device and presses green “come” button. Device calls ERPNext API passing the RFID tag id. ERPNext logs come and returns employee name, employee number, start date, start time.
User works his shift
When user goes into break or leaves work he presses the red “go” button. Device calls ERPNext API passing the RFID tag ID. ERPNext logs go and returns employee name, employee number, start date, start time, work time.
If user wants to know how many hours he has worked this month he can press the grey “info” button. It will give him his hours today and his ours this month.
- We will develop the hardware, create BOM and schematics on how to assemble this
- The devices’ software will have to be written
- Make changes to ERPNext employee DocType to store RFID Tag
- Create or modify DocType to store information (see Questions below)
- Implement API
How will we store the actual time logs start / stop and how will we analyze it? There are timesheets which are more to track specific actions instead of overall work time. Also there is employee attendance but that tracks only the days which employees were present.
@rmehta do you have an opinion on how we would save the time logs for the employees?
we have a similar topic, where we have extended the attendence module to not only cover present on a day or not, but actual working hours; also using a sign in/out. Maybe this would be the way to go in your case as well… (actual time tracking is done on timesheet, but not all time present is actually done in projects)
I did same for biomatrix
using attendance doctype add one child table for time logs in attendance doctype and add one custom field for total hours.
make three api’s
1)For In Punch:
when employee come and punch in then one entry add in time logs for IN.
2)For Out Punch:
when employee punch for out then update child table row that have last In punch and calculate OutTime-InTime=Total Hours
(Total Hours is update only when out punched)
3)For Total Hours Today&Month:
pass date today and make api which give today total hours from “total_hours” field and current month “total hours” sum of “total_hours” field from all document of current month.
Hardware progress update
Working first prototype with Arduino Uno, LCD Display, RFID RC5522 Kit and a few resistors and buttons. It currently waits for the start button (left) or stop button (right), then gives the user 3 seconds to present the RFID tag. If tag presented it reads it.
Next step will be API calls to ERPNext to get the employee info for the tag and to make start and stop calls. I will also add a buzzer to give an audible signal on button press and RFID tag read.
@rmehta @lasalesi @Maheshwari_Bhavesh thank you for your feedback. We will start our PR tomorrow.
- Add field „RFID Tag“ (Data) to Employee
- Add childtable „Attendance Times“ to Attendance with fields (Start Time, Stop Time, Duration)
- Add „Attendance Duration“ to Attendance as summarized field for that day.
When employee punches in add a row to the child table.
When Employee punches out add to the latest start and calculate duration in minutes.
Add API functions
Only works if employee not currently punched in, otherwise return error.
- status „OK“
- employee_name „John Doe“
- startdate „2018-08-01“
- timezone „…“
- starttime „17:14“
Only works if employee currently punched in, otherwise return error. Only works if start and end timezone the same.
- status „OK“
- employee_name „John Doe“
- stopdate „2018-08-01“
- stoptime „18:14“
- timezone „…“
- duration_min „60“
- If employee punches in, automatically create Attendance for that day
- If employee works over midnight, automatically create proper records for first and second day
- Consider employee timezone (don’t log server but employee timezone)
- API needs a dedicated API user that can be set in the Arduino
This is a preliminary space usage sketch of how an integrated hardware could look like:
Hi All, here are a few notes from our testing and our design suggestion:
In the current design in ERPNext, here is how we should do it.
- We have to setup “Salary Structure” to set per Hour rate of hourly employees.
- When employee Punches IN first for the day, it will create “Timesheet” record with first line Item. It will put entry in “From Time”, leaving the “To Time” empty. When it punches “Go” then it will log the “To Time” of the first line. We will create multiple lines in one timesheet basing from how many times the employee time in and out.
- For the Info Button, it will just calculate the tentative time for the day and the summation of all submitted timesheet in the current month.
- at the end of the month or at the end of a salary cycle, accounting personnel can create Salary Slip basing from all the timesheet it created and calculate total amount from the Salary Structure set rate
- As for the current “Attendance” doctype in ERPNext, it will only log if employee is present or not regardless of the time it consumed. So once a timesheet is submitted by end of shift, it will create an entry to Attendance tagging employee as present.
This is okay but there are concerns that we need to raise:
- If the attendance time is track in Timesheet and the employee tracks an Activity within his attendance duration, then this is a duplicate.
- Timesheet can be manipulated unless restricted through permission.
Any thoughts on these concerns?
Tagging @nabinhait @rmehta
Hardware progress update
First preliminary 3D model of PCB for component placing.
Thanks for your great write up @dominik
Great to see your thinking behind your requirements and ongoing realisation of it
The hardware is designed, circuit boards and all components have been purchased for 10 prototypes and will arrive here on Thursday.
We are also designing and 3D prining the casing as we speak.
I expect the boards to be finished this Friday.
We are now writing the firmware for the embedded system in C++.
What’s needed now is the ERPNext side of things. I would really appreciate some input and ideas on how to do it right. We need to get this going.
If anyone is interested in a device please write me an email. I would give away 5 of the first boards for manufacturing cost so we can test it and optimize it together.
This is awesome @dominik, @creamdory
Attendance: Maybe we can have a new doctype called “Employee Checkin” (Employee, Location, Timestamp) that can log an employee at a location multiple times. At the end of the day we can run a scheduled script to mark in-time and out-time in Attendance (min and max)
Hourly Payroll: I like @creamdory’s idea to a weekly or monthly timesheet from checkins (with each shift in the line item) and link it to payroll. So before going to payroll there, someone can verify the total hours etc. This can automatically be created from the checkins.
I think @Pawan may have some ideas here!
Thank you for your feedback @rmehta
I think the timesheets (what billable or non billable thing did they do specifically) and the attendance (when were thy present) are two things. I also think that it should maybe go the other way that we pay per attendance and a time sheet could create attendance.
Instead of employee checkin what about attendance log?
@creamdory and @Pawan could you two connect and make a proposal that we can implement?
@Pawan thanks for your thoughts. So here is my assessment and suggested Design.
- Create new child doctype in Attendance called
Attendance Log. This is the doctype Rushabh is referring to “Employee Checkin”. Fields will be:
- Time In
- Time Out
In HR Setting > Payroll Section, add field “Salary Slip Based On” with select options “Timesheet” and “Attendance Log”.
Max working hours against Timesheet will show only for “Timesheet”.
Salary Structure, add checkbox “Salary Slip Based on Attendance Log”. We can have this auto populated based on the HR setting.
Add new Doctype
Attendance Log Validate. It will have the fields below:
- Employee Link
- Date From
- Date To
- Table which will be autopopulated with all the attendance logs base on the date duration.
User will be allowed to edit this for Salary Slip purposes. This will be the information pulled in the Salary Slip for payment.
- Edit script for these changes.
If this is okay, we can proceed with the development.