Merge pull request #23159 from milenmk/v16-Wrong-invoice-amount-when-billing-Project-task-spent-time

FIX|Fix [#23075]
This commit is contained in:
Laurent Destailleur 2022-12-14 01:57:53 +01:00 committed by GitHub
commit 402ff37465
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -462,17 +462,22 @@ 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
$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));