Prevent exceed the max allowed working time.

When the user overload the balance, the script was eventually
exceeding the max allowed working time in some days.

The min_worked_time must be calculated regarding the average
worked time, instead of being a fixed value.