Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Rounding total price goes wrong #733

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions extensions/ki_export/private_func.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function export_get_data($start, $end, $users = null, $customers = null, $projec
$arr['time_out'] = $timeSheetEntries[$timeSheetEntries_index]['end'];
$arr['duration'] = $timeSheetEntries[$timeSheetEntries_index]['duration'];
$arr['formattedDuration'] = $timeSheetEntries[$timeSheetEntries_index]['formattedDuration'];
$arr['decimalDuration'] = sprintf("%01.2f", $timeSheetEntries[$timeSheetEntries_index]['duration'] / 3600);
$arr['decimalDuration'] = sprintf("%01.2f", round($timeSheetEntries[$timeSheetEntries_index]['duration'] / 3600, 2));
$arr['rate'] = $timeSheetEntries[$timeSheetEntries_index]['rate'];
$arr['wage'] = $timeSheetEntries[$timeSheetEntries_index]['wage'];
$arr['wage_decimal'] = $timeSheetEntries[$timeSheetEntries_index]['wage_decimal'];
Expand Down Expand Up @@ -197,7 +197,7 @@ function export_get_data($start, $end, $users = null, $customers = null, $projec
$arr['time_out'] = $timeSheetEntries[$timeSheetEntries_index]['end'];
$arr['duration'] = $timeSheetEntries[$timeSheetEntries_index]['duration'];
$arr['formattedDuration'] = $timeSheetEntries[$timeSheetEntries_index]['formattedDuration'];
$arr['decimalDuration'] = sprintf("%01.2f", $timeSheetEntries[$timeSheetEntries_index]['duration'] / 3600);
$arr['decimalDuration'] = sprintf("%01.2f", round($timeSheetEntries[$timeSheetEntries_index]['duration'] / 3600, 2));
$arr['rate'] = $timeSheetEntries[$timeSheetEntries_index]['rate'];
$arr['wage'] = $timeSheetEntries[$timeSheetEntries_index]['wage'];
$arr['wage_decimal'] = $timeSheetEntries[$timeSheetEntries_index]['wage_decimal'];
Expand Down
14 changes: 7 additions & 7 deletions libraries/Kimai/Database/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -2753,8 +2753,8 @@ public function get_timeSheet($start, $end, $users = null, $customers = null, $p
// only calculate time after recording is complete
$arr[$i]['duration'] = $arr[$i]['end'] - $arr[$i]['start'];
$arr[$i]['formattedDuration'] = Kimai_Format::formatDuration($arr[$i]['duration']);
$arr[$i]['wage_decimal'] = $arr[$i]['duration'] / 3600 * $row->rate;

$arr[$i]['wage_decimal'] = round($arr[$i]['duration'] / 3600, 2) * $row->rate;
$fixedRate = (double)$row->fixedRate;
if ($fixedRate) {
$arr[$i]['wage'] = sprintf("%01.2f", $fixedRate);
Expand Down Expand Up @@ -4044,7 +4044,7 @@ public function get_time_users($start, $end, $users = null, $customers = null, $
$whereClauses[] = "start < $end";
}

$query = "SELECT start, end, userID, (end - start) / 3600 * rate AS costs, fixedRate
$query = "SELECT start, end, userID, ROUND((end - start) / 3600, 2) * rate AS costs, fixedRate
FROM ${p}timeSheet
JOIN ${p}projects USING(projectID)
JOIN ${p}customers USING(customerID)
Expand Down Expand Up @@ -4133,8 +4133,8 @@ public function get_time_customers($start, $end, $users = null, $customers = nul
if ($end) {
$whereClauses[] = "start < $end";
}

$query = "SELECT start, end, customerID, (end - start) / 3600 * rate AS costs, fixedRate
$query = "SELECT start, end, customerID, ROUND((end - start) / 3600, 2) * rate AS costs, fixedRate
FROM ${p}timeSheet
LEFT JOIN ${p}projects USING(projectID)
LEFT JOIN ${p}customers USING(customerID) " .
Expand Down Expand Up @@ -4220,7 +4220,7 @@ public function get_time_projects($start, $end, $users = null, $customers = null
$whereClauses[] = "start < $end";
}

$query = "SELECT start, end, projectID, (end - start) / 3600 * rate AS costs, fixedRate
$query = "SELECT start, end, projectID, ROUND((end - start) / 3600, 2) * rate AS costs, fixedRate
FROM ${p}timeSheet
LEFT JOIN ${p}projects USING(projectID)
LEFT JOIN ${p}customers USING(customerID) " .
Expand Down Expand Up @@ -4305,7 +4305,7 @@ public function get_time_activities($start, $end, $users = null, $customers = nu
$whereClauses[] = "start < $end";
}

$query = "SELECT start, end, activityID, (end - start) / 3600 * rate AS costs, fixedRate
$query = "SELECT start, end, activityID, ROUND((end - start) / 3600, 2) * rate AS costs, fixedRate
FROM ${p}timeSheet
LEFT JOIN ${p}activities USING(activityID)
LEFT JOIN ${p}projects USING(projectID)
Expand Down