Change to define unit price from timespent data instead from the user hourly rate

This commit is contained in:
Milen Karaganski 2022-12-10 21:15:00 +02:00
parent ee7e394ebf
commit 811e24fd7c

View File

@ -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));