diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index ededeab44a1f8dd8ccd4933b5e8c4290796701ed..316c589f0461bdf4491e835d45e79f34879f3d81 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -798,7 +798,8 @@ else if ($action == 'add' && $user->rights->facture->creer) $object->fetch_thirdparty(); // If creation from another object of another module (Example: origin=propal, originid=1) - if ($_POST['origin'] && $_POST['originid']) { + if ($_POST['origin'] && $_POST['originid']) + { // Parse element/subelement (ex: project_task) $element = $subelement = $_POST['origin']; if (preg_match('/^([^_]+)_([^_]+)/i', $_POST['origin'], $regs)) { @@ -835,15 +836,20 @@ else if ($action == 'add' && $user->rights->facture->creer) $id = $object->create($user); - if ($id > 0) { + if ($id > 0) + { // If deposit invoice - if ($_POST['type'] == 3) { + if ($_POST['type'] == 3) + { $typeamount = GETPOST('typedeposit', 'alpha'); $valuedeposit = GETPOST('valuedeposit', 'int'); - if ($typeamount == 'amount') { + if ($typeamount == 'amount') + { $amountdeposit = $valuedeposit; - } else { + } + else + { $amountdeposit = 0; dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); @@ -853,7 +859,8 @@ else if ($action == 'add' && $user->rights->facture->creer) dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add deposit lines"); $result = $srcobject->fetch($object->origin_id); - if ($result > 0) { + if ($result > 0) + { $totalamount = 0; $lines = $srcobject->lines; $numlines=count($lines); @@ -898,7 +905,9 @@ else if ($action == 'add' && $user->rights->facture->creer) 0, $langs->trans('Deposit') ); - } else { + } + else + { dol_include_once('/' . $element . '/class/' . $subelement . '.class.php'); @@ -907,10 +916,10 @@ else if ($action == 'add' && $user->rights->facture->creer) dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); $result = $srcobject->fetch($object->origin_id); - if ($result > 0) { + if ($result > 0) + { $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject, 'fetch_lines')) - $lines = $srcobject->fetch_lines(); + if (empty($lines) && method_exists($srcobject, 'fetch_lines')) $lines = $srcobject->fetch_lines(); $fk_parent_line=0; $num=count($lines); @@ -919,7 +928,8 @@ else if ($action == 'add' && $user->rights->facture->creer) $label=(! empty($lines[$i]->label)?$lines[$i]->label:''); $desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle); - if ($lines [$i]->subprice < 0) { + if ($lines [$i]->subprice < 0) + { // Negative line, we create a discount line $discount = new DiscountAbsolute($db); $discount->fk_soc = $object->socid; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 6bafdd827cd1c17f04bdff0a4533dca11b3fbeac..81bf47715e68a10c74b7956707e5579a0581a628 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2056,7 +2056,7 @@ class Facture extends CommonInvoice $localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc); - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, '', $localtaxes_type); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -2133,7 +2133,7 @@ class Facture extends CommonInvoice if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); // Mise a jour informations denormalisees au niveau de la facture meme - $result=$this->update_price(1,'auto'); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. + $result=$this->update_price(1,'auto',0,$mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. if ($result > 0) { $this->db->commit(); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 6eae61063ba61ae5246e9a0e2779207713dd5de5..a6e8b5fe3b20ebb118918602f6180e600627e504 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1518,7 +1518,7 @@ abstract class CommonObject * @param int $exclspec >0 = Exclude special product (product_type=9) * @param string $roundingadjust 'none'=Do nothing, 'auto'=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or '0'), '0'=Force use total of rounding, '1'=Force use rounding of total * @param int $nodatabaseupdate 1=Do not update database. Update only properties of object. - * @param Societe $seller If roundingadjust is 0, it means we recalculate total for lines before calculating total for object. For this, we need seller object. + * @param Societe $seller If roundingadjust is '0' or '1', it means we recalculate total for lines before calculating total for object. For this, we need seller object. * @return int <0 if KO, >0 if OK */ function update_price($exclspec=0,$roundingadjust='none',$nodatabaseupdate=0,$seller='')