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

Delay OverTime Calculation for Penalty and Reward #2

Open
13 tasks
jigneshpshah opened this issue Nov 1, 2018 · 13 comments
Open
13 tasks

Delay OverTime Calculation for Penalty and Reward #2

jigneshpshah opened this issue Nov 1, 2018 · 13 comments

Comments

@jigneshpshah
Copy link
Owner

jigneshpshah commented Nov 1, 2018

  • Overall Design Diagram

  • Create Employee Checkin Doctype

  • Attendance doctype field additions

  • Shift Doctype - Fields Addition

  • Delay Penalty Rules Doctype

  • Company > Payroll Settings

  • Company > Payroll Settings > Delay and OverTime Calculation Settings

  • Delay OverTime Entry (like Payroll Entry) with Calculation Logic

  • Additional Salary Record Creation based on Delay OverTime Entry

  • Preconditions and Standard Data

  • Daily Night Scriptto convert Employee Checkin to Attendance doctype

  • Salary Component > add flag > is delay and overtime applicable

  • Department Doctype ( Add field = Overtime Multiplication Factor, field Type =float)

@jigneshpshah
Copy link
Owner Author

Employee Checkin DocType Fields

Field Type Remarks
EMPID Link Employee
RFID Data Linked with employee.rfid
InTime DateTime  
OutTime DateTime  
Duration Time HH:MM:SS Readonly , auto calculated based on in-out info
Device Tag Select
Options
CheckIn, CheckOut,BreakIn,BreakOut,OTIn,OTOut
Could be used to store few more information for the record from the device. E.g. Few device support explicit checkin, out parameter from the employee

@jigneshpshah
Copy link
Owner Author

jigneshpshah commented Nov 1, 2018

Attendance Doctype

Field Type Remarks
Employee ID Link ERPNext Employeee ID
Attendance Date Date employee.deviceemployeeid
Status Select  
Leave Type Link  
CheckIn CheckOut Section  Everything below from here are new fields
Checkin Time DateTime It will have the final check-in info for the day for the employee
Checkout Time DateTime It will have the final checkout info for the day for the employee
Duration Readonly (HH:MM:SS) Difference between checkout and checkin
Delay OverTime Info Section  
Shift Link Shift assigned for the attendance date from shift assignment doctype
Shift In Time ReadOnly Fetch From Shift, , Keeping it here to maintain information for that day
Shift Out Time ReadOnly Fetch From Shift , Keeping it here to maintain information for that day
Shift Duration ReadOnly Fetch From Shift , Keeping it for info and for delay and overtime calculation
Delay (in Mins) Int Total Delay for the day
OverTIme (in Mins) Int Total Overtime for the day
Is Review Required checkbox Default value 0

@jigneshpshah
Copy link
Owner Author

Shift Doctype

Shift In Time Out Time Ignore Delay (in Mins) Ignore Ealry Out (in Mins) Min Overtime (in Mins) Max Overtime Allowed Delay Penalty Based on Early Checkout Penalty Based on
Morning 8:00 17:00 15 15 60 120 Actual Minutes/ Delay Rules Table Actual Minutes

@jigneshpshah
Copy link
Owner Author

jigneshpshah commented Nov 1, 2018

Delay Penalty Rules DocType

Shift From Time To Time Penalty (in Mins)
Morning 8:16 9:00 60
Morning 9:01 10:00 120
Morning 10:01 11:00 180
Morning 11:01 12:00 240
Morning 12:01 17:00 300

@jigneshpshah
Copy link
Owner Author

jigneshpshah commented Nov 2, 2018

Delay OverTime Entry (like Payroll Entry)
Same Structure as that of Payroll Entry Form

Filter Criteria and based on that Get Employees

Filter Criteria
Company
Branch
Department
Designation
Shift
From Date
To Date

Field Type Remark
Series Data DOE-.YY.MM.-####
Employee Delay OverTime Child Table  
Payroll Date Date
From Date Date  
To Date Date  

Employee Delay OverTime Table

Employee RFID Tag Total Delay (in Mins) Total Delay Amount Total OverTime ( in Mins) Total OverTime Amount
E001/Ramesh 1001 20 500 60 1800

For each record in the delay and overtime table, 2 records will be created in additional salary doctype for the employee

  1. for delay ( if > 0)
  2. for overtime ( if >0)

Logical Steps to calculate Delay and OverTime (in Mins)

  1. Sum all DelayTime from Attendance Doctye for the provided From and To Date Range
  2. Sum all OverTime from Attendance Doctye for the provided From and To Date Range

To Calculate the per minute amount for OverTime and Delay

For all Employees start in Loop

  1. For each employee check if the shift duration is unique across all records in attendance doctype between the from date and to date

  2. If yes then store it in local loop variable for that employee if no need to break the records shiftwise between the said period and loop in that slice.

  3. Get the Salary Components from the assigned salary structure for the employee for which the flag (is delay and overtime applicable) is set true , sum all such components and divide it by 30 or calendar days based on Company Payroll Settings / no of working hours in the shift ( as calculated in point 1,2 )/ 60.

  4. For Overtime based on multiplication factor multiply the amount .

@jigneshpshah
Copy link
Owner Author

jigneshpshah commented Nov 2, 2018

Company > Payroll Settings (Section) > Delay and OverTime Calculation Settings (sub- section)

