From ee7e394ebf8a2b0d68fcf4785746e826822b20e3 Mon Sep 17 00:00:00 2001 From: Milen Karaganski Date: Thu, 8 Dec 2022 20:22:41 +0200 Subject: [PATCH 1/2] FIX|Fix [#23075] Wrong invoice unit price when billing Project task spent time --- htdocs/projet/tasks/time.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index cf2de5bef28..888bd4fb50b 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -462,7 +462,7 @@ if ($action == 'confirm_generateinvoice') { foreach ($arrayoftasks as $userid => $value) { $fuser->fetch($userid); - //$pu_ht = $value['timespent'] * $fuser->thm; + $pu_ht = $fuser->thm; $username = $fuser->getFullName($langs); // Define qty per hour From 811e24fd7c9fdb2fdaba3de42b7391dd7cab54e8 Mon Sep 17 00:00:00 2001 From: Milen Karaganski Date: Sat, 10 Dec 2022 21:15:00 +0200 Subject: [PATCH 2/2] Change to define unit price from timespent data instead from the user hourly rate --- htdocs/projet/tasks/time.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 888bd4fb50b..debfb427111 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -469,10 +469,15 @@ if ($action == 'confirm_generateinvoice') { $qtyhour = $value['timespent'] / 3600; $qtyhourtext = convertSecondToTime($value['timespent'], 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); + /* // If no unit price known if (empty($pu_ht)) { $pu_ht = price2num($value['totalvaluetodivideby3600'] / 3600, 'MU'); } + */ + + //Unit price + $pu_ht = price2num(($value['totalvaluetodivideby3600'] / $value['timespent']), 'MU'); // Add lines $lineid = $tmpinvoice->addline($langs->trans("TimeSpentForInvoice", $username).' : '.$qtyhourtext, $pu_ht, round($qtyhour / $prodDurationHours, 2), $txtva, $localtax1, $localtax2, ($idprod > 0 ? $idprod : 0));