Link to home
Start Free TrialLog in
Avatar of Hiroyuki Tamura
Hiroyuki TamuraFlag for United States of America

asked on

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.
Avatar of JoJohn2004
JoJohn2004

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.
Avatar of Hiroyuki Tamura

ASKER

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...
ASKER CERTIFIED SOLUTION
Avatar of JoJohn2004
JoJohn2004

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank u