Earnings Formula for Basic + Overtime - Lunch

Hello,

We have our security clock-in and clock-out our employees which we use to enter hours for that day, and then total_hours for the week on a timesheet. Currently I use a excel formula to break out Basic, Overtime, and Lunch, but do not know how to program that into the earnings formula in the Salary Structure.

Excel Formula:
((IF(total_hours<=48,total_hours,48))*hour_rate)+((IF((total_hours-48)>=0,total_hours-48,0))hour_rate1.5)-((ROUNDDOWN((total_hours/8),0)*hour_rate)

It has three components:

Basic:
((IF(total_hours<=48,total_hours,48))*hour_rate)

Overtime:
((IF((total_hours-48)>=0,total_hours-48,0))hour_rate1.5)

Lunch:
((ROUNDDOWN((total_hours/8),0)*hour_rate)

Thanks,
Steve

1 Like

I keep getting the following errors when I try to use form names in the earnings formula:

Name error: name ‘total_hours’ is not defined

Does the earnings formula not recognize form names?

in the Salary Structure, you can only define “base” and abbreviation of other salary component in the formula.

https://frappe.github.io/erpnext/user/manual/en/human-resources/salary-and-payroll

1 Like