Delay and OverTime Settings

Calculate Per min Salary Based on
Select Options

          1. Working Days
          2. Fixed Days

if Fixed Days , Please Mention No. Of Fixed Days = 30 (Default Value)

What IF Rules
If CheckIn Found and No Checkout Record found Options : 1. Automatically update shift checkout time
-- 2. Manually correct attendance records. ( default value)
If Checkout Found and No Checkin Record found Options : 1. Automatically update shift checkin time
-- 2. Manually correct attendance records. ( default value)
  • Consider Hours on Holiday as Overtime
    checkbox , default = false

system will ignore the checkin, checkouts on non-working days / holiday.

  1. OverTime Multiplication Factor (Int)
    default value = 1

*OverTime Multiplication Factor set at department wise will have higher priority.

  • Future Priority could be in the below order ( from highest to lowest),
Level Priority
Employee 1
Designation 2
Department 3
Company 4
  • Ignore Delay and OverTime Calculation for Additional Salary
    in below order ( Highest to Lowest)
Level Priority
Employee 1
Company 2

@jigneshpshah
Copy link
Owner Author

jigneshpshah commented Nov 2, 2018

Biometric ERPNext Integration Attendance Design

flexhr design

@jigneshpshah
Copy link
Owner Author

jigneshpshah commented Nov 2, 2018

Daily Night Script , maintain Log for the same
will run at 11 pm daily.

Field Type Remark
Processing Date Date
Status Select Error , Success
Employees Processed int count of the employees processed
Error Log Code Detailed Error Log

Employee Attendance Script

Logic

  1. Check if it is holiday for today for the employee, Ignore records of Employee-checkin. Don't create any relevant records in attendance doctype.

  2. if it is working day (non-holiday) , check if already attendance record exist for employee, then mark that employee for Review Flag in Attendance Doctype Record.

  3. If it is working day , check if multiple records exist for an employee, fetch minimum - checkin and maximum checkout , and difference as duration.

  4. if the min checkin is less than the shift in time, calculate delay through function
    ( * can define a function which takes arguments shift , checkin-time and returns delay based on the rules applicable for that shift )

  5. if max checkout time is greater than the shift out time, calculate overtime through function
    ( * can define a function which takes arguments shift , checkout-time and returns overtime based on the rules applicable for that shift )

At the End, Send Script Run Report .

@jigneshpshah
Copy link
Owner Author

jigneshpshah commented Nov 2, 2018

Precondition
required if delay and overtime calculation need

  1. Holiday List should be present and assigned to each company
  2. Employee needs to have salary structure.

Standards Data (not to delete)

Salary Components
1. Delay
2. OverTime

@ashish-greycube
Copy link
Collaborator

ashish-greycube commented Nov 13, 2018

Employee Checkin DocType Fields

Field Type Remarks
EMPID Link Employee
RFID Data Linked with employee.rfid
InTime DateTime  
OutTime DateTime  
Duration Time HH:MM:SS Readonly , auto calculated based on in-out info
Device Tag Select
Options
CheckIn, CheckOut,BreakIn,BreakOut,OTIn,OTOut Could be used to store few more information for the record from the device. E.g. Few device support explicit checkin, out parameter from the employee

Do we require company field here?
No. Since in Employee Doctype company field is already there.

@ashish-greycube
Copy link
Collaborator

ashish-greycube commented Nov 13, 2018

Attendance Doctype

Field Type Remarks
Employee ID Link ERPNext Employeee ID
Attendance Date Date employee.deviceemployeeid
Status Select  
Leave Type Link  
CheckIn CheckOut Section  
Checkin Time DateTime It will have the final check-in info for the day for the employee
Checkout Time DateTime It will have the final checkout info for the day for the employee
Duration Readonly (HH:MM:SS) Difference between checkout and checkin
Delay OverTime Info Section  
Shift Link Shift assigned for the attendance date from shift assignment doctype
Shift In Time ReadOnly Fetch From Shift, , Keeping it here to maintain information for that day
Shift Out Time ReadOnly Fetch From Shift , Keeping it here to maintain information for that day
Shift Duration ReadOnly Fetch From Shift , Keeping it for info and for delay and overtime calculation
Delay (in Mins) Int Total Delay for the day
OverTIme (in Mins) Int Total Overtime for the day

Indicate which are new fields?
CheckIn CheckOut | Section |  Everything below from here are new fields , Updated in the original comment.

@ashish-greycube
Copy link
Collaborator

ashish-greycube commented Nov 13, 2018

Delay Penalty Rules DocType

Shift From Time To Time Penalty (in Mins)
Morning 8:16 9:00 60
Morning 9:01 10:00 120
Morning 10:01 11:00 180
Morning 11:01 12:00 240
Morning 12:01 17:00 300

If delay is more than say 3 hours (in 8 hour shift) do you want to call it half-day?
No. Penalty based on Delay Penalty Rules. ( Not Half Day).

@ashish-greycube
Copy link
Collaborator

Do we require company field here?
No. Since in Employee Doctype company field is already there.

ESSO had company field not sure why? https://raw.githubusercontent.com/creamdory/erpnext/c1971a3ffa5aa9c816c6e50ffbf56dd95c032fa9/erpnext/hr/doctype/employee_checkin/employee_checkin.json

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

2 participants