Transfer Punch Calculation Error

General support regarding TimeTrex, such as
configuring policies/taxes or processing payroll.
Locked
blabj
Posts: 70
Joined: Wed Dec 26, 2007 5:09 pm

Transfer Punch Calculation Error

Post by blabj »

OK, I have an afternoon shift (4:00pm - 12:30am) employee with an in and out punch (at 4pm and 12:30am) with 0:30 lunch deduction.. so 8:00 hours regular time.

He switched departments after 1.5 hours, so I have to add a department transfer punch at 5:30pm.

Unfortunately TimeTrex does not allow a simple transfer punch on the edit/add punch screen, AND it does not allow a punch between an IN/OUT pair.

So, the only way I could do this, was to delete the 12:30am OUT punch, insert a 5:30pm OUT punch, insert a 5:30pm IN punch (with new department) and then insert a 12:30am OUT punch. Quite painfull!

But more importantly, the calculations of time split between departments is messed up. It calculates 01:35 for one department and 06:24 for the other department, instead of 01:30 and 06:30.

I disabled rounding on those punches but it doesn't change the calculations.

This is on 2.2.15.

-Bob
shaunw
Posts: 7839
Joined: Tue Sep 19, 2006 2:22 pm

Post by shaunw »

I was unable to replicate this on our end, TimeTrex calculated:

Department #1: 1:24
Department #2: 6:35
(did you perhaps mix up the minutes when you wrote your post?)

How do you calculate 1:30 and 6:30 for each department?

I'm assuming a 30min auto-deduct lunch, so TimeTrex sees this as:

Department #1: 1:30
Department #2: 7:00
Total: 8:30hrs

Now TimeTrex has to deduct 30 minutes from the entire day...

So what it does is use a percentage calculation formula to determine how much time to deduct from each department.

Department #1 was approx. 17% of the entire days time, so 17% of 30minute auto-deduct time is approx 5mins. So TimeTrex deducts 5mins from the first department, and the remaining 25mins from the second department.

Since the unit format of HH:MM does not show seconds, it won't always add up to the proper total due to the seconds column missing, but TimeTrex does all calculations to the nearest second in the backend.

If you don't want TimeTrex to split up the lunch time between departments like this, you can't use auto-deduct policies, employees must punch in/out for lunch themselves.
blabj
Posts: 70
Joined: Wed Dec 26, 2007 5:09 pm

Post by blabj »

Department #1: 1:24
Department #2: 6:35
(did you perhaps mix up the minutes when you wrote your post?)
Yes - I was going from my memory, so yes I think you are correct and this is what it did.
How do you calculate 1:30 and 6:30 for each department?
Well, no one switches department in the middle of lunch, so whatever department is "in effect" 4 hours into the shift, gets the lunch deduction.

Essentially, logic which states department with most hours gets deduction should work. I'll look at making this mod.

Thanks again for your help,

-Bob
shaunw
Posts: 7839
Joined: Tue Sep 19, 2006 2:22 pm

Post by shaunw »

In a generic sense its not an easy problem to solve. Anyway you look at it, there has to be logic in place to deduct the lunch from multiple departments.

An employee may not transfer departments during lunch, but there are many scenarios where the department with the most time doesn't have enough time to account for a lunch deduction.

Furthermore it may not be ideal to have 35mins being the longest time spent in a department, to have it drop down to 5minutes due to the lunch deduction.

This may not be a common occurrence for you, but it can happen, and if it does obviously TimeTrex needs to take it into consideration, otherwise a lot of accounting can be incorrect which would affect much more then just a single punch/day too.

Based off previous posts, it appears that you have made several customizations to TimeTrex, I recommend if at all possible that you consider contributing them back, if not for other companies that use TimeTrex but to ease the burden on upgrading for yourself.
blabj
Posts: 70
Joined: Wed Dec 26, 2007 5:09 pm

Post by blabj »

Likely the best fix would be a meal policy flag "department allocation", which would have values "average" or "most time" or something like that.

Of course I am happy to contribute anything back.. the one major piece I did was validated custom fields which I posted here:
http://forums.timetrex.com/viewtopic.php?t=634

All other mods I'm working on are incomplete atm, but will certainly pass along.

-Bob
blabj
Posts: 70
Joined: Wed Dec 26, 2007 5:09 pm

Post by blabj »

Here is the patch I'm using to only deduct the meal from the largest chunk of department time.

Again Ideal patch would be a flag to meal policy to drive the logic, but I don't have the time atm.

-Bob

Code: Select all

--- classes/modules/core/UserDateTotalFactory.class.php (revision 694)
+++ classes/modules/core/UserDateTotalFactory.class.php (working copy)
@@ -2484,6 +2484,7 @@
                Debug::text('Meal Policy Time: '. $meal_policy_time, __FILE__, __LINE__, __METHOD__, 10);

                $day_total_time = 0;
+               $largest_time = 0;
                $retarr = array();

                $udtlf = new UserDateTotalListFactory();
@@ -2491,7 +2492,10 @@
                if ( $udtlf->getRecordCount() > 0 ) {
                        foreach( $udtlf as $udt_obj ) {
                                $udt_arr[$udt_obj->getId()] = $udt_obj->getTotalTime();
-
+                               if ( $udt_arr[$udt_obj->getId()] > $largest_time) {
+                                       $largest_time_id = $udt_obj->getId();
+                                       $largest_time = $udt_arr[$largest_time_id];
+                               }
                                $day_total_time = bcadd($day_total_time, $udt_obj->getTotalTime() );
                        }
                        Debug::text('Day Total Time: '. $day_total_time, __FILE__, __LINE__, __METHOD__, 10);
@@ -2499,7 +2503,8 @@
                        if ( is_array($udt_arr) ) {
                                $remainder = 0;
                                foreach( $udt_arr as $udt_id => $total_time ) {
-                                       $udt_raw_meal_policy_time = bcmul( bcdiv( $total_time, $day_total_time ), $meal_policy_time );
+                                       //$udt_raw_meal_policy_time = bcmul( bcdiv( $total_time, $day_total_time ), $meal_policy_time );
+                                       $udt_raw_meal_policy_time = 0;
                                        if ( $meal_policy_time > 0 ) {
                                                $rounded_udt_raw_meal_policy_time = floor($udt_raw_meal_policy_time);
                                                $remainder = bcadd( $remainder, bcsub( $udt_raw_meal_policy_time, $rounded_udt_raw_meal_policy_time ) );
@@ -2518,7 +2523,8 @@
                                } else {
                                        $remainder = floor( $remainder );
                                }
-                               $retarr[$udt_id] = (int)bcadd($retarr[$udt_id], $remainder);
+                               //$retarr[$udt_id] = (int)bcadd($retarr[$udt_id], $remainder);
+                               $retarr[$largest_time_id] = (int)bcadd($retarr[$largest_time_id], $meal_policy_time);
                        }
                } else {
                        Debug::text('No UserDateTotal rows...', __FILE__, __LINE__, __METHOD__, 10);
Locked