filemaker script with overtime and calcuration

do you know how to make this script?

40 hours max per week regular work hour and if it get more, it becomes overtime.
lunch hour deduct from overtime first and if there is no overtime, deduct from regular time.
i can't figure out how to make lunch hour deduction "if script" like this case;

if overtime is 3 hour and lunch time is 4 hour, they deduct 3 hours from overtime and 1hour from regular time..

please help me.
Hiroyuki TamuraField EngineerAsked:
Who is Participating?
 
JoJohn2004Connect With a Mentor Commented:
If they are deducting as the same unit you don't have to do anything to the data. Add up the total number of hours and subtract lunch then calculate how much time is over 40 for the overtime.
0
 
JoJohn2004Commented:
I am going to assume that overtime is 1.5 times regular time so that if you work 41 hours in a week you actually get paid for 41.5 hours.  I am also going to assume that you need to calculate the number of hours that a person will be paid for before subtracting the lunch time. If this is the case you can do the following:

Create 2 number fields, HoursWorked and LunchTime

Make a Calculation field called CalcHoursWorked which results in a number:

CalcHoursWorked =
Let(
[
RegTime = If(HoursWorked>40;40;HoursWorked);
Overtime = If(HoursWorked>40;HoursWorked-40;0);
CalcTotalTime = regTime +Overtime*1.5
];
CalcTotalTime-LunchTime
)


Make 2 fields called StraightTime and OverTime which are calculations that results in numbers:

StraightTime = If(CalcHoursWorked>40;40;CalcHoursWorked)

Overtime = If(CalcHoursWorked>40;CalcHoursWorked-40;0)


If you do not have to calculate the effictive hours that a person has to be paid for before subtracting the lunch, you can just subtract the lunch from the hours worked instead of going through all these steps but I don't think that is what you were asking.
0
 
Hiroyuki TamuraField EngineerAuthor Commented:
thank you, JoJohn2004!

i have some problem;

case 1
HoursWorked: 60hours, Lunch 4 Hours

Regular 40hours, Overtime 20hours - Lunch 4 Hours = CalcOvertime 16hours

case 2
HoursWorked: 44hours, Lunch 4 Hours

Regular 40hours, Overtime 4hours - Lunch 4 Hours = CalcOvertime 0hours

case 3
HoursWorked: 43hours, Lunch 4 Hours

Regular 40hours, Overtime 3hours - Lunch 4 Hours = CalcOvertime 0hours (even -1 hours)
CalcRegular 39hours (they deduct from regular)

it's little weird but they deduct from overtime and Lunchtime same unit...
0
 
Hiroyuki TamuraField EngineerAuthor Commented:
thank u
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.