$lastLine->fetch($lastLine->id); if (!empty($conf->global->ARRONDITOTAL_B2B)) { $tx_tva = 1; } else { $tx_tva = 1 + $lastLine->tva_tx / 100; } $diff_compta = $newTotal - $object->{$field_total}; // diff entre le total voulu et le nouveau total calculé (décalage de centimes) $diff_compta = $diff_compta / $lastLine->qty; // diff à diviser par la qty car on doit obtenir au final un prix unitaire $pu = $lastLine->subprice * $tx_tva; // calcul du ttc unitaire $pu = $pu + $diff_compta; $pu = $pu / $tx_tva; // calcul du nouvel ht unitaire _updateLine($object, $lastLine, $pu); $outputlangs =& _getOutPutLangs($object); $object->generateDocument('', $outputlangs); } else { setEventMessages($langs->trans('arronditotalErrorNoLine'), null, 'errors'); } function _exitOrNot(&$object, $className) { if ($object->statut != $className::STATUS_DRAFT) { setEventMessages($langs->trans('arronditotalErrorObjectNotDraft'), null, 'errors'); exit; } if ($object->element == 'facture') { if ($object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_SITUATION) { setEventMessages($langs->trans('arronditotalErrorTypeInvoice'), null, 'errors'); exit;
<?php require '../config.php'; dol_include_once('/comm/propal/class/propal.class.php'); dol_include_once('/compta/facture/class/facture.class.php'); dol_include_once('/commande/class/commande.class.php'); $put = GETPOST('put'); switch ($put) { case 'price': $Tab = _updateLine(GETPOST('objectid'), GETPOST('objectelement'), GETPOST('lineid'), GETPOST('column'), GETPOST('value')); __out($Tab, 'json'); break; } function _updateLine($objectid, $objectelement, $lineid, $column, $value) { global $db, $conf, $langs; ${$column} = price2num($value); $Tab = array(); $o = new $objectelement($db); $o->fetch($objectid); $find = false; foreach ($o->lines as &$line) { if ($line->id == $lineid || $line->rowid == $lineid) { $find = true; break; } } if ($find) { if (is_null($qty)) { $qty = $line->qty; }