- $sql = "select $group_field as group_field, sum(time_to_sec(l.duration)) as time, null as expenses from tt_log l
- $group_join $where group by $group_field";
+ $sql = "select $group_field as group_field, sum(time_to_sec(l.duration)) as time,
+ sum(if(l.billable = 0 or time_to_sec(l.duration)/60 < $user->first_unit_threshold, 0, ceil(time_to_sec(l.duration)/60/$user->minutes_in_unit))) as units,
+ null as expenses from tt_log l
+ $group_join $where group by $group_field";